296 typedef typename Teuchos::Array<Teuchos::RCP<MV> >::size_type size_type;
300 typedef Teuchos::ScalarTraits<scalar_type>
SCT;
302 typedef Teuchos::ScalarTraits<magnitude_type>
SMT;
324 const bool isRankRevealing,
325 const Teuchos::RCP<MV>& S,
330 using Teuchos::Array;
334 using Teuchos::rcp_dynamic_cast;
335 using Teuchos::tuple;
352 const int sizeS = MVT::GetNumberVecs (*S);
358 debugOut <<
"Generating X1,X2 for testing... ";
368 debugOut <<
"Filling X1 with random values... ";
371 <<
"Calling normalize() on X1... ";
379 "normalize(X1) returned rank "
381 <<
" vectors. Cannot continue.");
383 <<
"Calling orthonormError() on X1... ";
386 "After normalize(X1), orthonormError(X1) = "
387 <<
err <<
" > TOL = " <<
TOL);
388 debugOut <<
"done: ||<X1,X1> - I|| = " <<
err << endl;
394 debugOut <<
"Filling X2 with random values... ";
397 <<
"Calling projectAndNormalize(X2, C, B, tuple(X1))... "
408 "projectAndNormalize(X2,X1) returned rank "
410 <<
" vectors. Cannot continue.");
412 <<
"Calling orthonormError() on X2... ";
413 err =
OM->orthonormError (*
X2);
416 "projectAndNormalize(X2,X1) did not meet tolerance: "
417 "orthonormError(X2) = " <<
err <<
" > TOL = " <<
TOL);
418 debugOut <<
"done: || <X2,X2> - I || = " <<
err << endl
419 <<
"Calling orthogError(X2, X1)... ";
423 "projectAndNormalize(X2,X1) did not meet tolerance: "
424 "orthogError(X2,X1) = " <<
err <<
" > TOL = " <<
TOL);
425 debugOut <<
"done: || <X2,X1> || = " <<
err << endl;
428#ifdef HAVE_BELOS_TSQR
435 if (!
tsqr.is_null())
439 <<
"=== OutOfPlaceNormalizerMixin tests ==="
449 debugOut <<
"Filling X1_in with random values... ";
450 MVT::MvRandom(*
X1_in);
452 debugOut <<
"Filling X1_out with different random values...";
456 <<
"Calling normalizeOutOfPlace(*X1_in, *X1_out, null)... ";
460 "normalizeOutOfPlace(*X1_in, *X1_out, null) "
462 <<
sizeX1 <<
" vectors. Cannot continue.");
464 <<
"Calling orthonormError() on X1_out... ";
467 "After calling normalizeOutOfPlace(*X1_in, "
468 "*X1_out, null), orthonormError(X1) = "
469 <<
err <<
" > TOL = " <<
TOL);
470 debugOut <<
"done: ||<X1_out,X1_out> - I|| = " <<
err << endl;
481 debugOut <<
"Filling X2_in with random values... ";
482 MVT::MvRandom(*
X2_in);
484 <<
"Filling X2_out with different random values...";
488 <<
"Calling projectAndNormalizeOutOfPlace(X2_in, X2_out, "
489 <<
"C, B, X1_out)...";
500 "projectAndNormalizeOutOfPlace(*X2_in, "
501 "*X2_out, C, B, tuple(X1_out)) returned rank "
503 <<
" vectors. Cannot continue.");
505 <<
"Calling orthonormError() on X2_out... ";
508 "projectAndNormalizeOutOfPlace(*X2_in, *X2_out, "
509 "C, B, tuple(X1_out)) did not meet tolerance: "
510 "orthonormError(X2_out) = "
511 <<
err <<
" > TOL = " <<
TOL);
512 debugOut <<
"done: || <X2_out,X2_out> - I || = " <<
err << endl
513 <<
"Calling orthogError(X2_out, X1_out)... ";
516 "projectAndNormalizeOutOfPlace(*X2_in, *X2_out, "
517 "C, B, tuple(X1_out)) did not meet tolerance: "
518 "orthogError(X2_out, X1_out) = "
519 <<
err <<
" > TOL = " <<
TOL);
520 debugOut <<
"done: || <X2_out,X1_out> || = " <<
err << endl;
522 <<
"=== Done with OutOfPlaceNormalizerMixin tests ==="
534 debugOut <<
"Testing project() by projecting a random multivector S "
535 "against various combinations of X1 and X2 " << endl;
541 <<
" failed." << endl;
548 debugOut <<
"Testing normalize() on bad multivectors " << endl;
569 debugOut <<
"Testing project() by projecting [X1 X2]-range multivector "
570 "against P_X1 P_X2 " << endl;
576 <<
" failed." << endl;
581 if (isRankRevealing &&
sizeS > 2)
587 std::vector<int>
ind(1);
589 MVT::SetBlock(*
mid,
ind,*S);
591 debugOut <<
"Testing normalize() on a rank-deficient multivector " << endl;
597 <<
" failed." << endl;
602 if (isRankRevealing &&
sizeS > 1)
612 std::vector<int>
ind(1);
617 debugOut <<
"Testing normalize() on a rank-1 multivector " << endl;
623 <<
" failed." << endl;
627 std::vector<int>
ind(1);
630 debugOut <<
"Testing projectAndNormalize() on a random multivector " << endl;
636 <<
" failed." << endl;
653 debugOut <<
"Testing projectAndNormalize() by projecting [X1 X2]-range "
654 "multivector against P_X1 P_X2 " << endl;
660 <<
" failed." << endl;
665 if (isRankRevealing &&
sizeS > 2)
671 std::vector<int>
ind(1);
673 MVT::SetBlock(*
mid,
ind,*S);
675 debugOut <<
"Testing projectAndNormalize() on a rank-deficient "
676 "multivector " << endl;
682 <<
" failed." << endl;
687 if (isRankRevealing &&
sizeS > 1)
697 std::vector<int>
ind(1);
702 debugOut <<
"Testing projectAndNormalize() on a rank-1 multivector " << endl;
704 if (! MVT::HasConstantStride(*S)) {
705 debugOut <<
"-- S does not have constant stride" << endl;
708 if (! MVT::HasConstantStride(*
X1)) {
709 debugOut <<
"-- X1 does not have constant stride" << endl;
712 if (! MVT::HasConstantStride(*
X2)) {
713 debugOut <<
"-- X2 does not have constant stride" << endl;
717 debugOut <<
"-- Skipping this test, since TSQR does not work on "
718 "multivectors with nonconstant stride" << endl;
726 <<
" failed." << endl;
744 MVDiff (
const MV&
X,
const MV& Y)
749 const int numCols = MVT::GetNumberVecs(
X);
752 "MVDiff: X and Y should have the same number of columns."
753 " X has " <<
numCols <<
" column(s) and Y has "
754 << MVT::GetNumberVecs(Y) <<
" columns." );
760 return frobeniusNorm (*
Resid);
768 frobeniusNorm (
const MV&
X)
773 const int numCols = MVT::GetNumberVecs(
X);
777 MVT::MvTransMv (
ONE,
X,
X, *C);
778 DMT::SyncDeviceToHost( *C );
782 err += SCT::magnitude (DMT::ValueConst(*C,
i,
i));
784 return SCT::magnitude (SCT::squareroot (
err));
790 const Teuchos::RCP< const MV >& S,
791 const Teuchos::RCP< const MV >& X1,
792 const Teuchos::RCP< const MV >& X2,
795 return testProjectAndNormalizeNew (OM, S, X1, X2, MyOM);
804 const Teuchos::RCP< const MV >& S,
805 const Teuchos::RCP< const MV >& X1,
806 const Teuchos::RCP< const MV >& X2,
809 using Teuchos::Array;
813 using Teuchos::tuple;
823 const int sizeS = MVT::GetNumberVecs(*S);
824 const int sizeX1 = MVT::GetNumberVecs(*X1);
825 const int sizeX2 = MVT::GetNumberVecs(*X2);
827 std::ostringstream sout;
863 sout <<
" || <S,X1> || before : " << err << endl;
867 sout <<
" || <S,X2> || before : " << err << endl;
870 for (
int t=0; t<numtests; t++) {
872 Array< RCP< const MV > > theX;
873 RCP<DM> B = DMT::Create( sizeS,sizeS );
875 if ( (t % 3) == 0 ) {
879 else if ( (t % 3) == 1 ) {
882 C = tuple( DMT::Create(sizeX1,sizeS) );
884 else if ( (t % 3) == 2 ) {
887 C = tuple( DMT::Create(sizeX2,sizeS) );
892 C = tuple( DMT::Create(sizeX1,sizeS),
893 DMT::Create(sizeX2,sizeS) );
909 Array<RCP<MV> > S_outs;
910 Array<Array<RCP<DM > > > C_outs;
911 Array<RCP<DM > > B_outs;
916 Scopy = MVT::CloneCopy(*S);
918 RandomSyncedMpiMatrix<Scalar,DM>(*B);
919 for (size_type i=0; i<C.size(); i++) {
920 RandomSyncedMpiMatrix<Scalar,DM>(*C[i]);
929 int ret = OM->projectAndNormalize(*Scopy,C,B,theX);
930 sout <<
"projectAndNormalize() returned rank " << ret << endl;
932 sout <<
" *** Error: returned rank is zero, cannot continue tests" << endl;
936 ret_out.push_back(ret);
946 std::vector<int> ind(ret);
947 for (
int i=0; i<ret; i++) {
950 S_outs.push_back( MVT::CloneViewNonConst(*Scopy,ind) );
951 B_outs.push_back( DMT::SubviewCopy(*B,ret,sizeS) );
954 S_outs.push_back( Scopy );
955 B_outs.push_back( DMT::CreateCopy( *B ) );
957 C_outs.push_back( Array<RCP<DM> >(0) );
959 C_outs.back().push_back( DMT::CreateCopy( *C[0] ) );
962 C_outs.back().push_back( DMT::CreateCopy( *C[1]) );
966 if ( (t % 3) == 3 ) {
968 Scopy = MVT::CloneCopy(*S);
974 RandomSyncedMpiMatrix<Scalar,DM>(*B);
975 for (size_type i=0; i<C.size(); i++) {
976 RandomSyncedMpiMatrix<Scalar,DM>(*C[i]);
979 theX = tuple( theX[1], theX[0] );
983 ret = OM->projectAndNormalize(*Scopy,C,B,theX);
984 sout <<
"projectAndNormalize() returned rank " << ret << endl;
986 sout <<
" *** Error: returned rank is zero, cannot continue tests" << endl;
990 ret_out.push_back(ret);
1000 std::vector<int> ind(ret);
1001 for (
int i=0; i<ret; i++) {
1004 S_outs.push_back( MVT::CloneViewNonConst(*Scopy,ind) );
1005 B_outs.push_back( DMT::SubviewCopy( *B,ret,sizeS) );
1008 S_outs.push_back( Scopy );
1009 B_outs.push_back( DMT::CreateCopy( *B ) );
1011 C_outs.push_back( Array<RCP<DM> >() );
1013 C_outs.back().push_back( DMT::CreateCopy(*C[1]) );
1014 C_outs.back().push_back( DMT::CreateCopy(*C[0]) );
1016 theX = tuple( theX[1], theX[0] );
1021 for (size_type o=0; o<S_outs.size(); o++) {
1027 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1028 <<
" total tests) failed: Tolerance exceeded! Error = "
1029 << err <<
" > TOL = " << TOL <<
"."
1033 sout <<
" || <S,S> - I || after : " << err << endl;
1037 RCP<MV> tmp = MVT::Clone(*S,sizeS);
1038 MVT::MvTimesMatAddMv(ONE,*S_outs[o],*B_outs[o],ZERO,*tmp);
1039 if (C_outs[o].size() > 0) {
1040 MVT::MvTimesMatAddMv(ONE,*X1,*C_outs[o][0],ONE,*tmp);
1041 if (C_outs[o].size() > 1) {
1042 MVT::MvTimesMatAddMv(ONE,*X2,*C_outs[o][1],ONE,*tmp);
1046 if (err > ATOL*TOL) {
1048 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1049 <<
" total tests) failed: Tolerance exceeded! Error = "
1050 << err <<
" > ATOL*TOL = " << (ATOL*TOL) <<
"."
1054 sout <<
" " << t <<
"|| S_in - X1*C1 - X2*C2 - S_out*B || : " << err << endl;
1057 if (theX.size() > 0 && theX[0] != null) {
1061 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1062 <<
" total tests) failed: Tolerance exceeded! Error = "
1063 << err <<
" > TOL = " << TOL <<
"."
1067 sout <<
" " << t <<
"|| <X[0],S> || after : " << err << endl;
1070 if (theX.size() > 1 && theX[1] != null) {
1074 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1075 <<
" total tests) failed: Tolerance exceeded! Error = "
1076 << err <<
" > TOL = " << TOL <<
"."
1080 sout <<
" " << t <<
"|| <X[1],S> || after : " << err << endl;
1085 sout <<
" *** Error: OrthoManager threw exception: " << e.what() << endl;
1096 const int msgType = (numerr > 0) ?
1097 (
static_cast<int>(
Debug) |
static_cast<int>(
Errors)) :
1098 static_cast<int>(
Debug);
1102 MyOM->stream(
static_cast< MsgType >(msgType)) << sout.str() << endl;
1112 const Teuchos::RCP< const MV >& S,
1117 int numFailures = 0;
1120 const int msgType = (
static_cast<int>(
Debug) |
static_cast<int>(
Errors));
1123 RCP<MV> zeroVec = MVT::Clone(*S,1);
1124 RCP<DM> bZero = DMT::Create(1,1);
1125 std::vector< magnitude_type > zeroNorm( 1 );
1127 MVT::MvInit( *zeroVec, ZERO );
1128 OM->normalize( *zeroVec, bZero );
1129 MVT::MvNorm( *zeroVec, zeroNorm );
1131 if ( zeroNorm[0] != ZERO )
1133 MyOM->stream(
static_cast< MsgType >(msgType)) <<
" --> Normalization of zero vector FAILED!" << std::endl;
1146 const Teuchos::RCP< const MV >& S,
1149 using Teuchos::Array;
1152 using Teuchos::tuple;
1155 std::ostringstream sout;
1180 const int numRows = MVT::GetGlobalLength(*S);
1181 const int numCols = MVT::GetNumberVecs(*S);
1182 const int sizeS = MVT::GetNumberVecs(*S);
1200 sout <<
"The test matrix S has Frobenius norm " << ATOL
1201 <<
", and the relative error tolerance is TOL = "
1202 << TOL <<
"." << endl;
1204 const int numtests = 1;
1205 for (
int t = 0; t < numtests; ++t) {
1214 RCP< MV > S_copy = MVT::CloneCopy (*S);
1217 RCP< DM > B = DMT::Create(sizeS, sizeS);
1222 RandomSyncedMpiMatrix<Scalar,DM>(*B);
1224 const int reportedRank = OM->normalize (*S_copy, B);
1225 sout <<
"normalize() returned rank " << reportedRank << endl;
1226 if (reportedRank == 0) {
1227 sout <<
" *** Error: Cannot continue, since normalize() "
1228 "reports that S has rank 0" << endl;
1242 std::vector<int> indices (reportedRank);
1243 for (
int j = 0; j < reportedRank; ++j)
1245 RCP< MV > S_view = MVT::CloneViewNonConst (*S_copy, indices);
1251 RCP< DM > B_top = DMT::SubviewCopy(*B, reportedRank, sizeS);
1257 sout <<
" *** Error: Tolerance exceeded: err = "
1258 << err <<
" > TOL = " << TOL << endl;
1261 sout <<
" || <S,S> - I || after : " << err << endl;
1272 RCP< MV > Residual = MVT::CloneCopy (*S);
1275 MVT::MvTimesMatAddMv (-ONE, *S_view, *B_top, ONE, *Residual);
1279 if (err > ATOL*TOL) {
1280 sout <<
" *** Error: Tolerance exceeded: err = "
1281 << err <<
" > ATOL*TOL = " << (ATOL*TOL) << endl;
1284 sout <<
" " << t <<
"|| S - Q*B || : " << err << endl;
1288 sout <<
" *** Error: the OrthoManager's normalize() method "
1289 "threw an exception: " << e.what() << endl;
1296 MyOM->stream(type) << sout.str();
1297 MyOM->stream(type) << endl;
1308 const Teuchos::RCP< const MV >& S,
1309 const Teuchos::RCP< const MV >& X1,
1310 const Teuchos::RCP< const MV >& X2,
1313 using Teuchos::Array;
1314 using Teuchos::null;
1317 using Teuchos::tuple;
1321 std::ostringstream sout;
1325 const int numRows = MVT::GetGlobalLength(*S);
1326 const int numCols = MVT::GetNumberVecs(*S);
1327 const int sizeS = MVT::GetNumberVecs(*S);
1358 sout <<
"-- The test matrix S has Frobenius norm " << ATOL
1359 <<
", and the relative error tolerance is TOL = "
1360 << TOL <<
"." << endl;
1363 RCP< MV > Q = MVT::CloneCopy(*S);
1365 RCP< MV > Residual = MVT::CloneCopy(*S);
1368 const int num_X = 2;
1369 Array< RCP< const MV > > X (num_X);
1370 X[0] = MVT::CloneCopy(*X1);
1371 X[1] = MVT::CloneCopy(*X2);
1374 RCP< DM > B = DMT::Create( sizeS, sizeS );
1379 Array< RCP< DM > > C (num_X);
1380 for (
int k = 0; k < num_X; ++k)
1382 C[k] = DMT::Create( MVT::GetNumberVecs(*X[k]), sizeS );
1383 RandomSyncedMpiMatrix<Scalar,DM>(*C[k]);
1387 const int reportedRank = OM->projectAndNormalize (*Q, C, B, X);
1390 std::vector<int> indices (reportedRank);
1391 for (
int j = 0; j < reportedRank; ++j)
1393 RCP< const MV > Q_left = MVT::CloneView (*Q, indices);
1399 sout <<
"-- ||Q(1:" << reportedRank <<
")^* Q(1:" << reportedRank
1400 <<
") - I||_F = " << orthoError << endl;
1401 if (orthoError > TOL)
1403 sout <<
" *** Error: ||Q(1:" << reportedRank <<
")^* Q(1:"
1404 << reportedRank <<
") - I||_F = " << orthoError
1405 <<
" > TOL = " << TOL <<
"." << endl;
1415 MVT::MvAddMv (SCT::one(), *S, SCT::zero(), *Residual, *Residual);
1421 RCP< const DM > B_top = DMT::SubviewCopy( *B, reportedRank, DMT::GetNumCols(*B) );
1423 MVT::MvTimesMatAddMv (-SCT::one(), *Q_left, *B_top, SCT::one(), *Residual);
1426 for (
int k = 0; k < num_X; ++k)
1427 MVT::MvTimesMatAddMv (-SCT::one(), *X[k], *C[k], SCT::one(), *Residual);
1429 sout <<
"-- ||S - Q(:, 1:" << reportedRank <<
")*B(1:"
1430 << reportedRank <<
", :) - X1*C1 - X2*C2||_F = "
1431 << residErr << endl;
1432 if (residErr > ATOL * TOL)
1434 sout <<
" *** Error: ||S - Q(:, 1:" << reportedRank
1435 <<
")*B(1:" << reportedRank <<
", :) "
1436 <<
"- X1*C1 - X2*C2||_F = " << residErr
1437 <<
" > ATOL*TOL = " << (ATOL*TOL) <<
"." << endl;
1442 if (reportedRank == 0)
1444 sout <<
"-- Reported rank of Q is zero: skipping Q, X[k] "
1445 "orthogonality test." << endl;
1449 for (
int k = 0; k < num_X; ++k)
1453 sout <<
"-- ||<Q(1:" << reportedRank <<
"), X[" << k
1454 <<
"]>||_F = " << projErr << endl;
1455 if (projErr > ATOL*TOL)
1457 sout <<
" *** Error: ||<Q(1:" << reportedRank <<
"), X["
1458 << k <<
"]>||_F = " << projErr <<
" > ATOL*TOL = "
1459 << (ATOL*TOL) <<
"." << endl;
1465 sout <<
" *** Error: The OrthoManager subclass instance threw "
1466 "an exception: " << e.what() << endl;
1473 MyOM->stream(type) << sout.str();
1474 MyOM->stream(type) << endl;
1485 const Teuchos::RCP< const MV >& S,
1486 const Teuchos::RCP< const MV >& X1,
1487 const Teuchos::RCP< const MV >& X2,
1490 using Teuchos::Array;
1491 using Teuchos::null;
1494 using Teuchos::tuple;
1498 std::ostringstream sout;
1502 const int numRows = MVT::GetGlobalLength(*S);
1503 const int numCols = MVT::GetNumberVecs(*S);
1504 const int sizeS = MVT::GetNumberVecs(*S);
1535 sout <<
"The test matrix S has Frobenius norm " << ATOL
1536 <<
", and the relative error tolerance is TOL = "
1537 << TOL <<
"." << endl;
1542 RCP< MV > S_copy = MVT::CloneCopy(*S);
1543 RCP< MV > Residual = MVT::CloneCopy(*S);
1544 const int num_X = 2;
1545 Array< RCP< const MV > > X (num_X);
1546 X[0] = MVT::CloneCopy(*X1);
1547 X[1] = MVT::CloneCopy(*X2);
1552 Array< RCP< DM > > C (num_X);
1553 for (
int k = 0; k < num_X; ++k)
1555 C[k] = DMT::Create( MVT::GetNumberVecs(*X[k]), sizeS );
1556 RandomSyncedMpiMatrix<Scalar,DM>(*C[k]);
1560 OM->project(*S_copy, C, X);
1567 MVT::MvAddMv (SCT::one(), *S, -SCT::one(), *S_copy, *Residual);
1569 for (
int k = 0; k < num_X; ++k)
1570 MVT::MvTimesMatAddMv (-SCT::one(), *X[k], *C[k], SCT::one(), *Residual);
1572 sout <<
" ||S - S_copy - X1*C1 - X2*C2||_F = " << residErr;
1573 if (residErr > ATOL * TOL)
1575 sout <<
" *** Error: ||S - S_copy - X1*C1 - X2*C2||_F = " << residErr
1576 <<
" > ATOL*TOL = " << (ATOL*TOL) <<
".";
1579 for (
int k = 0; k < num_X; ++k)
1585 sout <<
" *** Error: S is not orthogonal to X[" << k
1586 <<
"] by a factor of " << projErr <<
" > TOL = "
1592 sout <<
" *** Error: The OrthoManager subclass instance threw "
1593 "an exception: " << e.what() << endl;
1600 MyOM->stream(type) << sout.str();
1601 MyOM->stream(type) << endl;
1608 const Teuchos::RCP< const MV >& S,
1609 const Teuchos::RCP< const MV >& X1,
1610 const Teuchos::RCP< const MV >& X2,
1613 return testProjectNew (OM, S, X1, X2, MyOM);
1621 const Teuchos::RCP< const MV >& S,
1622 const Teuchos::RCP< const MV >& X1,
1623 const Teuchos::RCP< const MV >& X2,
1626 using Teuchos::Array;
1627 using Teuchos::null;
1630 using Teuchos::tuple;
1635 std::ostringstream sout;
1639 const int numRows = MVT::GetGlobalLength(*S);
1640 const int numCols = MVT::GetNumberVecs(*S);
1641 const int sizeS = MVT::GetNumberVecs(*S);
1642 const int sizeX1 = MVT::GetNumberVecs(*X1);
1643 const int sizeX2 = MVT::GetNumberVecs(*X2);
1674 sout <<
"The test matrix S has Frobenius norm " << ATOL
1675 <<
", and the relative error tolerance is TOL = "
1676 << TOL <<
"." << endl;
1712 sout <<
" || <S,X1> || before : " << err << endl;
1716 sout <<
" || <S,X2> || before : " << err << endl;
1719 for (
int t = 0; t < numtests; ++t)
1721 Array< RCP< const MV > > theX;
1722 Array< RCP< DM > > C;
1723 if ( (t % 3) == 0 ) {
1727 else if ( (t % 3) == 1 ) {
1730 C = tuple( DMT::Create(sizeX1,sizeS) );
1732 else if ( (t % 3) == 2 ) {
1735 C = tuple( DMT::Create(sizeX2,sizeS) );
1739 theX = tuple(X1,X2);
1740 C = tuple( DMT::Create(sizeX1,sizeS),
1741 DMT::Create(sizeX2,sizeS) );
1753 Array< RCP< MV > > S_outs;
1754 Array< Array< RCP< DM > > > C_outs;
1758 Scopy = MVT::CloneCopy(*S);
1760 for (size_type i = 0; i < C.size(); ++i) {
1761 RandomSyncedMpiMatrix<Scalar,DM>(*C[i]);
1766 OM->project(*Scopy,C,theX);
1769 S_outs.push_back( Scopy );
1770 C_outs.push_back( Array< RCP< DM > >(0) );
1772 C_outs.back().push_back( DMT::CreateCopy( *C[0]) );
1775 C_outs.back().push_back( DMT::CreateCopy( *C[1]) );
1779 if ( (t % 3) == 3 ) {
1781 Scopy = MVT::CloneCopy(*S);
1783 for (size_type i = 0; i < C.size(); ++i) {
1784 RandomSyncedMpiMatrix<Scalar,DM>(*C[i]);
1787 theX = tuple( theX[1], theX[0] );
1791 OM->project(*Scopy,C,theX);
1794 S_outs.push_back( Scopy );
1797 C_outs.push_back( Array<RCP<DM> >() );
1799 C_outs.back().push_back( DMT::CreateCopy(*C[1]) );
1800 C_outs.back().push_back( DMT::CreateCopy(*C[0]) );
1802 theX = tuple( theX[1], theX[0] );
1806 for (size_type o = 0; o < S_outs.size(); ++o) {
1809 RCP<MV> tmp = MVT::CloneCopy(*S_outs[o]);
1810 if (C_outs[o].size() > 0) {
1811 MVT::MvTimesMatAddMv(ONE,*X1,*C_outs[o][0],ONE,*tmp);
1812 if (C_outs[o].size() > 1) {
1813 MVT::MvTimesMatAddMv(ONE,*X2,*C_outs[o][1],ONE,*tmp);
1817 if (err > ATOL*TOL) {
1818 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1821 sout <<
" " << t <<
"|| S_in - X1*C1 - X2*C2 - S_out || : " << err << endl;
1824 if (theX.size() > 0 && theX[0] != null) {
1827 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1830 sout <<
" " << t <<
"|| <X[0],S> || after : " << err << endl;
1833 if (theX.size() > 1 && theX[1] != null) {
1836 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1839 sout <<
" " << t <<
"|| <X[1],S> || after : " << err << endl;
1848 for (size_type o1=0; o1<S_outs.size(); o1++) {
1849 for (size_type o2=o1+1; o2<S_outs.size(); o2++) {
1857 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1865 sout <<
" ------------------------------------------- project() threw exception" << endl;
1866 sout <<
" Error: " << e.what() << endl;
1872 if (numerr>0) type =
Errors;
1873 MyOM->stream(type) << sout.str();
1874 MyOM->stream(type) << endl;