295 typedef typename Teuchos::Array<Teuchos::RCP<MV> >::size_type size_type;
299 typedef Teuchos::ScalarTraits<scalar_type>
SCT;
301 typedef Teuchos::ScalarTraits<magnitude_type>
SMT;
303 typedef Teuchos::SerialDenseMatrix<int, scalar_type>
mat_type;
323 const bool isRankRevealing,
324 const Teuchos::RCP<MV>& S,
329 using Teuchos::Array;
333 using Teuchos::rcp_dynamic_cast;
334 using Teuchos::tuple;
351 const int sizeS = MVT::GetNumberVecs (*S);
357 debugOut <<
"Generating X1,X2 for testing... ";
367 debugOut <<
"Filling X1 with random values... ";
370 <<
"Calling normalize() on X1... ";
378 "normalize(X1) returned rank "
380 <<
" vectors. Cannot continue.");
382 <<
"Calling orthonormError() on X1... ";
385 "After normalize(X1), orthonormError(X1) = "
386 <<
err <<
" > TOL = " <<
TOL);
387 debugOut <<
"done: ||<X1,X1> - I|| = " <<
err << endl;
393 debugOut <<
"Filling X2 with random values... ";
396 <<
"Calling projectAndNormalize(X2, C, B, tuple(X1))... "
414 "projectAndNormalize(X2,X1) returned rank "
416 <<
" vectors. Cannot continue.");
418 <<
"Calling orthonormError() on X2... ";
419 err =
OM->orthonormError (*
X2);
422 "projectAndNormalize(X2,X1) did not meet tolerance: "
423 "orthonormError(X2) = " <<
err <<
" > TOL = " <<
TOL);
424 debugOut <<
"done: || <X2,X2> - I || = " <<
err << endl
425 <<
"Calling orthogError(X2, X1)... ";
429 "projectAndNormalize(X2,X1) did not meet tolerance: "
430 "orthogError(X2,X1) = " <<
err <<
" > TOL = " <<
TOL);
431 debugOut <<
"done: || <X2,X1> || = " <<
err << endl;
434#ifdef HAVE_BELOS_TSQR
441 if (!
tsqr.is_null())
445 <<
"=== OutOfPlaceNormalizerMixin tests ==="
455 debugOut <<
"Filling X1_in with random values... ";
456 MVT::MvRandom(*
X1_in);
458 debugOut <<
"Filling X1_out with different random values...";
462 <<
"Calling normalizeOutOfPlace(*X1_in, *X1_out, null)... ";
466 "normalizeOutOfPlace(*X1_in, *X1_out, null) "
468 <<
sizeX1 <<
" vectors. Cannot continue.");
470 <<
"Calling orthonormError() on X1_out... ";
473 "After calling normalizeOutOfPlace(*X1_in, "
474 "*X1_out, null), orthonormError(X1) = "
475 <<
err <<
" > TOL = " <<
TOL);
476 debugOut <<
"done: ||<X1_out,X1_out> - I|| = " <<
err << endl;
487 debugOut <<
"Filling X2_in with random values... ";
488 MVT::MvRandom(*
X2_in);
490 <<
"Filling X2_out with different random values...";
494 <<
"Calling projectAndNormalizeOutOfPlace(X2_in, X2_out, "
495 <<
"C, B, X1_out)...";
506 "projectAndNormalizeOutOfPlace(*X2_in, "
507 "*X2_out, C, B, tuple(X1_out)) returned rank "
509 <<
" vectors. Cannot continue.");
511 <<
"Calling orthonormError() on X2_out... ";
514 "projectAndNormalizeOutOfPlace(*X2_in, *X2_out, "
515 "C, B, tuple(X1_out)) did not meet tolerance: "
516 "orthonormError(X2_out) = "
517 <<
err <<
" > TOL = " <<
TOL);
518 debugOut <<
"done: || <X2_out,X2_out> - I || = " <<
err << endl
519 <<
"Calling orthogError(X2_out, X1_out)... ";
522 "projectAndNormalizeOutOfPlace(*X2_in, *X2_out, "
523 "C, B, tuple(X1_out)) did not meet tolerance: "
524 "orthogError(X2_out, X1_out) = "
525 <<
err <<
" > TOL = " <<
TOL);
526 debugOut <<
"done: || <X2_out,X1_out> || = " <<
err << endl;
528 <<
"=== Done with OutOfPlaceNormalizerMixin tests ==="
540 debugOut <<
"Testing project() by projecting a random multivector S "
541 "against various combinations of X1 and X2 " << endl;
547 <<
" failed." << endl;
554 debugOut <<
"Testing normalize() on bad multivectors " << endl;
568 Teuchos::randomSyncedMatrix(
C1);
569 Teuchos::randomSyncedMatrix(
C2);
575 debugOut <<
"Testing project() by projecting [X1 X2]-range multivector "
576 "against P_X1 P_X2 " << endl;
582 <<
" failed." << endl;
587 if (isRankRevealing &&
sizeS > 2)
593 std::vector<int>
ind(1);
595 MVT::SetBlock(*
mid,
ind,*S);
597 debugOut <<
"Testing normalize() on a rank-deficient multivector " << endl;
603 <<
" failed." << endl;
608 if (isRankRevealing &&
sizeS > 1)
614 Teuchos::randomSyncedMatrix(
scaleS);
618 std::vector<int>
ind(1);
623 debugOut <<
"Testing normalize() on a rank-1 multivector " << endl;
629 <<
" failed." << endl;
633 std::vector<int>
ind(1);
636 debugOut <<
"Testing projectAndNormalize() on a random multivector " << endl;
642 <<
" failed." << endl;
654 Teuchos::randomSyncedMatrix(
C1);
655 Teuchos::randomSyncedMatrix(
C2);
659 debugOut <<
"Testing projectAndNormalize() by projecting [X1 X2]-range "
660 "multivector against P_X1 P_X2 " << endl;
666 <<
" failed." << endl;
671 if (isRankRevealing &&
sizeS > 2)
677 std::vector<int>
ind(1);
679 MVT::SetBlock(*
mid,
ind,*S);
681 debugOut <<
"Testing projectAndNormalize() on a rank-deficient "
682 "multivector " << endl;
688 <<
" failed." << endl;
693 if (isRankRevealing &&
sizeS > 1)
699 Teuchos::randomSyncedMatrix(
scaleS);
703 std::vector<int>
ind(1);
708 debugOut <<
"Testing projectAndNormalize() on a rank-1 multivector " << endl;
710 if (! MVT::HasConstantStride(*S)) {
711 debugOut <<
"-- S does not have constant stride" << endl;
714 if (! MVT::HasConstantStride(*
X1)) {
715 debugOut <<
"-- X1 does not have constant stride" << endl;
718 if (! MVT::HasConstantStride(*
X2)) {
719 debugOut <<
"-- X2 does not have constant stride" << endl;
723 debugOut <<
"-- Skipping this test, since TSQR does not work on "
724 "multivectors with nonconstant stride" << endl;
732 <<
" failed." << endl;
750 MVDiff (
const MV&
X,
const MV& Y)
755 const int numCols = MVT::GetNumberVecs(
X);
758 "MVDiff: X and Y should have the same number of columns."
759 " X has " <<
numCols <<
" column(s) and Y has "
760 << MVT::GetNumberVecs(Y) <<
" columns." );
766 return frobeniusNorm (*
Resid);
774 frobeniusNorm (
const MV&
X)
777 const int numCols = MVT::GetNumberVecs(
X);
781 MVT::MvTransMv (
ONE,
X,
X, C);
785 err += SCT::magnitude (C(
i,
i));
787 return SCT::magnitude (SCT::squareroot (
err));
793 const Teuchos::RCP< const MV >& S,
794 const Teuchos::RCP< const MV >& X1,
795 const Teuchos::RCP< const MV >& X2,
798 return testProjectAndNormalizeNew (OM, S, X1, X2, MyOM);
807 const Teuchos::RCP< const MV >& S,
808 const Teuchos::RCP< const MV >& X1,
809 const Teuchos::RCP< const MV >& X2,
812 using Teuchos::Array;
816 using Teuchos::tuple;
826 const int sizeS = MVT::GetNumberVecs(*S);
827 const int sizeX1 = MVT::GetNumberVecs(*X1);
828 const int sizeX2 = MVT::GetNumberVecs(*X2);
830 std::ostringstream sout;
866 sout <<
" || <S,X1> || before : " << err << endl;
870 sout <<
" || <S,X2> || before : " << err << endl;
873 for (
int t=0; t<numtests; t++) {
875 Array< RCP< const MV > > theX;
876 RCP<mat_type > B = rcp(
new mat_type(sizeS,sizeS) );
877 Array<RCP<mat_type > > C;
878 if ( (t % 3) == 0 ) {
882 else if ( (t % 3) == 1 ) {
885 C = tuple( rcp(
new mat_type(sizeX1,sizeS)) );
887 else if ( (t % 3) == 2 ) {
890 C = tuple( rcp(
new mat_type(sizeX2,sizeS)) );
895 C = tuple( rcp(
new mat_type(sizeX1,sizeS)),
912 Array<RCP<MV> > S_outs;
913 Array<Array<RCP<mat_type > > > C_outs;
914 Array<RCP<mat_type > > B_outs;
919 Scopy = MVT::CloneCopy(*S);
921 Teuchos::randomSyncedMatrix(*B);
922 for (size_type i=0; i<C.size(); i++) {
923 Teuchos::randomSyncedMatrix(*C[i]);
932 int ret = OM->projectAndNormalize(*Scopy,C,B,theX);
933 sout <<
"projectAndNormalize() returned rank " << ret << endl;
935 sout <<
" *** Error: returned rank is zero, cannot continue tests" << endl;
939 ret_out.push_back(ret);
949 std::vector<int> ind(ret);
950 for (
int i=0; i<ret; i++) {
953 S_outs.push_back( MVT::CloneViewNonConst(*Scopy,ind) );
954 B_outs.push_back( rcp(
new mat_type(Teuchos::Copy,*B,ret,sizeS) ) );
957 S_outs.push_back( Scopy );
958 B_outs.push_back( rcp(
new mat_type(*B) ) );
960 C_outs.push_back( Array<RCP<mat_type > >(0) );
962 C_outs.back().push_back( rcp(
new mat_type(*C[0]) ) );
965 C_outs.back().push_back( rcp(
new mat_type(*C[1]) ) );
969 if ( (t % 3) == 3 ) {
971 Scopy = MVT::CloneCopy(*S);
977 Teuchos::randomSyncedMatrix(*B);
978 for (size_type i=0; i<C.size(); i++) {
979 Teuchos::randomSyncedMatrix(*C[i]);
982 theX = tuple( theX[1], theX[0] );
986 ret = OM->projectAndNormalize(*Scopy,C,B,theX);
987 sout <<
"projectAndNormalize() returned rank " << ret << endl;
989 sout <<
" *** Error: returned rank is zero, cannot continue tests" << endl;
993 ret_out.push_back(ret);
1003 std::vector<int> ind(ret);
1004 for (
int i=0; i<ret; i++) {
1007 S_outs.push_back( MVT::CloneViewNonConst(*Scopy,ind) );
1008 B_outs.push_back( rcp(
new mat_type(Teuchos::Copy,*B,ret,sizeS) ) );
1011 S_outs.push_back( Scopy );
1012 B_outs.push_back( rcp(
new mat_type(*B) ) );
1014 C_outs.push_back( Array<RCP<mat_type > >() );
1016 C_outs.back().push_back( rcp(
new mat_type(*C[1]) ) );
1017 C_outs.back().push_back( rcp(
new mat_type(*C[0]) ) );
1019 theX = tuple( theX[1], theX[0] );
1024 for (size_type o=0; o<S_outs.size(); o++) {
1030 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1031 <<
" total tests) failed: Tolerance exceeded! Error = "
1032 << err <<
" > TOL = " << TOL <<
"."
1036 sout <<
" || <S,S> - I || after : " << err << endl;
1040 RCP<MV> tmp = MVT::Clone(*S,sizeS);
1041 MVT::MvTimesMatAddMv(ONE,*S_outs[o],*B_outs[o],ZERO,*tmp);
1042 if (C_outs[o].size() > 0) {
1043 MVT::MvTimesMatAddMv(ONE,*X1,*C_outs[o][0],ONE,*tmp);
1044 if (C_outs[o].size() > 1) {
1045 MVT::MvTimesMatAddMv(ONE,*X2,*C_outs[o][1],ONE,*tmp);
1049 if (err > ATOL*TOL) {
1051 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1052 <<
" total tests) failed: Tolerance exceeded! Error = "
1053 << err <<
" > ATOL*TOL = " << (ATOL*TOL) <<
"."
1057 sout <<
" " << t <<
"|| S_in - X1*C1 - X2*C2 - S_out*B || : " << err << endl;
1060 if (theX.size() > 0 && theX[0] != null) {
1064 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1065 <<
" total tests) failed: Tolerance exceeded! Error = "
1066 << err <<
" > TOL = " << TOL <<
"."
1070 sout <<
" " << t <<
"|| <X[0],S> || after : " << err << endl;
1073 if (theX.size() > 1 && theX[1] != null) {
1077 <<
" *** Test (number " << (t+1) <<
" of " << numtests
1078 <<
" total tests) failed: Tolerance exceeded! Error = "
1079 << err <<
" > TOL = " << TOL <<
"."
1083 sout <<
" " << t <<
"|| <X[1],S> || after : " << err << endl;
1088 sout <<
" *** Error: OrthoManager threw exception: " << e.what() << endl;
1099 const int msgType = (numerr > 0) ?
1100 (
static_cast<int>(
Debug) |
static_cast<int>(
Errors)) :
1101 static_cast<int>(
Debug);
1105 MyOM->stream(
static_cast< MsgType >(msgType)) << sout.str() << endl;
1115 const Teuchos::RCP< const MV >& S,
1120 int numFailures = 0;
1123 const int msgType = (
static_cast<int>(
Debug) |
static_cast<int>(
Errors));
1126 RCP<MV> zeroVec = MVT::Clone(*S,1);
1127 RCP< mat_type > bZero (
new mat_type (1, 1));
1128 std::vector< magnitude_type > zeroNorm( 1 );
1130 MVT::MvInit( *zeroVec, ZERO );
1131 OM->normalize( *zeroVec, bZero );
1132 MVT::MvNorm( *zeroVec, zeroNorm );
1134 if ( zeroNorm[0] != ZERO )
1136 MyOM->stream(
static_cast< MsgType >(msgType)) <<
" --> Normalization of zero vector FAILED!" << std::endl;
1149 const Teuchos::RCP< const MV >& S,
1152 using Teuchos::Array;
1155 using Teuchos::tuple;
1158 std::ostringstream sout;
1183 const int numRows = MVT::GetGlobalLength(*S);
1184 const int numCols = MVT::GetNumberVecs(*S);
1185 const int sizeS = MVT::GetNumberVecs(*S);
1203 sout <<
"The test matrix S has Frobenius norm " << ATOL
1204 <<
", and the relative error tolerance is TOL = "
1205 << TOL <<
"." << endl;
1207 const int numtests = 1;
1208 for (
int t = 0; t < numtests; ++t) {
1217 RCP< MV > S_copy = MVT::CloneCopy (*S);
1220 RCP< mat_type > B (
new mat_type (sizeS, sizeS));
1225 Teuchos::randomSyncedMatrix(*B);
1227 const int reportedRank = OM->normalize (*S_copy, B);
1228 sout <<
"normalize() returned rank " << reportedRank << endl;
1229 if (reportedRank == 0) {
1230 sout <<
" *** Error: Cannot continue, since normalize() "
1231 "reports that S has rank 0" << endl;
1245 std::vector<int> indices (reportedRank);
1246 for (
int j = 0; j < reportedRank; ++j)
1248 RCP< MV > S_view = MVT::CloneViewNonConst (*S_copy, indices);
1257 RCP< mat_type > B_top (
new mat_type (Teuchos::Copy, *B, reportedRank, sizeS));
1263 sout <<
" *** Error: Tolerance exceeded: err = "
1264 << err <<
" > TOL = " << TOL << endl;
1267 sout <<
" || <S,S> - I || after : " << err << endl;
1278 RCP< MV > Residual = MVT::CloneCopy (*S);
1281 MVT::MvTimesMatAddMv (-ONE, *S_view, *B_top, ONE, *Residual);
1285 if (err > ATOL*TOL) {
1286 sout <<
" *** Error: Tolerance exceeded: err = "
1287 << err <<
" > ATOL*TOL = " << (ATOL*TOL) << endl;
1290 sout <<
" " << t <<
"|| S - Q*B || : " << err << endl;
1294 sout <<
" *** Error: the OrthoManager's normalize() method "
1295 "threw an exception: " << e.what() << endl;
1302 MyOM->stream(type) << sout.str();
1303 MyOM->stream(type) << endl;
1314 const Teuchos::RCP< const MV >& S,
1315 const Teuchos::RCP< const MV >& X1,
1316 const Teuchos::RCP< const MV >& X2,
1319 using Teuchos::Array;
1320 using Teuchos::null;
1323 using Teuchos::tuple;
1327 std::ostringstream sout;
1331 const int numRows = MVT::GetGlobalLength(*S);
1332 const int numCols = MVT::GetNumberVecs(*S);
1333 const int sizeS = MVT::GetNumberVecs(*S);
1364 sout <<
"-- The test matrix S has Frobenius norm " << ATOL
1365 <<
", and the relative error tolerance is TOL = "
1366 << TOL <<
"." << endl;
1369 RCP< MV > Q = MVT::CloneCopy(*S);
1371 RCP< MV > Residual = MVT::CloneCopy(*S);
1374 const int num_X = 2;
1375 Array< RCP< const MV > > X (num_X);
1376 X[0] = MVT::CloneCopy(*X1);
1377 X[1] = MVT::CloneCopy(*X2);
1380 RCP< mat_type > B (
new mat_type (sizeS, sizeS));
1385 Array< RCP< mat_type > > C (num_X);
1386 for (
int k = 0; k < num_X; ++k)
1388 C[k] = rcp (
new mat_type (MVT::GetNumberVecs(*X[k]), sizeS));
1389 Teuchos::randomSyncedMatrix(*C[k]);
1393 const int reportedRank = OM->projectAndNormalize (*Q, C, B, X);
1396 std::vector<int> indices (reportedRank);
1397 for (
int j = 0; j < reportedRank; ++j)
1399 RCP< const MV > Q_left = MVT::CloneView (*Q, indices);
1405 sout <<
"-- ||Q(1:" << reportedRank <<
")^* Q(1:" << reportedRank
1406 <<
") - I||_F = " << orthoError << endl;
1407 if (orthoError > TOL)
1409 sout <<
" *** Error: ||Q(1:" << reportedRank <<
")^* Q(1:"
1410 << reportedRank <<
") - I||_F = " << orthoError
1411 <<
" > TOL = " << TOL <<
"." << endl;
1421 MVT::MvAddMv (SCT::one(), *S, SCT::zero(), *Residual, *Residual);
1427 RCP< const mat_type > B_top (
new mat_type (Teuchos::Copy, *B, reportedRank, B->numCols()));
1429 MVT::MvTimesMatAddMv (-SCT::one(), *Q_left, *B_top, SCT::one(), *Residual);
1432 for (
int k = 0; k < num_X; ++k)
1433 MVT::MvTimesMatAddMv (-SCT::one(), *X[k], *C[k], SCT::one(), *Residual);
1435 sout <<
"-- ||S - Q(:, 1:" << reportedRank <<
")*B(1:"
1436 << reportedRank <<
", :) - X1*C1 - X2*C2||_F = "
1437 << residErr << endl;
1438 if (residErr > ATOL * TOL)
1440 sout <<
" *** Error: ||S - Q(:, 1:" << reportedRank
1441 <<
")*B(1:" << reportedRank <<
", :) "
1442 <<
"- X1*C1 - X2*C2||_F = " << residErr
1443 <<
" > ATOL*TOL = " << (ATOL*TOL) <<
"." << endl;
1448 if (reportedRank == 0)
1450 sout <<
"-- Reported rank of Q is zero: skipping Q, X[k] "
1451 "orthogonality test." << endl;
1455 for (
int k = 0; k < num_X; ++k)
1459 sout <<
"-- ||<Q(1:" << reportedRank <<
"), X[" << k
1460 <<
"]>||_F = " << projErr << endl;
1461 if (projErr > ATOL*TOL)
1463 sout <<
" *** Error: ||<Q(1:" << reportedRank <<
"), X["
1464 << k <<
"]>||_F = " << projErr <<
" > ATOL*TOL = "
1465 << (ATOL*TOL) <<
"." << endl;
1471 sout <<
" *** Error: The OrthoManager subclass instance threw "
1472 "an exception: " << e.what() << endl;
1479 MyOM->stream(type) << sout.str();
1480 MyOM->stream(type) << endl;
1491 const Teuchos::RCP< const MV >& S,
1492 const Teuchos::RCP< const MV >& X1,
1493 const Teuchos::RCP< const MV >& X2,
1496 using Teuchos::Array;
1497 using Teuchos::null;
1500 using Teuchos::tuple;
1504 std::ostringstream sout;
1508 const int numRows = MVT::GetGlobalLength(*S);
1509 const int numCols = MVT::GetNumberVecs(*S);
1510 const int sizeS = MVT::GetNumberVecs(*S);
1541 sout <<
"The test matrix S has Frobenius norm " << ATOL
1542 <<
", and the relative error tolerance is TOL = "
1543 << TOL <<
"." << endl;
1548 RCP< MV > S_copy = MVT::CloneCopy(*S);
1549 RCP< MV > Residual = MVT::CloneCopy(*S);
1550 const int num_X = 2;
1551 Array< RCP< const MV > > X (num_X);
1552 X[0] = MVT::CloneCopy(*X1);
1553 X[1] = MVT::CloneCopy(*X2);
1558 Array< RCP< mat_type > > C (num_X);
1559 for (
int k = 0; k < num_X; ++k)
1561 C[k] = rcp (
new mat_type (MVT::GetNumberVecs(*X[k]), sizeS));
1562 Teuchos::randomSyncedMatrix(*C[k]);
1566 OM->project(*S_copy, C, X);
1573 MVT::MvAddMv (SCT::one(), *S, -SCT::one(), *S_copy, *Residual);
1575 for (
int k = 0; k < num_X; ++k)
1576 MVT::MvTimesMatAddMv (-SCT::one(), *X[k], *C[k], SCT::one(), *Residual);
1578 sout <<
" ||S - S_copy - X1*C1 - X2*C2||_F = " << residErr;
1579 if (residErr > ATOL * TOL)
1581 sout <<
" *** Error: ||S - S_copy - X1*C1 - X2*C2||_F = " << residErr
1582 <<
" > ATOL*TOL = " << (ATOL*TOL) <<
".";
1585 for (
int k = 0; k < num_X; ++k)
1591 sout <<
" *** Error: S is not orthogonal to X[" << k
1592 <<
"] by a factor of " << projErr <<
" > TOL = "
1598 sout <<
" *** Error: The OrthoManager subclass instance threw "
1599 "an exception: " << e.what() << endl;
1606 MyOM->stream(type) << sout.str();
1607 MyOM->stream(type) << endl;
1614 const Teuchos::RCP< const MV >& S,
1615 const Teuchos::RCP< const MV >& X1,
1616 const Teuchos::RCP< const MV >& X2,
1619 return testProjectNew (OM, S, X1, X2, MyOM);
1627 const Teuchos::RCP< const MV >& S,
1628 const Teuchos::RCP< const MV >& X1,
1629 const Teuchos::RCP< const MV >& X2,
1632 using Teuchos::Array;
1633 using Teuchos::null;
1636 using Teuchos::tuple;
1641 std::ostringstream sout;
1645 const int numRows = MVT::GetGlobalLength(*S);
1646 const int numCols = MVT::GetNumberVecs(*S);
1647 const int sizeS = MVT::GetNumberVecs(*S);
1648 const int sizeX1 = MVT::GetNumberVecs(*X1);
1649 const int sizeX2 = MVT::GetNumberVecs(*X2);
1680 sout <<
"The test matrix S has Frobenius norm " << ATOL
1681 <<
", and the relative error tolerance is TOL = "
1682 << TOL <<
"." << endl;
1718 sout <<
" || <S,X1> || before : " << err << endl;
1722 sout <<
" || <S,X2> || before : " << err << endl;
1725 for (
int t = 0; t < numtests; ++t)
1727 Array< RCP< const MV > > theX;
1728 Array< RCP< mat_type > > C;
1729 if ( (t % 3) == 0 ) {
1733 else if ( (t % 3) == 1 ) {
1736 C = tuple( rcp(
new mat_type(sizeX1,sizeS)) );
1738 else if ( (t % 3) == 2 ) {
1741 C = tuple( rcp(
new mat_type(sizeX2,sizeS)) );
1745 theX = tuple(X1,X2);
1746 C = tuple( rcp(
new mat_type(sizeX1,sizeS)),
1759 Array< RCP< MV > > S_outs;
1760 Array< Array< RCP< mat_type > > > C_outs;
1764 Scopy = MVT::CloneCopy(*S);
1766 for (size_type i = 0; i < C.size(); ++i) {
1767 Teuchos::randomSyncedMatrix(*C[i]);
1772 OM->project(*Scopy,C,theX);
1775 S_outs.push_back( Scopy );
1776 C_outs.push_back( Array< RCP< mat_type > >(0) );
1778 C_outs.back().push_back( rcp(
new mat_type(*C[0]) ) );
1781 C_outs.back().push_back( rcp(
new mat_type(*C[1]) ) );
1785 if ( (t % 3) == 3 ) {
1787 Scopy = MVT::CloneCopy(*S);
1789 for (size_type i = 0; i < C.size(); ++i) {
1790 Teuchos::randomSyncedMatrix(*C[i]);
1793 theX = tuple( theX[1], theX[0] );
1797 OM->project(*Scopy,C,theX);
1800 S_outs.push_back( Scopy );
1803 C_outs.push_back( Array<RCP<mat_type > >() );
1805 C_outs.back().push_back( rcp(
new mat_type(*C[1]) ) );
1806 C_outs.back().push_back( rcp(
new mat_type(*C[0]) ) );
1808 theX = tuple( theX[1], theX[0] );
1812 for (size_type o = 0; o < S_outs.size(); ++o) {
1815 RCP<MV> tmp = MVT::CloneCopy(*S_outs[o]);
1816 if (C_outs[o].size() > 0) {
1817 MVT::MvTimesMatAddMv(ONE,*X1,*C_outs[o][0],ONE,*tmp);
1818 if (C_outs[o].size() > 1) {
1819 MVT::MvTimesMatAddMv(ONE,*X2,*C_outs[o][1],ONE,*tmp);
1823 if (err > ATOL*TOL) {
1824 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1827 sout <<
" " << t <<
"|| S_in - X1*C1 - X2*C2 - S_out || : " << err << endl;
1830 if (theX.size() > 0 && theX[0] != null) {
1833 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1836 sout <<
" " << t <<
"|| <X[0],S> || after : " << err << endl;
1839 if (theX.size() > 1 && theX[1] != null) {
1842 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1845 sout <<
" " << t <<
"|| <X[1],S> || after : " << err << endl;
1854 for (size_type o1=0; o1<S_outs.size(); o1++) {
1855 for (size_type o2=o1+1; o2<S_outs.size(); o2++) {
1863 sout <<
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv tolerance exceeded! test failed!" << endl;
1871 sout <<
" ------------------------------------------- project() threw exception" << endl;
1872 sout <<
" Error: " << e.what() << endl;
1878 if (numerr>0) type =
Errors;
1879 MyOM->stream(type) << sout.str();
1880 MyOM->stream(type) << endl;