ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/test/math/SquareMatrixTestCase.cpp
Revision: 1616
Committed: Wed Oct 20 18:07:08 2004 UTC (19 years, 8 months ago) by tim
File size: 2613 byte(s)
Log Message:
Math library pass the unit test

File Contents

# User Rev Content
1 tim 1571 #include "SquareMatrixTestCase.hpp"
2    
3     // Registers the fixture into the 'registry'
4     CPPUNIT_TEST_SUITE_REGISTRATION( SquareMatrixTestCase );
5    
6     void SquareMatrixTestCase::setUp() {
7    
8     identMat(0, 0) = 1.0;
9     identMat(0, 1) = 0.0;
10     identMat(0, 2) = 0.0;
11     identMat(1, 0) = 0.0;
12     identMat(1, 1) = 1.0;
13     identMat(1, 2) = 0.0;
14     identMat(2, 0) = 0.0;
15     identMat(2, 1) = 0.0;
16     identMat(2, 2) = 1.0;
17    
18     symMat(0, 0) = 2.0;
19     symMat(0, 1) = 4.0;
20     symMat(0, 2) = 0.5;
21     symMat(1, 0) = 4.0;
22     symMat(1, 1) = 1.0;
23     symMat(1, 2) = 3.0;
24     symMat(2, 0) = 0.5;
25     symMat(2, 1) = 3.0;
26     symMat(2, 2) = 1.0;
27    
28     ortMat(0, 0) = 1.0;
29     ortMat(0, 1) = 0.0;
30     ortMat(0, 2) = 0.0;
31     ortMat(1, 0) = 0.0;
32     ortMat(1, 1) = cos(0.5);
33     ortMat(1, 2) = -sin(0.5);
34     ortMat(2, 0) = 0.0;
35     ortMat(2, 1) = sin(0.5);
36     ortMat(2, 2) = cos(0.5);
37    
38     diagMat(0, 0) = 8.0;
39     diagMat(0, 1) = 0.0;
40     diagMat(0, 2) = 0.0;
41     diagMat(1, 0) = 0.0;
42     diagMat(1, 1) = 1.0;
43     diagMat(1, 2) = 0.0;
44     diagMat(2, 0) = 0.0;
45     diagMat(2, 1) = 0.0;
46     diagMat(2, 2) = 3.0;
47    
48     }
49    
50     void SquareMatrixTestCase::testConstructor() {
51    
52     }
53    
54     void SquareMatrixTestCase::testIdentity() {
55     CPPUNIT_ASSERT(SMat3x3::identity() == identMat);
56     }
57    
58    
59 tim 1616 void SquareMatrixTestCase::testJacobi() {
60     SMat3x3 a;
61     Vector<double, 3> w1L;
62     Vector<double, 3> w1R;
63     SMat3x3 v;
64     a(0, 0) = 3.0;
65     a(0, 1) = 4.0;
66     a(0, 2) = 5.0;
67     a(1, 0) = 4.0;
68     a(1, 1) = 5.0;
69     a(1, 2) = 6.0;
70     a(2, 0) = 5.0;
71     a(2, 1) = 6.0;
72     a(2, 2) = 7.0;
73 tim 1571
74 tim 1616 w1R[0] = 15.3899;
75     w1R[1] = 0.0;
76     w1R[2] = -0.389867;
77    
78     SMat3x3::jacobi(a, w1L, v);
79 tim 1571
80 tim 1616 CPPUNIT_ASSERT_DOUBLES_EQUAL(w1L[0], w1R[0], 0.0001);
81     CPPUNIT_ASSERT_DOUBLES_EQUAL(w1L[1], w1R[1], oopse::epsilon);
82     CPPUNIT_ASSERT_DOUBLES_EQUAL(w1L[2], w1R[2], oopse::epsilon);
83    
84 tim 1571 }
85    
86     void SquareMatrixTestCase::testTrace() {
87     CPPUNIT_ASSERT_DOUBLES_EQUAL(identMat.trace(), 3.0, oopse::epsilon);
88     CPPUNIT_ASSERT_DOUBLES_EQUAL(symMat.trace(), 4.0, oopse::epsilon);
89     }
90     void SquareMatrixTestCase::testIsSymmertric(){
91     CPPUNIT_ASSERT(identMat.isSymmetric());
92     CPPUNIT_ASSERT(symMat.isSymmetric());
93     }
94    
95     void SquareMatrixTestCase::testIsOrthogonal(){
96     CPPUNIT_ASSERT(ortMat.isOrthogonal());
97     }
98    
99     void SquareMatrixTestCase::testIsDiagonal() {
100     CPPUNIT_ASSERT(identMat.isDiagonal());
101     CPPUNIT_ASSERT(diagMat.isDiagonal());
102     CPPUNIT_ASSERT(!symMat.isDiagonal());
103     }
104     void SquareMatrixTestCase::testIsUnitMatrix() {
105     CPPUNIT_ASSERT(identMat.isUnitMatrix());
106     CPPUNIT_ASSERT(!symMat.isUnitMatrix());
107     }

Properties

Name Value
svn:executable *