48 const Teuchos::RCP<const MV> &A ) {
51 using Teuchos::SetScientific;
127 typedef Teuchos::ScalarTraits<ScalarType> SCT;
128 typedef typename SCT::magnitudeType MagType;
130 const ScalarType one = SCT::one();
131 const ScalarType zero = SCT::zero();
132 const MagType zero_mag = Teuchos::ScalarTraits<MagType>::zero();
133 const MagType tol = SCT::eps()*100;
136 const int numvecs = 10;
137 const int numvecs_2 = 5;
139 std::vector<int> ind(numvecs_2);
149 TEUCHOS_TEST_FOR_EXCEPT(numvecs_2 != 5);
160 if ( MVT::GetNumberVecs(*A) <= 0 ) {
162 <<
"*** ERROR *** MultiVectorTraits::GetNumberVecs()." << endl
163 <<
"Returned <= 0." << endl;
171 if ( MVT::GetGlobalLength(*A) <= 0 ) {
173 <<
"*** ERROR *** MultiVectorTraitsExt::GetGlobalLength()" << endl
174 <<
"Returned <= 0." << endl;
185 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
187 std::vector<MagType> norms(2*numvecs);
188 bool ResizeWarning =
false;
189 if ( MVT::GetNumberVecs(*B) != numvecs ) {
191 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
192 <<
"Did not allocate requested number of vectors." << endl;
195 if ( MVT::GetGlobalLength(*B) != MVT::GetGlobalLength(*A) ) {
197 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
198 <<
"Did not allocate requested number of vectors." << endl;
201 MVT::MvNorm(*B, norms);
202 if ( (
int)norms.size() != 2*numvecs && (ResizeWarning ==
false) ) {
204 <<
"*** WARNING *** MultiVecTraits::MvNorm()." << endl
205 <<
"Method resized the output vector." << endl;
206 ResizeWarning =
true;
208 for (
int i=0; i<numvecs; i++) {
209 if ( norms[i] < zero_mag ) {
211 <<
"*** ERROR *** MultiVecTraits::Clone()." << endl
212 <<
"Vector had negative norm." << endl;
235 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
236 std::vector<MagType> norms(numvecs), norms2(numvecs);
239 MVT::MvNorm(*B, norms);
240 for (
int i=0; i<numvecs; i++) {
241 if ( norms[i] != zero_mag ) {
243 <<
"*** ERROR *** MultiVecTraits::MvInit() "
244 <<
"and MultiVecTraits::MvNorm()" << endl
245 <<
"Supposedly zero vector has non-zero norm." << endl;
250 MVT::MvNorm(*B, norms);
252 MVT::MvNorm(*B, norms2);
253 for (
int i=0; i<numvecs; i++) {
254 if ( norms[i] == zero_mag || norms2[i] == zero_mag ) {
256 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
257 <<
"Random vector was empty (very unlikely)." << endl;
260 else if ( norms[i] < zero_mag || norms2[i] < zero_mag ) {
262 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
263 <<
"Vector had negative norm." << endl;
266 else if ( norms[i] == norms2[i] ) {
268 <<
"*** ERROR *** MutliVecTraits::MvRandom()." << endl
269 <<
"Vectors not random enough." << endl;
284 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
285 std::vector<MagType> norms(numvecs);
288 MVT::MvScale(*B,SCT::zero());
289 MVT::MvNorm(*B, norms);
290 for (
int i=0; i<numvecs; i++) {
291 if ( norms[i] != zero_mag ) {
293 <<
"*** ERROR *** MultiVecTraits::MvScale(alpha) "
294 <<
"Supposedly zero vector has non-zero norm." << endl;
300 std::vector<ScalarType> zeros(numvecs,SCT::zero());
301 MVT::MvScale(*B,zeros);
302 MVT::MvNorm(*B, norms);
303 for (
int i=0; i<numvecs; i++) {
304 if ( norms[i] != zero_mag ) {
306 <<
"*** ERROR *** MultiVecTraits::MvScale(alphas) "
307 <<
"Supposedly zero vector has non-zero norm." << endl;
328 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
329 std::vector<MagType> norms(numvecs);
332 MVT::MvNorm(*B, norms);
333 bool BadNormWarning =
false;
334 for (
int i=0; i<numvecs; i++) {
335 if ( norms[i] < zero_mag ) {
337 <<
"*** ERROR *** MultiVecTraits::MvRandom()." << endl
338 <<
"Vector had negative norm." << endl;
341 else if ( norms[i] != SCT::squareroot(MVT::GetGlobalLength(*B)) && !BadNormWarning ) {
344 <<
"Warning testing MultiVecTraits::MvInit()." << endl
345 <<
"Ones vector should have norm sqrt(dim)." << endl
346 <<
"norms[i]: " << norms[i] <<
"\tdim: " << MVT::GetGlobalLength(*B) << endl << endl;
347 BadNormWarning =
true;
361 Teuchos::RCP<MV> B = MVT::Clone(*A,numvecs);
362 std::vector<MagType> norms(numvecs);
363 MVT::MvInit(*B, zero_mag);
364 MVT::MvNorm(*B, norms);
365 for (
int i=0; i<numvecs; i++) {
366 if ( norms[i] < zero_mag ) {
368 <<
"*** ERROR *** MultiVecTraits::MvInit()." << endl
369 <<
"Vector had negative norm." << endl;
372 else if ( norms[i] != zero_mag ) {
374 <<
"*** ERROR *** MultiVecTraits::MvInit()." << endl
375 <<
"Zero vector should have norm zero." << endl;
388 Teuchos::RCP<MV> B, C;
389 std::vector<MagType> norms(numvecs), norms2(ind.size());
391 B = MVT::Clone(*A,numvecs);
393 MVT::MvNorm(*B, norms);
394 C = MVT::CloneCopy(*B,ind);
395 MVT::MvNorm(*C, norms2);
396 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
398 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
399 <<
"Wrong number of vectors." << endl;
402 if ( MVT::GetGlobalLength(*C) != MVT::GetGlobalLength(*B) ) {
404 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
405 <<
"Vector lengths don't match." << endl;
408 for (
int i=0; i<numvecs_2; i++) {
409 if ( SCT::magnitude( norms2[i] - norms[ind[i]] ) > tol ) {
411 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
412 <<
"Copied vectors do not agree:"
413 << norms2[i] <<
" != " << norms[ind[i]] << endl
414 <<
"Difference " << SCT::magnitude (norms2[i] - norms[ind[i]])
415 <<
" exceeds the tolerance 100*eps = " << tol << endl;
420 MVT::MvInit(*B,zero);
421 MVT::MvNorm(*C, norms2);
422 for (
int i=0; i<numvecs_2; i++) {
423 if ( SCT::magnitude( norms2[i] - norms2[i] ) > tol ) {
425 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." << endl
426 <<
"Copied vectors were not independent." << endl
427 <<
"Difference " << SCT::magnitude (norms2[i] - norms[i])
428 <<
" exceeds the tolerance 100*eps = " << tol << endl;
441 Teuchos::RCP<MV> B, C;
442 std::vector<MagType> norms(numvecs), norms2(numvecs);
444 B = MVT::Clone(*A,numvecs);
446 MVT::MvNorm(*B, norms);
447 C = MVT::CloneCopy(*B);
448 MVT::MvNorm(*C, norms2);
449 if ( MVT::GetNumberVecs(*C) != numvecs ) {
451 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
452 <<
"Wrong number of vectors." << endl;
455 for (
int i=0; i<numvecs; i++) {
456 if ( SCT::magnitude( norms2[i] - norms[i] ) > tol ) {
458 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
459 <<
"Copied vectors do not agree." << endl
460 <<
"Difference " << SCT::magnitude (norms2[i] - norms[i])
461 <<
" exceeds the tolerance 100*eps = " << tol << endl;
465 MVT::MvInit(*B,zero);
466 MVT::MvNorm(*C, norms);
467 for (
int i=0; i<numvecs; i++) {
468 if ( SCT::magnitude( norms2[i] - norms[i] ) > tol ) {
470 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." << endl
471 <<
"Copied vectors were not independent." << endl
472 <<
"Difference " << SCT::magnitude (norms2[i] - norms[i])
473 <<
" exceeds the tolerance 100*eps = " << tol << endl;
487 Teuchos::RCP<MV> B, C;
488 std::vector<MagType> norms(numvecs), norms2(ind.size());
490 B = MVT::Clone(*A,numvecs);
492 MVT::MvNorm(*B, norms);
493 C = MVT::CloneViewNonConst(*B,ind);
494 MVT::MvNorm(*C, norms2);
495 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
497 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." << endl
498 <<
"Wrong number of vectors." << endl;
501 for (
int i=0; i<numvecs_2; i++) {
502 if ( SCT::magnitude( norms2[i] - norms[ind[i]] ) > tol ) {
504 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." << endl
505 <<
"Viewed vectors do not agree." << endl;
520 Teuchos::RCP<const MV> constB, C;
521 std::vector<MagType> normsB(numvecs), normsC(ind.size());
522 std::vector<int> allind(numvecs);
523 for (
int i=0; i<numvecs; i++) {
527 B = MVT::Clone(*A,numvecs);
529 MVT::MvNorm(*B, normsB);
530 C = MVT::CloneView(*B,ind);
531 MVT::MvNorm(*C, normsC);
532 if ( MVT::GetNumberVecs(*C) != numvecs_2 ) {
534 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." << endl
535 <<
"Wrong number of vectors." << endl;
538 for (
int i=0; i<numvecs_2; i++) {
539 if ( SCT::magnitude( normsC[i] - normsB[ind[i]] ) > tol ) {
541 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." << endl
542 <<
"Viewed vectors do not agree." << endl;
561 Teuchos::RCP<MV> B, C;
562 std::vector<MagType> normsB1(numvecs), normsB2(numvecs),
563 normsC1(numvecs_2), normsC2(numvecs_2);
565 B = MVT::Clone(*A,numvecs);
566 C = MVT::Clone(*A,numvecs_2);
568 ind.resize(numvecs_2);
569 for (
int i=0; i<numvecs_2; i++) {
575 MVT::MvNorm(*B,normsB1);
576 MVT::MvNorm(*C,normsC1);
577 MVT::SetBlock(*C,ind,*B);
578 MVT::MvNorm(*B,normsB2);
579 MVT::MvNorm(*C,normsC2);
582 for (
int i=0; i<numvecs_2; i++) {
583 if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
585 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
586 <<
"Operation modified source vectors." << endl;
592 for (
int i=0; i<numvecs; i++) {
595 if ( SCT::magnitude(normsB2[i]-normsC1[i/2]) > tol ) {
597 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
598 <<
"Copied vectors do not agree." << endl
599 <<
"Difference " << SCT::magnitude (normsB2[i] - normsC1[i/2])
600 <<
" exceeds the tolerance 100*eps = " << tol << endl;
606 if ( SCT::magnitude(normsB1[i]-normsB2[i]) > tol ) {
608 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
609 <<
"Incorrect vectors were modified." << endl;
614 MVT::MvInit(*C,zero);
615 MVT::MvNorm(*B,normsB1);
617 for (
int i=0; i<numvecs; i++) {
618 if ( SCT::magnitude(normsB1[i]-normsB2[i]) > tol ) {
620 <<
"*** ERROR *** MultiVecTraits::SetBlock()." << endl
621 <<
"Copied vectors were not independent." << endl;
654 Teuchos::RCP<MV> B, C;
655 std::vector<MagType> normsB(p), normsC(q);
656 Teuchos::SerialDenseMatrix<int,ScalarType> SDM(p,q);
658 B = MVT::Clone(*A,p);
659 C = MVT::Clone(*A,q);
663 MVT::MvNorm(*B,normsB);
665 MVT::MvNorm(*C,normsC);
668 MVT::MvTransMv( zero, *B, *C, SDM );
671 if ( SDM.numRows() != p || SDM.numCols() != q ) {
673 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
674 <<
"Routine resized SerialDenseMatrix." << endl;
679 if ( SDM.normOne() != zero ) {
681 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
682 <<
"Scalar argument processed incorrectly." << endl;
687 MVT::MvTransMv( one, *B, *C, SDM );
691 for (
int i=0; i<p; i++) {
692 for (
int j=0; j<q; j++) {
693 if ( SCT::magnitude(SDM(i,j))
694 > SCT::magnitude(normsB[i]*normsC[j]) ) {
696 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
697 <<
"Triangle inequality did not hold: "
698 << SCT::magnitude(SDM(i,j))
700 << SCT::magnitude(normsB[i]*normsC[j])
708 MVT::MvTransMv( one, *B, *C, SDM );
709 for (
int i=0; i<p; i++) {
710 for (
int j=0; j<q; j++) {
711 if ( SDM(i,j) != zero ) {
713 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
714 <<
"Inner products not zero for C==0." << endl;
721 MVT::MvTransMv( one, *B, *C, SDM );
722 for (
int i=0; i<p; i++) {
723 for (
int j=0; j<q; j++) {
724 if ( SDM(i,j) != zero ) {
726 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
727 <<
"Inner products not zero for B==0." << endl;
740 Teuchos::SerialDenseMatrix<int, ScalarType> largeSDM(p+1,q+1);
741 Teuchos::SerialDenseMatrix<int, ScalarType> SDM2(Teuchos::View, largeSDM, p, q);
742 largeSDM.putScalar( one );
745 MVT::MvTransMv( one, *B, *C, SDM2 );
746 for (
int i=0; i<p; i++) {
747 for (
int j=0; j<q; j++) {
748 if ( SDM2(i,j) != zero ) {
750 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." << endl
751 <<
"Inner products not zero for C==0 when using a view into Teuchos::SerialDenseMatrix<>." << endl;
769 Teuchos::RCP<MV> B, C;
770 std::vector<ScalarType> iprods(q);
771 std::vector<MagType> normsB(p), normsC(p);
773 B = MVT::Clone(*A,p);
774 C = MVT::Clone(*A,p);
778 MVT::MvNorm(*B,normsB);
779 MVT::MvNorm(*C,normsC);
780 MVT::MvDot( *B, *C, iprods );
781 if ( (
int)iprods.size() != q ) {
783 <<
"*** ERROR *** MultiVecTraits::MvDot." << endl
784 <<
"Routine resized results vector." << endl;
787 for (
int i=0; i<p; i++) {
788 if ( SCT::magnitude(iprods[i])
789 > SCT::magnitude(normsB[i]*normsC[i]) ) {
791 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
792 <<
"Inner products not valid." << endl;
798 MVT::MvDot( *B, *C, iprods );
799 for (
int i=0; i<p; i++) {
800 if ( iprods[i] != zero ) {
802 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
803 <<
"Inner products not zero for B==0." << endl;
809 MVT::MvDot( *B, *C, iprods );
810 for (
int i=0; i<p; i++) {
811 if ( iprods[i] != zero ) {
813 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
814 <<
"Inner products not zero for C==0." << endl;
818 if constexpr (SCT::isComplex) {
819 auto J = ScalarType(0., 1.);
821 MVT::MvInit(*C, SCT::one());
822 MVT::MvDot( *B, *C, iprods );
824 auto size = MVT::GetGlobalLength(*B);
825 auto expected = Teuchos::as<ScalarType>(size)*J;
826 for (
int i=0; i<p; i++) {
827 if ( SCT::magnitude(iprods[i]-expected) > SCT::eps()) {
829 <<
"*** ERROR *** MultiVecTraits::MvDot()." << endl
830 <<
"Inner products gave bad value: " << iprods[i] <<
". Expected: " << expected << endl;
846 Teuchos::RCP<MV> B, C, D;
847 std::vector<MagType> normsB1(p), normsB2(p),
848 normsC1(p), normsC2(p),
849 normsD1(p), normsD2(p);
850 ScalarType alpha = MagType(0.5) * SCT::one();
851 ScalarType beta = MagType(0.33) * SCT::one();
853 B = MVT::Clone(*A,p);
854 C = MVT::Clone(*A,p);
855 D = MVT::Clone(*A,p);
859 MVT::MvNorm(*B,normsB1);
860 MVT::MvNorm(*C,normsC1);
863 MVT::MvAddMv(zero,*B,one,*C,*D);
864 MVT::MvNorm(*B,normsB2);
865 MVT::MvNorm(*C,normsC2);
866 MVT::MvNorm(*D,normsD1);
867 for (
int i=0; i<p; i++) {
868 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
870 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
871 <<
"Input arguments were modified." << endl;
874 else if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
876 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
877 <<
"Input arguments were modified." << endl;
880 else if ( SCT::magnitude(normsC1[i]-normsD1[i]) > tol ) {
882 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
883 <<
"Assignment did not work." << endl;
889 MVT::MvAddMv(one,*B,zero,*C,*D);
890 MVT::MvNorm(*B,normsB2);
891 MVT::MvNorm(*C,normsC2);
892 MVT::MvNorm(*D,normsD1);
893 for (
int i=0; i<p; i++) {
894 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
896 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
897 <<
"Input arguments were modified." << endl;
900 else if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
902 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
903 <<
"Input arguments were modified." << endl;
906 else if ( SCT::magnitude( normsB1[i] - normsD1[i] ) > tol ) {
908 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
909 <<
"Assignment did not work." << endl;
917 MVT::MvAddMv(alpha,*B,beta,*C,*D);
918 MVT::MvNorm(*B,normsB2);
919 MVT::MvNorm(*C,normsC2);
920 MVT::MvNorm(*D,normsD1);
922 for (
int i=0; i<p; i++) {
923 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
925 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
926 <<
"Input arguments were modified." << endl;
929 else if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
931 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
932 <<
"Input arguments were modified." << endl;
938 MVT::MvAddMv(alpha,*B,beta,*C,*D);
939 MVT::MvNorm(*B,normsB2);
940 MVT::MvNorm(*C,normsC2);
941 MVT::MvNorm(*D,normsD2);
944 for (
int i=0; i<p; i++) {
945 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
947 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
948 <<
"Input arguments were modified." << endl;
951 else if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
953 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
954 <<
"Input arguments were modified." << endl;
957 else if ( SCT::magnitude( normsD1[i] - normsD2[i] ) > tol ) {
959 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." << endl
960 <<
"Results varies depending on initial state of dest vectors." << endl;
986 Teuchos::RCP<MV> B, D;
987 Teuchos::RCP<const MV> C;
988 std::vector<MagType> normsB(p),
990 std::vector<int> lclindex(p);
991 for (
int i=0; i<p; i++) lclindex[i] = i;
993 B = MVT::Clone(*A,p);
994 C = MVT::CloneView(*B,lclindex);
995 D = MVT::CloneViewNonConst(*B,lclindex);
998 MVT::MvNorm(*B,normsB);
1001 MVT::MvAddMv(zero,*B,one,*C,*D);
1002 MVT::MvNorm(*D,normsD);
1003 for (
int i=0; i<p; i++) {
1004 if ( SCT::magnitude( normsB[i] - normsD[i] ) > tol ) {
1006 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" << endl
1007 <<
"Assignment did not work." << endl;
1013 MVT::MvAddMv(one,*B,zero,*C,*D);
1014 MVT::MvNorm(*D,normsD);
1015 for (
int i=0; i<p; i++) {
1016 if ( SCT::magnitude( normsB[i] - normsD[i] ) > tol ) {
1018 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" << endl
1019 <<
"Assignment did not work." << endl;
1037 const int p = 7, q = 5;
1038 Teuchos::RCP<MV> B, C;
1039 Teuchos::RCP<MV> Vp, Vq;
1041 Teuchos::SerialDenseMatrix<int,ScalarType> SDM(p,q);
1042 std::vector<MagType> normsC1(q), normsC2(q),
1043 normsB1(p), normsB2(p);
1045 B = MVT::Clone(*A,p);
1046 C = MVT::Clone(*A,q);
1049 Vp = MVT::Clone(*A,p);
1050 Vq = MVT::Clone(*A,q);
1053 MVT::MvTransMv( one, *Vp, *Vq, SDM );
1058 MVT::MvNorm(*B,normsB1);
1059 MVT::MvNorm(*C,normsC1);
1060 MVT::MvTimesMatAddMv(zero,*B,SDM,one,*C);
1061 MVT::MvNorm(*B,normsB2);
1062 MVT::MvNorm(*C,normsC2);
1063 for (
int i=0; i<p; i++) {
1064 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1066 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1067 <<
"Input vectors were modified." << endl;
1071 for (
int i=0; i<q; i++) {
1072 if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
1074 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1075 <<
"Arithmetic test 1 failed." << endl;
1083 MVT::MvNorm(*B,normsB1);
1084 MVT::MvNorm(*C,normsC1);
1087 MVT::MvTransMv( one, *Vp, *Vq, SDM );
1088 MVT::MvTimesMatAddMv(zero,*B,SDM,zero,*C);
1089 MVT::MvNorm(*B,normsB2);
1090 MVT::MvNorm(*C,normsC2);
1091 for (
int i=0; i<p; i++) {
1092 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1094 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1095 <<
"Input vectors were modified." << endl;
1099 for (
int i=0; i<q; i++) {
1100 if ( normsC2[i] != zero ) {
1102 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1103 <<
"Arithmetic test 2 failed: "
1116 MVT::MvNorm(*B,normsB1);
1117 MVT::MvNorm(*C,normsC1);
1119 for (
int i=0; i<q; i++) {
1122 MVT::MvTimesMatAddMv(one,*B,SDM,zero,*C);
1123 MVT::MvNorm(*B,normsB2);
1124 MVT::MvNorm(*C,normsC2);
1125 for (
int i=0; i<p; i++) {
1126 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1128 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1129 <<
"Input vectors were modified." << endl;
1133 for (
int i=0; i<q; i++) {
1134 if ( SCT::magnitude( normsB1[i] - normsC2[i] ) > tol ) {
1136 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1137 <<
"Arithmetic test 3 failed: "
1149 MVT::MvNorm(*B,normsB1);
1150 MVT::MvNorm(*C,normsC1);
1152 MVT::MvTimesMatAddMv(one,*B,SDM,one,*C);
1153 MVT::MvNorm(*B,normsB2);
1154 MVT::MvNorm(*C,normsC2);
1155 for (
int i=0; i<p; i++) {
1156 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1158 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1159 <<
"Input vectors were modified." << endl;
1163 for (
int i=0; i<q; i++) {
1164 if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
1166 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1167 <<
"Arithmetic test 4 failed." << endl;
1183 const int p = 5, q = 7;
1184 Teuchos::RCP<MV> B, C;
1185 Teuchos::RCP<MV> Vp, Vq;
1186 Teuchos::SerialDenseMatrix<int,ScalarType> SDM(p,q);
1187 std::vector<MagType> normsC1(q), normsC2(q),
1188 normsB1(p), normsB2(p);
1190 B = MVT::Clone(*A,p);
1191 C = MVT::Clone(*A,q);
1194 Vp = MVT::Clone(*A,p);
1195 Vq = MVT::Clone(*A,q);
1198 MVT::MvTransMv( one, *Vp, *Vq, SDM );
1203 MVT::MvNorm(*B,normsB1);
1204 MVT::MvNorm(*C,normsC1);
1205 MVT::MvTimesMatAddMv(zero,*B,SDM,one,*C);
1206 MVT::MvNorm(*B,normsB2);
1207 MVT::MvNorm(*C,normsC2);
1208 for (
int i=0; i<p; i++) {
1209 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1211 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1212 <<
"Input vectors were modified." << endl;
1216 for (
int i=0; i<q; i++) {
1217 if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
1219 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1220 <<
"Arithmetic test 5 failed." << endl;
1228 MVT::MvNorm(*B,normsB1);
1229 MVT::MvNorm(*C,normsC1);
1232 MVT::MvTransMv( one, *Vp, *Vq, SDM );
1233 MVT::MvTimesMatAddMv(zero,*B,SDM,zero,*C);
1234 MVT::MvNorm(*B,normsB2);
1235 MVT::MvNorm(*C,normsC2);
1236 for (
int i=0; i<p; i++) {
1237 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1239 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1240 <<
"Input vectors were modified." << endl;
1244 for (
int i=0; i<q; i++) {
1245 if ( normsC2[i] != zero ) {
1247 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1248 <<
"Arithmetic test 6 failed: "
1260 MVT::MvNorm(*B,normsB1);
1261 MVT::MvNorm(*C,normsC1);
1263 for (
int i=0; i<p; i++) {
1266 MVT::MvTimesMatAddMv(one,*B,SDM,zero,*C);
1267 MVT::MvNorm(*B,normsB2);
1268 MVT::MvNorm(*C,normsC2);
1269 for (
int i=0; i<p; i++) {
1270 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1272 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1273 <<
"Input vectors were modified." << endl;
1277 for (
int i=0; i<p; i++) {
1278 if ( SCT::magnitude( normsB1[i] - normsC2[i] ) > tol ) {
1280 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1281 <<
"Arithmetic test 7 failed." << endl;
1285 for (
int i=p; i<q; i++) {
1286 if ( normsC2[i] != zero ) {
1288 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1289 <<
"Arithmetic test 7 failed." << endl;
1297 MVT::MvNorm(*B,normsB1);
1298 MVT::MvNorm(*C,normsC1);
1300 MVT::MvTimesMatAddMv(one,*B,SDM,one,*C);
1301 MVT::MvNorm(*B,normsB2);
1302 MVT::MvNorm(*C,normsC2);
1303 for (
int i=0; i<p; i++) {
1304 if ( SCT::magnitude( normsB1[i] - normsB2[i] ) > tol ) {
1306 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1307 <<
"Input vectors were modified." << endl;
1311 for (
int i=0; i<q; i++) {
1312 if ( SCT::magnitude( normsC1[i] - normsC2[i] ) > tol ) {
1314 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." << endl
1315 <<
"Arithmetic test 8 failed." << endl;