87 const Teuchos::RCP<const MV> &A)
89 using Teuchos::SetScientific;
92 typedef Teuchos::ScalarTraits<ScalarType> STS;
93 typedef typename STS::magnitudeType MagType;
97 SetScientific<ScalarType> sci (om->stream (
Warnings));
102 const MagType tol = Teuchos::as<MagType> (100) * STS::eps ();
178 const ScalarType one = STS::one();
179 const ScalarType zero = STS::zero();
180 const MagType zero_mag = Teuchos::ScalarTraits<MagType>::zero();
183 const int numvecs = 10;
184 const int numvecs_2 = 5;
186 std::vector<int> ind(numvecs_2);
196 TEUCHOS_TEST_FOR_EXCEPT(numvecs_2 != 5);
207 if ( MVT::GetNumberVecs(*A) <= 0 ) {
209 <<
"*** ERROR *** MultiVectorTraits::GetNumberVecs()." << endl
210 <<
"Returned <= 0." << endl;
219 if ( MVT::GetGlobalLength(*A) <= 0 ) {
221 <<
"*** ERROR *** MultiVectorTraitsExt::GetGlobalLength()" << endl
222 <<
"Returned <= 0." << endl;
235 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
236 std::vector<MagType> norms(2*numvecs);
237 bool ResizeWarning =
false;
238 if ( MVT::GetNumberVecs(*B) != numvecs ) {
240 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
241 <<
"Did not allocate requested number of vectors." << endl;
244 if ( MVT::GetGlobalLength(*B) != MVT::GetGlobalLength(*A) ) {
246 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
247 <<
"Did not allocate requested number of vectors." << endl;
250 MVT::MvNorm(*B, norms);
251 if ( norms.size() != 2*numvecs && ResizeWarning==
false ) {
253 <<
"*** WARNING *** MultiVecTraits::MvNorm()." << endl
254 <<
"Method resized the output vector." << endl;
255 ResizeWarning =
true;
257 for (
int i=0; i<numvecs; i++) {
258 if ( norms[i] < zero_mag ) {
260 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
261 <<
"Vector had negative norm." << endl;
284 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
285 std::vector<MagType> norms(numvecs), norms2(numvecs);
288 MVT::MvNorm(*B, norms);
289 for (
int i=0; i<numvecs; i++) {
290 if ( norms[i] != zero_mag ) {
292 <<
"*** ERROR *** MultiVecTraits::MvInit() "
293 <<
"and MultiVecTraits::MvNorm()" << endl
294 <<
"Supposedly zero vector has non-zero norm." << endl;
299 MVT::MvNorm(*B, norms);
301 MVT::MvNorm(*B, norms2);
302 for (
int i=0; i<numvecs; i++) {
303 if ( norms[i] == zero_mag || norms2[i] == zero_mag ) {
305 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
306 <<
"Random vector was empty (very unlikely)." << endl;
309 else if ( norms[i] < zero_mag || norms2[i] < zero_mag ) {
311 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
312 <<
"Vector had negative norm." << endl;
315 else if ( norms[i] == norms2[i] ) {
317 <<
"*** ERROR *** MutliVecTraits::MvRandom()." << endl
318 <<
"Vectors not random enough." << endl;
333 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
334 std::vector<MagType> norms(numvecs);
337 MVT::MvScale(*B,STS::zero());
338 MVT::MvNorm(*B, norms);
339 for (
int i=0; i<numvecs; i++) {
340 if ( norms[i] != zero_mag ) {
342 <<
"*** ERROR *** MultiVecTraits::MvScale(alpha) "
343 <<
"Supposedly zero vector has non-zero norm." << endl;
349 std::vector<ScalarType> zeros(numvecs,STS::zero());
350 MVT::MvScale(*B,zeros);
351 MVT::MvNorm(*B, norms);
352 for (
int i=0; i<numvecs; i++) {
353 if ( norms[i] != zero_mag ) {
355 <<
"*** ERROR *** MultiVecTraits::MvScale(alphas) "
356 <<
"Supposedly zero vector has non-zero norm." << endl;
377 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
378 std::vector<MagType> norms(numvecs);
381 MVT::MvNorm(*B, norms);
382 bool BadNormWarning =
false;
383 for (
int i=0; i<numvecs; i++) {
384 if ( norms[i] < zero_mag ) {
386 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
387 <<
"Vector had negative norm." << endl;
390 else if ( norms[i] != STS::squareroot(MVT::GetGlobalLength(*B)) && !BadNormWarning ) {
393 <<
"Warning testing MultiVecTraits::MvInit()." << endl
394 <<
"Ones std::vector should have norm std::sqrt(dim)." << endl
395 <<
"norms[i]: " << norms[i] <<
"\tdim: " << MVT::GetGlobalLength(*B) << endl << endl;
396 BadNormWarning =
true;
410 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
411 std::vector<MagType> norms(numvecs);
412 MVT::MvInit(*B, zero_mag);
413 MVT::MvNorm(*B, norms);
414 for (
int i=0; i<numvecs; i++) {
415 if ( norms[i] < zero_mag ) {
417 <<
"*** ERROR *** MultiVecTraits::MvInit()." << endl
418 <<
"Vector had negative norm." << endl;
421 else if ( norms[i] != zero_mag ) {
423 <<
"*** ERROR *** MultiVecTraits::MvInit()." << endl
424 <<
"Zero std::vector should have norm zero." << endl;
437 Teuchos::RCP<MV> B, C;
438 std::vector<MagType> norms(numvecs), norms2(numvecs);
440 B = MVT::Clone(*A,numvecs);
442 MVT::MvNorm(*B, norms);
443 C = MVT::CloneCopy(*B,ind);
444 MVT::MvNorm(*C, norms2);
445 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
447 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
448 <<
"Wrong number of vectors." << endl;
451 if ( MVT::GetGlobalLength(*C) != MVT::GetGlobalLength(*B) ) {
453 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
454 <<
"Vector lengths don't match." << endl;
457 for (
int i=0; i<numvecs_2; i++) {
458 if (STS::magnitude (norms2[i] - norms[ind[i]]) > tol) {
460 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
461 <<
"Copied vectors do not agree: "
462 << norms2[i] <<
" != " << norms[ind[i]] << endl
463 <<
"Difference " << STS::magnitude (norms2[i] - norms[ind[i]])
464 <<
" exceeds the tolerance 100*eps = " << tol << endl;
470 MVT::MvInit(*B,zero);
471 MVT::MvNorm(*C, norms);
472 for (
int i=0; i<numvecs_2; i++) {
474 if (STS::magnitude (norms2[i] - norms[i]) > tol) {
476 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
477 <<
"Copied vectors were not independent." << endl
478 << norms2[i] <<
" != " << norms[i] << endl
479 <<
"Difference " << STS::magnitude (norms2[i] - norms[i])
480 <<
" exceeds the tolerance 100*eps = " << tol << endl;
492 Teuchos::RCP<MV> B, C;
493 std::vector<MagType> norms(numvecs), norms2(numvecs);
495 B = MVT::Clone(*A,numvecs);
497 MVT::MvNorm(*B, norms);
498 C = MVT::CloneCopy(*B);
499 MVT::MvNorm(*C, norms2);
500 if ( MVT::GetNumberVecs(*C) != numvecs ) {
502 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
503 <<
"Wrong number of vectors." << endl;
506 for (
int i=0; i<numvecs; i++) {
507 if (STS::magnitude (norms2[i] - norms[i]) > tol) {
509 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
510 <<
"Copied vectors do not agree: "
511 << norms2[i] <<
" != " << norms[i] << endl
512 <<
"Difference " << STS::magnitude (norms2[i] - norms[i])
513 <<
" exceeds the tolerance 100*eps = " << tol << endl;
517 MVT::MvInit(*B,zero);
518 MVT::MvNorm(*C, norms);
519 for (
int i=0; i<numvecs; i++) {
521 if (STS::magnitude (norms2[i] - norms[i]) > tol) {
523 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
524 <<
"Copied vectors were not independent." << endl
525 << norms2[i] <<
" != " << norms[i] << endl
526 <<
"Difference " << STS::magnitude (norms2[i] - norms[i])
527 <<
" exceeds the tolerance 100*eps = " << tol << endl;
541 Teuchos::RCP<MV> B, C;
542 std::vector<MagType> norms(numvecs), norms2(numvecs);
544 B = MVT::Clone(*A,numvecs);
546 MVT::MvNorm(*B, norms);
547 C = MVT::CloneViewNonConst(*B,ind);
548 MVT::MvNorm(*C, norms2);
549 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
551 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." << endl
552 <<
"Wrong number of vectors." << endl;
555 for (
int i=0; i<numvecs_2; i++) {
557 if (STS::magnitude (norms2[i] - norms[ind[i]]) > tol) {
559 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." << endl
560 <<
"Viewed vectors do not agree." << endl;
575 Teuchos::RCP<const MV> C;
576 std::vector<MagType> normsB(numvecs), normsC(numvecs_2);
577 std::vector<int> allind(numvecs);
578 for (
int i=0; i<numvecs; i++) {
582 B = MVT::Clone(*A,numvecs);
584 MVT::MvNorm(*B, normsB);
585 C = MVT::CloneView(*B,ind);
586 MVT::MvNorm(*C, normsC);
587 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
589 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." << endl
590 <<
"Wrong number of vectors." << endl;
593 for (
int i=0; i<numvecs_2; i++) {
595 if (STS::magnitude (normsC[i] - normsB[ind[i]]) > tol) {
597 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." << endl
598 <<
"Viewed vectors do not agree." << endl;
617 Teuchos::RCP<MV> B, C;
618 std::vector<MagType> normsB1(numvecs), normsB2(numvecs),
619 normsC1(numvecs_2), normsC2(numvecs_2);
621 B = MVT::Clone(*A,numvecs);
622 C = MVT::Clone(*A,numvecs_2);
624 ind.resize(numvecs_2);
625 for (
int i=0; i<numvecs_2; i++) {
631 MVT::MvNorm(*B,normsB1);
632 MVT::MvNorm(*C,normsC1);
633 MVT::SetBlock(*C,ind,*B);
634 MVT::MvNorm(*B,normsB2);
635 MVT::MvNorm(*C,normsC2);
638 for (
int i=0; i<numvecs_2; i++) {
640 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
642 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
643 <<
"Operation modified source vectors." << endl;
649 for (
int i=0; i<numvecs; i++) {
652 if (STS::magnitude (normsB2[i] - normsC1[i/2]) > tol) {
654 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
655 <<
"Copied vectors do not agree: " << endl
656 << normsB2[i] <<
" != " << normsC1[i/2] << endl
657 <<
"Difference " << STS::magnitude (normsB2[i] - normsC1[i/2])
658 <<
" exceeds the tolerance 100*eps = " << tol << endl;
664 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
666 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
667 <<
"Incorrect vectors were modified." << endl
668 << normsB1[i] <<
" != " << normsB2[i] << endl
669 <<
"Difference " << STS::magnitude (normsB2[i] - normsB2[i])
670 <<
" exceeds the tolerance 100*eps = " << tol << endl;
675 MVT::MvInit(*C,zero);
676 MVT::MvNorm(*B,normsB1);
678 for (
int i=0; i<numvecs; i++) {
680 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
682 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
683 <<
"Copied vectors were not independent." << endl
684 << normsB1[i] <<
" != " << normsB2[i] << endl
685 <<
"Difference " << STS::magnitude (normsB1[i] - normsB2[i])
686 <<
" exceeds the tolerance 100*eps = " << tol << endl;
709 Teuchos::RCP<MV> B, C;
714 std::vector<MagType> normsB1(BSize), normsB2(BSize),
715 normsC1(CSize), normsC2(CSize);
717 B = MVT::Clone(*A,BSize);
718 C = MVT::Clone(*A,CSize);
721 for (
int i=0; i<setSize; i++) {
727 MVT::MvNorm(*B,normsB1);
728 MVT::MvNorm(*C,normsC1);
729 MVT::SetBlock(*C,ind,*B);
730 MVT::MvNorm(*B,normsB2);
731 MVT::MvNorm(*C,normsC2);
734 for (
int i=0; i<CSize; i++) {
736 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
738 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
739 <<
"Operation modified source vectors." << endl;
745 for (
int i=0; i<BSize; i++) {
748 const MagType diff = STS::magnitude (normsB2[i] - normsC1[i/2]);
751 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
752 <<
"Copied vectors do not agree: " << endl
753 << normsB2[i] <<
" != " << normsC1[i/2] << endl
754 <<
"Difference " << diff <<
" exceeds the tolerance 100*eps = "
761 const MagType diff = STS::magnitude (normsB1[i] - normsB2[i]);
765 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
766 <<
"Incorrect vectors were modified." << endl
767 << normsB1[i] <<
" != " << normsB2[i] << endl
768 <<
"Difference " << diff <<
" exceeds the tolerance 100*eps = "
774 MVT::MvInit(*C,zero);
775 MVT::MvNorm(*B,normsB1);
777 for (
int i=0; i<numvecs; i++) {
779 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
781 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
782 <<
"Copied vectors were not independent." << endl
783 << normsB1[i] <<
" != " << normsB2[i] << endl
784 <<
"Difference " << STS::magnitude (normsB1[i] - normsB2[i])
785 <<
" exceeds the tolerance 100*eps = " << tol << endl;
814 Teuchos::RCP<MV> B, C;
815 std::vector<MagType> normsB(p), normsC(q);
816 Teuchos::SerialDenseMatrix<int,ScalarType> SDM(p,q);
818 B = MVT::Clone(*A,p);
819 C = MVT::Clone(*A,q);
823 MVT::MvNorm(*B,normsB);
825 MVT::MvNorm(*C,normsC);
828 MVT::MvTransMv( zero, *B, *C, SDM );
831 if ( SDM.numRows() != p || SDM.numCols() != q ) {
833 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
834 <<
"Routine resized SerialDenseMatrix." << endl;
839 if ( SDM.normOne() != zero ) {
841 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
842 <<
"Scalar argument processed incorrectly." << endl;
847 MVT::MvTransMv( one, *B, *C, SDM );
851 for (
int i=0; i<p; i++) {
852 for (
int j=0; j<q; j++) {
853 if ( STS::magnitude(SDM(i,j))
854 > STS::magnitude(normsB[i]*normsC[j]) ) {
856 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
857 <<
"Triangle inequality did not hold: "
858 << STS::magnitude(SDM(i,j))
860 << STS::magnitude(normsB[i]*normsC[j])
868 MVT::MvTransMv( one, *B, *C, SDM );
869 for (
int i=0; i<p; i++) {
870 for (
int j=0; j<q; j++) {
871 if ( SDM(i,j) != zero ) {
873 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
874 <<
"Inner products not zero for C==0." << endl;
881 MVT::MvTransMv( one, *B, *C, SDM );
882 for (
int i=0; i<p; i++) {
883 for (
int j=0; j<q; j++) {
884 if ( SDM(i,j) != zero ) {
886 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
887 <<
"Inner products not zero for B==0." << endl;
904 Teuchos::RCP<MV> B, C;
905 std::vector<ScalarType> iprods(p+q);
906 std::vector<MagType> normsB(numvecs), normsC(numvecs);
908 B = MVT::Clone(*A,p);
909 C = MVT::Clone(*A,p);
913 MVT::MvNorm(*B,normsB);
914 MVT::MvNorm(*C,normsC);
915 MVT::MvDot( *B, *C, iprods );
916 if ( iprods.size() != p+q ) {
918 <<
"*** ERROR *** MultiVecTraits::MvDot." << endl
919 <<
"Routine resized results std::vector." << endl;
923 if ( STS::magnitude(iprods[i])
924 > STS::magnitude(normsB[i]*normsC[i]) ) {
926 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
927 <<
"Inner products not valid." << endl;
933 MVT::MvDot( *B, *C, iprods );
934 for (
int i=0; i<p; i++) {
935 if ( iprods[i] != zero ) {
937 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
938 <<
"Inner products not zero for B==0." << endl;
944 MVT::MvDot( *B, *C, iprods );
945 for (
int i=0; i<p; i++) {
946 if ( iprods[i] != zero ) {
948 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
949 <<
"Inner products not zero for C==0." << endl;
965 Teuchos::RCP<MV> B, C, D;
966 std::vector<MagType> normsB1(p), normsB2(p),
967 normsC1(p), normsC2(p),
968 normsD1(p), normsD2(p);
970 Teuchos::SerialDenseMatrix<int,ScalarType> Alpha(1,1), Beta(1,1);
971 Teuchos::randomSyncedMatrix( Alpha );
972 Teuchos::randomSyncedMatrix( Beta );
973 ScalarType alpha = Alpha(0,0),
976 B = MVT::Clone(*A,p);
977 C = MVT::Clone(*A,p);
978 D = MVT::Clone(*A,p);
982 MVT::MvNorm(*B,normsB1);
983 MVT::MvNorm(*C,normsC1);
986 MVT::MvAddMv(zero,*B,one,*C,*D);
987 MVT::MvNorm(*B,normsB2);
988 MVT::MvNorm(*C,normsC2);
989 MVT::MvNorm(*D,normsD1);
990 for (
int i=0; i<p; i++) {
991 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
993 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
994 <<
"Input arguments were modified." << endl;
997 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
999 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1000 <<
"Input arguments were modified." << endl;
1003 else if (STS::magnitude (normsC1[i] - normsD1[i]) > tol) {
1005 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1006 <<
"Assignment did not work." << endl;
1012 MVT::MvAddMv(one,*B,zero,*C,*D);
1013 MVT::MvNorm(*B,normsB2);
1014 MVT::MvNorm(*C,normsC2);
1015 MVT::MvNorm(*D,normsD1);
1016 for (
int i=0; i<p; i++) {
1017 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1019 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1020 <<
"Input arguments were modified." << endl;
1023 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1025 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1026 <<
"Input arguments were modified." << endl;
1029 else if (STS::magnitude (normsB1[i] - normsD1[i]) > tol) {
1031 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1032 <<
"Assignment did not work." << endl;
1040 MVT::MvAddMv(alpha,*B,beta,*C,*D);
1041 MVT::MvNorm(*B,normsB2);
1042 MVT::MvNorm(*C,normsC2);
1043 MVT::MvNorm(*D,normsD1);
1045 for (
int i=0; i<p; i++) {
1046 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1048 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1049 <<
"Input arguments were modified." << endl;
1052 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1054 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1055 <<
"Input arguments were modified." << endl;
1061 MVT::MvAddMv(alpha,*B,beta,*C,*D);
1062 MVT::MvNorm(*B,normsB2);
1063 MVT::MvNorm(*C,normsC2);
1064 MVT::MvNorm(*D,normsD2);
1067 for (
int i=0; i<p; i++) {
1068 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1070 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1071 <<
"Input arguments were modified." << endl;
1074 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1076 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1077 <<
"Input arguments were modified." << endl;
1080 else if (STS::magnitude (normsD1[i] - normsD2[i]) > tol) {
1082 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1083 <<
"Results varies depending on initial state of dest vectors." << endl;
1109 Teuchos::RCP<MV> B, D;
1110 Teuchos::RCP<const MV> C;
1111 std::vector<MagType> normsB(p),
1113 std::vector<int> lclindex(p);
1114 for (
int i=0; i<p; i++) lclindex[i] = i;
1116 B = MVT::Clone(*A,p);
1117 C = MVT::CloneView(*B,lclindex);
1118 D = MVT::CloneViewNonConst(*B,lclindex);
1121 MVT::MvNorm(*B,normsB);
1124 MVT::MvAddMv(zero,*B,one,*C,*D);
1125 MVT::MvNorm(*D,normsD);
1126 for (
int i=0; i<p; i++) {
1127 if (STS::magnitude (normsB[i] - normsD[i]) > tol) {
1129 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" << endl
1130 <<
"Assignment did not work." << endl;
1136 MVT::MvAddMv(one,*B,zero,*C,*D);
1137 MVT::MvNorm(*D,normsD);
1138 for (
int i=0; i<p; i++) {
1139 if (STS::magnitude (normsB[i] - normsD[i]) > tol) {
1141 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" << endl
1142 <<
"Assignment did not work." << endl;
1160 const int p = 7, q = 5;
1161 Teuchos::RCP<MV> B, C;
1162 Teuchos::SerialDenseMatrix<int,ScalarType> SDM(p,q);
1163 std::vector<MagType> normsC1(q), normsC2(q),
1164 normsB1(p), normsB2(p);
1166 B = MVT::Clone(*A,p);
1167 C = MVT::Clone(*A,q);
1172 MVT::MvNorm(*B,normsB1);
1173 MVT::MvNorm(*C,normsC1);
1174 Teuchos::randomSyncedMatrix(SDM);
1175 MVT::MvTimesMatAddMv(zero,*B,SDM,one,*C);
1176 MVT::MvNorm(*B,normsB2);
1177 MVT::MvNorm(*C,normsC2);
1178 for (
int i=0; i<p; i++) {
1179 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1181 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1182 <<
"Input vectors were modified." << endl;
1186 for (
int i=0; i<q; i++) {
1187 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1189 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1190 <<
"Arithmetic test 1 failed." << endl;
1198 MVT::MvNorm(*B,normsB1);
1199 MVT::MvNorm(*C,normsC1);
1200 Teuchos::randomSyncedMatrix(SDM);
1201 MVT::MvTimesMatAddMv(zero,*B,SDM,zero,*C);
1202 MVT::MvNorm(*B,normsB2);
1203 MVT::MvNorm(*C,normsC2);
1204 for (
int i=0; i<p; i++) {
1205 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1207 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1208 <<
"Input vectors were modified." << endl;
1212 for (
int i=0; i<q; i++) {
1213 if ( normsC2[i] != zero ) {
1215 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1216 <<
"Arithmetic test 2 failed: "
1229 MVT::MvNorm(*B,normsB1);
1230 MVT::MvNorm(*C,normsC1);
1232 for (
int i=0; i<q; i++) {
1235 MVT::MvTimesMatAddMv(one,*B,SDM,zero,*C);
1236 MVT::MvNorm(*B,normsB2);
1237 MVT::MvNorm(*C,normsC2);
1238 for (
int i=0; i<p; i++) {
1239 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1241 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1242 <<
"Input vectors were modified." << endl;
1246 for (
int i=0; i<q; i++) {
1247 if (STS::magnitude (normsB1[i] - normsC2[i]) > tol) {
1249 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1250 <<
"Arithmetic test 3 failed: "
1262 MVT::MvNorm(*B,normsB1);
1263 MVT::MvNorm(*C,normsC1);
1265 MVT::MvTimesMatAddMv(one,*B,SDM,one,*C);
1266 MVT::MvNorm(*B,normsB2);
1267 MVT::MvNorm(*C,normsC2);
1268 for (
int i=0; i<p; i++) {
1269 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1271 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1272 <<
"Input vectors were modified." << endl;
1276 for (
int i=0; i<q; i++) {
1277 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1279 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1280 <<
"Arithmetic test 4 failed." << endl;
1296 const int p = 5, q = 7;
1297 Teuchos::RCP<MV> B, C;
1298 Teuchos::SerialDenseMatrix<int,ScalarType> SDM(p,q);
1299 std::vector<MagType> normsC1(q), normsC2(q),
1300 normsB1(p), normsB2(p);
1302 B = MVT::Clone(*A,p);
1303 C = MVT::Clone(*A,q);
1308 MVT::MvNorm(*B,normsB1);
1309 MVT::MvNorm(*C,normsC1);
1310 Teuchos::randomSyncedMatrix(SDM);
1311 MVT::MvTimesMatAddMv(zero,*B,SDM,one,*C);
1312 MVT::MvNorm(*B,normsB2);
1313 MVT::MvNorm(*C,normsC2);
1314 for (
int i=0; i<p; i++) {
1315 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1317 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1318 <<
"Input vectors were modified." << endl;
1322 for (
int i=0; i<q; i++) {
1323 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1325 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1326 <<
"Arithmetic test 5 failed." << endl;
1334 MVT::MvNorm(*B,normsB1);
1335 MVT::MvNorm(*C,normsC1);
1336 Teuchos::randomSyncedMatrix(SDM);
1337 MVT::MvTimesMatAddMv(zero,*B,SDM,zero,*C);
1338 MVT::MvNorm(*B,normsB2);
1339 MVT::MvNorm(*C,normsC2);
1340 for (
int i=0; i<p; i++) {
1341 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1343 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1344 <<
"Input vectors were modified." << endl;
1348 for (
int i=0; i<q; i++) {
1349 if ( normsC2[i] != zero ) {
1351 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1352 <<
"Arithmetic test 6 failed: "
1364 MVT::MvNorm(*B,normsB1);
1365 MVT::MvNorm(*C,normsC1);
1367 for (
int i=0; i<p; i++) {
1370 MVT::MvTimesMatAddMv(one,*B,SDM,zero,*C);
1371 MVT::MvNorm(*B,normsB2);
1372 MVT::MvNorm(*C,normsC2);
1373 for (
int i=0; i<p; i++) {
1374 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1376 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1377 <<
"Input vectors were modified." << endl;
1381 for (
int i=0; i<p; i++) {
1382 if (STS::magnitude (normsB1[i] - normsC2[i]) > tol) {
1384 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1385 <<
"Arithmetic test 7 failed." << endl;
1389 for (
int i=p; i<q; i++) {
1390 if ( normsC2[i] != zero ) {
1392 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1393 <<
"Arithmetic test 7 failed." << endl;
1401 MVT::MvNorm(*B,normsB1);
1402 MVT::MvNorm(*C,normsC1);
1404 MVT::MvTimesMatAddMv(one,*B,SDM,one,*C);
1405 MVT::MvNorm(*B,normsB2);
1406 MVT::MvNorm(*C,normsC2);
1407 for (
int i=0; i<p; i++) {
1408 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1410 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1411 <<
"Input vectors were modified." << endl;
1415 for (
int i=0; i<q; i++) {
1416 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1418 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1419 <<
"Arithmetic test 8 failed." << endl;