33 template<
class Scalar,
class MV>
66 Array<RCP<MV> > V (numBlocks);
67 for (
int k = 0; k < numBlocks; ++k) {
73 RCP<Time> timer = TimeMonitor::getNewCounter (
"Baseline for OrthoManager benchmark");
79 TimeMonitor monitor (*timer);
80 for (
int trial = 0; trial < numTrials; ++trial) {
81 for (
int k = 0; k < numBlocks; ++k) {
82 for (
int j = 0; j < k; ++j)
123 const std::string& orthoManName,
124 const std::string& normalization,
130 std::ostream& resultStream,
131 const bool displayResultsCompactly=
false)
146 "numCols = " << numCols <<
" < 1");
147 TEUCHOS_TEST_FOR_EXCEPTION(numBlocks < 1, std::invalid_argument,
148 "numBlocks = " << numBlocks <<
" < 1");
149 TEUCHOS_TEST_FOR_EXCEPTION(numTrials < 1, std::invalid_argument,
150 "numTrials = " << numTrials <<
" < 1");
152 std::ostream& debugOut = outMan->stream(
Debug);
164 Array<RCP<mat_type> >
C (numBlocks);
165 for (
int k = 0; k < numBlocks; ++k) {
168 RCP<mat_type>
B (
new mat_type (numCols, numCols));
174 Array<RCP<MV> > V (numBlocks);
175 for (
int k = 0; k < numBlocks; ++k) {
183 RCP<Time> firstRunTimer;
185 std::ostringstream os;
186 os <<
"OrthoManager: " << orthoManName <<
" first run";
187 firstRunTimer = TimeMonitor::getNewCounter (os.str());
191 std::ostringstream os;
192 os <<
"OrthoManager: " << orthoManName <<
" total over "
193 << numTrials <<
" trials (excluding first run above)";
194 timer = TimeMonitor::getNewCounter (os.str());
200 TimeMonitor monitor (*firstRunTimer);
202 (void) orthoMan->normalize (*V[0], B);
203 for (
int k = 1; k < numBlocks; ++k) {
209 ArrayView<RCP<MV> > V_0k_nonconst = V.view (0, k);
210 ArrayView<RCP<const MV> > V_0k =
211 Teuchos::av_reinterpret_cast<RCP<const MV> > (V_0k_nonconst);
212 (void) orthoMan->projectAndNormalize (*V[k], C, B, V_0k);
224 debugOut <<
"Orthogonality of V[0:" << (numBlocks-1)
226 for (
int k = 0; k < numBlocks; ++k) {
228 debugOut <<
"For block V[" << k <<
"]:" << endl;
229 debugOut <<
" ||<V[" << k <<
"], V[" << k <<
"]> - I|| = "
230 << orthoMan->orthonormError(*V[k]) << endl;
232 for (
int j = 0; j < k; ++j) {
233 debugOut <<
" ||< V[" << j <<
"], V[" << k <<
"] >|| = "
234 << orthoMan->orthogError(*V[j], *V[k]) << endl;
242 TimeMonitor monitor (*timer);
244 for (
int trial = 0; trial < numTrials; ++trial) {
245 (void) orthoMan->normalize (*V[0], B);
246 for (
int k = 1; k < numBlocks; ++k) {
247 ArrayView<RCP<MV> > V_0k_nonconst = V.view (0, k);
248 ArrayView<RCP<const MV> > V_0k =
249 Teuchos::av_reinterpret_cast<RCP<const MV> > (V_0k_nonconst);
250 (void) orthoMan->projectAndNormalize (*V[k], C, B, V_0k);
256 if (displayResultsCompactly)
264 resultStream <<
"#orthoManName"
269 <<
",firstRunTimeInSeconds"
273 resultStream << orthoManName
274 <<
"," << (orthoManName==
"Simple" ? normalization :
"N/A")
278 <<
"," << firstRunTimer->totalElapsedTime()
279 <<
"," << timer->totalElapsedTime()
284 TimeMonitor::summarize (resultStream);
292 template<
class Scalar,
class MV >
323 const bool isRankRevealing,
333 using Teuchos::rcp_dynamic_cast;
334 using Teuchos::tuple;
348 std::ostream& debugOut = MyOM->stream(
Debug);
357 debugOut <<
"Generating X1,X2 for testing... ";
360 debugOut <<
"done." << endl;
367 debugOut <<
"Filling X1 with random values... ";
369 debugOut <<
"done." << endl
370 <<
"Calling normalize() on X1... ";
378 "normalize(X1) returned rank "
379 << initialX1Rank <<
" from " << sizeX1
380 <<
" vectors. Cannot continue.");
381 debugOut <<
"done." << endl
382 <<
"Calling orthonormError() on X1... ";
383 err = OM->orthonormError(*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... ";
395 debugOut <<
"done." << endl
396 <<
"Calling projectAndNormalize(X2, C, B, tuple(X1))... "
407 Array<RCP<mat_type> >
C (1);
410 OM->projectAndNormalize (*X2, C, B, tuple<RCP<const MV> >(X1));
414 "projectAndNormalize(X2,X1) returned rank "
415 << initialX2Rank <<
" from " << sizeX2
416 <<
" vectors. Cannot continue.");
417 debugOut <<
"done." << endl
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)... ";
426 err = OM->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
440 RCP<mixin_type> tsqr = rcp_dynamic_cast<mixin_type>(OM);
441 if (! tsqr.is_null())
445 <<
"=== OutOfPlaceNormalizerMixin tests ==="
455 debugOut <<
"Filling X1_in with random values... ";
457 debugOut <<
"done." << endl;
458 debugOut <<
"Filling X1_out with different random values...";
461 debugOut <<
"done." << endl
462 <<
"Calling normalizeOutOfPlace(*X1_in, *X1_out, null)... ";
463 const int initialX1Rank =
466 "normalizeOutOfPlace(*X1_in, *X1_out, null) "
467 "returned rank " << initialX1Rank <<
" from "
468 << sizeX1 <<
" vectors. Cannot continue.");
469 debugOut <<
"done." << endl
470 <<
"Calling orthonormError() on X1_out... ";
471 err = OM->orthonormError(*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... ";
489 debugOut <<
"done." << endl
490 <<
"Filling X2_out with different random values...";
493 debugOut <<
"done." << endl
494 <<
"Calling projectAndNormalizeOutOfPlace(X2_in, X2_out, "
495 <<
"C, B, X1_out)...";
498 Array<RCP<mat_type> >
C (1);
501 tsqr->projectAndNormalizeOutOfPlace (*X2_in, *X2_out, C, B,
502 tuple<RCP<const MV> >(X1_out));
506 "projectAndNormalizeOutOfPlace(*X2_in, "
507 "*X2_out, C, B, tuple(X1_out)) returned rank "
508 << initialX2Rank <<
" from " << sizeX2
509 <<
" vectors. Cannot continue.");
510 debugOut <<
"done." << endl
511 <<
"Calling orthonormError() on X2_out... ";
512 err = OM->orthonormError (*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)... ";
520 err = OM->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 ==="
531 #endif // HAVE_BELOS_TSQR
540 debugOut <<
"Testing project() by projecting a random multivector S "
541 "against various combinations of X1 and X2 " << endl;
542 const int thisNumFailed =
testProject(OM,S,X1,X2,MyOM);
543 numFailed += thisNumFailed;
544 if (thisNumFailed > 0)
545 debugOut <<
" *** " << thisNumFailed
546 << (thisNumFailed > 1 ?
" tests" :
" test")
547 <<
" failed." << endl;
554 debugOut <<
"Testing normalize() on bad multivectors " << endl;
556 numFailed += thisNumFailed;
567 mat_type C1(sizeX1,sizeS), C2(sizeX2,sizeS);
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;
577 const int thisNumFailed =
testProject(OM,S,X1,X2,MyOM);
578 numFailed += thisNumFailed;
579 if (thisNumFailed > 0)
580 debugOut <<
" *** " << thisNumFailed
581 << (thisNumFailed > 1 ?
" tests" :
" test")
582 <<
" failed." << endl;
587 if (isRankRevealing && sizeS > 2)
593 std::vector<int> ind(1);
597 debugOut <<
"Testing normalize() on a rank-deficient multivector " << endl;
599 numFailed += thisNumFailed;
600 if (thisNumFailed > 0)
601 debugOut <<
" *** " << thisNumFailed
602 << (thisNumFailed > 1 ?
" tests" :
" test")
603 <<
" failed." << endl;
608 if (isRankRevealing && sizeS > 1)
614 Teuchos::randomSyncedMatrix(scaleS);
616 for (
int i=0; i<sizeS; i++)
618 std::vector<int> ind(1);
623 debugOut <<
"Testing normalize() on a rank-1 multivector " << endl;
625 numFailed += thisNumFailed;
626 if (thisNumFailed > 0)
627 debugOut <<
" *** " << thisNumFailed
628 << (thisNumFailed > 1 ?
" tests" :
" test")
629 <<
" failed." << endl;
633 std::vector<int> ind(1);
636 debugOut <<
"Testing projectAndNormalize() on a random multivector " << endl;
638 numFailed += thisNumFailed;
639 if (thisNumFailed > 0)
640 debugOut <<
" *** " << thisNumFailed
641 << (thisNumFailed > 1 ?
" tests" :
" test")
642 <<
" failed." << endl;
653 mat_type C1(sizeX1,sizeS), C2(sizeX2,sizeS);
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;
662 numFailed += thisNumFailed;
663 if (thisNumFailed > 0)
664 debugOut <<
" *** " << thisNumFailed
665 << (thisNumFailed > 1 ?
" tests" :
" test")
666 <<
" failed." << endl;
671 if (isRankRevealing && sizeS > 2)
677 std::vector<int> ind(1);
681 debugOut <<
"Testing projectAndNormalize() on a rank-deficient "
682 "multivector " << endl;
684 numFailed += thisNumFailed;
685 if (thisNumFailed > 0)
686 debugOut <<
" *** " << thisNumFailed
687 << (thisNumFailed > 1 ?
" tests" :
" test")
688 <<
" failed." << endl;
693 if (isRankRevealing && sizeS > 1)
699 Teuchos::randomSyncedMatrix(scaleS);
701 for (
int i=0; i<sizeS; i++)
703 std::vector<int> ind(1);
708 debugOut <<
"Testing projectAndNormalize() on a rank-1 multivector " << endl;
709 bool constantStride =
true;
711 debugOut <<
"-- S does not have constant stride" << endl;
712 constantStride =
false;
715 debugOut <<
"-- X1 does not have constant stride" << endl;
716 constantStride =
false;
719 debugOut <<
"-- X2 does not have constant stride" << endl;
720 constantStride =
false;
722 if (! constantStride) {
723 debugOut <<
"-- Skipping this test, since TSQR does not work on "
724 "multivectors with nonconstant stride" << endl;
728 numFailed += thisNumFailed;
729 if (thisNumFailed > 0) {
730 debugOut <<
" *** " << thisNumFailed
731 << (thisNumFailed > 1 ?
" tests" :
" test")
732 <<
" failed." << endl;
737 if (numFailed != 0) {
738 MyOM->stream(
Errors) << numFailed <<
" total test failures." << endl;
758 "MVDiff: X and Y should have the same number of columns."
759 " X has " << numCols <<
" column(s) and Y has "
784 for (
int i = 0; i < numCols; ++i)
816 using Teuchos::tuple;
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;
877 Array<RCP<mat_type > >
C;
878 if ( (t % 3) == 0 ) {
882 else if ( (t % 3) == 1 ) {
887 else if ( (t % 3) == 2 ) {
912 Array<RCP<MV> > S_outs;
913 Array<Array<RCP<mat_type > > > C_outs;
914 Array<RCP<mat_type > > B_outs;
921 Teuchos::randomSyncedMatrix(*B);
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++) {
957 S_outs.push_back( Scopy );
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 ) {
977 Teuchos::randomSyncedMatrix(*B);
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++) {
1011 S_outs.push_back( Scopy );
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;
1042 if (C_outs[o].size() > 0) {
1044 if (C_outs[o].size() > 1) {
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;
1120 int numFailures = 0;
1123 const int msgType = (
static_cast<int>(
Debug) | static_cast<int>(
Errors));
1127 RCP< mat_type > bZero (
new mat_type (1, 1));
1128 std::vector< magnitude_type > zeroNorm( 1 );
1131 OM->normalize( *zeroVec, bZero );
1134 if ( zeroNorm[0] != ZERO )
1136 MyOM->stream(static_cast< MsgType >(msgType)) <<
" --> Normalization of zero vector FAILED!" << std::endl;
1155 using Teuchos::tuple;
1158 std::ostringstream sout;
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) {
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)
1263 sout <<
" *** Error: Tolerance exceeded: err = "
1264 << err <<
" > TOL = " << TOL << endl;
1267 sout <<
" || <S,S> - I || after : " << err << endl;
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;
1301 const MsgType type = (numerr == 0) ?
Debug : static_cast<MsgType> (static_cast<int>(
Errors) |
static_cast<int>(
Debug));
1302 MyOM->stream(type) << sout.str();
1303 MyOM->stream(type) << endl;
1323 using Teuchos::tuple;
1327 std::ostringstream sout;
1364 sout <<
"-- The test matrix S has Frobenius norm " << ATOL
1365 <<
", and the relative error tolerance is TOL = "
1366 << TOL <<
"." << endl;
1374 const int num_X = 2;
1375 Array< RCP< const MV > > X (num_X);
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)
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)
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;
1432 for (
int k = 0; k < num_X; ++k)
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;
1478 const MsgType type = (numerr == 0) ?
Debug : static_cast<MsgType> (static_cast<int>(
Errors) |
static_cast<int>(
Debug));
1479 MyOM->stream(type) << sout.str();
1480 MyOM->stream(type) << endl;
1500 using Teuchos::tuple;
1504 std::ostringstream sout;
1541 sout <<
"The test matrix S has Frobenius norm " << ATOL
1542 <<
", and the relative error tolerance is TOL = "
1543 << TOL <<
"." << endl;
1550 const int num_X = 2;
1551 Array< RCP< const MV > > X (num_X);
1558 Array< RCP< mat_type > >
C (num_X);
1559 for (
int k = 0; k < num_X; ++k)
1562 Teuchos::randomSyncedMatrix(*C[k]);
1566 OM->project(*S_copy, C, X);
1575 for (
int k = 0; k < num_X; ++k)
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;
1605 const MsgType type = (numerr == 0) ?
Debug : static_cast<MsgType> (static_cast<int>(
Errors) |
static_cast<int>(
Debug));
1606 MyOM->stream(type) << sout.str();
1607 MyOM->stream(type) << endl;
1636 using Teuchos::tuple;
1641 std::ostringstream sout;
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 ) {
1738 else if ( (t % 3) == 2 ) {
1745 theX = tuple(X1,X2);
1759 Array< RCP< MV > > S_outs;
1760 Array< Array< RCP< mat_type > > > C_outs;
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 ) {
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) {
1816 if (C_outs[o].size() > 0) {
1818 if (C_outs[o].size() > 1) {
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;
Class which manages the output and verbosity of the Belos solvers.
static int testNormalize(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > &OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Test OrthoManager::normalize() for the specific OrthoManager instance.
static void baseline(const Teuchos::RCP< const MV > &X, const int numCols, const int numBlocks, const int numTrials)
Establish baseline run time for OrthoManager benchmark.
static int testProjectAndNormalizeOld(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > &OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< const MV > &X1, const Teuchos::RCP< const MV > &X2, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Test OrthoManager::projectAndNormalize() for the specific OrthoManager instance.
static magnitudeType eps()
static void MvRandom(MV &mv)
Replace the vectors in mv with random vectors.
Mixin for out-of-place orthogonalization.
MsgType
Available message types recognized by the linear solvers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
Creates a new const MV that shares the selected contents of mv (shallow copy).
Declaration of basic traits for the multivector type.
Teuchos::SerialDenseMatrix< int, scalar_type > mat_type
MultiVecTraits< scalar_type, MV > MVT
static void MvInit(MV &mv, const ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
Replace each element of the vectors in mv with alpha.
static void MvTransMv(const ScalarType alpha, const MV &A, const MV &mv, Teuchos::SerialDenseMatrix< int, ScalarType > &B)
Compute a dense matrix B through the matrix-matrix multiply .
Teuchos::ScalarTraits< scalar_type > SCT
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
static void Assign(const MV &A, MV &mv)
mv := A
static void benchmark(const Teuchos::RCP< OrthoManager< Scalar, MV > > &orthoMan, const std::string &orthoManName, const std::string &normalization, const Teuchos::RCP< const MV > &X, const int numCols, const int numBlocks, const int numTrials, const Teuchos::RCP< OutputManager< Scalar > > &outMan, std::ostream &resultStream, const bool displayResultsCompactly=false)
Benchmark the given orthogonalization manager.
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Replace mv with .
Traits class which defines basic operations on multivectors.
SCT::magnitudeType magnitude_type
static void SetBlock(const MV &A, const std::vector< int > &index, MV &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index...
bool Residual(int N, int NRHS, double *A, int LDA, bool Transpose, double *X, int LDX, double *B, int LDB, double *resid)
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow copy).
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool is_null(const RCP< T > &p)
static int testProjectNew(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< const MV > &X1, const Teuchos::RCP< const MV > &X2, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Test OrthoManager::project() for the specific OrthoManager instance.
static int testProject(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< const MV > &X1, const Teuchos::RCP< const MV > &X2, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
Exception thrown to signal error in an orthogonalization manager method.
static int runTests(const Teuchos::RCP< OrthoManager< Scalar, MV > > &OM, const bool isRankRevealing, const Teuchos::RCP< MV > &S, const int sizeX1, const int sizeX2, const Teuchos::RCP< OutputManager< Scalar > > &MyOM)
Run all the tests.
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
static int testProjectAndNormalizeNew(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< const MV > &X1, const Teuchos::RCP< const MV > &X2, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Test OrthoManager::projectAndNormalize() for the specific OrthoManager instance.
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
static bool HasConstantStride(const MV &mv)
Whether the given multivector mv has constant stride.
static magnitudeType magnitude(T a)
Teuchos::ScalarTraits< magnitude_type > SMT
static ptrdiff_t GetGlobalLength(const MV &mv)
Return the number of rows in the given multivector mv.
static magnitude_type MVDiff(const MV &X, const MV &Y)
Compute and return $|X - Y|_F$, the Frobenius (sum of squares) norm of the difference between X and Y...
static int testProjectOld(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< const MV > &X1, const Teuchos::RCP< const MV > &X2, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Test OrthoManager::project() for the specific OrthoManager instance.
Teuchos::Array< Teuchos::RCP< MV > >::size_type size_type
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, NormType type=TwoNorm)
Compute the norm of each individual vector of mv. Upon return, normvec[i] holds the value of ...
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
static int testNormalizeRankReveal(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > &OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)
Test OrthoManager::normalize() for the specific OrthoManager instance.
static magnitude_type frobeniusNorm(const MV &X)
Compute and return the Frobenius norm of X.
Belos header file which uses auto-configuration information to include necessary C++ headers...
Wrapper around OrthoManager test functionality.
MultiVecTraits< Scalar, MV > MVT
static int testProjectAndNormalize(const Teuchos::RCP< Belos::OrthoManager< Scalar, MV > > OM, const Teuchos::RCP< const MV > &S, const Teuchos::RCP< const MV > &X1, const Teuchos::RCP< const MV > &X2, const Teuchos::RCP< Belos::OutputManager< Scalar > > &MyOM)