// testBug6181.cc // // The bug reported an erroneous result in inverting a 7x7 matrix. // // 7x7 represents the break point between the low-n methods and // the general-size method. This test program tests the case triggering // the bug report, and also inversion for matrices (both symmetric and // general) of sizes 1 - 9. #include #include #include "CLHEP/Matrix/Matrix.h" #include "CLHEP/Matrix/SymMatrix.h" int test_inversion (int N) { int i; int j; CLHEP::HepMatrix M(N,N,0); CLHEP::HepSymMatrix S(N,0); for(i=1;i<=N;++i) { for(j=1;j<=N;++j) { if(i<=j) { S (i,j) = 10*i+j; M (i,j) = 10*i+j; M (j,i) = M(i,j) + .1 * (i-j)*(i-j); } } } CLHEP::HepMatrix MM(N,N,0); CLHEP::HepSymMatrix SS(N,0); MM = M; SS = S; int ierr = 0; MM.invert(ierr); if (ierr) { std::cout<<"MM.invert failed!!!! N = " << N << " ierr = "<< ierr <