Ignore:
Timestamp:
Jan 10, 2010, 7:25:50 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
9cdbee
Parents:
7b991d
Message:

Added Determinant() function to class GSLMatrix.

  • new function GSLMatrix::Determinant() which calculates the determinant for square matrices by LU decomposition.

Signed-off-by: Frederik Heber <heber@tabletINS.(none)>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/unittests/gslmatrixsymmetricunittest.cpp

    r7b991d r9291f85  
    247247  m->SetFromDoubleArray(array);
    248248  CPPUNIT_ASSERT_EQUAL( true, m->IsPositiveDefinite() );
     249
     250  //determinant
     251  m->SetIdentity();
     252  CPPUNIT_ASSERT_EQUAL( 1., m->Determinant() );
     253
     254  m->SetZero();
     255  CPPUNIT_ASSERT_EQUAL( 0., m->Determinant() );
     256
     257  m->Set( 0, 0, 1.);
     258  m->Set( 1, 1, 1.);
     259  m->Set( 2, 1, 1.);
     260  CPPUNIT_ASSERT_EQUAL( 0., m->Determinant() );
     261 
     262  double array2[] = { 2., 0., 1.,
     263                     -3., 1., 1.,
     264                     1., 5.5, 1. };
     265  m->SetFromDoubleArray(array2);
     266  CPPUNIT_ASSERT_EQUAL( -26.5, m->Determinant() );
    249267};
    250268
Note: See TracChangeset for help on using the changeset viewer.