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();
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);
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;
204 <<
"*** WARNING *** MultiVecTraits::MvNorm()." <<
endl
205 <<
"Method resized the output vector." <<
endl;
211 <<
"*** ERROR *** MultiVecTraits::Clone()." <<
endl
212 <<
"Vector had negative norm." <<
endl;
235 Teuchos::RCP<MV>
B = MVT::Clone(*
A,
numvecs);
243 <<
"*** ERROR *** MultiVecTraits::MvInit() "
244 <<
"and MultiVecTraits::MvNorm()" <<
endl
245 <<
"Supposedly zero vector has non-zero norm." <<
endl;
256 <<
"*** ERROR *** MultiVecTraits::MvRandom()." <<
endl
257 <<
"Random vector was empty (very unlikely)." <<
endl;
262 <<
"*** ERROR *** MultiVecTraits::MvRandom()." <<
endl
263 <<
"Vector had negative norm." <<
endl;
268 <<
"*** ERROR *** MutliVecTraits::MvRandom()." <<
endl
269 <<
"Vectors not random enough." <<
endl;
284 Teuchos::RCP<MV>
B = MVT::Clone(*
A,
numvecs);
288 MVT::MvScale(*
B,SCT::zero());
293 <<
"*** ERROR *** MultiVecTraits::MvScale(alpha) "
294 <<
"Supposedly zero vector has non-zero norm." <<
endl;
306 <<
"*** ERROR *** MultiVecTraits::MvScale(alphas) "
307 <<
"Supposedly zero vector has non-zero norm." <<
endl;
328 Teuchos::RCP<MV>
B = MVT::Clone(*
A,
numvecs);
337 <<
"*** ERROR *** MultiVecTraits::MvRandom()." <<
endl
338 <<
"Vector had negative norm." <<
endl;
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;
361 Teuchos::RCP<MV>
B = MVT::Clone(*
A,
numvecs);
368 <<
"*** ERROR *** MultiVecTraits::MvInit()." <<
endl
369 <<
"Vector had negative norm." <<
endl;
374 <<
"*** ERROR *** MultiVecTraits::MvInit()." <<
endl
375 <<
"Zero vector should have norm zero." <<
endl;
388 Teuchos::RCP<MV>
B,
C;
394 C = MVT::CloneCopy(*
B,
ind);
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;
411 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." <<
endl
412 <<
"Copied vectors do not agree:"
415 <<
" exceeds the tolerance 100*eps = " <<
tol <<
endl;
420 MVT::MvInit(*
B,
zero);
425 <<
"*** ERROR *** MultiVecTraits::CloneCopy(ind)." <<
endl
426 <<
"Copied vectors were not independent." <<
endl
428 <<
" exceeds the tolerance 100*eps = " <<
tol <<
endl;
441 Teuchos::RCP<MV>
B,
C;
447 C = MVT::CloneCopy(*
B);
449 if ( MVT::GetNumberVecs(*
C) !=
numvecs ) {
451 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." <<
endl
452 <<
"Wrong number of vectors." <<
endl;
458 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." <<
endl
459 <<
"Copied vectors do not agree." <<
endl
461 <<
" exceeds the tolerance 100*eps = " <<
tol <<
endl;
465 MVT::MvInit(*
B,
zero);
470 <<
"*** ERROR *** MultiVecTraits::CloneCopy()." <<
endl
471 <<
"Copied vectors were not independent." <<
endl
473 <<
" exceeds the tolerance 100*eps = " <<
tol <<
endl;
487 Teuchos::RCP<MV>
B,
C;
493 C = MVT::CloneViewNonConst(*
B,
ind);
497 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." <<
endl
498 <<
"Wrong number of vectors." <<
endl;
504 <<
"*** ERROR *** MultiVecTraits::CloneView(ind)." <<
endl
505 <<
"Viewed vectors do not agree." <<
endl;
520 Teuchos::RCP<const MV>
constB,
C;
530 C = MVT::CloneView(*
B,
ind);
534 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." <<
endl
535 <<
"Wrong number of vectors." <<
endl;
541 <<
"*** ERROR *** const MultiVecTraits::CloneView(ind)." <<
endl
542 <<
"Viewed vectors do not agree." <<
endl;
561 Teuchos::RCP<MV>
B,
C;
577 MVT::SetBlock(*
C,
ind,*
B);
585 <<
"*** ERROR *** MultiVecTraits::SetBlock()." <<
endl
586 <<
"Operation modified source vectors." <<
endl;
597 <<
"*** ERROR *** MultiVecTraits::SetBlock()." <<
endl
598 <<
"Copied vectors do not agree." <<
endl
600 <<
" exceeds the tolerance 100*eps = " <<
tol <<
endl;
608 <<
"*** ERROR *** MultiVecTraits::SetBlock()." <<
endl
609 <<
"Incorrect vectors were modified." <<
endl;
614 MVT::MvInit(*
C,
zero);
620 <<
"*** ERROR *** MultiVecTraits::SetBlock()." <<
endl
621 <<
"Copied vectors were not independent." <<
endl;
654 Teuchos::RCP<MV>
B,
C;
656 Teuchos::SerialDenseMatrix<int,ScalarType>
SDM(
p,
q);
658 B = MVT::Clone(*
A,
p);
659 C = MVT::Clone(*
A,
q);
671 if (
SDM.numRows() !=
p ||
SDM.numCols() !=
q ) {
673 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." <<
endl
674 <<
"Routine resized SerialDenseMatrix." <<
endl;
681 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." <<
endl
682 <<
"Scalar argument processed incorrectly." <<
endl;
691 for (
int i=0;
i<
p;
i++) {
692 for (
int j=0;
j<
q;
j++) {
693 if ( SCT::magnitude(
SDM(
i,
j))
696 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." <<
endl
697 <<
"Triangle inequality did not hold: "
698 << SCT::magnitude(
SDM(
i,
j))
709 for (
int i=0;
i<
p;
i++) {
710 for (
int j=0;
j<
q;
j++) {
713 <<
"*** ERROR *** MultiVecTraits::MvTransMv()." <<
endl
714 <<
"Inner products not zero for C==0." <<
endl;
722 for (
int i=0;
i<
p;
i++) {
723 for (
int j=0;
j<
q;
j++) {
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);
746 for (
int i=0;
i<
p;
i++) {
747 for (
int j=0;
j<
q;
j++) {
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);
773 B = MVT::Clone(*
A,
p);
774 C = MVT::Clone(*
A,
p);
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++) {
791 <<
"*** ERROR *** MultiVecTraits::MvDot()." <<
endl
792 <<
"Inner products not valid." <<
endl;
799 for (
int i=0;
i<
p;
i++) {
802 <<
"*** ERROR *** MultiVecTraits::MvDot()." <<
endl
803 <<
"Inner products not zero for B==0." <<
endl;
810 for (
int i=0;
i<
p;
i++) {
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());
824 auto size = MVT::GetGlobalLength(*
B);
826 for (
int i=0;
i<
p;
i++) {
829 <<
"*** ERROR *** MultiVecTraits::MvDot()." <<
endl
846 Teuchos::RCP<MV>
B,
C,
D;
853 B = MVT::Clone(*
A,
p);
854 C = MVT::Clone(*
A,
p);
855 D = MVT::Clone(*
A,
p);
867 for (
int i=0;
i<
p;
i++) {
870 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
871 <<
"Input arguments were modified." <<
endl;
876 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
877 <<
"Input arguments were modified." <<
endl;
882 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
883 <<
"Assignment did not work." <<
endl;
893 for (
int i=0;
i<
p;
i++) {
896 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
897 <<
"Input arguments were modified." <<
endl;
902 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
903 <<
"Input arguments were modified." <<
endl;
908 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
909 <<
"Assignment did not work." <<
endl;
922 for (
int i=0;
i<
p;
i++) {
925 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
926 <<
"Input arguments were modified." <<
endl;
931 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
932 <<
"Input arguments were modified." <<
endl;
944 for (
int i=0;
i<
p;
i++) {
947 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
948 <<
"Input arguments were modified." <<
endl;
953 <<
"*** ERROR *** MultiVecTraits::MvAddMv()." <<
endl
954 <<
"Input arguments were modified." <<
endl;
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),
993 B = MVT::Clone(*
A,
p);
1003 for (
int i=0;
i<
p;
i++) {
1006 <<
"*** ERROR *** MultiVecTraits::MvAddMv() #2" <<
endl
1007 <<
"Assignment did not work." <<
endl;
1015 for (
int i=0;
i<
p;
i++) {
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);
1045 B = MVT::Clone(*
A,
p);
1046 C = MVT::Clone(*
A,
q);
1049 Vp = MVT::Clone(*
A,
p);
1050 Vq = MVT::Clone(*
A,
q);
1063 for (
int i=0;
i<
p;
i++) {
1066 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1067 <<
"Input vectors were modified." <<
endl;
1071 for (
int i=0;
i<
q;
i++) {
1074 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1075 <<
"Arithmetic test 1 failed." <<
endl;
1091 for (
int i=0;
i<
p;
i++) {
1094 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1095 <<
"Input vectors were modified." <<
endl;
1099 for (
int i=0;
i<
q;
i++) {
1102 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1103 <<
"Arithmetic test 2 failed: "
1119 for (
int i=0;
i<
q;
i++) {
1125 for (
int i=0;
i<
p;
i++) {
1128 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1129 <<
"Input vectors were modified." <<
endl;
1133 for (
int i=0;
i<
q;
i++) {
1136 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1137 <<
"Arithmetic test 3 failed: "
1155 for (
int i=0;
i<
p;
i++) {
1158 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1159 <<
"Input vectors were modified." <<
endl;
1163 for (
int i=0;
i<
q;
i++) {
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);
1190 B = MVT::Clone(*
A,
p);
1191 C = MVT::Clone(*
A,
q);
1194 Vp = MVT::Clone(*
A,
p);
1195 Vq = MVT::Clone(*
A,
q);
1208 for (
int i=0;
i<
p;
i++) {
1211 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1212 <<
"Input vectors were modified." <<
endl;
1216 for (
int i=0;
i<
q;
i++) {
1219 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1220 <<
"Arithmetic test 5 failed." <<
endl;
1236 for (
int i=0;
i<
p;
i++) {
1239 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1240 <<
"Input vectors were modified." <<
endl;
1244 for (
int i=0;
i<
q;
i++) {
1247 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1248 <<
"Arithmetic test 6 failed: "
1263 for (
int i=0;
i<
p;
i++) {
1269 for (
int i=0;
i<
p;
i++) {
1272 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1273 <<
"Input vectors were modified." <<
endl;
1277 for (
int i=0;
i<
p;
i++) {
1280 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1281 <<
"Arithmetic test 7 failed." <<
endl;
1285 for (
int i=
p;
i<
q;
i++) {
1288 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1289 <<
"Arithmetic test 7 failed." <<
endl;
1303 for (
int i=0;
i<
p;
i++) {
1306 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1307 <<
"Input vectors were modified." <<
endl;
1311 for (
int i=0;
i<
q;
i++) {
1314 <<
"*** ERROR *** MultiVecTraits::MvTimesMatAddMv()." <<
endl
1315 <<
"Arithmetic test 8 failed." <<
endl;
bool TestOperatorTraits(const Teuchos::RCP< OutputManager< ScalarType > > &om, const Teuchos::RCP< const MV > &A, const Teuchos::RCP< const OP > &M)
This function tests the correctness of an operator implementation with respect to an OperatorTraits s...