// @HEADER // ***************************************************************************** // Anasazi: Block Eigensolvers Package // // Copyright 2004 NTESS and the Anasazi contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER // // This test is for the OrthoManager interface to ICGSOrthoManager, // SVQBOrthoManager and BasicOrthoManager // // The matrix used is from MatrixMarket: // Name: MHD1280B: Alfven Spectra in Magnetohydrodynamics // Source: Source: A. Booten, M.N. Kooper, H.A. van der Vorst, S. Poedts and J.P. Goedbloed University of Utrecht, the Netherlands // Discipline: Plasma physics // URL: http://math.nist.gov/MatrixMarket/data/NEP/mhd/mhd1280b.html // Size: 1280 x 1280 // NNZ: 22778 entries // #include "AnasaziConfigDefs.hpp" #include "AnasaziSolverUtils.hpp" #include "AnasaziBasicOutputManager.hpp" #include "AnasaziSVQBOrthoManager.hpp" #include "AnasaziICGSOrthoManager.hpp" #include "AnasaziBasicOrthoManager.hpp" #include "Teuchos_CommandLineProcessor.hpp" #include "Teuchos_StandardCatchMacros.hpp" // I/O for Harwell-Boeing files #ifdef HAVE_ANASAZI_TRIUTILS #include "Trilinos_Util_iohb.h" #endif // templated multivector and sparse matrix classes #include "MyMultiVec.hpp" #include "MyBetterOperator.hpp" #include "MySDMHelpers.hpp" using namespace Teuchos; using namespace Anasazi; using namespace std; typedef std::complex ST; typedef MultiVec MV; typedef Operator OP; typedef MultiVecTraits MVT; typedef OperatorTraits OPT; typedef ScalarTraits SCT; typedef SCT::magnitudeType MT; // this is the tolerance that all tests are performed against const MT TOL = 1.0e-12; const MT ATOL = 10; // declare an output manager for handling local output RCP< Anasazi::BasicOutputManager > MyOM; // some forward declarations int testProject(RCP > OM, RCP S, RCP X1, RCP X2); int testNormalize(RCP > OM, RCP S); int testProjectAndNormalize(RCP > OM, RCP S, RCP X1, RCP X2); MT MVDiff(const MV &X, const MV &Y); int main(int argc, char *argv[]) { const ST ONE = SCT::one(); const MT ZERO = SCT::magnitude(SCT::zero()); bool verbose = false; int numFailed = 0; bool debug = false; string ortho = "SVQB"; std::string filename; int dim = 100; int sizeS = 5; int sizeX1 = 11; // MUST: sizeS + sizeX1 + sizeX2 <= elements[0]-1 int sizeX2 = 13; // MUST: sizeS + sizeX1 + sizeX2 <= elements[0]-1 bool success = true; try { CommandLineProcessor cmdp(false,true); cmdp.setOption("verbose","quiet",&verbose,"Print messages and results."); cmdp.setOption("debug","nodebug",&debug,"Print debugging information."); cmdp.setOption("ortho",&ortho,"Which ortho manager: SVQB or Basic or ICGS"); cmdp.setOption("dim",&dim,"Controls the size of multivectors."); cmdp.setOption("sizeS",&sizeS,"Controls the width of the input multivector."); cmdp.setOption("sizeX1",&sizeX1,"Controls the width of the first basis."); cmdp.setOption("sizeX2",&sizeX2,"Controls the width of the second basis."); cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix."); if (cmdp.parse(argc,argv) != CommandLineProcessor::PARSE_SUCCESSFUL) { return -1; } // below we will assume that sizeX1 > sizeX2 // however, it does allow us to simplify some logic if (sizeX1 < sizeX2) { swap(sizeX1,sizeX2); } // instantiate the output manager MyOM = rcp( new BasicOutputManager() ); if (verbose) { // output in this driver will be sent to Anasazi::Warnings MyOM->setVerbosity(Anasazi::Warnings); } // Output Anasazi version MyOM->stream(Anasazi::Warnings) << Anasazi_Version() << endl << endl; // Problem information RCP< const MyBetterOperator > M; if (filename != "") { int dim2,nnz; double *dvals; int *colptr,*rowind; nnz = -1; int info = readHB_newmat_double(filename.c_str(),&dim,&dim2,&nnz, &colptr,&rowind,&dvals); TEUCHOS_TEST_FOR_EXCEPTION(info == 0 || nnz < 0, std::runtime_error, "Error reading file " << filename << ". info == " << info << " and nnz == " << nnz); // Convert interleaved doubles to complex values std::vector cvals(nnz); for (int ii=0; ii(dim,colptr,nnz,rowind,&cvals[0]) ); } // Create ortho managers RCP > OM; if (ortho == "SVQB") { OM = rcp( new SVQBOrthoManager(M) ); } else if (ortho == "Basic") { OM = rcp( new BasicOrthoManager(M) ); } else if (ortho == "ICGS") { OM = rcp( new ICGSOrthoManager(M) ); } else { TEUCHOS_TEST_FOR_EXCEPTION(true,invalid_argument,"Command line parameter \"ortho\" must be \"SVQB\" or \"Basic\"."); } // multivector to spawn off of RCP S = rcp( new MyMultiVec(dim, sizeS) ); // create X1, X2 // they must be M-orthonormal and mutually M-orthogonal MyOM->stream(Errors) << " Generating X1,X2 for testing... " << endl; RCP X1 = MVT::Clone(*S,sizeX1), X2 = MVT::Clone(*S,sizeX2); { int dummy; MT err; // X1 MVT::MvRandom(*X1); dummy = OM->normalize(*X1); TEUCHOS_TEST_FOR_EXCEPTION(dummy != sizeX1, std::runtime_error, "normalize(X1) returned rank " << dummy << " from " << sizeX1 << " vectors. Cannot continue."); err = OM->orthonormError(*X1); TEUCHOS_TEST_FOR_EXCEPTION(err > TOL,std::runtime_error, "normalize(X1) did meet tolerance: orthonormError(X1) == " << err); MyOM->stream(Warnings) << " || - I || : " << err << endl; // X2 MVT::MvRandom(*X2); dummy = OM->projectAndNormalize(*X2,Teuchos::tuple >(X1)); TEUCHOS_TEST_FOR_EXCEPTION(dummy != sizeX2, std::runtime_error, "projectAndNormalize(X2,X1) returned rank " << dummy << " from " << sizeX2 << " vectors. Cannot continue."); err = OM->orthonormError(*X2); TEUCHOS_TEST_FOR_EXCEPTION(err > TOL,std::runtime_error, "projectAndNormalize(X2,X1) did not meet tolerance: orthonormError(X2) == " << err); err = OM->orthogError(*X2,*X1); MyOM->stream(Warnings) << " || - I || : " << err << endl; TEUCHOS_TEST_FOR_EXCEPTION(err > TOL,std::runtime_error, "projectAndNormalize(X2,X1) did not meet tolerance: orthogError(X2,X1) == " << err); MyOM->stream(Warnings) << " || || : " << err << endl; } MyOM->stream(Warnings) << endl; { // just a random multivector MVT::MvRandom(*S); MyOM->stream(Errors) << " project(): testing on random multivector " << endl; numFailed += testProject(OM,S,X1,X2); } { SerialDenseMatrix C1(sizeX1,sizeS), C2(sizeX2,sizeS); Anasazi::randomSDM(C1); Anasazi::randomSDM(C2); MVT::MvTimesMatAddMv(ONE,*X1,C1,ZERO,*S); MVT::MvTimesMatAddMv(ONE,*X2,C2,ONE,*S); MyOM->stream(Errors) << " project(): testing [X1 X2]-range multivector against P_X1 P_X2 " << endl; numFailed += testProject(OM,S,X1,X2); } if (sizeS > 2) { MVT::MvRandom(*S); RCP mid = MVT::Clone(*S,1); SerialDenseMatrix c(sizeS,1); MVT::MvTimesMatAddMv(ONE,*S,c,ZERO,*mid); std::vector ind(1); ind[0] = sizeS-1; MVT::SetBlock(*mid,ind,*S); MyOM->stream(Errors) << " normalize(): testing on rank-deficient multivector " << endl; numFailed += testNormalize(OM,S); } if (sizeS > 1) { // rank-1 RCP one = MVT::Clone(*S,1); MVT::MvRandom(*one); SerialDenseMatrix scaleS(sizeS,1); Anasazi::randomSDM(scaleS); // put multiple of column 0 in columns 0:sizeS-1 for (int i=0; i ind(1); ind[0] = i; RCP Si = MVT::CloneViewNonConst(*S,ind); MVT::MvAddMv(scaleS(i,0),*one,ZERO,*one,*Si); } MyOM->stream(Errors) << " normalize(): testing on rank-1 multivector " << endl; numFailed += testNormalize(OM,S); } { std::vector ind(1); MVT::MvRandom(*S); MyOM->stream(Errors) << " projectAndNormalize(): testing on random multivector " << endl; numFailed += testProjectAndNormalize(OM,S,X1,X2); } { // run a X1,X2 range multivector against P_X1 P_X2 // this is allowed as == 0 // it should require randomization, as // P_X1 P_X2 (X1*C1 + X2*C2) = P_X1 X1*C1 = 0 // and // P_X2 P_X1 (X2*C2 + X1*C1) = P_X2 X2*C2 = 0 SerialDenseMatrix C1(sizeX1,sizeS), C2(sizeX2,sizeS); Anasazi::randomSDM(C1); Anasazi::randomSDM(C2); MVT::MvTimesMatAddMv(ONE,*X1,C1,ZERO,*S); MVT::MvTimesMatAddMv(ONE,*X2,C2,ONE,*S); MyOM->stream(Errors) << " projectAndNormalize(): testing [X1 X2]-range multivector against P_X1 P_X2 " << endl; numFailed += testProjectAndNormalize(OM,S,X1,X2); } if (sizeS > 2) { MVT::MvRandom(*S); RCP mid = MVT::Clone(*S,1); SerialDenseMatrix c(sizeS,1); MVT::MvTimesMatAddMv(ONE,*S,c,ZERO,*mid); std::vector ind(1); ind[0] = sizeS-1; MVT::SetBlock(*mid,ind,*S); MyOM->stream(Errors) << " projectAndNormalize(): testing on rank-deficient multivector " << endl; numFailed += testProjectAndNormalize(OM,S,X1,X2); } if (sizeS > 1) { // rank-1 RCP one = MVT::Clone(*S,1); MVT::MvRandom(*one); SerialDenseMatrix scaleS(sizeS, 1); Anasazi::randomSDM(scaleS); // put multiple of column 0 in columns 0:sizeS-1 for (int i=0; i ind(1); ind[0] = i; RCP Si = MVT::CloneViewNonConst(*S,ind); MVT::MvAddMv(scaleS(i,0),*one,ZERO,*one,*Si); } MyOM->stream(Errors) << " projectAndNormalize(): testing on rank-1 multivector " << endl; numFailed += testProjectAndNormalize(OM,S,X1,X2); } } TEUCHOS_STANDARD_CATCH_STATEMENTS(true,cout,success); if (numFailed || success==false) { if (numFailed) { MyOM->stream(Errors) << numFailed << " errors." << endl; } MyOM->stream(Errors) << "End Result: TEST FAILED" << endl; return -1; } // // Default return value // MyOM->stream(Errors) << "End Result: TEST PASSED" << endl; return 0; } //////////////////////////////////////////////////////////////////////////// int testProjectAndNormalize(RCP > OM, RCP S, RCP X1, RCP X2) { const ST ONE = SCT::one(); const MT ZERO = SCT::magnitude(SCT::zero()); const int sizeS = MVT::GetNumberVecs(*S); const int sizeX1 = MVT::GetNumberVecs(*X1); const int sizeX2 = MVT::GetNumberVecs(*X2); int numerr = 0; std::ostringstream sout; // // output tests: // = I // = 0 // = 0 // S_in = S_out B + X1 C1 + X2 C2 // // we will loop over an integer specifying the test combinations // the bit pattern for the different tests is listed in parenthesis // // for the projectors, test the following combinations: // none (00) // P_X1 (01) // P_X2 (10) // P_X1 P_X2 (11) // P_X2 P_X1 (11) // the latter two should be tested to give the same answer // // for each of these, we should test with C1, C2 and B // int numtests; numtests = 4; // test ortho error before orthonormalizing if (X1 != null) { MT err = OM->orthogError(*S,*X1); sout << " || || before : " << err << endl; } if (X2 != null) { MT err = OM->orthogError(*S,*X2); sout << " || || before : " << err << endl; } for (int t=0; t > theX; RCP > B = rcp( new SerialDenseMatrix(sizeS,sizeS) ); Array > > C; if ( (t & 3) == 0 ) { // C, theX and theY are already empty } else if ( (t & 3) == 1 ) { // X1 theX = Teuchos::tuple(X1); C = Teuchos::tuple( rcp(new SerialDenseMatrix(sizeX1,sizeS)) ); } else if ( (t & 3) == 2 ) { // X2 theX = Teuchos::tuple(X2); C = Teuchos::tuple( rcp(new SerialDenseMatrix(sizeX2,sizeS)) ); } else if ( (t & 3) == 3 ) { // X1 and X2, and the reverse. theX = Teuchos::tuple(X1,X2); C = Teuchos::tuple( rcp(new SerialDenseMatrix(sizeX1,sizeS)), rcp(new SerialDenseMatrix(sizeX2,sizeS)) ); } else {} try { // call routine // if (t & 3) == 3, { // call with reversed input: X2 X1 // } // test all outputs for correctness // test all outputs for equivalence // here is where the outputs go Array > S_outs; Array > > > C_outs; Array > > B_outs; RCP Scopy; Array ret_out; // copies of S Scopy = MVT::CloneCopy(*S); // randomize this data, it should be overwritten Anasazi::randomSDM(*B); for (unsigned int i=0; iprojectAndNormalize(*Scopy,theX,C,B); sout << "projectAndNormalize() returned rank " << ret << endl; if (ret == 0) { sout << " Cannot continue." << endl; numerr++; break; } ret_out.push_back(ret); // projectAndNormalize() is only required to return a // basis of rank "ret" // this is what we will test: // the first "ret" columns in Scopy // the first "ret" rows in B // save just the parts that we want // we allocate S for each test, so we can save these as views // however, save copies of the C and B if (ret < sizeS) { vector ind(ret); for (int i=0; i(Teuchos::Copy,*B,ret,sizeS) ) ); } else { S_outs.push_back( Scopy ); B_outs.push_back( rcp( new SerialDenseMatrix(*B) ) ); } C_outs.push_back( Array > >(0) ); if (C.size() > 0) { C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[0]) ) ); } if (C.size() > 1) { C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[1]) ) ); } // do we run the reversed input? if ( (t & 3) == 3 ) { // copies of S Scopy = MVT::CloneCopy(*S); // randomize this data, it should be overwritten Anasazi::randomSDM(*B); for (unsigned int i=0; iprojectAndNormalize(*Scopy,theX,C,B); sout << "projectAndNormalize() returned rank " << ret << endl; if (ret == 0) { sout << " Cannot continue." << endl; numerr++; break; } ret_out.push_back(ret); // projectAndNormalize() is only required to return a // basis of rank "ret" // this is what we will test: // the first "ret" columns in Scopy // the first "ret" rows in B // save just the parts that we want // we allocate S for each test, so we can save these as views // however, save copies of the C and B if (ret < sizeS) { vector ind(ret); for (int i=0; i(Teuchos::Copy,*B,ret,sizeS) ) ); } else { S_outs.push_back( Scopy ); B_outs.push_back( rcp( new SerialDenseMatrix(*B) ) ); } C_outs.push_back( Array > >() ); // reverse the Cs to compensate for the reverse projectors C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[1]) ) ); C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[0]) ) ); // flip the inputs back C = Teuchos::tuple( C[1], C[0] ); theX = Teuchos::tuple( theX[1], theX[0] ); } // test all outputs for correctness for (unsigned int o=0; oorthonormError(*S_outs[o]); if (err > TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " || - I || after : " << err << endl; } // S_in = X1*C1 + C2*C2 + S_out*B { RCP tmp = MVT::Clone(*S,sizeS); MVT::MvTimesMatAddMv(ONE,*S_outs[o],*B_outs[o],ZERO,*tmp); if (C_outs[o].size() > 0) { MVT::MvTimesMatAddMv(ONE,*theX[0],*C_outs[o][0],ONE,*tmp); if (C_outs[o].size() > 1) { MVT::MvTimesMatAddMv(ONE,*theX[1],*C_outs[o][1],ONE,*tmp); } } MT err = MVDiff(*tmp,*S); if (err > ATOL*TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| S_in - X1*C1 - X2*C2 - S_out*B || : " << err << endl; } // == 0 if (theX.size() > 0 && theX[0] != null) { MT err = OM->orthogError(*theX[0],*S_outs[o]); if (err > TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| || after : " << err << endl; } // == 0 if (theX.size() > 1 && theX[1] != null) { MT err = OM->orthogError(*theX[1],*S_outs[o]); if (err > TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| || after : " << err << endl; } } } catch (const OrthoError &e) { sout << " ------------------------------------------- projectAndNormalize() threw exception" << endl; sout << " Error: " << e.what() << endl; numerr++; } } // test for MsgType type = Warnings; if (numerr>0) type = Errors; MyOM->stream(type) << sout.str(); MyOM->stream(type) << endl; return numerr; } //////////////////////////////////////////////////////////////////////////// int testNormalize(RCP > OM, RCP S) { const ST ONE = SCT::one(); const MT ZERO = SCT::magnitude(SCT::zero()); const int sizeS = MVT::GetNumberVecs(*S); int numerr = 0; std::ostringstream sout; // // output tests: // = I // S_in = S_out B // // we will loop over an integer specifying the test combinations // the bit pattern for the different tests is listed in parenthesis // // for each of the following, we should test B // int numtests; numtests = 1; for (int t=0; t Bdata = Teuchos::arcp(sizeS*sizeS); RCP > B = rcp( new SerialDenseMatrix(Teuchos::View,Bdata.getRawPtr(),sizeS,sizeS,sizeS) ); try { // call routine // test all outputs for correctness // here is where the outputs go RCP Scopy; int ret; // copies of S Scopy = MVT::CloneCopy(*S); // randomize this data, it should be overwritten Anasazi::randomSDM(*B); // run test ret = OM->normalize(*Scopy,B); sout << "normalize() returned rank " << ret << endl; if (ret == 0) { sout << " Cannot continue." << endl; numerr++; break; } // normalize() is only required to return a // basis of rank "ret" // this is what we will test: // the first "ret" columns in Scopy // the first "ret" rows in B // get pointers to the parts that we want if (ret < sizeS) { vector ind(ret); for (int i=0; i(Teuchos::View,Bdata.getRawPtr(),ret,ret,sizeS) ); } // test all outputs for correctness // S^T M S == I { MT err = OM->orthonormError(*Scopy); if (err > TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " || - I || after : " << err << endl; } // S_in = S_out*B { RCP tmp = MVT::Clone(*S,sizeS); MVT::MvTimesMatAddMv(ONE,*Scopy,*B,ZERO,*tmp); MT err = MVDiff(*tmp,*S); if (err > ATOL*TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| S_in - S_out*B || : " << err << endl; } } catch (const OrthoError &e) { sout << " ------------------------------------------- normalize() threw exception" << endl; sout << " Error: " << e.what() << endl; numerr++; } } // test for MsgType type = Warnings; if (numerr>0) type = Errors; MyOM->stream(type) << sout.str(); MyOM->stream(type) << endl; return numerr; } //////////////////////////////////////////////////////////////////////////// int testProject(RCP > OM, RCP S, RCP X1, RCP X2) { const ST ONE = SCT::one(); const int sizeS = MVT::GetNumberVecs(*S); const int sizeX1 = MVT::GetNumberVecs(*X1); const int sizeX2 = MVT::GetNumberVecs(*X2); int numerr = 0; std::ostringstream sout; // // output tests: // = 0 // = 0 // S_in = S_out + X1 C1 + X2 C2 // // we will loop over an integer specifying the test combinations // the bit pattern for the different tests is listed in parenthesis // // for the projectors, test the following combinations: // none (00) // P_X1 (01) // P_X2 (10) // P_X1 P_X2 (11) // P_X2 P_X1 (11) // the latter two should be tested to give the same answer // int numtests; numtests = 8; // test ortho error before orthonormalizing if (X1 != null) { MT err = OM->orthogError(*S,*X1); sout << " || || before : " << err << endl; } if (X2 != null) { MT err = OM->orthogError(*S,*X2); sout << " || || before : " << err << endl; } for (int t=0; t > theX; Array > > C; if ( (t & 3) == 0 ) { // neither X1 nor X2 // C and theX are already empty } else if ( (t & 3) == 1 ) { // X1 theX = Teuchos::tuple(X1); C = Teuchos::tuple( rcp(new SerialDenseMatrix(sizeX1,sizeS)) ); } else if ( (t & 3) == 2 ) { // X2 theX = Teuchos::tuple(X2); C = Teuchos::tuple( rcp(new SerialDenseMatrix(sizeX2,sizeS)) ); } else if ( (t & 3) == 3 ) { // X1 and X2, and the reverse. theX = Teuchos::tuple(X1,X2); C = Teuchos::tuple( rcp(new SerialDenseMatrix(sizeX1,sizeS)), rcp(new SerialDenseMatrix(sizeX2,sizeS)) ); } else {} try { // call routine // if (t & 3) == 3, { // call with reversed input: X2 X1 // } // test all outputs for correctness // test all outputs for equivalence // here is where the outputs go Array > S_outs; Array > > > C_outs; RCP Scopy; // copies of S Scopy = MVT::CloneCopy(*S); // randomize this data, it should be overwritten for (unsigned int i=0; iproject(*Scopy,theX,C); // we allocate S for each test, so we can save these as views // however, save copies of the C S_outs.push_back( Scopy ); C_outs.push_back( Array > >(0) ); if (C.size() > 0) { C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[0]) ) ); } if (C.size() > 1) { C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[1]) ) ); } // do we run the reversed input? if ( (t & 3) == 3 ) { // copies of S Scopy = MVT::CloneCopy(*S); // randomize this data, it should be overwritten for (unsigned int i=0; iproject(*Scopy,theX,C); // we allocate S for each test, so we can save these as views // however, save copies of the C S_outs.push_back( Scopy ); // we are in a special case: P_X1 and P_X2, so we know we applied // two projectors, and therefore have two C[i] C_outs.push_back( Array > >() ); // reverse the Cs to compensate for the reverse projectors C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[1]) ) ); C_outs.back().push_back( rcp( new SerialDenseMatrix(*C[0]) ) ); // flip the inputs back C = Teuchos::tuple( C[1], C[0] ); theX = Teuchos::tuple( theX[1], theX[0] ); } // test all outputs for correctness for (unsigned int o=0; o tmp = MVT::CloneCopy(*S_outs[o]); if (C_outs[o].size() > 0) { MVT::MvTimesMatAddMv(ONE,*theX[0],*C_outs[o][0],ONE,*tmp); if (C_outs[o].size() > 1) { MVT::MvTimesMatAddMv(ONE,*theX[1],*C_outs[o][1],ONE,*tmp); } } MT err = MVDiff(*tmp,*S); if (err > ATOL*TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| S_in - X1*C1 - X2*C2 - S_out || : " << err << endl; } // == 0 if (theX.size() > 0 && theX[0] != null) { MT err = OM->orthogError(*theX[0],*S_outs[o]); if (err > TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| || after : " << err << endl; } // == 0 if (theX.size() > 1 && theX[1] != null) { MT err = OM->orthogError(*theX[1],*S_outs[o]); if (err > TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } sout << " " << t << "|| || after : " << err << endl; } } // test all outputs for equivalence // check all combinations: // output 0 == output 1 // output 0 == output 2 // output 1 == output 2 for (unsigned int o1=0; o1 TOL) { sout << " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl; numerr++; } } } } catch (const OrthoError &e) { sout << " ------------------------------------------- project() threw exception" << endl; sout << " Error: " << e.what() << endl; numerr++; } } // test for MsgType type = Warnings; if (numerr>0) type = Errors; MyOM->stream(type) << sout.str(); MyOM->stream(type) << endl; return numerr; } MT MVDiff(const MV &X, const MV &Y) { const ST ONE = SCT::one(); const int sizeX = MVT::GetNumberVecs(X); SerialDenseMatrix xTmx(sizeX,sizeX); // tmp <- X RCP tmp = MVT::CloneCopy(X); // tmp <- tmp - Y MVT::MvAddMv(-ONE,Y,ONE,*tmp,*tmp); MVT::MvTransMv(ONE,*tmp,*tmp,xTmx); MT err = 0; for (int i=0; i