SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Macros | Functions
MatrixTestUtilities.h File Reference
#include <gtest/gtest.h>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/timer.hpp>
#include <boost/assign.hpp>
#include <boost/filesystem.hpp>
#include <stdexcept>
#include <Core/Datatypes/DenseMatrix.h>
#include <Core/Datatypes/DenseColumnMatrix.h>
#include <Core/Datatypes/SparseRowMatrix.h>
#include <Core/Utils/StringUtil.h>
#include <Testing/Utils/share.h>

Go to the source code of this file.

Classes

struct  ScopedTimer
 

Namespaces

 SCIRun
 STL datatypes needed.
 
 SCIRun::TestUtils
 

Macros

#define DEFAULT_MATRIX_PERCENT_TOLERANCE   1e-5
 
#define EXPECT_MATRIX_EQ_TOLERANCE(actual, expected, tolerance)   EXPECT_TRUE(compare_with_tolerance_readable((actual), (expected), (tolerance)))
 
#define EXPECT_MATRIX_EQ(actual, expected)   EXPECT_MATRIX_EQ_TOLERANCE((actual), (expected), DEFAULT_MATRIX_PERCENT_TOLERANCE)
 
#define EXPECT_COLUMN_MATRIX_EQ_BY_TWO_NORM(actual, expected, error)   EXPECT_TRUE(compare_with_two_norm((actual), (expected), (error)))
 
#define MAKE_DENSE_MATRIX(x)   (convertDataToMatrix(to_vector(boost::assign::tuple_list_of x)))
 
#define MAKE_DENSE_MATRIX_HANDLE(x)   (boost::make_shared<SCIRun::Core::Datatypes::DenseMatrix>(MAKE_DENSE_MATRIX(x)))
 
#define MAKE_SPARSE_MATRIX_HANDLE(x)   (toSparseHandle(MAKE_DENSE_MATRIX(x)))
 

Functions

bool equal_size (const Core::Datatypes::Matrix &m1, const Core::Datatypes::Matrix &m2)
 
bool compare_with_tolerance (const Core::Datatypes::DenseMatrix &m1, const Core::Datatypes::DenseMatrix &m2, double percentTolerance=DEFAULT_MATRIX_PERCENT_TOLERANCE)
 
bool compare_with_tolerance (const Core::Datatypes::SparseRowMatrix &m1, const Core::Datatypes::SparseRowMatrix &m2, double percentTolerance=DEFAULT_MATRIX_PERCENT_TOLERANCE)
 
inline::testing::AssertionResult compare_with_tolerance_readable (const Core::Datatypes::DenseMatrix &m1, const Core::Datatypes::DenseMatrix &m2, double percentTolerance, int printSize=50)
 
double relative_infinity_norm (const Core::Datatypes::DenseColumnMatrix &x, const Core::Datatypes::DenseColumnMatrix &xhat)
 
inline::testing::AssertionResult compare_with_relative_infinity_norm (const Core::Datatypes::DenseColumnMatrix &x, const Core::Datatypes::DenseColumnMatrix &xhat, double relativeError=DEFAULT_MATRIX_PERCENT_TOLERANCE, int printSize=50)
 
inline::testing::AssertionResult compare_with_two_norm (const Core::Datatypes::DenseColumnMatrix &x, const Core::Datatypes::DenseColumnMatrix &xhat, double error=1e-15, int printSize=50)
 
void copyDenseToSparse (const Core::Datatypes::DenseMatrix &from, Core::Datatypes::SparseRowMatrix &to)
 
Core::Datatypes::SparseRowMatrixHandle toSparseHandle (const Core::Datatypes::DenseMatrix &dense)
 
Core::Datatypes::DenseMatrixHandle makeDense (const Core::Datatypes::SparseRowMatrix &sparse)
 
template<class Tuple >
Core::Datatypes::DenseMatrix convertDataToMatrix (const std::vector< Tuple > &matrixData)
 
template<class Cont >
std::vector< typename
Cont::value_type > 
to_vector (const Cont &cont)
 
SCISHARE FieldHandle loadFieldFromFile (const boost::filesystem::path &filename)
 

Macro Definition Documentation

#define DEFAULT_MATRIX_PERCENT_TOLERANCE   1e-5
#define EXPECT_COLUMN_MATRIX_EQ_BY_TWO_NORM (   actual,
  expected,
  error 
)    EXPECT_TRUE(compare_with_two_norm((actual), (expected), (error)))
#define EXPECT_MATRIX_EQ (   actual,
  expected 
)    EXPECT_MATRIX_EQ_TOLERANCE((actual), (expected), DEFAULT_MATRIX_PERCENT_TOLERANCE)
#define EXPECT_MATRIX_EQ_TOLERANCE (   actual,
  expected,
  tolerance 
)    EXPECT_TRUE(compare_with_tolerance_readable((actual), (expected), (tolerance)))
#define MAKE_DENSE_MATRIX (   x)    (convertDataToMatrix(to_vector(boost::assign::tuple_list_of x)))
#define MAKE_DENSE_MATRIX_HANDLE (   x)    (boost::make_shared<SCIRun::Core::Datatypes::DenseMatrix>(MAKE_DENSE_MATRIX(x)))
#define MAKE_SPARSE_MATRIX_HANDLE (   x)    (toSparseHandle(MAKE_DENSE_MATRIX(x)))