MOAB: Mesh Oriented datABase  (version 5.3.1)
Matrix3DTest Class Reference
+ Inheritance diagram for Matrix3DTest:
+ Collaboration diagram for Matrix3DTest:

Public Member Functions

void setUp ()
void tearDown ()
 Matrix3DTest ()
void test_equal ()
void test_plus ()
void test_minus ()
void test_Frobenius_2 ()
void test_transpose ()
void test_plus_equal ()
void test_times_equal_scalar ()
void test_times_scalar ()
void test_plus_transpose ()
void test_plus_transpose_equal ()
void test_outer_product ()
void test_fill_lower_triangle ()
void test_times ()
void test_mult_element ()
void test_times_vector ()
void test_vector_times ()
void test_det ()
void test_B_times_invA ()

Private Member Functions

 CPPUNIT_TEST_SUITE (Matrix3DTest)
 CPPUNIT_TEST (test_equal)
 CPPUNIT_TEST (test_plus)
 CPPUNIT_TEST (test_minus)
 CPPUNIT_TEST (test_Frobenius_2)
 CPPUNIT_TEST (test_transpose)
 CPPUNIT_TEST (test_plus_equal)
 CPPUNIT_TEST (test_times_equal_scalar)
 CPPUNIT_TEST (test_times_scalar)
 CPPUNIT_TEST (test_plus_transpose)
 CPPUNIT_TEST (test_plus_transpose_equal)
 CPPUNIT_TEST (test_outer_product)
 CPPUNIT_TEST (test_fill_lower_triangle)
 CPPUNIT_TEST (test_times)
 CPPUNIT_TEST (test_mult_element)
 CPPUNIT_TEST (test_times_vector)
 CPPUNIT_TEST (test_vector_times)
 CPPUNIT_TEST (test_det)
 CPPUNIT_TEST (test_B_times_invA)
 CPPUNIT_TEST_SUITE_END ()

Private Attributes

Vector3D e1
Vector3D e2
Vector3D e3
Matrix3D mIdentity
Matrix3D mMat1
Matrix3D mMat1sym
Matrix3D mMat2
Matrix3D mMat2trans
Matrix3D mMat1plus2
Matrix3D mMat1plus2trans
Matrix3D mMat1times2
Matrix3D mMat1times2inv
double tolEps

Detailed Description

Definition at line 57 of file Matrix3DTest.cpp.


Constructor & Destructor Documentation

Definition at line 145 of file Matrix3DTest.cpp.

{}

Member Function Documentation

void Matrix3DTest::setUp ( ) [inline]

Definition at line 96 of file Matrix3DTest.cpp.

    {
        // sets up the unit vectors
        e1.set( 1, 0, 0 );
        e2.set( 0, 1, 0 );
        e3.set( 0, 0, 1 );

        mIdentity = " 1    0    0 "
                    " 0    1    0 "
                    " 0    0    1";

        mMat1 = " 1    4.2  2 "
                " 5.2  3    4 "
                " 1    7    0.4";

        mMat1sym = " 1    4.2  2 "
                   " 4.2  3    4 "
                   " 2    4    0.4";

        mMat2 = " 2    4    5 "
                " 2    1    3 "
                " 0    7    8 ";

        mMat2trans = " 2    2    0 "
                     " 4    1    7 "
                     " 5    3    8 ";

        mMat1plus2 = " 3    8.2   7 "
                     " 7.2  4     7 "
                     " 1    14    8.4";

        mMat1plus2trans = " 3    6.2   2 "
                          " 9.2  4     11 "
                          " 6    10    8.4";

        mMat1times2 = " 10.4 22.2  33.6 "
                      " 16.4 51.8  67.0 "
                      " 16.0 13.8  29.2 ";

        mMat1times2inv = " 2.519141   0.088216  -0.977863 "
                         " 1.009487   0.304594  -0.593375 "
                         " 5.838881  -0.699068  -2.203728 ";

        tolEps = 1e-12;
    }
void Matrix3DTest::tearDown ( ) [inline]

Definition at line 142 of file Matrix3DTest.cpp.

{}

Definition at line 290 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, and MBMesquite::timesInvA().

    {
        Matrix3D orig1( mMat1 );
        timesInvA( mMat2, mMat1 );

        // Checks mMat1 is unchanged
        CPPUNIT_ASSERT( mMat1 == orig1 );

        // Checks mMat2 now contains the correct result
        for( int i = 0; i < 3; ++i )
            for( int j = 0; j < 3; ++j )
                CPPUNIT_ASSERT_DOUBLES_EQUAL( mMat2[i][j], mMat1times2inv[i][j], 0.0001 );
    }
void Matrix3DTest::test_det ( ) [inline]

Definition at line 284 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT_DOUBLES_EQUAL, and MBMesquite::det().

    {
        double d = det( mMat1 );
        CPPUNIT_ASSERT_DOUBLES_EQUAL( 48.064, d, tolEps );
    }
void Matrix3DTest::test_equal ( ) [inline]

Definition at line 147 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

Definition at line 232 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

void Matrix3DTest::test_Frobenius_2 ( ) [inline]

Definition at line 170 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT_DOUBLES_EQUAL, and MBMesquite::Frobenius_2().

    {
        double fro = Frobenius_2( mMat1 );
        CPPUNIT_ASSERT_DOUBLES_EQUAL( 124.84, fro, tolEps );
    }
void Matrix3DTest::test_minus ( ) [inline]

Definition at line 160 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

    {
        Matrix3D res;
        res = mMat1 - mIdentity;
        Matrix3D correct( " 0    4.2  2 "
                          " 5.2  2    4 "
                          " 1    7    -0.6 " );
        CPPUNIT_ASSERT( res == correct );
    }

Definition at line 247 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, and MBMesquite::mult_element().

    {
        Matrix3D mat = mult_element( mMat1, mIdentity );
        Matrix3D correct( " 1 0 0 "
                          " 0 3 0 "
                          " 0 0 0.4" );
        CPPUNIT_ASSERT( mat == correct );
    }

Definition at line 219 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, and MBMesquite::Matrix3D::outer_product().

    {
        Matrix3D mat;
        Vector3D vec1( 2, 7, 3 );
        Vector3D vec2( 5, 8, 9 );
        mat.outer_product( vec1, vec2 );
        Matrix3D correct( " 10    16    18 "
                          " 35    56    63 "
                          " 15    24    27 " );

        CPPUNIT_ASSERT( mat == correct );
    }
void Matrix3DTest::test_plus ( ) [inline]

Definition at line 153 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, and moab::sum().

    {
        Matrix3D sum;
        sum = mMat1 + mMat2;
        CPPUNIT_ASSERT( sum == mMat1plus2 );
    }
void Matrix3DTest::test_plus_equal ( ) [inline]

Definition at line 182 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

Definition at line 207 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, and MBMesquite::plus_transpose().

    {
        Matrix3D plus_trans = plus_transpose( mMat1, mMat2 );
        CPPUNIT_ASSERT( plus_trans == mMat1plus2trans );
    }
void Matrix3DTest::test_times ( ) [inline]

Definition at line 238 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

    {
        Matrix3D mult = mMat1 * mMat2;
        CPPUNIT_ASSERT( mult == mMat1times2 );

        mult = mMat1 * mIdentity;
        CPPUNIT_ASSERT( mult == mMat1 );
    }

Definition at line 188 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

    {
        mMat2 *= 3;
        Matrix3D correct( " 6   12   15 "
                          " 6    3    9 "
                          " 0   21   24 " );
        CPPUNIT_ASSERT( mMat2 == correct );
    }

Definition at line 196 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT.

    {
        Matrix3D tmp = mMat2 * 3;
        Matrix3D correct( " 6   12   15 "
                          " 6    3    9 "
                          " 0   21   24 " );
        CPPUNIT_ASSERT( tmp == correct );
        tmp[0][0] = 0;
        tmp       = 3 * mMat2;
        CPPUNIT_ASSERT( tmp == correct );
    }

Definition at line 256 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, and MBMesquite::Vector3D::set().

    {
        Vector3D vec = mMat1 * e1;
        Vector3D correct( 1, 5.2, 1 );
        CPPUNIT_ASSERT( vec == correct );

        Vector3D vec_2( 3., 2., 5. );
        Vector3D vec_12 = mMat1 * vec_2;
        correct.set( 21.4, 41.6, 19. );
        CPPUNIT_ASSERT( vec_12 == correct );
    }
void Matrix3DTest::test_transpose ( ) [inline]

Definition at line 176 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, and MBMesquite::transpose().

    {
        Matrix3D trans = transpose( mMat2 );
        CPPUNIT_ASSERT( trans == mMat2trans );
    }

Definition at line 268 of file Matrix3DTest.cpp.

References CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, and MBMesquite::Vector3D::set().

    {
        Vector3D vec = e1 * mMat1;
        Vector3D correct( 1, 4.2, 2 );
        CPPUNIT_ASSERT( vec == correct );

        Vector3D vec2( 2.1, 3, 8 );
        vec = vec2 * mMat1;
        correct.set( 25.7, 73.82, 19.4 );
        int loop_i = 0;
        for( loop_i = 0; loop_i < 3; ++loop_i )
        {
            CPPUNIT_ASSERT_DOUBLES_EQUAL( vec[loop_i], correct[loop_i], tolEps );
        }
    }

Member Data Documentation

Definition at line 83 of file Matrix3DTest.cpp.

Definition at line 83 of file Matrix3DTest.cpp.

Definition at line 83 of file Matrix3DTest.cpp.

Definition at line 84 of file Matrix3DTest.cpp.

Definition at line 85 of file Matrix3DTest.cpp.

Definition at line 89 of file Matrix3DTest.cpp.

Definition at line 90 of file Matrix3DTest.cpp.

Definition at line 86 of file Matrix3DTest.cpp.

Definition at line 91 of file Matrix3DTest.cpp.

Definition at line 92 of file Matrix3DTest.cpp.

Definition at line 87 of file Matrix3DTest.cpp.

Definition at line 88 of file Matrix3DTest.cpp.

double Matrix3DTest::tolEps [private]

Definition at line 93 of file Matrix3DTest.cpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines