MOAB: Mesh Oriented datABase  (version 5.2.1)
TargetMetricTest.hpp File Reference

Templatized common code for testing various target metric implementation types. More...

#include "UnitUtil.hpp"
#include "MsqError.hpp"
#include "MsqMatrix.hpp"
#include "TMetric.hpp"
#include "TMetricBarrier.hpp"
#include "AWMetric.hpp"
#include "AWMetricBarrier.hpp"
+ Include dependency graph for TargetMetricTest.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TMetricTest< Metric, DIM >
 Common tests for all target metric types. More...

Defines

#define REGISTER_BASE_TESTS
#define REGISTER_GRAD_TESTS
#define REGISTER_HESS_TESTS
#define BEGIN_TEST_DECL(METRIC, DIM, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define END_TEST_DECL(SUITE, DIM, METRIC)
#define TEST_METRIC_NO_DERIVS_2D(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_METRIC_NO_DERIVS_3D(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_METRIC_NO_DERIVS(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_METRIC_WITH_GRAD_2D(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_METRIC_WITH_GRAD_3D(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_METRIC_WITH_GRAD(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_NAMED_METRIC_WITH_HESS_2D(METRIC, NAME, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_NAMED_METRIC_WITH_HESS_3D(METRIC, NAME, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_NAMED_METRIC_WITH_HESS(METRIC, NAME, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_METRIC_WITH_HESS_2D(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)   TEST_NAMED_METRIC_WITH_HESS_2D( METRIC, METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )
#define TEST_METRIC_WITH_HESS_3D(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)   TEST_NAMED_METRIC_WITH_HESS_3D( METRIC, METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )
#define TEST_METRIC_WITH_HESS(METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL)
#define TEST_NON_QUALITY_METRIC_WITH_HESS_2D(METRIC)
#define TEST_NON_QUALITY_METRIC_WITH_HESS_3D(METRIC)
#define TEST_NON_QUALITY_METRIC_WITH_HESS(METRIC)
#define TMETRIC_FUNC
#define MAT_TYPE   TMetricTest< Metric, DIM >::Matrix

Functions

static double releps (double a)
template<typename M >
double eps_mat (const M &mu)

Variables

const double Avals [][9]
const double Bvals [][9]
const double Cvals [][9]

Detailed Description

Templatized common code for testing various target metric implementation types.

Author:
Jason Kraftcheck

Definition in file TargetMetricTest.hpp.


Define Documentation

#define BEGIN_TEST_DECL (   METRIC,
  DIM,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
class METRIC##_##DIM##DTest : public TMetricTest< METRIC, DIM >                                               \
    {                                                                                                             \
      public:                                                                                                     \
        METRIC##_##DIM##DTest()                                                                                   \
            : TMetricTest< METRIC, DIM >( ( SHAPE_INVAR ), ( SIZE_INVAR ), ( ORIENT_INVAR ), ( BARRIER ), IDEAL ) \
        {                                                                                                         \
        }                                                                                                         \
        CPPUNIT_TEST_SUITE( METRIC##_##DIM##DTest )

Definition at line 68 of file TargetMetricTest.hpp.

#define END_TEST_DECL (   SUITE,
  DIM,
  METRIC 
)
Value:
CPPUNIT_TEST_SUITE_END();                                                                                   \
    }                                                                                                           \
    ;                                                                                                           \
    CPPUNIT_NS::AutoRegisterSuite< METRIC##_##DIM##DTest > METRIC##_##DIM##D_UnitRegister( "Unit" );            \
    CPPUNIT_NS::AutoRegisterSuite< METRIC##_##DIM##DTest > METRIC##_##DIM##D_FileRegister( TARGET_TEST_GROUP ); \
    CPPUNIT_NS::AutoRegisterSuite< METRIC##_##DIM##DTest > METRIC##_##DIM##D_BaseRegister( #SUITE "Test" )

Definition at line 78 of file TargetMetricTest.hpp.

#define MAT_TYPE   TMetricTest< Metric, DIM >::Matrix

Definition at line 319 of file TargetMetricTest.hpp.

Value:
CPPUNIT_TEST( test_ideal_eval );     \
    CPPUNIT_TEST( test_ideal_gradient ); \
    CPPUNIT_TEST( test_inverted );       \
    CPPUNIT_TEST( test_shape );          \
    CPPUNIT_TEST( test_scale );          \
    CPPUNIT_TEST( test_orient )

Definition at line 52 of file TargetMetricTest.hpp.

Value:
CPPUNIT_TEST( compare_eval_and_eval_with_grad ); \
    CPPUNIT_TEST( compare_anaytic_and_numeric_grads )

Definition at line 60 of file TargetMetricTest.hpp.

Value:
CPPUNIT_TEST( compare_eval_with_grad_and_eval_with_hess ); \
    CPPUNIT_TEST( compare_anaytic_and_numeric_hess )

Definition at line 64 of file TargetMetricTest.hpp.

#define TEST_METRIC_NO_DERIVS (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
TEST_METRIC_NO_DERIVS_2D( METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL ); \
    TEST_METRIC_NO_DERIVS_3D( METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )

Register tests for metric with no derivative implementations

Definition at line 99 of file TargetMetricTest.hpp.

#define TEST_METRIC_NO_DERIVS_2D (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
BEGIN_TEST_DECL( METRIC, 2, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL );          \
    REGISTER_BASE_TESTS;                                                                          \
    END_TEST_DECL( METRIC, 2, METRIC )

Register tests for metric with no derivative implementations

Definition at line 87 of file TargetMetricTest.hpp.

#define TEST_METRIC_NO_DERIVS_3D (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
BEGIN_TEST_DECL( METRIC, 3, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIE, IDEALR );          \
    REGISTER_BASE_TESTS;                                                                          \
    END_TEST_DECL( METRIC, 3, METRIC )

Register tests for metric with no derivative implementations

Definition at line 93 of file TargetMetricTest.hpp.

#define TEST_METRIC_WITH_GRAD (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
TEST_METRIC_WITH_GRAD_2D( METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL ); \
    TEST_METRIC_WITH_GRAD_3D( METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )

Register tests for metric with implementation of analytic gradient

Definition at line 118 of file TargetMetricTest.hpp.

#define TEST_METRIC_WITH_GRAD_2D (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
BEGIN_TEST_DECL( METRIC, 2, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL );          \
    REGISTER_BASE_TESTS;                                                                          \
    REGISTER_GRAD_TESTS;                                                                          \
    END_TEST_DECL( METRIC, 2, METRIC )

Register tests for metric with implementation of analytic gradient

Definition at line 104 of file TargetMetricTest.hpp.

#define TEST_METRIC_WITH_GRAD_3D (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
BEGIN_TEST_DECL( METRIC, 3, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL );          \
    REGISTER_BASE_TESTS;                                                                          \
    REGISTER_GRAD_TESTS;                                                                          \
    END_TEST_DECL( METRIC, 3, METRIC )

Register tests for metric with implementation of analytic gradient

Definition at line 111 of file TargetMetricTest.hpp.

#define TEST_METRIC_WITH_HESS (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
TEST_NAMED_METRIC_WITH_HESS_2D( METRIC, METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL ); \
    TEST_NAMED_METRIC_WITH_HESS_3D( METRIC, METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )

Register tests for metric with implementation of analytic gradient and Hessian

Definition at line 150 of file TargetMetricTest.hpp.

#define TEST_METRIC_WITH_HESS_2D (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)    TEST_NAMED_METRIC_WITH_HESS_2D( METRIC, METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )

Register tests for metric with implementation of analytic gradient and Hessian

Definition at line 142 of file TargetMetricTest.hpp.

#define TEST_METRIC_WITH_HESS_3D (   METRIC,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)    TEST_NAMED_METRIC_WITH_HESS_3D( METRIC, METRIC, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )

Register tests for metric with implementation of analytic gradient and Hessian

Definition at line 146 of file TargetMetricTest.hpp.

#define TEST_NAMED_METRIC_WITH_HESS (   METRIC,
  NAME,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
TEST_NAMED_METRIC_WITH_HESS_2D( METRIC, NAME, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL ); \
    TEST_NAMED_METRIC_WITH_HESS_3D( METRIC, NAME, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL )

Register tests for metric with implementation of analytic gradient and Hessian

Definition at line 137 of file TargetMetricTest.hpp.

#define TEST_NAMED_METRIC_WITH_HESS_2D (   METRIC,
  NAME,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
BEGIN_TEST_DECL( METRIC, 2, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL );                      \
    REGISTER_BASE_TESTS;                                                                                      \
    REGISTER_GRAD_TESTS;                                                                                      \
    REGISTER_HESS_TESTS;                                                                                      \
    END_TEST_DECL( NAME, 2, METRIC )

Definition at line 122 of file TargetMetricTest.hpp.

#define TEST_NAMED_METRIC_WITH_HESS_3D (   METRIC,
  NAME,
  SHAPE_INVAR,
  SIZE_INVAR,
  ORIENT_INVAR,
  BARRIER,
  IDEAL 
)
Value:
BEGIN_TEST_DECL( METRIC, 3, SHAPE_INVAR, SIZE_INVAR, ORIENT_INVAR, BARRIER, IDEAL );                      \
    REGISTER_BASE_TESTS;                                                                                      \
    REGISTER_GRAD_TESTS;                                                                                      \
    REGISTER_HESS_TESTS;                                                                                      \
    END_TEST_DECL( NAME, 3, METRIC )

Definition at line 129 of file TargetMetricTest.hpp.

Value:
TEST_NON_QUALITY_METRIC_WITH_HESS_2D( METRIC ); \
    TEST_NON_QUALITY_METRIC_WITH_HESS_3D( METRIC );

Regsiter tests for a metric that doesn't really measure quality

Definition at line 167 of file TargetMetricTest.hpp.

Value:
BEGIN_TEST_DECL( METRIC, 2, true, true, true, true, 0.0 ); \
    REGISTER_GRAD_TESTS;                                       \
    REGISTER_HESS_TESTS;                                       \
    END_TEST_DECL( NAME, 2, METRIC )

Definition at line 154 of file TargetMetricTest.hpp.

Value:
BEGIN_TEST_DECL( METRIC, 3, true, true, true, true, 0.0 ); \
    REGISTER_GRAD_TESTS;                                       \
    REGISTER_HESS_TESTS;                                       \
    END_TEST_DECL( NAME, 3, METRIC )

Definition at line 160 of file TargetMetricTest.hpp.

#define TMETRIC_FUNC
Value:
template < class Metric, unsigned DIM > \
    void TMetricTest< Metric, DIM >

Definition at line 316 of file TargetMetricTest.hpp.


Function Documentation

template<typename M >
double eps_mat ( const M &  mu)

Definition at line 539 of file TargetMetricTest.hpp.

References MBMesquite::Frobenius().

{
    return std::max( Frobenius( mu ) * 1e-2, 1e-4 );
}
static double releps ( double  a) [static]

Definition at line 460 of file TargetMetricTest.hpp.

{
    return std::max( 1e-6, 1e-8 * fabs( a ) );
}

Variable Documentation

const double Cvals[][9]
Initial value:
 { { 0 },
                            { 0.5 },
                            { -1.0, 0.5,  
                              0.0, 1.0 },
                            { 0.5, 0.0, 0.1,  
                              0.5, 1.0, 0.1, 0.0, 0.0, -1.5 } }

Definition at line 185 of file TargetMetricTest.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines