MOAB: Mesh Oriented datABase  (version 5.2.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     jason@kraftcheck.com
00024 
00025   ***************************************************************** */
00026 /** \file TMPDerivsTest.cpp
00027  * \autor Jason Kraftcheck <jason@kraftcheck.com>
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     };
00353 #endif
00354 
00355     ASSERT_MATRICES_EQUAL( a * E[0], R[0], e );
00356     ASSERT_MATRICES_EQUAL( a * E[1], R[1], e );
00357     ASSERT_MATRICES_EQUAL( a * E[2], R[2], e );
00358     ASSERT_MATRICES_EQUAL( a * E[3], R[3], e );
00359     ASSERT_MATRICES_EQUAL( a * E[4], R[4], e );
00360     ASSERT_MATRICES_EQUAL( a * E[5], R[5], e );
00361 }
00362 void TMPDerivsTest::test_set_scaled_sum_outer_product_2D()
00363 {
00364     const double vals1[] = { 1, 2, 3, 4 };
00365     const double vals2[] = { -1, -2, -3, -4 };
00366     const MsqMatrix< 2, 2 > A( vals1 ), B( vals2 );
00367     const double a = 2.3;
00368     const double e = 1e-12;
00369 
00370     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 };
00371     pluseq_scaled_sum_outer_product( R, a, A, B );
00372 
00373 #ifdef MSQ_ROW_BASED_OUTER_PRODUCT
00374     const MsqMatrix< 2, 2 > E[3] = {
00375         transpose( A.row( 0 ) ) * B.row( 0 ) + transpose( B.row( 0 ) ) * A.row( 0 ),
00376         transpose( A.row( 0 ) ) * B.row( 1 ) + transpose( B.row( 0 ) ) * A.row( 1 ),
00377         transpose( A.row( 1 ) ) * B.row( 1 ) + transpose( B.row( 1 ) ) * A.row( 1 ),
00378     };
00379 #else
00380     const MsqMatrix< 2, 2 > E[3] = {
00381         A.column( 0 ) * transpose( B.column( 0 ) ) + B.column( 0 ) * transpose( A.column( 0 ) ),
00382         A.column( 0 ) * transpose( B.column( 1 ) ) + B.column( 0 ) * transpose( A.column( 1 ) ),
00383         A.column( 1 ) * transpose( B.column( 1 ) ) + B.column( 1 ) * transpose( A.column( 1 ) ),
00384     };
00385 #endif
00386 
00387     ASSERT_MATRICES_EQUAL( a * E[0], R[0], e );
00388     ASSERT_MATRICES_EQUAL( a * E[1], R[1], e );
00389     ASSERT_MATRICES_EQUAL( a * E[2], R[2], e );
00390 }
00391 
00392 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_3D()
00393 {
00394     const double vals1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00395     const double vals2[] = { -1, -2, -3, -4, -5, -6, -7, -8, -9 };
00396     const MsqMatrix< 3, 3 > A( vals1 ), B( vals2 );
00397     const double a = 2.3;
00398     const double e = 1e-12;
00399 
00400     double off             = 0.5;
00401     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00402     MsqMatrix< 3, 3 > S[6] = { off, off, off, off, off, off };
00403     MsqMatrix< 3, 3 > E[6];
00404 
00405     pluseq_scaled_sum_outer_product( R, a, A, B );
00406     pluseq_scaled_sum_outer_product( S, a, A, B );
00407     set_scaled_sum_outer_product( E, a, A, B );
00408 
00409     ASSERT_MATRICES_EQUAL( E[0], R[0], e );
00410     ASSERT_MATRICES_EQUAL( E[1], R[1], e );
00411     ASSERT_MATRICES_EQUAL( E[2], R[2], e );
00412     ASSERT_MATRICES_EQUAL( E[3], R[3], e );
00413     ASSERT_MATRICES_EQUAL( E[4], R[4], e );
00414     ASSERT_MATRICES_EQUAL( E[5], R[5], e );
00415 
00416     MsqMatrix< 3, 3 > P( off );
00417     ASSERT_MATRICES_EQUAL( E[0] + P, S[0], e );
00418     ASSERT_MATRICES_EQUAL( E[1] + P, S[1], e );
00419     ASSERT_MATRICES_EQUAL( E[2] + P, S[2], e );
00420     ASSERT_MATRICES_EQUAL( E[3] + P, S[3], e );
00421     ASSERT_MATRICES_EQUAL( E[4] + P, S[4], e );
00422     ASSERT_MATRICES_EQUAL( E[5] + P, S[5], e );
00423 }
00424 
00425 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_2D()
00426 {
00427     const double vals1[] = { 1, 2, 3, 4 };
00428     const double vals2[] = { -1, -2, -3, -4 };
00429     const MsqMatrix< 2, 2 > A( vals1 ), B( vals2 );
00430     const double a = 2.3;
00431     const double e = 1e-12;
00432 
00433     double off             = 0.5;
00434     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 };
00435     MsqMatrix< 2, 2 > S[3] = { off, off, off };
00436     MsqMatrix< 2, 2 > E[3];
00437 
00438     pluseq_scaled_sum_outer_product( R, a, A, B );
00439     pluseq_scaled_sum_outer_product( S, a, A, B );
00440     set_scaled_sum_outer_product( E, a, A, B );
00441 
00442     ASSERT_MATRICES_EQUAL( E[0], R[0], e );
00443     ASSERT_MATRICES_EQUAL( E[1], R[1], e );
00444     ASSERT_MATRICES_EQUAL( E[2], R[2], e );
00445 
00446     MsqMatrix< 2, 2 > P( off );
00447     ASSERT_MATRICES_EQUAL( E[0] + P, S[0], e );
00448     ASSERT_MATRICES_EQUAL( E[1] + P, S[1], e );
00449     ASSERT_MATRICES_EQUAL( E[2] + P, S[2], e );
00450 }
00451 
00452 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_I_3D()
00453 {
00454     const double e      = 1e-12;
00455     const double vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00456     const MsqMatrix< 3, 3 > A( vals ), I( 1.0 );
00457 
00458     MsqMatrix< 3, 3 > R[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00459     MsqMatrix< 3, 3 > S[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00460     pluseq_scaled_sum_outer_product( R, 1.0, I, A );
00461     pluseq_scaled_sum_outer_product_I( S, 1.0, A );
00462     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00463     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00464     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00465     ASSERT_MATRICES_EQUAL( R[3], S[3], e );
00466     ASSERT_MATRICES_EQUAL( R[4], S[4], e );
00467     ASSERT_MATRICES_EQUAL( R[5], S[5], e );
00468 
00469     MsqMatrix< 3, 3 > T[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00470     MsqMatrix< 3, 3 > U[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
00471     pluseq_scaled_sum_outer_product( R, -0.333, I, A );
00472     pluseq_scaled_sum_outer_product_I( S, -0.333, A );
00473     ASSERT_MATRICES_EQUAL( T[0], U[0], e );
00474     ASSERT_MATRICES_EQUAL( T[1], U[1], e );
00475     ASSERT_MATRICES_EQUAL( T[2], U[2], e );
00476     ASSERT_MATRICES_EQUAL( T[3], U[3], e );
00477     ASSERT_MATRICES_EQUAL( T[4], U[4], e );
00478     ASSERT_MATRICES_EQUAL( T[5], U[5], e );
00479 }
00480 
00481 void TMPDerivsTest::test_pluseq_scaled_sum_outer_product_I_2D()
00482 {
00483     const double e      = 1e-12;
00484     const double vals[] = { 1, 2, 3, 4 };
00485     const MsqMatrix< 2, 2 > A( vals ), I( 1.0 );
00486 
00487     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 };
00488     MsqMatrix< 2, 2 > S[3] = { 0.0, 0.0, 0.0 };
00489     pluseq_scaled_sum_outer_product( R, 1.0, I, A );
00490     pluseq_scaled_sum_outer_product_I( S, 1.0, A );
00491     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00492     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00493     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00494 
00495     MsqMatrix< 2, 2 > T[3] = { 0.0, 0.0, 0.0 };
00496     MsqMatrix< 2, 2 > U[3] = { 0.0, 0.0, 0.0 };
00497     pluseq_scaled_sum_outer_product( R, -0.333, I, A );
00498     pluseq_scaled_sum_outer_product_I( S, -0.333, A );
00499     ASSERT_MATRICES_EQUAL( T[0], U[0], e );
00500     ASSERT_MATRICES_EQUAL( T[1], U[1], e );
00501     ASSERT_MATRICES_EQUAL( T[2], U[2], e );
00502 }
00503 
00504 void TMPDerivsTest::test_pluseq_scaled_outer_product_I_I_2D()
00505 {
00506     const double e         = 1e-12;
00507     MsqMatrix< 2, 2 > R[3] = { 0.0, 0.0, 0.0 }, S[3] = { 0.0, 0.0, 0.0 };
00508     const double alpha = 3.14;
00509     pluseq_scaled_outer_product( R, alpha, MsqMatrix< 2, 2 >( 1.0 ) );
00510     pluseq_scaled_outer_product_I_I( S, alpha );
00511     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00512     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00513     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00514 }
00515 
00516 void TMPDerivsTest::test_pluseq_scaled_outer_product_I_I_3D()
00517 {
00518     const double e         = 1e-12;
00519     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 };
00520     const double alpha = 3.14;
00521     pluseq_scaled_outer_product( R, alpha, MsqMatrix< 3, 3 >( 1.0 ) );
00522     pluseq_scaled_outer_product_I_I( S, alpha );
00523     ASSERT_MATRICES_EQUAL( R[0], S[0], e );
00524     ASSERT_MATRICES_EQUAL( R[1], S[1], e );
00525     ASSERT_MATRICES_EQUAL( R[2], S[2], e );
00526     ASSERT_MATRICES_EQUAL( R[3], S[3], e );
00527     ASSERT_MATRICES_EQUAL( R[4], S[4], e );
00528     ASSERT_MATRICES_EQUAL( R[5], S[5], e );
00529 }
00530 
00531 static inline MsqMatrix< 3, 3 > first_deriv_norm_sqr_adj( const MsqMatrix< 3, 3 >& T )
00532 {
00533     return 2 * ( ( sqr_Frobenius( T ) * T ) - ( T * transpose( T ) * T ) );
00534 }
00535 
00536 void TMPDerivsTest::test_set_scaled_2nd_deriv_norm_sqr_adj()
00537 {
00538     const double e      = 5e-2;
00539     const double delta  = 1e-3;
00540     const double vals[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
00541     const MsqMatrix< 3, 3 > A( vals );
00542     const MsqMatrix< 3, 3 > dA = first_deriv_norm_sqr_adj( A );
00543 
00544     MsqMatrix< 3, 3 > actual[6] = { -1, -1, -1, -1, -1, -1 };
00545     set_scaled_2nd_deriv_norm_sqr_adj( actual, 1.0, A );
00546 
00547     MsqMatrix< 3, 3 > B( A );
00548     B( 0, 0 ) += delta;
00549     MsqMatrix< 3, 3 > dB = first_deriv_norm_sqr_adj( B );
00550     dB -= dA;
00551     dB /= delta;
00552     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 0 ), actual[0]( 0, 0 ), e );
00553     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 1 ), actual[0]( 0, 1 ), e );
00554     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 2 ), actual[0]( 0, 2 ), e );
00555     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[1]( 0, 0 ), e );
00556     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[1]( 0, 1 ), e );
00557     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[1]( 0, 2 ), e );
00558     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[2]( 0, 0 ), e );
00559     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[2]( 0, 1 ), e );
00560     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[2]( 0, 2 ), e );
00561 
00562     B = A;
00563     B( 0, 1 ) += delta;
00564     dB = first_deriv_norm_sqr_adj( B );
00565     dB -= dA;
00566     dB /= delta;
00567     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 0 ), actual[0]( 1, 0 ), e );
00568     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 1 ), actual[0]( 1, 1 ), e );
00569     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 2 ), actual[0]( 1, 2 ), e );
00570     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[1]( 1, 0 ), e );
00571     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[1]( 1, 1 ), e );
00572     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[1]( 1, 2 ), e );
00573     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[2]( 1, 0 ), e );
00574     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[2]( 1, 1 ), e );
00575     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[2]( 1, 2 ), e );
00576 
00577     B = A;
00578     B( 0, 2 ) += delta;
00579     dB = first_deriv_norm_sqr_adj( B );
00580     dB -= dA;
00581     dB /= delta;
00582     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 0 ), actual[0]( 2, 0 ), e );
00583     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 1 ), actual[0]( 2, 1 ), e );
00584     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 0, 2 ), actual[0]( 2, 2 ), e );
00585     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[1]( 2, 0 ), e );
00586     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[1]( 2, 1 ), e );
00587     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[1]( 2, 2 ), e );
00588     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[2]( 2, 0 ), e );
00589     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[2]( 2, 1 ), e );
00590     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[2]( 2, 2 ), e );
00591 
00592     B = A;
00593     B( 1, 0 ) += delta;
00594     dB = first_deriv_norm_sqr_adj( B );
00595     dB -= dA;
00596     dB /= delta;
00597     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[3]( 0, 0 ), e );
00598     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[3]( 0, 1 ), e );
00599     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[3]( 0, 2 ), e );
00600     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[4]( 0, 0 ), e );
00601     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[4]( 0, 1 ), e );
00602     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[4]( 0, 2 ), e );
00603 
00604     B = A;
00605     B( 1, 1 ) += delta;
00606     dB = first_deriv_norm_sqr_adj( B );
00607     dB -= dA;
00608     dB /= delta;
00609     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[3]( 1, 0 ), e );
00610     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[3]( 1, 1 ), e );
00611     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[3]( 1, 2 ), e );
00612     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[4]( 1, 0 ), e );
00613     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[4]( 1, 1 ), e );
00614     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[4]( 1, 2 ), e );
00615 
00616     B = A;
00617     B( 1, 2 ) += delta;
00618     dB = first_deriv_norm_sqr_adj( B );
00619     dB -= dA;
00620     dB /= delta;
00621     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 0 ), actual[3]( 2, 0 ), e );
00622     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 1 ), actual[3]( 2, 1 ), e );
00623     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 1, 2 ), actual[3]( 2, 2 ), e );
00624     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[4]( 2, 0 ), e );
00625     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[4]( 2, 1 ), e );
00626     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[4]( 2, 2 ), e );
00627 
00628     B = A;
00629     B( 2, 0 ) += delta;
00630     dB = first_deriv_norm_sqr_adj( B );
00631     dB -= dA;
00632     dB /= delta;
00633     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[5]( 0, 0 ), e );
00634     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[5]( 0, 1 ), e );
00635     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[5]( 0, 2 ), e );
00636 
00637     B = A;
00638     B( 2, 1 ) += delta;
00639     dB = first_deriv_norm_sqr_adj( B );
00640     dB -= dA;
00641     dB /= delta;
00642     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[5]( 1, 0 ), e );
00643     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[5]( 1, 1 ), e );
00644     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[5]( 1, 2 ), e );
00645 
00646     B = A;
00647     B( 2, 2 ) += delta;
00648     dB = first_deriv_norm_sqr_adj( B );
00649     dB -= dA;
00650     dB /= delta;
00651     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 0 ), actual[5]( 2, 0 ), e );
00652     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 1 ), actual[5]( 2, 1 ), e );
00653     CPPUNIT_ASSERT_DOUBLES_EQUAL( dB( 2, 2 ), actual[5]( 2, 2 ), e );
00654 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines