SOFA API  1a4bb3e7
Open source framework for multi-physics simuation
sofa::linearalgebra::testing::TestSparseMatrixProduct< T > Struct Template Reference

#include <SparseMatrixProduct_test.h>

Inheritance diagram for sofa::linearalgebra::testing::TestSparseMatrixProduct< T >:

Detailed Description

template<class T>
struct sofa::linearalgebra::testing::TestSparseMatrixProduct< T >

Test the class SparseMatrixProduct The class is designed to use the templates defined in TestSparseMatrixProductTraits The type of matrix can be any of the types supported by SparseMatrixProduct.

Public Member Functions

bool checkMatrix (typename LHSMatrix::Index nbRowsA, typename LHSMatrix::Index nbColsA, typename RHSMatrix::Index nbColsB, Real sparsity)
 
- Public Member Functions inherited from sofa::testing::NumericTest< _Real >
 NumericTest ()
 
template<class Container1 , class Container2 >
Real vectorMaxDiff (const Container1 &c1, const Container2 &c2)
 Return the maximum difference between two containers. Issues a failure if sizes are different. More...
 
template<class Container >
Real vectorMaxAbs (const Container &c)
 Return the maximum absolute value of a container. More...
 
- Public Member Functions inherited from sofa::testing::BaseTest
 BaseTest ()
 Initialize Sofa and the random number generator. More...
 
 ~BaseTest () override
 
virtual void onSetUp ()
 
virtual void onTearDown ()
 

Static Public Member Functions

template<int EigenSparseMatrixOptions>
static void generateRandomSparseMatrix (Eigen::SparseMatrix< TReal, EigenSparseMatrixOptions > &eigenMatrix, Eigen::Index nbRows, Eigen::Index nbCols, TReal sparsity)
 
template<typename _DstScalar , int _DstOptions, typename _DstStorageIndex , typename _SrcScalar , int _SrcOptions, typename _SrcStorageIndex >
static void copyFromEigen (Eigen::SparseMatrix< _DstScalar, _DstOptions, _DstStorageIndex > &dst, const Eigen::SparseMatrix< _SrcScalar, _SrcOptions, _SrcStorageIndex > &src)
 
static void copyFromEigen (linearalgebra::BaseMatrix &dst, const Eigen::SparseMatrix< TReal > &src)
 
template<typename _AScalar , int _AOptions, typename _AStorageIndex , typename _BScalar , int _BOptions, typename _BStorageIndex >
static bool compareSparseMatrix (const Eigen::SparseMatrix< _AScalar, _AOptions, _AStorageIndex > &A, const Eigen::SparseMatrix< _BScalar, _BOptions, _BStorageIndex > &B)
 
- Static Public Member Functions inherited from sofa::testing::SparseMatrixTest< T::LhsScalar >
static void generateRandomSparseMatrix (Eigen::SparseMatrix< T::LhsScalar, EigenSparseMatrixOptions > &eigenMatrix, Eigen::Index nbRows, Eigen::Index nbCols, T::LhsScalar sparsity)
 
static void generateFromTriplets (Eigen::SparseMatrix< T::LhsScalar > &eigenMatrix, InputIt first, InputIt last, Eigen::Index nbRows, Eigen::Index nbCols)
 
static void copyFromEigen (Eigen::SparseMatrix< _DstScalar, _DstOptions, _DstStorageIndex > &dst, const Eigen::SparseMatrix< _SrcScalar, _SrcOptions, _SrcStorageIndex > &src)
 
static void copyFromEigen (linearalgebra::BaseMatrix &dst, const Eigen::SparseMatrix< T::LhsScalar > &src)
 
static bool compareSparseMatrix (const Eigen::SparseMatrix< _AScalar, _AOptions, _AStorageIndex > &A, const Eigen::SparseMatrix< _BScalar, _BOptions, _BStorageIndex > &B)
 
static bool compareEigenSparseMatrix (const Eigen::SparseMatrix< _AScalar, _AOptions, _AStorageIndex > &A, const Eigen::SparseMatrix< _BScalar, _BOptions, _BStorageIndex > &B)
 
- Static Public Member Functions inherited from sofa::testing::NumericTest< _Real >
template<typename Matrix1 , typename Matrix2 >
static Real matrixMaxDiff (const Matrix1 &m1, const Matrix2 &m2)
 return the maximum difference between corresponding entries, or the infinity if the matrices have different sizes More...
 
template<Size M, Size N, typename Real , typename Matrix2 >
static Real matrixMaxDiff (const sofa::type::Mat< M, N, Real > &m1, const Matrix2 &m2)
 Return the maximum difference between corresponding entries, or the infinity if the matrices have different sizes. More...
 
static Real epsilon ()
 the smallest real number More...
 
static Real infinity ()
 Infinity. More...
 
static bool isSmall (Real r, Real ratio=1.)
 true if the magnitude of r is less than ratio*epsilon More...
 
template<Size N, typename Real , typename Vector2 >
static Real vectorMaxDiff (const sofa::type::Vec< N, Real > &m1, const Vector2 &m2)
 return the maximum difference between corresponding entries, or the infinity if the vectors have different sizes More...
 
template<Size N, typename Real >
static Real vectorMaxDiff (const sofa::type::Vec< N, Real > &m1, const sofa::type::Vec< N, Real > &m2)
 return the maximum difference between corresponding entries More...
 

Additional Inherited Members

- Public Attributes inherited from sofa::testing::BaseTest
sofa::testing::MessageAsTestFailure m_fatal
 
sofa::testing::MessageAsTestFailure m_error
 
- Static Public Attributes inherited from sofa::testing::BaseTest
static int seed = (unsigned int)time(nullptr)
 Seed value. More...
 
- Static Protected Member Functions inherited from sofa::testing::NumericTest< _Real >
static float norm (float a)
 
static double norm (double a)
 
template<typename T >
static Real norm (T a)
 

Function details

◆ checkMatrix()

template<class T >
bool sofa::linearalgebra::testing::TestSparseMatrixProduct< T >::checkMatrix ( typename LHSMatrix::Index  nbRowsA,
typename LHSMatrix::Index  nbColsA,
typename RHSMatrix::Index  nbColsB,
Real  sparsity 
)
inline

◆ compareSparseMatrix()

template<class T >
template<typename _AScalar , int _AOptions, typename _AStorageIndex , typename _BScalar , int _BOptions, typename _BStorageIndex >
static bool sofa::testing::SparseMatrixTest< TReal >::compareSparseMatrix ( typename _AScalar  ,
int  _AOptions,
typename _AStorageIndex  ,
typename _BScalar  ,
int  _BOptions,
typename _BStorageIndex   
)
inlinestatic

◆ copyFromEigen() [1/2]

template<class T >
template<typename _DstScalar , int _DstOptions, typename _DstStorageIndex , typename _SrcScalar , int _SrcOptions, typename _SrcStorageIndex >
static void sofa::testing::SparseMatrixTest< TReal >::copyFromEigen ( typename _DstScalar  ,
int  _DstOptions,
typename _DstStorageIndex  ,
typename _SrcScalar  ,
int  _SrcOptions,
typename _SrcStorageIndex   
)
inlinestatic

◆ copyFromEigen() [2/2]

template<class T >
static void sofa::testing::SparseMatrixTest< TReal >::copyFromEigen
inlinestatic

◆ generateRandomSparseMatrix()

template<class T >
template<int EigenSparseMatrixOptions>
static void sofa::testing::SparseMatrixTest< TReal >::generateRandomSparseMatrix ( int  EigenSparseMatrixOptions)
inlinestatic

Generate a sparse matrix of size nbRows x nbCols. The sparsity is the ratio of non-zero values compared to the total size of the matrix (= nbRows x nbCols).