MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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"
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] |
Templatized common code for testing various target metric implementation types.
Definition in file TargetMetricTest.hpp.
#define BEGIN_TEST_DECL | ( | METRIC, | |
DIM, | |||
SHAPE_INVAR, | |||
SIZE_INVAR, | |||
ORIENT_INVAR, | |||
BARRIER, | |||
IDEAL | |||
) |
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 | |||
) |
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 355 of file TargetMetricTest.hpp.
#define REGISTER_BASE_TESTS |
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.
#define REGISTER_GRAD_TESTS |
CPPUNIT_TEST( compare_eval_and_eval_with_grad ); \ CPPUNIT_TEST( compare_anaytic_and_numeric_grads )
Definition at line 60 of file TargetMetricTest.hpp.
#define REGISTER_HESS_TESTS |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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 | |||
) |
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.
#define TEST_NON_QUALITY_METRIC_WITH_HESS | ( | METRIC | ) |
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.
#define TEST_NON_QUALITY_METRIC_WITH_HESS_2D | ( | METRIC | ) |
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.
#define TEST_NON_QUALITY_METRIC_WITH_HESS_3D | ( | METRIC | ) |
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 |
template < class Metric, unsigned DIM > \ void TMetricTest< Metric, DIM >
Definition at line 352 of file TargetMetricTest.hpp.
double eps_mat | ( | const M & | mu | ) |
Definition at line 575 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 496 of file TargetMetricTest.hpp.
{
return std::max( 1e-6, 1e-8 * fabs( a ) );
}
const double Avals[][9] |
{ { 0 }, { 2 }, { 2, 1, 1, 2 }, { 2, 1, 1, 1, 2, 1, 1, 1, 2 } }
Definition at line 173 of file TargetMetricTest.hpp.
Referenced by TMetricTest< Metric, DIM >::test_numerical_gradient_2D(), AWMetricTest::test_numerical_gradient_2D(), TMetricTest< Metric, DIM >::test_numerical_gradient_3D(), AWMetricTest::test_numerical_gradient_3D(), TMetricTest< Metric, DIM >::test_numerical_hessian_2D(), AWMetricTest::test_numerical_hessian_2D(), TMetricTest< Metric, DIM >::test_numerical_hessian_3D(), and AWMetricTest::test_numerical_hessian_3D().
const double Bvals[][9] |
{ { 0 }, { -0.1 }, { -0.1, -0.15, -0.25, -0.8 }, { 1.5, -0.7, -0.8, 0.8, -1.3, -0.7, 0.6, -0.9, -2.0 } }
Definition at line 179 of file TargetMetricTest.hpp.
Referenced by TMetricTest< Metric, DIM >::test_numerical_gradient_2D(), AWMetricTest::test_numerical_gradient_2D(), TMetricTest< Metric, DIM >::test_numerical_gradient_3D(), AWMetricTest::test_numerical_gradient_3D(), TMetricTest< Metric, DIM >::test_numerical_hessian_2D(), AWMetricTest::test_numerical_hessian_2D(), TMetricTest< Metric, DIM >::test_numerical_hessian_3D(), and AWMetricTest::test_numerical_hessian_3D().
const double Cvals[][9] |
{ { 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.