SOFA API  6a688117
Open source framework for multi-physics simuation
sofa::helper::testing::NumericTest< _Real > Struct Template Reference

#include <NumericTest.h>

Helper functions to compare scalars, vectors, matrices, etc. More...

Inheritance diagram for sofa::helper::testing::NumericTest< _Real >:

Detailed Description

template<typename _Real = SReal>
struct sofa::helper::testing::NumericTest< _Real >

Helper functions to compare scalars, vectors, matrices, etc.

Public Member Functions

 NumericTest ()
 
- Public Member Functions inherited from sofa::helper::testing::BaseTest
 BaseTest ()
 Initialize Sofa and the random number generator. More...
 
 ~BaseTest () override
 
virtual void onSetUp ()
 
virtual void onTearDown ()
 

Static Public Member Functions

Matrices

Functions to compare matrices

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<std::size_t M, std::size_t N, typename Real , typename Matrix2 >
static Real matrixMaxDiff (const sofa::defaulttype::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 Protected Member Functions

static float norm (float a)
 
static double norm (double a)
 
template<typename T >
static Real norm (T a)
 

Scalars

Type and functions to manipulate real numbers.

typedef _Real Real
 Scalar type. 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...
 

Vectors

Functions to compare vectors

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...
 
template<std::size_t N, typename Real , typename Vector2 >
static Real vectorMaxDiff (const sofa::defaulttype::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<std::size_t N, typename Real >
static Real vectorMaxDiff (const sofa::defaulttype::Vec< N, Real > &m1, const sofa::defaulttype::Vec< N, Real > &m2)
 return the maximum difference between corresponding entries More...
 

Additional Inherited Members

- Public Attributes inherited from sofa::helper::testing::BaseTest
sofa::helper::logging::MessageAsTestFailure m_fatal
 
sofa::helper::logging::MessageAsTestFailure m_error
 
- Static Public Attributes inherited from sofa::helper::testing::BaseTest
static int seed = (unsigned int)time(nullptr)
 Seed value. More...
 

Constructor details

template<typename _Real = SReal>
sofa::helper::testing::NumericTest< _Real >::NumericTest ( )
inline

Function details

template<typename _Real = SReal>
static Real sofa::helper::testing::NumericTest< _Real >::epsilon ( )
inlinestatic

the smallest real number

template<typename _Real = SReal>
static Real sofa::helper::testing::NumericTest< _Real >::infinity ( )
inlinestatic

Infinity.

template<typename _Real = SReal>
static bool sofa::helper::testing::NumericTest< _Real >::isSmall ( Real  r,
Real  ratio = 1. 
)
inlinestatic

true if the magnitude of r is less than ratio*epsilon

template<typename _Real = SReal>
template<typename Matrix1 , typename Matrix2 >
static Real sofa::helper::testing::NumericTest< _Real >::matrixMaxDiff ( const Matrix1 &  m1,
const Matrix2 m2 
)
inlinestatic

return the maximum difference between corresponding entries, or the infinity if the matrices have different sizes

template<typename _Real = SReal>
template<std::size_t M, std::size_t N, typename Real , typename Matrix2 >
static Real sofa::helper::testing::NumericTest< _Real >::matrixMaxDiff ( const sofa::defaulttype::Mat< M, N, Real > &  m1,
const Matrix2 m2 
)
inlinestatic

Return the maximum difference between corresponding entries, or the infinity if the matrices have different sizes.

template<typename _Real = SReal>
static float sofa::helper::testing::NumericTest< _Real >::norm ( float  a)
inlinestaticprotected
template<typename _Real = SReal>
static double sofa::helper::testing::NumericTest< _Real >::norm ( double  a)
inlinestaticprotected
template<typename _Real = SReal>
template<typename T >
static Real sofa::helper::testing::NumericTest< _Real >::norm ( a)
inlinestaticprotected
template<typename _Real = SReal>
template<class Container >
Real sofa::helper::testing::NumericTest< _Real >::vectorMaxAbs ( const Container &  c)
inline

Return the maximum absolute value of a container.

template<typename _Real = SReal>
template<std::size_t N, typename Real , typename Vector2 >
static Real sofa::helper::testing::NumericTest< _Real >::vectorMaxDiff ( const sofa::defaulttype::Vec< N, Real > &  m1,
const Vector2 &  m2 
)
inlinestatic

return the maximum difference between corresponding entries, or the infinity if the vectors have different sizes

template<typename _Real = SReal>
template<std::size_t N, typename Real >
static Real sofa::helper::testing::NumericTest< _Real >::vectorMaxDiff ( const sofa::defaulttype::Vec< N, Real > &  m1,
const sofa::defaulttype::Vec< N, Real > &  m2 
)
inlinestatic

return the maximum difference between corresponding entries

template<typename _Real = SReal>
template<class Container1 , class Container2 >
Real sofa::helper::testing::NumericTest< _Real >::vectorMaxDiff ( const Container1 &  c1,
const Container2 &  c2 
)
inline

Return the maximum difference between two containers. Issues a failure if sizes are different.