[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[5630bd] | 8 | /*
|
---|
[7a0340] | 9 | * RealSpaceMatrixUnitTest.cpp
|
---|
[5630bd] | 10 | *
|
---|
| 11 | * Created on: Jul 7, 2010
|
---|
| 12 | * Author: crueger
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[5630bd] | 20 | #include <cppunit/CompilerOutputter.h>
|
---|
| 21 | #include <cppunit/extensions/TestFactoryRegistry.h>
|
---|
| 22 | #include <cppunit/ui/text/TestRunner.h>
|
---|
| 23 |
|
---|
[31fb1d] | 24 | #include <cmath>
|
---|
[9b410d] | 25 | #include <limits>
|
---|
[31fb1d] | 26 |
|
---|
[7a0340] | 27 | #include "RealSpaceMatrixUnitTest.hpp"
|
---|
[06aedc] | 28 |
|
---|
[bf4b9f] | 29 | #include "defs.hpp"
|
---|
| 30 | #include "Exceptions.hpp"
|
---|
| 31 | #include "RealSpaceMatrix.hpp"
|
---|
| 32 | #include "Vector.hpp"
|
---|
[5630bd] | 33 |
|
---|
| 34 | #ifdef HAVE_TESTRUNNER
|
---|
| 35 | #include "UnitTestMain.hpp"
|
---|
| 36 | #endif /*HAVE_TESTRUNNER*/
|
---|
| 37 |
|
---|
| 38 | // Registers the fixture into the 'registry'
|
---|
[7a0340] | 39 | CPPUNIT_TEST_SUITE_REGISTRATION( RealSpaceMatrixTest );
|
---|
[5630bd] | 40 |
|
---|
[7a0340] | 41 | void RealSpaceMatrixTest::setUp(){
|
---|
[cca9ef] | 42 | zero = new RealSpaceMatrix();
|
---|
[3bc926] | 43 | for(int i =NDIM;i--;) {
|
---|
| 44 | for(int j =NDIM;j--;) {
|
---|
| 45 | zero->at(i,j)=0.;
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
[cca9ef] | 48 | one = new RealSpaceMatrix();
|
---|
[5630bd] | 49 | for(int i =NDIM;i--;){
|
---|
| 50 | one->at(i,i)=1.;
|
---|
| 51 | }
|
---|
[cca9ef] | 52 | full=new RealSpaceMatrix();
|
---|
[5630bd] | 53 | for(int i=NDIM;i--;){
|
---|
| 54 | for(int j=NDIM;j--;){
|
---|
| 55 | full->at(i,j)=1.;
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
[cca9ef] | 58 | diagonal = new RealSpaceMatrix();
|
---|
[5630bd] | 59 | for(int i=NDIM;i--;){
|
---|
| 60 | diagonal->at(i,i)=i+1.;
|
---|
| 61 | }
|
---|
[cca9ef] | 62 | perm1 = new RealSpaceMatrix();
|
---|
[407782] | 63 | perm1->column(0) = unitVec[0];
|
---|
| 64 | perm1->column(1) = unitVec[2];
|
---|
| 65 | perm1->column(2) = unitVec[1];
|
---|
[5630bd] | 66 |
|
---|
| 67 |
|
---|
[cca9ef] | 68 | perm2 = new RealSpaceMatrix();
|
---|
[407782] | 69 | perm2->column(0) = unitVec[1];
|
---|
| 70 | perm2->column(1) = unitVec[0];
|
---|
| 71 | perm2->column(2) = unitVec[2];
|
---|
[5630bd] | 72 |
|
---|
[cca9ef] | 73 | perm3 = new RealSpaceMatrix();
|
---|
[407782] | 74 | perm3->column(0) = unitVec[1];
|
---|
| 75 | perm3->column(1) = unitVec[2];
|
---|
| 76 | perm3->column(2) = unitVec[0];
|
---|
[5630bd] | 77 |
|
---|
[cca9ef] | 78 | perm4 = new RealSpaceMatrix();
|
---|
[407782] | 79 | perm4->column(0) = unitVec[2];
|
---|
| 80 | perm4->column(1) = unitVec[1];
|
---|
| 81 | perm4->column(2) = unitVec[0];
|
---|
[5630bd] | 82 |
|
---|
[cca9ef] | 83 | perm5 = new RealSpaceMatrix();
|
---|
[407782] | 84 | perm5->column(0) = unitVec[2];
|
---|
| 85 | perm5->column(1) = unitVec[0];
|
---|
| 86 | perm5->column(2) = unitVec[1];
|
---|
[5630bd] | 87 |
|
---|
| 88 | }
|
---|
[7a0340] | 89 | void RealSpaceMatrixTest::tearDown(){
|
---|
[5630bd] | 90 | delete zero;
|
---|
| 91 | delete one;
|
---|
| 92 | delete full;
|
---|
| 93 | delete diagonal;
|
---|
| 94 | delete perm1;
|
---|
| 95 | delete perm2;
|
---|
| 96 | delete perm3;
|
---|
| 97 | delete perm4;
|
---|
| 98 | delete perm5;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
[7a0340] | 101 | void RealSpaceMatrixTest::AccessTest(){
|
---|
[cca9ef] | 102 | RealSpaceMatrix mat;
|
---|
[5630bd] | 103 | for(int i=NDIM;i--;){
|
---|
| 104 | for(int j=NDIM;j--;){
|
---|
| 105 | CPPUNIT_ASSERT_EQUAL(mat.at(i,j),0.);
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 | int k=1;
|
---|
| 109 | for(int i=NDIM;i--;){
|
---|
| 110 | for(int j=NDIM;j--;){
|
---|
| 111 | mat.at(i,j)=k++;
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 | k=1;
|
---|
| 115 | for(int i=NDIM;i--;){
|
---|
| 116 | for(int j=NDIM;j--;){
|
---|
| 117 | CPPUNIT_ASSERT_EQUAL(mat.at(i,j),(double)k);
|
---|
| 118 | ++k;
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[7a0340] | 123 | void RealSpaceMatrixTest::VectorTest(){
|
---|
[cca9ef] | 124 | RealSpaceMatrix mat;
|
---|
[5630bd] | 125 | for(int i=NDIM;i--;){
|
---|
| 126 | CPPUNIT_ASSERT_EQUAL(mat.row(i),zeroVec);
|
---|
| 127 | CPPUNIT_ASSERT_EQUAL(mat.column(i),zeroVec);
|
---|
| 128 | }
|
---|
| 129 | CPPUNIT_ASSERT_EQUAL(mat.diagonal(),zeroVec);
|
---|
| 130 |
|
---|
[9eb7580] | 131 | mat.setIdentity();
|
---|
[407782] | 132 | CPPUNIT_ASSERT_EQUAL(mat.row(0),unitVec[0]);
|
---|
| 133 | CPPUNIT_ASSERT_EQUAL(mat.row(1),unitVec[1]);
|
---|
| 134 | CPPUNIT_ASSERT_EQUAL(mat.row(2),unitVec[2]);
|
---|
| 135 | CPPUNIT_ASSERT_EQUAL(mat.column(0),unitVec[0]);
|
---|
| 136 | CPPUNIT_ASSERT_EQUAL(mat.column(1),unitVec[1]);
|
---|
| 137 | CPPUNIT_ASSERT_EQUAL(mat.column(2),unitVec[2]);
|
---|
[5630bd] | 138 |
|
---|
| 139 | Vector t1=Vector(1.,1.,1.);
|
---|
| 140 | Vector t2=Vector(2.,2.,2.);
|
---|
| 141 | Vector t3=Vector(3.,3.,3.);
|
---|
| 142 | Vector t4=Vector(1.,2.,3.);
|
---|
| 143 |
|
---|
| 144 | mat.row(0)=t1;
|
---|
| 145 | mat.row(1)=t2;
|
---|
| 146 | mat.row(2)=t3;
|
---|
| 147 | CPPUNIT_ASSERT_EQUAL(mat.row(0),t1);
|
---|
| 148 | CPPUNIT_ASSERT_EQUAL(mat.row(1),t2);
|
---|
| 149 | CPPUNIT_ASSERT_EQUAL(mat.row(2),t3);
|
---|
| 150 | CPPUNIT_ASSERT_EQUAL(mat.column(0),t4);
|
---|
| 151 | CPPUNIT_ASSERT_EQUAL(mat.column(1),t4);
|
---|
| 152 | CPPUNIT_ASSERT_EQUAL(mat.column(2),t4);
|
---|
| 153 | CPPUNIT_ASSERT_EQUAL(mat.diagonal(),t4);
|
---|
| 154 | for(int i=NDIM;i--;){
|
---|
| 155 | for(int j=NDIM;j--;){
|
---|
| 156 | CPPUNIT_ASSERT_EQUAL(mat.at(i,j),i+1.);
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | mat.column(0)=t1;
|
---|
| 161 | mat.column(1)=t2;
|
---|
| 162 | mat.column(2)=t3;
|
---|
| 163 | CPPUNIT_ASSERT_EQUAL(mat.column(0),t1);
|
---|
| 164 | CPPUNIT_ASSERT_EQUAL(mat.column(1),t2);
|
---|
| 165 | CPPUNIT_ASSERT_EQUAL(mat.column(2),t3);
|
---|
| 166 | CPPUNIT_ASSERT_EQUAL(mat.row(0),t4);
|
---|
| 167 | CPPUNIT_ASSERT_EQUAL(mat.row(1),t4);
|
---|
| 168 | CPPUNIT_ASSERT_EQUAL(mat.row(2),t4);
|
---|
| 169 | CPPUNIT_ASSERT_EQUAL(mat.diagonal(),t4);
|
---|
| 170 | for(int i=NDIM;i--;){
|
---|
| 171 | for(int j=NDIM;j--;){
|
---|
| 172 | CPPUNIT_ASSERT_EQUAL(mat.at(i,j),j+1.);
|
---|
| 173 | }
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 |
|
---|
[7a0340] | 177 | void RealSpaceMatrixTest::TransposeTest(){
|
---|
[cca9ef] | 178 | RealSpaceMatrix res;
|
---|
[31fb1d] | 179 |
|
---|
| 180 | // transpose of unit is unit
|
---|
[9eb7580] | 181 | res.setIdentity();
|
---|
[3bc926] | 182 | res.transpose();
|
---|
[31fb1d] | 183 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 184 |
|
---|
| 185 | // transpose of transpose is same matrix
|
---|
[9eb7580] | 186 | res.setZero();
|
---|
[31fb1d] | 187 | res.set(2,2, 1.);
|
---|
| 188 | CPPUNIT_ASSERT_EQUAL(res.transpose().transpose(),res);
|
---|
| 189 | }
|
---|
| 190 |
|
---|
[7a0340] | 191 | void RealSpaceMatrixTest::OperationTest(){
|
---|
[cca9ef] | 192 | RealSpaceMatrix res;
|
---|
[5630bd] | 193 |
|
---|
| 194 | res =(*zero) *(*zero);
|
---|
[9b410d] | 195 | //std::cout << *zero << " times " << *zero << " is " << res << std::endl;
|
---|
[5630bd] | 196 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 197 | res =(*zero) *(*one);
|
---|
| 198 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 199 | res =(*zero) *(*full);
|
---|
| 200 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 201 | res =(*zero) *(*diagonal);
|
---|
| 202 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 203 | res =(*zero) *(*perm1);
|
---|
| 204 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 205 | res =(*zero) *(*perm2);
|
---|
| 206 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 207 | res =(*zero) *(*perm3);
|
---|
| 208 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 209 | res =(*zero) *(*perm4);
|
---|
| 210 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 211 | res =(*zero) *(*perm5);
|
---|
| 212 | CPPUNIT_ASSERT_EQUAL(res,*zero);
|
---|
| 213 |
|
---|
| 214 | res =(*one)*(*one);
|
---|
| 215 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 216 | res =(*one)*(*full);
|
---|
| 217 | CPPUNIT_ASSERT_EQUAL(res,*full);
|
---|
| 218 | res =(*one)*(*diagonal);
|
---|
| 219 | CPPUNIT_ASSERT_EQUAL(res,*diagonal);
|
---|
| 220 | res =(*one)*(*perm1);
|
---|
| 221 | CPPUNIT_ASSERT_EQUAL(res,*perm1);
|
---|
| 222 | res =(*one)*(*perm2);
|
---|
| 223 | CPPUNIT_ASSERT_EQUAL(res,*perm2);
|
---|
| 224 | res =(*one)*(*perm3);
|
---|
| 225 | CPPUNIT_ASSERT_EQUAL(res,*perm3);
|
---|
| 226 | res =(*one)*(*perm4);
|
---|
| 227 | CPPUNIT_ASSERT_EQUAL(res,*perm4);
|
---|
| 228 | res =(*one)*(*perm5);
|
---|
| 229 | CPPUNIT_ASSERT_EQUAL(res,*perm5);
|
---|
| 230 |
|
---|
| 231 | res = (*full)*(*perm1);
|
---|
| 232 | CPPUNIT_ASSERT_EQUAL(res,*full);
|
---|
| 233 | res = (*full)*(*perm2);
|
---|
| 234 | CPPUNIT_ASSERT_EQUAL(res,*full);
|
---|
| 235 | res = (*full)*(*perm3);
|
---|
| 236 | CPPUNIT_ASSERT_EQUAL(res,*full);
|
---|
| 237 | res = (*full)*(*perm4);
|
---|
| 238 | CPPUNIT_ASSERT_EQUAL(res,*full);
|
---|
| 239 | res = (*full)*(*perm5);
|
---|
| 240 | CPPUNIT_ASSERT_EQUAL(res,*full);
|
---|
| 241 |
|
---|
| 242 | res = (*diagonal)*(*perm1);
|
---|
[407782] | 243 | CPPUNIT_ASSERT_EQUAL(res.column(0),unitVec[0]);
|
---|
| 244 | CPPUNIT_ASSERT_EQUAL(res.column(1),3*unitVec[2]);
|
---|
| 245 | CPPUNIT_ASSERT_EQUAL(res.column(2),2*unitVec[1]);
|
---|
[5630bd] | 246 | res = (*diagonal)*(*perm2);
|
---|
[407782] | 247 | CPPUNIT_ASSERT_EQUAL(res.column(0),2*unitVec[1]);
|
---|
| 248 | CPPUNIT_ASSERT_EQUAL(res.column(1),unitVec[0]);
|
---|
| 249 | CPPUNIT_ASSERT_EQUAL(res.column(2),3*unitVec[2]);
|
---|
[5630bd] | 250 | res = (*diagonal)*(*perm3);
|
---|
[407782] | 251 | CPPUNIT_ASSERT_EQUAL(res.column(0),2*unitVec[1]);
|
---|
| 252 | CPPUNIT_ASSERT_EQUAL(res.column(1),3*unitVec[2]);
|
---|
| 253 | CPPUNIT_ASSERT_EQUAL(res.column(2),unitVec[0]);
|
---|
[5630bd] | 254 | res = (*diagonal)*(*perm4);
|
---|
[407782] | 255 | CPPUNIT_ASSERT_EQUAL(res.column(0),3*unitVec[2]);
|
---|
| 256 | CPPUNIT_ASSERT_EQUAL(res.column(1),2*unitVec[1]);
|
---|
| 257 | CPPUNIT_ASSERT_EQUAL(res.column(2),unitVec[0]);
|
---|
[5630bd] | 258 | res = (*diagonal)*(*perm5);
|
---|
[407782] | 259 | CPPUNIT_ASSERT_EQUAL(res.column(0),3*unitVec[2]);
|
---|
| 260 | CPPUNIT_ASSERT_EQUAL(res.column(1),unitVec[0]);
|
---|
| 261 | CPPUNIT_ASSERT_EQUAL(res.column(2),2*unitVec[1]);
|
---|
[5630bd] | 262 | }
|
---|
| 263 |
|
---|
[7a0340] | 264 | void RealSpaceMatrixTest::RotationTest(){
|
---|
[cca9ef] | 265 | RealSpaceMatrix res;
|
---|
| 266 | RealSpaceMatrix inverse;
|
---|
[31fb1d] | 267 |
|
---|
| 268 | // zero rotation angles yields unity matrix
|
---|
[9eb7580] | 269 | res.setRotation(0,0,0);
|
---|
[31fb1d] | 270 | CPPUNIT_ASSERT_EQUAL(*one, res);
|
---|
| 271 |
|
---|
| 272 | // arbitrary rotation matrix has det = 1
|
---|
[9eb7580] | 273 | res.setRotation(M_PI/3.,1.,M_PI/7.);
|
---|
[819cbe] | 274 | CPPUNIT_ASSERT(fabs(res.determinant() - 1.) <= LINALG_MYEPSILON());
|
---|
[31fb1d] | 275 |
|
---|
| 276 | // inverse is rotation matrix with negative angles
|
---|
[9eb7580] | 277 | res.setRotation(M_PI/3.,0.,0.);
|
---|
| 278 | inverse.setRotation(-M_PI/3.,0.,0.);
|
---|
[31fb1d] | 279 | CPPUNIT_ASSERT_EQUAL(*one, res * inverse);
|
---|
| 280 |
|
---|
| 281 | // ... or transposed
|
---|
[9eb7580] | 282 | res.setRotation(M_PI/3.,0.,0.);
|
---|
[cca9ef] | 283 | CPPUNIT_ASSERT_EQUAL(inverse, ((const RealSpaceMatrix) res).transpose());
|
---|
[31fb1d] | 284 | }
|
---|
[5630bd] | 285 |
|
---|
[7a0340] | 286 | void RealSpaceMatrixTest::InvertTest(){
|
---|
[5630bd] | 287 | CPPUNIT_ASSERT_THROW(zero->invert(),NotInvertibleException);
|
---|
| 288 | CPPUNIT_ASSERT_THROW(full->invert(),NotInvertibleException);
|
---|
| 289 |
|
---|
[cca9ef] | 290 | RealSpaceMatrix res;
|
---|
[5630bd] | 291 | res = (*one)*one->invert();
|
---|
| 292 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 293 | res = (*diagonal)*diagonal->invert();
|
---|
| 294 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 295 | res = (*perm1)*perm1->invert();
|
---|
| 296 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 297 | res = (*perm2)*perm2->invert();
|
---|
| 298 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 299 | res = (*perm3)*perm3->invert();
|
---|
| 300 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 301 | res = (*perm4)*perm4->invert();
|
---|
| 302 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 303 | res = (*perm5)*perm5->invert();
|
---|
| 304 | CPPUNIT_ASSERT_EQUAL(res,*one);
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 |
|
---|
[7a0340] | 308 | void RealSpaceMatrixTest::DeterminantTest(){
|
---|
[5630bd] | 309 | CPPUNIT_ASSERT_EQUAL(zero->determinant(),0.);
|
---|
| 310 | CPPUNIT_ASSERT_EQUAL(one->determinant(),1.);
|
---|
| 311 | CPPUNIT_ASSERT_EQUAL(diagonal->determinant(),6.);
|
---|
| 312 | CPPUNIT_ASSERT_EQUAL(full->determinant(),0.);
|
---|
| 313 | CPPUNIT_ASSERT_EQUAL(perm1->determinant(),-1.);
|
---|
| 314 | CPPUNIT_ASSERT_EQUAL(perm2->determinant(),-1.);
|
---|
| 315 | CPPUNIT_ASSERT_EQUAL(perm3->determinant(),1.);
|
---|
| 316 | CPPUNIT_ASSERT_EQUAL(perm4->determinant(),-1.);
|
---|
| 317 | CPPUNIT_ASSERT_EQUAL(perm5->determinant(),1.);
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[7a0340] | 320 | void RealSpaceMatrixTest::VecMultTest(){
|
---|
[407782] | 321 | CPPUNIT_ASSERT_EQUAL((*zero)*unitVec[0],zeroVec);
|
---|
| 322 | CPPUNIT_ASSERT_EQUAL((*zero)*unitVec[1],zeroVec);
|
---|
| 323 | CPPUNIT_ASSERT_EQUAL((*zero)*unitVec[2],zeroVec);
|
---|
[5630bd] | 324 | CPPUNIT_ASSERT_EQUAL((*zero)*zeroVec,zeroVec);
|
---|
| 325 |
|
---|
[407782] | 326 | CPPUNIT_ASSERT_EQUAL((*one)*unitVec[0],unitVec[0]);
|
---|
| 327 | CPPUNIT_ASSERT_EQUAL((*one)*unitVec[1],unitVec[1]);
|
---|
| 328 | CPPUNIT_ASSERT_EQUAL((*one)*unitVec[2],unitVec[2]);
|
---|
[5630bd] | 329 | CPPUNIT_ASSERT_EQUAL((*one)*zeroVec,zeroVec);
|
---|
| 330 |
|
---|
[407782] | 331 | CPPUNIT_ASSERT_EQUAL((*diagonal)*unitVec[0],unitVec[0]);
|
---|
| 332 | CPPUNIT_ASSERT_EQUAL((*diagonal)*unitVec[1],2*unitVec[1]);
|
---|
| 333 | CPPUNIT_ASSERT_EQUAL((*diagonal)*unitVec[2],3*unitVec[2]);
|
---|
[5630bd] | 334 | CPPUNIT_ASSERT_EQUAL((*diagonal)*zeroVec,zeroVec);
|
---|
| 335 |
|
---|
[407782] | 336 | CPPUNIT_ASSERT_EQUAL((*perm1)*unitVec[0],unitVec[0]);
|
---|
| 337 | CPPUNIT_ASSERT_EQUAL((*perm1)*unitVec[1],unitVec[2]);
|
---|
| 338 | CPPUNIT_ASSERT_EQUAL((*perm1)*unitVec[2],unitVec[1]);
|
---|
[5630bd] | 339 | CPPUNIT_ASSERT_EQUAL((*perm1)*zeroVec,zeroVec);
|
---|
| 340 |
|
---|
[407782] | 341 | CPPUNIT_ASSERT_EQUAL((*perm2)*unitVec[0],unitVec[1]);
|
---|
| 342 | CPPUNIT_ASSERT_EQUAL((*perm2)*unitVec[1],unitVec[0]);
|
---|
| 343 | CPPUNIT_ASSERT_EQUAL((*perm2)*unitVec[2],unitVec[2]);
|
---|
[5630bd] | 344 | CPPUNIT_ASSERT_EQUAL((*perm2)*zeroVec,zeroVec);
|
---|
| 345 |
|
---|
[407782] | 346 | CPPUNIT_ASSERT_EQUAL((*perm3)*unitVec[0],unitVec[1]);
|
---|
| 347 | CPPUNIT_ASSERT_EQUAL((*perm3)*unitVec[1],unitVec[2]);
|
---|
| 348 | CPPUNIT_ASSERT_EQUAL((*perm3)*unitVec[2],unitVec[0]);
|
---|
[5630bd] | 349 | CPPUNIT_ASSERT_EQUAL((*perm3)*zeroVec,zeroVec);
|
---|
| 350 |
|
---|
[407782] | 351 | CPPUNIT_ASSERT_EQUAL((*perm4)*unitVec[0],unitVec[2]);
|
---|
| 352 | CPPUNIT_ASSERT_EQUAL((*perm4)*unitVec[1],unitVec[1]);
|
---|
| 353 | CPPUNIT_ASSERT_EQUAL((*perm4)*unitVec[2],unitVec[0]);
|
---|
[5630bd] | 354 | CPPUNIT_ASSERT_EQUAL((*perm4)*zeroVec,zeroVec);
|
---|
| 355 |
|
---|
[407782] | 356 | CPPUNIT_ASSERT_EQUAL((*perm5)*unitVec[0],unitVec[2]);
|
---|
| 357 | CPPUNIT_ASSERT_EQUAL((*perm5)*unitVec[1],unitVec[0]);
|
---|
| 358 | CPPUNIT_ASSERT_EQUAL((*perm5)*unitVec[2],unitVec[1]);
|
---|
[5630bd] | 359 | CPPUNIT_ASSERT_EQUAL((*perm5)*zeroVec,zeroVec);
|
---|
| 360 |
|
---|
| 361 | Vector t = Vector(1.,2.,3.);
|
---|
| 362 | CPPUNIT_ASSERT_EQUAL((*perm1)*t,Vector(1,3,2));
|
---|
| 363 | CPPUNIT_ASSERT_EQUAL((*perm2)*t,Vector(2,1,3));
|
---|
| 364 | CPPUNIT_ASSERT_EQUAL((*perm3)*t,Vector(3,1,2));
|
---|
| 365 | CPPUNIT_ASSERT_EQUAL((*perm4)*t,Vector(3,2,1));
|
---|
| 366 | CPPUNIT_ASSERT_EQUAL((*perm5)*t,Vector(2,3,1));
|
---|
| 367 | }
|
---|