MOAB: Mesh Oriented datABase  (version 5.4.1)
TMPDerivsTest.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2009 Sandia Corporation and Argonne National
00005     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
00006     with Sandia Corporation, the U.S. Government retains certain
00007     rights in this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     [email protected]
00024 
00025   ***************************************************************** */
00026 /** \file TMPDerivsTest.cpp
00027  * \autor Jason Kraftcheck <[email protected]>
00028  */
00029 
00030 #include "TMPDerivs.hpp"
00031 #include "UnitUtil.hpp"
00032 
00033 using namespace MBMesquite;
00034 
00035 class TMPDerivsTest : public CppUnit::TestFixture
00036 {
00037   private:
00038     CPPUNIT_TEST_SUITE( TMPDerivsTest );
00039     CPPUNIT_TEST( test_set_scaled_I );
00040     CPPUNIT_TEST( test_pluseq_scaled_I );
00041     CPPUNIT_TEST( test_pluseq_scaled_2nd_deriv_of_det );
00042     CPPUNIT_TEST( test_set_scaled_2nd_deriv_of_det );
00043     CPPUNIT_TEST( test_pluseq_scaled_outer_product );
00044     CPPUNIT_TEST( test_set_scaled_outer_product );
00045     CPPUNIT_TEST( test_set_scaled_sum_outer_product_2D );
00046     CPPUNIT_TEST( test_set_scaled_sum_outer_product_3D );
00047     CPPUNIT_TEST( test_pluseq_scaled_sum_outer_product_2D );
00048     CPPUNIT_TEST( test_pluseq_scaled_sum_outer_product_3D );
00049     CPPUNIT_TEST( test_pluseq_scaled_sum_outer_product_I_2D );
00050     CPPUNIT_TEST( test_pluseq_scaled_sum_outer_product_I_3D );
00051     CPPUNIT_TEST( test_pluseq_scaled_outer_product_I_I_2D );
00052     CPPUNIT_TEST( test_pluseq_scaled_outer_product_I_I_3D );
00053     CPPUNIT_TEST( test_set_scaled_2nd_deriv_norm_sqr_adj );
00054     CPPUNIT_TEST_SUITE_END();
00055 
00056   public:
00057     void test_set_scaled_I();
00058     void test_pluseq_scaled_I();
00059     void test_pluseq_scaled_2nd_deriv_of_det();
00060     void test_set_scaled_2nd_deriv_of_det();
00061     void test_pluseq_scaled_outer_product();
00062     void test_set_scaled_outer_product();
00063     void test_set_scaled_sum_outer_product_2D();
00064     void test_set_scaled_sum_outer_product_3D();
00065     void test_pluseq_scaled_sum_outer_product_2D();
00066     void test_pluseq_scaled_sum_outer_product_3D();
00067     void test_pluseq_scaled_sum_outer_product_I_2D();
00068     void test_pluseq_scaled_sum_outer_product_I_3D();
00069     void test_pluseq_scaled_outer_product_I_I_2D();
00070     void test_pluseq_scaled_outer_product_I_I_3D();
00071     void test_set_scaled_2nd_deriv_norm_sqr_adj();
00072 };
00073 
00074 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TMPDerivsTest, "TMPDerivsTest" );
00075 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TMPDerivsTest, "Unit" );
00076 
00077 void TMPDerivsTest::test_set_scaled_I()
00078 {
00079     const double alpha = 3.14159, eps = 1e-12;
00080     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00081     set_scaled_I( R, alpha );
00082 
00083     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( alpha ) ), R[0], eps );
00084     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 0.0 ) ), R[1], eps );
00085     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 0.0 ) ), R[2], eps );
00086     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( alpha ) ), R[3], eps );
00087     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 0.0 ) ), R[4], eps );
00088     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( alpha ) ), R[5], eps );
00089 }
00090 
00091 void TMPDerivsTest::test_pluseq_scaled_I()
00092 {
00093     const double s = 3.14159, eps = 1e-12, alpha = 0.222;
00094     MsqMatrix< 3, 3 > R[6];
00095     for( int i = 0; i < 6; ++i )
00096         R[i] = MsqMatrix< 3, 3 >( s * i );
00097     pluseq_scaled_I( R, alpha );
00098 
00099     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 0 * s + alpha ) ), R[0], eps );
00100     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 1 * s ) ), R[1], eps );
00101     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 2 * s ) ), R[2], eps );
00102     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 3 * s + alpha ) ), R[3], eps );
00103     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 4 * s ) ), R[4], eps );
00104     ASSERT_MATRICES_EQUAL( ( MsqMatrix< 3, 3 >( 5 * s + alpha ) ), R[5], eps );
00105 }
00106 
00107 void TMPDerivsTest::test_pluseq_scaled_2nd_deriv_of_det()
00108 {
00109     const double a = 1.33;
00110     const double e = 1e-12;
00111     MsqMatrix< 3, 3 > T;
00112     T( 0, 0 )              = 11;
00113     T( 0, 1 )              = 12;
00114     T( 0, 2 )              = 13;
00115     T( 1, 0 )              = 21;
00116     T( 1, 1 )              = 22;
00117     T( 1, 2 )              = 23;
00118     T( 2, 0 )              = 31;
00119     T( 2, 1 )              = 32;
00120     T( 2, 2 )              = 33;
00121     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00122     pluseq_scaled_2nd_deriv_of_det( R, a, T );
00123 
00124     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 0, 0 ), e );
00125     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 0, 1 ), e );
00126     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 0, 2 ), e );
00127     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 1, 0 ), e );
00128     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 1, 1 ), e );
00129     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 1, 2 ), e );
00130     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 2, 0 ), e );
00131     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 2, 1 ), e );
00132     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 2, 2 ), e );
00133 
00134     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[1]( 0, 0 ), e );
00135     CPPUNIT_ASSERT_DOUBLES_EQUAL( 33 * a, R[1]( 0, 1 ), e );
00136     CPPUNIT_ASSERT_DOUBLES_EQUAL( -32 * a, R[1]( 0, 2 ), e );
00137     CPPUNIT_ASSERT_DOUBLES_EQUAL( -33 * a, R[1]( 1, 0 ), e );
00138     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[1]( 1, 1 ), e );
00139     CPPUNIT_ASSERT_DOUBLES_EQUAL( 31 * a, R[1]( 1, 2 ), e );
00140     CPPUNIT_ASSERT_DOUBLES_EQUAL( 32 * a, R[1]( 2, 0 ), e );
00141     CPPUNIT_ASSERT_DOUBLES_EQUAL( -31 * a, R[1]( 2, 1 ), e );
00142     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[1]( 2, 2 ), e );
00143 
00144     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[2]( 0, 0 ), e );
00145     CPPUNIT_ASSERT_DOUBLES_EQUAL( -23 * a, R[2]( 0, 1 ), e );
00146     CPPUNIT_ASSERT_DOUBLES_EQUAL( 22 * a, R[2]( 0, 2 ), e );
00147     CPPUNIT_ASSERT_DOUBLES_EQUAL( 23 * a, R[2]( 1, 0 ), e );
00148     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[2]( 1, 1 ), e );
00149     CPPUNIT_ASSERT_DOUBLES_EQUAL( -21 * a, R[2]( 1, 2 ), e );
00150     CPPUNIT_ASSERT_DOUBLES_EQUAL( -22 * a, R[2]( 2, 0 ), e );
00151     CPPUNIT_ASSERT_DOUBLES_EQUAL( 21 * a, R[2]( 2, 1 ), e );
00152     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[2]( 2, 2 ), e );
00153 
00154     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 0, 0 ), e );
00155     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 0, 1 ), e );
00156     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 0, 2 ), e );
00157     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 1, 0 ), e );
00158     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 1, 1 ), e );
00159     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 1, 2 ), e );
00160     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 2, 0 ), e );
00161     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 2, 1 ), e );
00162     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 2, 2 ), e );
00163 
00164     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[4]( 0, 0 ), e );
00165     CPPUNIT_ASSERT_DOUBLES_EQUAL( 13 * a, R[4]( 0, 1 ), e );
00166     CPPUNIT_ASSERT_DOUBLES_EQUAL( -12 * a, R[4]( 0, 2 ), e );
00167     CPPUNIT_ASSERT_DOUBLES_EQUAL( -13 * a, R[4]( 1, 0 ), e );
00168     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[4]( 1, 1 ), e );
00169     CPPUNIT_ASSERT_DOUBLES_EQUAL( 11 * a, R[4]( 1, 2 ), e );
00170     CPPUNIT_ASSERT_DOUBLES_EQUAL( 12 * a, R[4]( 2, 0 ), e );
00171     CPPUNIT_ASSERT_DOUBLES_EQUAL( -11 * a, R[4]( 2, 1 ), e );
00172     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[4]( 2, 2 ), e );
00173 
00174     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 0, 0 ), e );
00175     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 0, 1 ), e );
00176     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 0, 2 ), e );
00177     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 1, 0 ), e );
00178     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 1, 1 ), e );
00179     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 1, 2 ), e );
00180     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 2, 0 ), e );
00181     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 2, 1 ), e );
00182     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 2, 2 ), e );
00183 }
00184 
00185 void TMPDerivsTest::test_set_scaled_2nd_deriv_of_det()
00186 {
00187     const double a = 0.7;
00188     const double e = 1e-12;
00189     MsqMatrix< 3, 3 > T;
00190     T( 0, 0 ) = 11;
00191     T( 0, 1 ) = 12;
00192     T( 0, 2 ) = 13;
00193     T( 1, 0 ) = 21;
00194     T( 1, 1 ) = 22;
00195     T( 1, 2 ) = 23;
00196     T( 2, 0 ) = 31;
00197     T( 2, 1 ) = 32;
00198     T( 2, 2 ) = 33;
00199     MsqMatrix< 3, 3 > R[6];
00200     for( int i = 0; i < 6; ++i )
00201         for( int r = 0; r < 3; ++r )
00202             for( int c = 0; c < 3; ++c )
00203                 R[i]( r, c ) = 9 * i + 3 * r + c;
00204 
00205     set_scaled_2nd_deriv_of_det( R, a, T );
00206 
00207     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 0, 0 ), e );
00208     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 0, 1 ), e );
00209     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 0, 2 ), e );
00210     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 1, 0 ), e );
00211     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 1, 1 ), e );
00212     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 1, 2 ), e );
00213     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 2, 0 ), e );
00214     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 2, 1 ), e );
00215     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[0]( 2, 2 ), e );
00216 
00217     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[1]( 0, 0 ), e );
00218     CPPUNIT_ASSERT_DOUBLES_EQUAL( 33 * a, R[1]( 0, 1 ), e );
00219     CPPUNIT_ASSERT_DOUBLES_EQUAL( -32 * a, R[1]( 0, 2 ), e );
00220     CPPUNIT_ASSERT_DOUBLES_EQUAL( -33 * a, R[1]( 1, 0 ), e );
00221     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[1]( 1, 1 ), e );
00222     CPPUNIT_ASSERT_DOUBLES_EQUAL( 31 * a, R[1]( 1, 2 ), e );
00223     CPPUNIT_ASSERT_DOUBLES_EQUAL( 32 * a, R[1]( 2, 0 ), e );
00224     CPPUNIT_ASSERT_DOUBLES_EQUAL( -31 * a, R[1]( 2, 1 ), e );
00225     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[1]( 2, 2 ), e );
00226 
00227     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[2]( 0, 0 ), e );
00228     CPPUNIT_ASSERT_DOUBLES_EQUAL( -23 * a, R[2]( 0, 1 ), e );
00229     CPPUNIT_ASSERT_DOUBLES_EQUAL( 22 * a, R[2]( 0, 2 ), e );
00230     CPPUNIT_ASSERT_DOUBLES_EQUAL( 23 * a, R[2]( 1, 0 ), e );
00231     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[2]( 1, 1 ), e );
00232     CPPUNIT_ASSERT_DOUBLES_EQUAL( -21 * a, R[2]( 1, 2 ), e );
00233     CPPUNIT_ASSERT_DOUBLES_EQUAL( -22 * a, R[2]( 2, 0 ), e );
00234     CPPUNIT_ASSERT_DOUBLES_EQUAL( 21 * a, R[2]( 2, 1 ), e );
00235     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[2]( 2, 2 ), e );
00236 
00237     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 0, 0 ), e );
00238     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 0, 1 ), e );
00239     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 0, 2 ), e );
00240     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 1, 0 ), e );
00241     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 1, 1 ), e );
00242     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 1, 2 ), e );
00243     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 2, 0 ), e );
00244     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 2, 1 ), e );
00245     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[3]( 2, 2 ), e );
00246 
00247     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[4]( 0, 0 ), e );
00248     CPPUNIT_ASSERT_DOUBLES_EQUAL( 13 * a, R[4]( 0, 1 ), e );
00249     CPPUNIT_ASSERT_DOUBLES_EQUAL( -12 * a, R[4]( 0, 2 ), e );
00250     CPPUNIT_ASSERT_DOUBLES_EQUAL( -13 * a, R[4]( 1, 0 ), e );
00251     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[4]( 1, 1 ), e );
00252     CPPUNIT_ASSERT_DOUBLES_EQUAL( 11 * a, R[4]( 1, 2 ), e );
00253     CPPUNIT_ASSERT_DOUBLES_EQUAL( 12 * a, R[4]( 2, 0 ), e );
00254     CPPUNIT_ASSERT_DOUBLES_EQUAL( -11 * a, R[4]( 2, 1 ), e );
00255     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[4]( 2, 2 ), e );
00256 
00257     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 0, 0 ), e );
00258     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 0, 1 ), e );
00259     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 0, 2 ), e );
00260     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 1, 0 ), e );
00261     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 1, 1 ), e );
00262     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 1, 2 ), e );
00263     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 2, 0 ), e );
00264     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 2, 1 ), e );
00265     CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, R[5]( 2, 2 ), e );
00266 }
00267 
00268 void TMPDerivsTest::test_pluseq_scaled_outer_product()
00269 {
00270     const double vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00271     const MsqMatrix< 3, 3 > M( vals );
00272     const double a = 0.1212;
00273     const double e = 1e-12;
00274 
00275     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00276     pluseq_scaled_outer_product( R, a, M );
00277 
00278 #ifdef MSQ_ROW_BASED_OUTER_PRODUCT
00279     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 0 ) ) * M.row( 0 ), R[0], e );
00280     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 0 ) ) * M.row( 1 ), R[1], e );
00281     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 0 ) ) * M.row( 2 ), R[2], e );
00282     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 1 ) ) * M.row( 1 ), R[3], e );
00283     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 1 ) ) * M.row( 2 ), R[4], e );
00284     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 2 ) ) * M.row( 2 ), R[5], e );
00285 #else
00286     ASSERT_MATRICES_EQUAL( a * M.column( 0 ) * transpose( M.column( 0 ) ), R[0], e );
00287     ASSERT_MATRICES_EQUAL( a * M.column( 0 ) * transpose( M.column( 1 ) ), R[1], e );
00288     ASSERT_MATRICES_EQUAL( a * M.column( 0 ) * transpose( M.column( 2 ) ), R[2], e );
00289     ASSERT_MATRICES_EQUAL( a * M.column( 1 ) * transpose( M.column( 1 ) ), R[3], e );
00290     ASSERT_MATRICES_EQUAL( a * M.column( 1 ) * transpose( M.column( 2 ) ), R[4], e );
00291     ASSERT_MATRICES_EQUAL( a * M.column( 2 ) * transpose( M.column( 2 ) ), R[5], e );
00292 #endif
00293 }
00294 
00295 void TMPDerivsTest::test_set_scaled_outer_product()
00296 {
00297     const double vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00298     const MsqMatrix< 3, 3 > M( vals );
00299     const double a = 0.1212;
00300     const double e = 1e-12;
00301 
00302     MsqMatrix< 3, 3 > R[6];
00303     for( int i = 0; i < 6; ++i )
00304         for( int r = 0; r < 3; ++r )
00305             for( int c = 0; c < 3; ++c )
00306                 R[i]( r, c ) = 9 * i + 3 * r + c;
00307     set_scaled_outer_product( R, a, M );
00308 
00309 #ifdef MSQ_ROW_BASED_OUTER_PRODUCT
00310     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 0 ) ) * M.row( 0 ), R[0], e );
00311     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 0 ) ) * M.row( 1 ), R[1], e );
00312     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 0 ) ) * M.row( 2 ), R[2], e );
00313     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 1 ) ) * M.row( 1 ), R[3], e );
00314     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 1 ) ) * M.row( 2 ), R[4], e );
00315     ASSERT_MATRICES_EQUAL( a * transpose( M.row( 2 ) ) * M.row( 2 ), R[5], e );
00316 #else
00317     ASSERT_MATRICES_EQUAL( a * M.column( 0 ) * transpose( M.column( 0 ) ), R[0], e );
00318     ASSERT_MATRICES_EQUAL( a * M.column( 0 ) * transpose( M.column( 1 ) ), R[1], e );
00319     ASSERT_MATRICES_EQUAL( a * M.column( 0 ) * transpose( M.column( 2 ) ), R[2], e );
00320     ASSERT_MATRICES_EQUAL( a * M.column( 1 ) * transpose( M.column( 1 ) ), R[3], e );
00321     ASSERT_MATRICES_EQUAL( a * M.column( 1 ) * transpose( M.column( 2 ) ), R[4], e );
00322     ASSERT_MATRICES_EQUAL( a * M.column( 2 ) * transpose( M.column( 2 ) ), R[5], e );
00323 #endif
00324 }
00325 
00326 void TMPDerivsTest::test_set_scaled_sum_outer_product_3D()
00327 {
00328     const double vals1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00329     const double vals2[] = { -1, -2, -3, -4, -5, -6, -7, -8, -9 };
00330     const MsqMatrix< 3, 3 > A( vals1 ), B( vals2 );
00331     const double a = 2.3;
00332     const double e = 1e-12;
00333 
00334     MsqMatrix< 3, 3 > R[6] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
00335     set_scaled_sum_outer_product( R, a, A, B );
00336 
00337 #ifdef MSQ_ROW_BASED_OUTER_PRODUCT
00338     const MsqMatrix< 3, 3 > E[6] = { transpose( A.row( 0 ) ) * B.row( 0 ) + transpose( B.row( 0 ) ) * A.row( 0 ),
00339                                      transpose( A.row( 0 ) ) * B.row( 1 ) + transpose( B.row( 0 ) ) * A.row( 1 ),
00340                                      transpose( A.row( 0 ) ) * B.row( 2 ) + transpose( B.row( 0 ) ) * A.row( 2 ),
00341                                      transpose( A.row( 1 ) ) * B.row( 1 ) + transpose( B.row( 1 ) ) * A.row( 1 ),
00342                                      transpose( A.row( 1 ) ) * B.row( 2 ) + transpose( B.row( 1 ) ) * A.row( 2 ),
00343                                      transpose( A.row( 2 ) ) * B.row( 2 ) + transpose( B.row( 2 ) ) * A.row( 2 ) };
00344 #else
00345     const MsqMatrix< 3, 3 > E[6] = {
00346         A.column( 0 ) * transpose( B.column( 0 ) ) + B.column( 0 ) * transpose( A.column( 0 ) ),
00347         A.column( 0 ) * transpose( B.column( 1 ) ) + B.column( 0 ) * transpose( A.column( 1 ) ),
00348         A.column( 0 ) * transpose( B.column( 2 ) ) + B.column( 0 ) * transpose( A.column( 2 ) ),
00349         A.column( 1 ) * transpose( B.column( 1 ) ) + B.column( 1 ) * transpose( A.column( 1 ) ),
00350         A.column( 1 ) * transpose( B.column( 2 ) ) + B.column( 1 ) * transpose( A.column( 2 ) ),
00351         A.column( 2 ) * transpose( B.column( 2 ) ) + B.column( 2 ) * transpose( A.column( 2 ) ) };
00352 #endif
00353 
00354     ASSERT_MATRICES_EQUAL( a * E[0], R[0], e );
00355     ASSERT_MATRICES_EQUAL( a * E[1], R[1], e );
00356     ASSERT_MATRICES_EQUAL( a * E[2], R[2], e );
00357     ASSERT_MATRICES_EQUAL( a * E[3], R[3], e );
00358     ASSERT_MATRICES_EQUAL( a * E[4], R[4], e );
00359     ASSERT_MATRICES_EQUAL( a * E[5], R[5], e );
00360 }
00361 void TMPDerivsTest::test_set_scaled_sum_outer_product_2D()
00362 {
00363     const double vals1[] = { 1, 2, 3, 4 };
00364     const double vals2[] = { -1, -2, -3, -4 };
00365     const MsqMatrix< 2, 2 > A( vals1 ), B( vals2 );
00366     const double a = 2.3;
00367     const double e = 1e-12;
00368 
00369     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 };
00370     pluseq_scaled_sum_outer_product( R, a, A, B );
00371 
00372 #ifdef MSQ_ROW_BASED_OUTER_PRODUCT
00373     const MsqMatrix< 2, 2 > E[3] = {
00374         transpose( A.row( 0 ) ) * B.row( 0 ) + transpose( B.row( 0 ) ) * A.row( 0 ),
00375         transpose( A.row( 0 ) ) * B.row( 1 ) + transpose( B.row( 0 ) ) * A.row( 1 ),
00376         transpose( A.row( 1 ) ) * B.row( 1 ) + transpose( B.row( 1 ) ) * A.row( 1 ),
00377     };
00378 #else
00379     const MsqMatrix< 2, 2 > E[3] = {
00380         A.column( 0 ) * transpose( B.column( 0 ) ) + B.column( 0 ) * transpose( A.column( 0 ) ),
00381         A.column( 0 ) * transpose( B.column( 1 ) ) + B.column( 0 ) * transpose( A.column( 1 ) ),
00382         A.column( 1 ) * transpose( B.column( 1 ) ) + B.column( 1 ) * transpose( A.column( 1 ) ),
00383     };
00384 #endif
00385 
00386     ASSERT_MATRICES_EQUAL( a * E[0], R[0], e );
00387     ASSERT_MATRICES_EQUAL( a * E[1], R[1], e );
00388     ASSERT_MATRICES_EQUAL( a * E[2], R[2], e );
00389 }
00390 
00391 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_3D()
00392 {
00393     const double vals1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00394     const double vals2[] = { -1, -2, -3, -4, -5, -6, -7, -8, -9 };
00395     const MsqMatrix< 3, 3 > A( vals1 ), B( vals2 );
00396     const double a = 2.3;
00397     const double e = 1e-12;
00398 
00399     double off             = 0.5;
00400     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00401     MsqMatrix< 3, 3 > S[6] = { off, off, off, off, off, off };
00402     MsqMatrix< 3, 3 > E[6];
00403 
00404     pluseq_scaled_sum_outer_product( R, a, A, B );
00405     pluseq_scaled_sum_outer_product( S, a, A, B );
00406     set_scaled_sum_outer_product( E, a, A, B );
00407 
00408     ASSERT_MATRICES_EQUAL( E[0], R[0], e );
00409     ASSERT_MATRICES_EQUAL( E[1], R[1], e );
00410     ASSERT_MATRICES_EQUAL( E[2], R[2], e );
00411     ASSERT_MATRICES_EQUAL( E[3], R[3], e );
00412     ASSERT_MATRICES_EQUAL( E[4], R[4], e );
00413     ASSERT_MATRICES_EQUAL( E[5], R[5], e );
00414 
00415     MsqMatrix< 3, 3 > P( off );
00416     ASSERT_MATRICES_EQUAL( E[0] + P, S[0], e );
00417     ASSERT_MATRICES_EQUAL( E[1] + P, S[1], e );
00418     ASSERT_MATRICES_EQUAL( E[2] + P, S[2], e );
00419     ASSERT_MATRICES_EQUAL( E[3] + P, S[3], e );
00420     ASSERT_MATRICES_EQUAL( E[4] + P, S[4], e );
00421     ASSERT_MATRICES_EQUAL( E[5] + P, S[5], e );
00422 }
00423 
00424 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_2D()
00425 {
00426     const double vals1[] = { 1, 2, 3, 4 };
00427     const double vals2[] = { -1, -2, -3, -4 };
00428     const MsqMatrix< 2, 2 > A( vals1 ), B( vals2 );
00429     const double a = 2.3;
00430     const double e = 1e-12;
00431 
00432     double off             = 0.5;
00433     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 };
00434     MsqMatrix< 2, 2 > S[3] = { off, off, off };
00435     MsqMatrix< 2, 2 > E[3];
00436 
00437     pluseq_scaled_sum_outer_product( R, a, A, B );
00438     pluseq_scaled_sum_outer_product( S, a, A, B );
00439     set_scaled_sum_outer_product( E, a, A, B );
00440 
00441     ASSERT_MATRICES_EQUAL( E[0], R[0], e );
00442     ASSERT_MATRICES_EQUAL( E[1], R[1], e );
00443     ASSERT_MATRICES_EQUAL( E[2], R[2], e );
00444 
00445     MsqMatrix< 2, 2 > P( off );
00446     ASSERT_MATRICES_EQUAL( E[0] + P, S[0], e );
00447     ASSERT_MATRICES_EQUAL( E[1] + P, S[1], e );
00448     ASSERT_MATRICES_EQUAL( E[2] + P, S[2], e );
00449 }
00450 
00451 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_I_3D()
00452 {
00453     const double e      = 1e-12;
00454     const double vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00455     const MsqMatrix< 3, 3 > A( vals ), I( 1.0 );
00456 
00457     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00458     MsqMatrix< 3, 3 > S[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00459     pluseq_scaled_sum_outer_product( R, 1.0, I, A );
00460     pluseq_scaled_sum_outer_product_I( S, 1.0, A );
00461     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00462     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00463     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00464     ASSERT_MATRICES_EQUAL( R[3], S[3], e );
00465     ASSERT_MATRICES_EQUAL( R[4], S[4], e );
00466     ASSERT_MATRICES_EQUAL( R[5], S[5], e );
00467 
00468     MsqMatrix< 3, 3 > T[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00469     MsqMatrix< 3, 3 > U[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00470     pluseq_scaled_sum_outer_product( R, -0.333, I, A );
00471     pluseq_scaled_sum_outer_product_I( S, -0.333, A );
00472     ASSERT_MATRICES_EQUAL( T[0], U[0], e );
00473     ASSERT_MATRICES_EQUAL( T[1], U[1], e );
00474     ASSERT_MATRICES_EQUAL( T[2], U[2], e );
00475     ASSERT_MATRICES_EQUAL( T[3], U[3], e );
00476     ASSERT_MATRICES_EQUAL( T[4], U[4], e );
00477     ASSERT_MATRICES_EQUAL( T[5], U[5], e );
00478 }
00479 
00480 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_I_2D()
00481 {
00482     const double e      = 1e-12;
00483     const double vals[] = { 1, 2, 3, 4 };
00484     const MsqMatrix< 2, 2 > A( vals ), I( 1.0 );
00485 
00486     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 };
00487     MsqMatrix< 2, 2 > S[3] = { 0.0, 0.0, 0.0 };
00488     pluseq_scaled_sum_outer_product( R, 1.0, I, A );
00489     pluseq_scaled_sum_outer_product_I( S, 1.0, A );
00490     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00491     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00492     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00493 
00494     MsqMatrix< 2, 2 > T[3] = { 0.0, 0.0, 0.0 };
00495     MsqMatrix< 2, 2 > U[3] = { 0.0, 0.0, 0.0 };
00496     pluseq_scaled_sum_outer_product( R, -0.333, I, A );
00497     pluseq_scaled_sum_outer_product_I( S, -0.333, A );
00498     ASSERT_MATRICES_EQUAL( T[0], U[0], e );
00499     ASSERT_MATRICES_EQUAL( T[1], U[1], e );
00500     ASSERT_MATRICES_EQUAL( T[2], U[2], e );
00501 }
00502 
00503 void TMPDerivsTest::test_pluseq_scaled_outer_product_I_I_2D()
00504 {
00505     const double e         = 1e-12;
00506     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 }, S[3] = { 0.0, 0.0, 0.0 };
00507     const double alpha = 3.14;
00508     pluseq_scaled_outer_product( R, alpha, MsqMatrix< 2, 2 >( 1.0 ) );
00509     pluseq_scaled_outer_product_I_I( S, alpha );
00510     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00511     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00512     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00513 }
00514 
00515 void TMPDerivsTest::test_pluseq_scaled_outer_product_I_I_3D()
00516 {
00517     const double e         = 1e-12;
00518     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, S[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00519     const double alpha = 3.14;
00520     pluseq_scaled_outer_product( R, alpha, MsqMatrix< 3, 3 >( 1.0 ) );
00521     pluseq_scaled_outer_product_I_I( S, alpha );
00522     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00523     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00524     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00525     ASSERT_MATRICES_EQUAL( R[3], S[3], e );
00526     ASSERT_MATRICES_EQUAL( R[4], S[4], e );
00527     ASSERT_MATRICES_EQUAL( R[5], S[5], e );
00528 }
00529 
00530 static inline MsqMatrix< 3, 3 > first_deriv_norm_sqr_adj( const MsqMatrix< 3, 3 >& T )
00531 {
00532     return 2 * ( ( sqr_Frobenius( T ) * T ) - ( T * transpose( T ) * T ) );
00533 }
00534 
00535 void TMPDerivsTest::test_set_scaled_2nd_deriv_norm_sqr_adj()
00536 {
00537     const double e      = 5e-2;
00538     const double delta  = 1e-3;
00539     const double vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00540     const MsqMatrix< 3, 3 > A( vals );
00541     const MsqMatrix< 3, 3 > dA = first_deriv_norm_sqr_adj( A );
00542 
00543     MsqMatrix< 3, 3 > actual[6] = { -1, -1, -1, -1, -1, -1 };
00544     set_scaled_2nd_deriv_norm_sqr_adj( actual, 1.0, A );
00545 
00546     MsqMatrix< 3, 3 > B( A );
00547     B( 0, 0 ) += delta;
00548     MsqMatrix< 3, 3 > dB = first_deriv_norm_sqr_adj( B );
00549     dB -= dA;
00550     dB /= delta;
00551     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 0 ), actual[0]( 0, 0 ), e );
00552     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 1 ), actual[0]( 0, 1 ), e );
00553     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 2 ), actual[0]( 0, 2 ), e );
00554     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[1]( 0, 0 ), e );
00555     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[1]( 0, 1 ), e );
00556     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[1]( 0, 2 ), e );
00557     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[2]( 0, 0 ), e );
00558     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[2]( 0, 1 ), e );
00559     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[2]( 0, 2 ), e );
00560 
00561     B = A;
00562     B( 0, 1 ) += delta;
00563     dB = first_deriv_norm_sqr_adj( B );
00564     dB -= dA;
00565     dB /= delta;
00566     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 0 ), actual[0]( 1, 0 ), e );
00567     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 1 ), actual[0]( 1, 1 ), e );
00568     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 2 ), actual[0]( 1, 2 ), e );
00569     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[1]( 1, 0 ), e );
00570     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[1]( 1, 1 ), e );
00571     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[1]( 1, 2 ), e );
00572     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[2]( 1, 0 ), e );
00573     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[2]( 1, 1 ), e );
00574     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[2]( 1, 2 ), e );
00575 
00576     B = A;
00577     B( 0, 2 ) += delta;
00578     dB = first_deriv_norm_sqr_adj( B );
00579     dB -= dA;
00580     dB /= delta;
00581     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 0 ), actual[0]( 2, 0 ), e );
00582     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 1 ), actual[0]( 2, 1 ), e );
00583     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 2 ), actual[0]( 2, 2 ), e );
00584     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[1]( 2, 0 ), e );
00585     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[1]( 2, 1 ), e );
00586     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[1]( 2, 2 ), e );
00587     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[2]( 2, 0 ), e );
00588     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[2]( 2, 1 ), e );
00589     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[2]( 2, 2 ), e );
00590 
00591     B = A;
00592     B( 1, 0 ) += delta;
00593     dB = first_deriv_norm_sqr_adj( B );
00594     dB -= dA;
00595     dB /= delta;
00596     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[3]( 0, 0 ), e );
00597     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[3]( 0, 1 ), e );
00598     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[3]( 0, 2 ), e );
00599     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[4]( 0, 0 ), e );
00600     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[4]( 0, 1 ), e );
00601     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[4]( 0, 2 ), e );
00602 
00603     B = A;
00604     B( 1, 1 ) += delta;
00605     dB = first_deriv_norm_sqr_adj( B );
00606     dB -= dA;
00607     dB /= delta;
00608     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[3]( 1, 0 ), e );
00609     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[3]( 1, 1 ), e );
00610     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[3]( 1, 2 ), e );
00611     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[4]( 1, 0 ), e );
00612     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[4]( 1, 1 ), e );
00613     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[4]( 1, 2 ), e );
00614 
00615     B = A;
00616     B( 1, 2 ) += delta;
00617     dB = first_deriv_norm_sqr_adj( B );
00618     dB -= dA;
00619     dB /= delta;
00620     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[3]( 2, 0 ), e );
00621     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[3]( 2, 1 ), e );
00622     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[3]( 2, 2 ), e );
00623     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[4]( 2, 0 ), e );
00624     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[4]( 2, 1 ), e );
00625     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[4]( 2, 2 ), e );
00626 
00627     B = A;
00628     B( 2, 0 ) += delta;
00629     dB = first_deriv_norm_sqr_adj( B );
00630     dB -= dA;
00631     dB /= delta;
00632     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[5]( 0, 0 ), e );
00633     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[5]( 0, 1 ), e );
00634     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[5]( 0, 2 ), e );
00635 
00636     B = A;
00637     B( 2, 1 ) += delta;
00638     dB = first_deriv_norm_sqr_adj( B );
00639     dB -= dA;
00640     dB /= delta;
00641     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[5]( 1, 0 ), e );
00642     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[5]( 1, 1 ), e );
00643     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[5]( 1, 2 ), e );
00644 
00645     B = A;
00646     B( 2, 2 ) += delta;
00647     dB = first_deriv_norm_sqr_adj( B );
00648     dB -= dA;
00649     dB /= delta;
00650     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[5]( 2, 0 ), e );
00651     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[5]( 2, 1 ), e );
00652     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[5]( 2, 2 ), e );
00653 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines