99 const Teuchos::RCP<const MV> &A)
101 using Teuchos::SetScientific;
105 typedef Teuchos::ScalarTraits<ScalarType> STS;
106 typedef typename STS::magnitudeType MagType;
110 SetScientific<ScalarType> sci (om->stream (
Warnings));
115 const MagType tol = Teuchos::as<MagType> (130) * STS::eps ();
196 const ScalarType one = STS::one();
197 const ScalarType zero = STS::zero();
198 const MagType zero_mag = Teuchos::ScalarTraits<MagType>::zero();
201 const int numvecs = 10;
202 const int numvecs_2 = 5;
204 std::vector<int> ind(numvecs_2);
214 TEUCHOS_TEST_FOR_EXCEPT(numvecs_2 != 5);
225 if ( MVT::GetNumberVecs(*A) <= 0 ) {
227 <<
"*** ERROR *** MultiVectorTraits::GetNumberVecs()." << endl
228 <<
"Returned <= 0." << endl;
237 if ( MVT::GetGlobalLength(*A) <= 0 ) {
239 <<
"*** ERROR *** MultiVectorTraitsExt::GetGlobalLength()" << endl
240 <<
"Returned <= 0." << endl;
253 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
255 std::vector<MagType> norms(2*numvecs);
256 bool ResizeWarning =
false;
257 if ( MVT::GetNumberVecs(*B) != numvecs ) {
259 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
260 <<
"Did not allocate requested number of vectors." << endl;
263 if ( MVT::GetGlobalLength(*B) != MVT::GetGlobalLength(*A) ) {
265 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
266 <<
"Did not allocate requested number of vectors." << endl;
269 MVT::MvNorm(*B, norms);
270 if ( norms.size() != 2*numvecs && ResizeWarning==
false ) {
272 <<
"*** WARNING *** MultiVecTraits::MvNorm()." << endl
273 <<
"Method resized the output vector." << endl;
274 ResizeWarning =
true;
276 for (
int i=0; i<numvecs; i++) {
277 if ( norms[i] < zero_mag ) {
279 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
280 <<
"Vector had negative norm." << endl;
303 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
304 std::vector<MagType> norms(numvecs), norms2(numvecs);
307 MVT::MvNorm(*B, norms);
308 for (
int i=0; i<numvecs; i++) {
309 if ( norms[i] != zero_mag ) {
311 <<
"*** ERROR *** MultiVecTraits::MvInit() "
312 <<
"and MultiVecTraits::MvNorm()" << endl
313 <<
"Supposedly zero vector has non-zero norm." << endl;
318 MVT::MvNorm(*B, norms);
320 MVT::MvNorm(*B, norms2);
321 for (
int i=0; i<numvecs; i++) {
322 if ( norms[i] == zero_mag || norms2[i] == zero_mag ) {
324 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
325 <<
"Random vector was empty (very unlikely)." << endl;
328 else if ( norms[i] < zero_mag || norms2[i] < zero_mag ) {
330 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
331 <<
"Vector had negative norm." << endl;
334 else if ( norms[i] == norms2[i] ) {
336 <<
"*** ERROR *** MutliVecTraits::MvRandom()." << endl
337 <<
"Vectors not random enough." << endl;
352 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
353 std::vector<MagType> norms(numvecs);
356 MVT::MvScale(*B,STS::zero());
357 MVT::MvNorm(*B, norms);
358 for (
int i=0; i<numvecs; i++) {
359 if ( norms[i] != zero_mag ) {
361 <<
"*** ERROR *** MultiVecTraits::MvScale(alpha) "
362 <<
"Supposedly zero vector has non-zero norm." << endl;
368 std::vector<ScalarType> zeros(numvecs,STS::zero());
369 MVT::MvScale(*B,zeros);
370 MVT::MvNorm(*B, norms);
371 for (
int i=0; i<numvecs; i++) {
372 if ( norms[i] != zero_mag ) {
374 <<
"*** ERROR *** MultiVecTraits::MvScale(alphas) "
375 <<
"Supposedly zero vector has non-zero norm." << endl;
396 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
397 std::vector<MagType> norms(numvecs);
400 MVT::MvNorm(*B, norms);
401 bool BadNormWarning =
false;
402 for (
int i=0; i<numvecs; i++) {
403 if ( norms[i] < zero_mag ) {
405 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
406 <<
"Vector had negative norm." << endl;
409 else if ( norms[i] != STS::squareroot(MVT::GetGlobalLength(*B)) && !BadNormWarning ) {
412 <<
"Warning testing MultiVecTraits::MvInit()." << endl
413 <<
"Ones std::vector should have norm std::sqrt(dim)." << endl
414 <<
"norms[i]: " << norms[i] <<
"\tdim: " << MVT::GetGlobalLength(*B) << endl << endl;
415 BadNormWarning =
true;
429 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
430 std::vector<MagType> norms(numvecs);
431 MVT::MvInit(*B, zero_mag);
432 MVT::MvNorm(*B, norms);
433 for (
int i=0; i<numvecs; i++) {
434 if ( norms[i] < zero_mag ) {
436 <<
"*** ERROR *** MultiVecTraits::MvInit()." << endl
437 <<
"Vector had negative norm." << endl;
440 else if ( norms[i] != zero_mag ) {
442 <<
"*** ERROR *** MultiVecTraits::MvInit()." << endl
443 <<
"Zero std::vector should have norm zero." << endl;
456 Teuchos::RCP<MV> B, C;
457 std::vector<MagType> norms(numvecs), norms2(numvecs);
459 B = MVT::Clone(*A,numvecs);
461 MVT::MvNorm(*B, norms);
462 C = MVT::CloneCopy(*B,ind);
463 MVT::MvNorm(*C, norms2);
464 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
466 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
467 <<
"Wrong number of vectors." << endl;
470 if ( MVT::GetGlobalLength(*C) != MVT::GetGlobalLength(*B) ) {
472 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
473 <<
"Vector lengths don't match." << endl;
476 for (
int i=0; i<numvecs_2; i++) {
477 if (STS::magnitude (norms2[i] - norms[ind[i]]) > tol) {
479 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
480 <<
"Copied vectors do not agree: "
481 << norms2[i] <<
" != " << norms[ind[i]] << endl
482 <<
"Difference " << STS::magnitude (norms2[i] - norms[ind[i]])
483 <<
" exceeds the tolerance 100*eps = " << tol << endl;
489 MVT::MvInit(*B,zero);
490 MVT::MvNorm(*C, norms);
491 for (
int i=0; i<numvecs_2; i++) {
493 if (STS::magnitude (norms2[i] - norms[i]) > tol) {
495 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
496 <<
"Copied vectors were not independent." << endl
497 << norms2[i] <<
" != " << norms[i] << endl
498 <<
"Difference " << STS::magnitude (norms2[i] - norms[i])
499 <<
" exceeds the tolerance 100*eps = " << tol << endl;
511 Teuchos::RCP<MV> B, C;
512 std::vector<MagType> norms(numvecs), norms2(numvecs);
514 B = MVT::Clone(*A,numvecs);
516 MVT::MvNorm(*B, norms);
517 C = MVT::CloneCopy(*B);
518 MVT::MvNorm(*C, norms2);
519 if ( MVT::GetNumberVecs(*C) != numvecs ) {
521 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
522 <<
"Wrong number of vectors." << endl;
525 for (
int i=0; i<numvecs; i++) {
526 if (STS::magnitude (norms2[i] - norms[i]) > tol) {
528 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
529 <<
"Copied vectors do not agree: "
530 << norms2[i] <<
" != " << norms[i] << endl
531 <<
"Difference " << STS::magnitude (norms2[i] - norms[i])
532 <<
" exceeds the tolerance 100*eps = " << tol << endl;
536 MVT::MvInit(*B,zero);
537 MVT::MvNorm(*C, norms);
538 for (
int i=0; i<numvecs; i++) {
540 if (STS::magnitude (norms2[i] - norms[i]) > tol) {
542 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
543 <<
"Copied vectors were not independent." << endl
544 << norms2[i] <<
" != " << norms[i] << endl
545 <<
"Difference " << STS::magnitude (norms2[i] - norms[i])
546 <<
" exceeds the tolerance 100*eps = " << tol << endl;
560 Teuchos::RCP<MV> B, C;
561 std::vector<MagType> norms(numvecs), norms2(numvecs);
563 B = MVT::Clone(*A,numvecs);
565 MVT::MvNorm(*B, norms);
566 C = MVT::CloneViewNonConst(*B,ind);
567 MVT::MvNorm(*C, norms2);
568 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
570 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." << endl
571 <<
"Wrong number of vectors." << endl;
574 for (
int i=0; i<numvecs_2; i++) {
576 if (STS::magnitude (norms2[i] - norms[ind[i]]) > tol) {
578 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." << endl
579 <<
"Viewed vectors do not agree." << endl;
594 Teuchos::RCP<const MV> C;
595 std::vector<MagType> normsB(numvecs), normsC(numvecs_2);
596 std::vector<int> allind(numvecs);
597 for (
int i=0; i<numvecs; i++) {
601 B = MVT::Clone(*A,numvecs);
603 MVT::MvNorm(*B, normsB);
604 C = MVT::CloneView(*B,ind);
605 MVT::MvNorm(*C, normsC);
606 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
608 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." << endl
609 <<
"Wrong number of vectors." << endl;
612 for (
int i=0; i<numvecs_2; i++) {
614 if (STS::magnitude (normsC[i] - normsB[ind[i]]) > tol) {
616 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." << endl
617 <<
"Viewed vectors do not agree." << endl;
636 Teuchos::RCP<MV> B, C;
637 std::vector<MagType> normsB1(numvecs), normsB2(numvecs),
638 normsC1(numvecs_2), normsC2(numvecs_2);
640 B = MVT::Clone(*A,numvecs);
641 C = MVT::Clone(*A,numvecs_2);
643 ind.resize(numvecs_2);
644 for (
int i=0; i<numvecs_2; i++) {
650 MVT::MvNorm(*B,normsB1);
651 MVT::MvNorm(*C,normsC1);
652 MVT::SetBlock(*C,ind,*B);
653 MVT::MvNorm(*B,normsB2);
654 MVT::MvNorm(*C,normsC2);
657 for (
int i=0; i<numvecs_2; i++) {
659 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
661 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
662 <<
"Operation modified source vectors." << endl;
668 for (
int i=0; i<numvecs; i++) {
671 if (STS::magnitude (normsB2[i] - normsC1[i/2]) > tol) {
673 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
674 <<
"Copied vectors do not agree: " << endl
675 << normsB2[i] <<
" != " << normsC1[i/2] << endl
676 <<
"Difference " << STS::magnitude (normsB2[i] - normsC1[i/2])
677 <<
" exceeds the tolerance 100*eps = " << tol << endl;
683 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
685 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
686 <<
"Incorrect vectors were modified." << endl
687 << normsB1[i] <<
" != " << normsB2[i] << endl
688 <<
"Difference " << STS::magnitude (normsB2[i] - normsB2[i])
689 <<
" exceeds the tolerance 100*eps = " << tol << endl;
694 MVT::MvInit(*C,zero);
695 MVT::MvNorm(*B,normsB1);
697 for (
int i=0; i<numvecs; i++) {
699 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
701 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
702 <<
"Copied vectors were not independent." << endl
703 << normsB1[i] <<
" != " << normsB2[i] << endl
704 <<
"Difference " << STS::magnitude (normsB1[i] - normsB2[i])
705 <<
" exceeds the tolerance 100*eps = " << tol << endl;
728 Teuchos::RCP<MV> B, C;
733 std::vector<MagType> normsB1(BSize), normsB2(BSize),
734 normsC1(CSize), normsC2(CSize);
736 B = MVT::Clone(*A,BSize);
737 C = MVT::Clone(*A,CSize);
740 for (
int i=0; i<setSize; i++) {
746 MVT::MvNorm(*B,normsB1);
747 MVT::MvNorm(*C,normsC1);
748 MVT::SetBlock(*C,ind,*B);
749 MVT::MvNorm(*B,normsB2);
750 MVT::MvNorm(*C,normsC2);
753 for (
int i=0; i<CSize; i++) {
755 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
757 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
758 <<
"Operation modified source vectors." << endl;
764 for (
int i=0; i<BSize; i++) {
767 const MagType diff = STS::magnitude (normsB2[i] - normsC1[i/2]);
770 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
771 <<
"Copied vectors do not agree: " << endl
772 << normsB2[i] <<
" != " << normsC1[i/2] << endl
773 <<
"Difference " << diff <<
" exceeds the tolerance 100*eps = "
780 const MagType diff = STS::magnitude (normsB1[i] - normsB2[i]);
784 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
785 <<
"Incorrect vectors were modified." << endl
786 << normsB1[i] <<
" != " << normsB2[i] << endl
787 <<
"Difference " << diff <<
" exceeds the tolerance 100*eps = "
793 MVT::MvInit(*C,zero);
794 MVT::MvNorm(*B,normsB1);
796 for (
int i=0; i<numvecs; i++) {
798 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
800 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
801 <<
"Copied vectors were not independent." << endl
802 << normsB1[i] <<
" != " << normsB2[i] << endl
803 <<
"Difference " << STS::magnitude (normsB1[i] - normsB2[i])
804 <<
" exceeds the tolerance 100*eps = " << tol << endl;
833 Teuchos::RCP<MV> B, C;
834 std::vector<MagType> normsB(p), normsC(q);
835 Teuchos::RCP<DM> SDM = DMT::Create(p,q);
837 B = MVT::Clone(*A,p);
838 C = MVT::Clone(*A,q);
842 MVT::MvNorm(*B,normsB);
844 MVT::MvNorm(*C,normsC);
847 MVT::MvTransMv( zero, *B, *C, *SDM );
848 DMT::SyncDeviceToHost(*SDM);
851 if ( DMT::GetNumRows(*SDM) != p || DMT::GetNumCols(*SDM) != q ) {
853 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
854 <<
"Routine resized DenseMatrix." << endl;
859 if (DMT::NormOne(*SDM) != zero ) {
861 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
862 <<
"Scalar argument processed incorrectly." << endl;
867 MVT::MvTransMv( one, *B, *C, *SDM );
868 DMT::SyncDeviceToHost(*SDM);
872 for (
int i=0; i<p; i++) {
873 for (
int j=0; j<q; j++) {
874 if ( STS::magnitude(DMT::ValueConst(*SDM,i,j))
875 > STS::magnitude(normsB[i]*normsC[j]) ) {
877 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
878 <<
"Triangle inequality did not hold: "
879 << STS::magnitude(DMT::ValueConst(*SDM,i,j))
881 << STS::magnitude(normsB[i]*normsC[j])
889 MVT::MvTransMv( one, *B, *C, *SDM );
890 DMT::SyncDeviceToHost(*SDM);
891 for (
int i=0; i<p; i++) {
892 for (
int j=0; j<q; j++) {
893 if ( DMT::ValueConst(*SDM,i,j) != zero ) {
895 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
896 <<
"Inner products not zero for C==0." << endl;
903 MVT::MvTransMv( one, *B, *C, *SDM );
904 DMT::SyncDeviceToHost(*SDM);
905 for (
int i=0; i<p; i++) {
906 for (
int j=0; j<q; j++) {
907 if ( DMT::ValueConst(*SDM,i,j) != zero ) {
909 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
910 <<
"Inner products not zero for B==0." << endl;
926 Teuchos::RCP<MV> B, C;
927 std::vector<ScalarType> iprods(p+q);
928 std::vector<MagType> normsB(numvecs), normsC(numvecs);
930 B = MVT::Clone(*A,p);
931 C = MVT::Clone(*A,p);
935 MVT::MvNorm(*B,normsB);
936 MVT::MvNorm(*C,normsC);
937 MVT::MvDot( *B, *C, iprods );
938 if ( iprods.size() != p+q ) {
940 <<
"*** ERROR *** MultiVecTraits::MvDot." << endl
941 <<
"Routine resized results std::vector." << endl;
945 if ( STS::magnitude(iprods[i])
946 > STS::magnitude(normsB[i]*normsC[i]) ) {
948 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
949 <<
"Inner products not valid." << endl;
955 MVT::MvDot( *B, *C, iprods );
956 for (
int i=0; i<p; i++) {
957 if ( iprods[i] != zero ) {
959 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
960 <<
"Inner products not zero for B==0." << endl;
966 MVT::MvDot( *B, *C, iprods );
967 for (
int i=0; i<p; i++) {
968 if ( iprods[i] != zero ) {
970 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
971 <<
"Inner products not zero for C==0." << endl;
975 if constexpr (Teuchos::ScalarTraits<ScalarType>::isComplex) {
976 auto J = ScalarType(0., 1.);
978 MVT::MvInit(*C, STS::one());
979 MVT::MvDot( *B, *C, iprods );
981 auto size = MVT::GetGlobalLength(*B);
982 auto expected = Teuchos::as<ScalarType>(size)*J;
983 for (
int i=0; i<p; i++) {
984 if ( STS::magnitude(iprods[i]-expected) > STS::eps()) {
986 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
987 <<
"Inner products gave bad value: " << iprods[i] <<
". Expected: " << expected << endl;
1003 Teuchos::RCP<MV> B, C, D;
1004 std::vector<MagType> normsB1(p), normsB2(p),
1005 normsC1(p), normsC2(p),
1006 normsD1(p), normsD2(p);
1008 Teuchos::RCP<DM> Alpha = DMT::Create(1,1);
1009 Teuchos::RCP<DM> Beta = DMT::Create(1,1);
1012 ScalarType alpha = DMT::ValueConst(*Alpha,0,0),
1013 beta = DMT::ValueConst(*Beta,0,0);
1015 B = MVT::Clone(*A,p);
1016 C = MVT::Clone(*A,p);
1017 D = MVT::Clone(*A,p);
1021 MVT::MvNorm(*B,normsB1);
1022 MVT::MvNorm(*C,normsC1);
1025 MVT::MvAddMv(zero,*B,one,*C,*D);
1026 MVT::MvNorm(*B,normsB2);
1027 MVT::MvNorm(*C,normsC2);
1028 MVT::MvNorm(*D,normsD1);
1029 for (
int i=0; i<p; i++) {
1030 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1032 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1033 <<
"Input arguments were modified." << endl;
1036 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1038 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1039 <<
"Input arguments were modified." << endl;
1042 else if (STS::magnitude (normsC1[i] - normsD1[i]) > tol) {
1044 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1045 <<
"Assignment did not work." << endl;
1051 MVT::MvAddMv(one,*B,zero,*C,*D);
1052 MVT::MvNorm(*B,normsB2);
1053 MVT::MvNorm(*C,normsC2);
1054 MVT::MvNorm(*D,normsD1);
1055 for (
int i=0; i<p; i++) {
1056 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1058 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1059 <<
"Input arguments were modified." << endl;
1062 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1064 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1065 <<
"Input arguments were modified." << endl;
1068 else if (STS::magnitude (normsB1[i] - normsD1[i]) > tol) {
1070 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1071 <<
"Assignment did not work." << endl;
1079 MVT::MvAddMv(alpha,*B,beta,*C,*D);
1080 MVT::MvNorm(*B,normsB2);
1081 MVT::MvNorm(*C,normsC2);
1082 MVT::MvNorm(*D,normsD1);
1084 for (
int i=0; i<p; i++) {
1085 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1087 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1088 <<
"Input arguments were modified." << endl;
1091 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1093 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1094 <<
"Input arguments were modified." << endl;
1100 MVT::MvAddMv(alpha,*B,beta,*C,*D);
1101 MVT::MvNorm(*B,normsB2);
1102 MVT::MvNorm(*C,normsC2);
1103 MVT::MvNorm(*D,normsD2);
1106 for (
int i=0; i<p; i++) {
1107 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1109 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1110 <<
"Input arguments were modified." << endl;
1113 else if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1115 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1116 <<
"Input arguments were modified." << endl;
1119 else if (STS::magnitude (normsD1[i] - normsD2[i]) > tol) {
1121 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
1122 <<
"Results varies depending on initial state of dest vectors." << endl;
1148 Teuchos::RCP<MV> B, D;
1149 Teuchos::RCP<const MV> C;
1150 std::vector<MagType> normsB(p),
1152 std::vector<int> lclindex(p);
1153 for (
int i=0; i<p; i++) lclindex[i] = i;
1155 B = MVT::Clone(*A,p);
1156 C = MVT::CloneView(*B,lclindex);
1157 D = MVT::CloneViewNonConst(*B,lclindex);
1160 MVT::MvNorm(*B,normsB);
1163 MVT::MvAddMv(zero,*B,one,*C,*D);
1164 MVT::MvNorm(*D,normsD);
1165 for (
int i=0; i<p; i++) {
1166 if (STS::magnitude (normsB[i] - normsD[i]) > tol) {
1168 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" << endl
1169 <<
"Assignment did not work." << endl;
1175 MVT::MvAddMv(one,*B,zero,*C,*D);
1176 MVT::MvNorm(*D,normsD);
1177 for (
int i=0; i<p; i++) {
1178 if (STS::magnitude (normsB[i] - normsD[i]) > tol) {
1180 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" << endl
1181 <<
"Assignment did not work." << endl;
1199 const int p = 7, q = 5;
1200 Teuchos::RCP<MV> B, C;
1201 Teuchos::RCP<DM> SDM = DMT::Create(p,q);
1202 std::vector<MagType> normsC1(q), normsC2(q),
1203 normsB1(p), normsB2(p);
1205 B = MVT::Clone(*A,p);
1206 C = MVT::Clone(*A,q);
1211 MVT::MvNorm(*B,normsB1);
1212 MVT::MvNorm(*C,normsC1);
1214 MVT::MvTimesMatAddMv(zero,*B,*SDM,one,*C);
1215 MVT::MvNorm(*B,normsB2);
1216 MVT::MvNorm(*C,normsC2);
1217 for (
int i=0; i<p; i++) {
1218 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1220 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1221 <<
"Input vectors were modified." << endl;
1225 for (
int i=0; i<q; i++) {
1226 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1228 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1229 <<
"Arithmetic test 1 failed." << endl;
1237 MVT::MvNorm(*B,normsB1);
1238 MVT::MvNorm(*C,normsC1);
1240 MVT::MvTimesMatAddMv(zero,*B,*SDM,zero,*C);
1241 MVT::MvNorm(*B,normsB2);
1242 MVT::MvNorm(*C,normsC2);
1243 for (
int i=0; i<p; i++) {
1244 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1246 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1247 <<
"Input vectors were modified." << endl;
1251 for (
int i=0; i<q; i++) {
1252 if ( normsC2[i] != zero ) {
1254 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1255 <<
"Arithmetic test 2 failed: "
1268 MVT::MvNorm(*B,normsB1);
1269 MVT::MvNorm(*C,normsC1);
1270 DMT::Scale(*SDM,zero);
1271 DMT::SyncDeviceToHost(*SDM);
1272 for (
int i=0; i<q; i++) {
1273 DMT::Value(*SDM,i,i) = one;
1275 DMT::SyncHostToDevice(*SDM);
1276 MVT::MvTimesMatAddMv(one,*B,*SDM,zero,*C);
1277 MVT::MvNorm(*B,normsB2);
1278 MVT::MvNorm(*C,normsC2);
1279 for (
int i=0; i<p; i++) {
1280 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1282 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1283 <<
"Input vectors were modified." << endl;
1287 for (
int i=0; i<q; i++) {
1288 if (STS::magnitude (normsB1[i] - normsC2[i]) > tol) {
1290 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1291 <<
"Arithmetic test 3 failed: "
1303 MVT::MvNorm(*B,normsB1);
1304 MVT::MvNorm(*C,normsC1);
1305 DMT::Scale(*SDM,zero);
1306 MVT::MvTimesMatAddMv(one,*B,*SDM,one,*C);
1307 MVT::MvNorm(*B,normsB2);
1308 MVT::MvNorm(*C,normsC2);
1309 for (
int i=0; i<p; i++) {
1310 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1312 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1313 <<
"Input vectors were modified." << endl;
1317 for (
int i=0; i<q; i++) {
1318 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1320 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1321 <<
"Arithmetic test 4 failed." << endl;
1337 const int p = 5, q = 7;
1338 Teuchos::RCP<MV> B, C;
1339 Teuchos::RCP<DM> SDM = DMT::Create(p,q);
1340 std::vector<MagType> normsC1(q), normsC2(q),
1341 normsB1(p), normsB2(p);
1343 B = MVT::Clone(*A,p);
1344 C = MVT::Clone(*A,q);
1349 MVT::MvNorm(*B,normsB1);
1350 MVT::MvNorm(*C,normsC1);
1352 MVT::MvTimesMatAddMv(zero,*B,*SDM,one,*C);
1353 MVT::MvNorm(*B,normsB2);
1354 MVT::MvNorm(*C,normsC2);
1355 for (
int i=0; i<p; i++) {
1356 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1358 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1359 <<
"Input vectors were modified." << endl;
1363 for (
int i=0; i<q; i++) {
1364 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1366 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1367 <<
"Arithmetic test 5 failed." << endl;
1375 MVT::MvNorm(*B,normsB1);
1376 MVT::MvNorm(*C,normsC1);
1378 MVT::MvTimesMatAddMv(zero,*B,*SDM,zero,*C);
1379 MVT::MvNorm(*B,normsB2);
1380 MVT::MvNorm(*C,normsC2);
1381 for (
int i=0; i<p; i++) {
1382 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1384 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1385 <<
"Input vectors were modified." << endl;
1389 for (
int i=0; i<q; i++) {
1390 if ( normsC2[i] != zero ) {
1392 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1393 <<
"Arithmetic test 6 failed: "
1405 MVT::MvNorm(*B,normsB1);
1406 MVT::MvNorm(*C,normsC1);
1407 DMT::Scale(*SDM,zero);
1408 DMT::SyncDeviceToHost(*SDM);
1409 for (
int i=0; i<p; i++) {
1410 DMT::Value(*SDM,i,i) = one;
1412 DMT::SyncHostToDevice(*SDM);
1413 MVT::MvTimesMatAddMv(one,*B,*SDM,zero,*C);
1414 MVT::MvNorm(*B,normsB2);
1415 MVT::MvNorm(*C,normsC2);
1416 for (
int i=0; i<p; i++) {
1417 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1419 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1420 <<
"Input vectors were modified." << endl;
1424 for (
int i=0; i<p; i++) {
1425 if (STS::magnitude (normsB1[i] - normsC2[i]) > tol) {
1427 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1428 <<
"Arithmetic test 7 failed." << endl;
1432 for (
int i=p; i<q; i++) {
1433 if ( normsC2[i] != zero ) {
1435 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1436 <<
"Arithmetic test 7 failed." << endl;
1444 MVT::MvNorm(*B,normsB1);
1445 MVT::MvNorm(*C,normsC1);
1446 DMT::Scale(*SDM,zero);
1447 MVT::MvTimesMatAddMv(one,*B,*SDM,one,*C);
1448 MVT::MvNorm(*B,normsB2);
1449 MVT::MvNorm(*C,normsC2);
1450 for (
int i=0; i<p; i++) {
1451 if (STS::magnitude (normsB1[i] - normsB2[i]) > tol) {
1453 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1454 <<
"Input vectors were modified." << endl;
1458 for (
int i=0; i<q; i++) {
1459 if (STS::magnitude (normsC1[i] - normsC2[i]) > tol) {
1461 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1462 <<
"Arithmetic test 8 failed." << endl;