42 #ifndef THYRA_MULTI_VECTOR_STD_OPS_TESTER_HPP
43 #define THYRA_MULTI_VECTOR_STD_OPS_TESTER_HPP
45 #include "Thyra_MultiVectorStdOpsTester_decl.hpp"
46 #include "Thyra_MultiVectorStdOps.hpp"
47 #include "Thyra_VectorStdOps.hpp"
48 #include "Thyra_TestingTools.hpp"
54 template <
class Scalar>
58 ,
const int num_mv_cols_in
60 :warning_tol_(warning_tol_in)
61 ,error_tol_(error_tol_in)
62 ,num_mv_cols_(num_mv_cols_in)
65 template <
class Scalar>
76 typedef typename ST::magnitudeType
ScalarMag;
79 *out <<
"\n*** Entering MultiVectorStdOpsTester<"<<ST::name()<<
">::checkStdOps(...) ...\n"
80 <<
"using a \'" << vecSpc.
description() <<
"\' object ...\n";
83 if(out) *out <<
"\nvecSpc.dim() = " << vecSpc.
dim() << std::endl;
88 two = as<Scalar>(2.0),
89 three = as<Scalar>(3.0),
90 four = as<Scalar>(4.0);
94 if(out) *out <<
"\nCreating MultiVectorBase objects V1, V2, and V3 ...\n";
96 V1 = createMembers(vecSpc,num_mv_cols()),
97 V2 = createMembers(vecSpc,num_mv_cols()),
98 V3 = createMembers(vecSpc,num_mv_cols());
100 if(out) *out <<
"\nassign(V1.ptr(),-2.0);\n";
101 assign(V1.
ptr(),Scalar(-two));
109 if(out) *out <<
"\n"<<tc<<
") sums(*V1);\n";
112 sums(*V1, scalars1());
114 scalars2[i] = -two*as<Scalar>(vecSpc.
dim());
115 if (!testRelErrors<Scalar, Scalar, ScalarMag>(
116 "sums(*V1)", scalars1(),
117 "-2.0*n", scalars2(),
118 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
124 if(out) *out <<
"\n"<<tc<<
") norms_1(*V1);\n";
127 norms_1(*V1, mags1());
129 mags2[i] = ST::magnitude(two)*as<ScalarMag>(vecSpc.
dim());
130 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
131 "norms_1(*V1)", mags1(),
133 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
139 if(out) *out <<
"\n"<<tc<<
") norms_2(*V1);\n";
142 norms_2(*V1, mags1());
144 mags2[i] = ST::magnitude(two * ST::squareroot(as<Scalar>(n)));
145 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
146 "norms_2(*V1)", mags1(),
147 "2.0*sqrt(n)", mags2(),
148 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
154 if(out) *out <<
"\n"<<tc<<
") norms_inf(*V1);\n";
157 norms_inf(*V1, mags1());
159 mags2[i] = ST::magnitude(two);
160 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
161 "norms_inf(*V1)", mags1(),
163 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
169 if(out) *out <<
"\n"<<tc<<
") assign(V2.ptr(), alpha);\n";
172 assign(V2.ptr(), three);
173 norms_2(*V2, mags1());
175 mags2[i] = ST::magnitude(three * ST::squareroot(as<Scalar>(n)));
176 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
177 "norms_2(*V2)", mags1(),
178 "3.0*sqrt(n)", mags2(),
179 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
185 if(out) *out <<
"\n"<<tc<<
") assign(V2.ptr(), *V1);\n";
187 assign(V2.ptr(), *V1);
188 norms_2(*V1, mags1());
189 norms_2(*V2, mags2());
190 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
191 "norms_2(*V1)", mags1(),
192 "norms_2(*V2)", mags2(),
193 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
198 if(out) *out <<
"\n"<<tc<<
") scale(alpha,V2.ptr());\n";
201 Scalar alpha = as<Scalar>(1.2345);
202 assign(V2.ptr(), *V1);
203 scale(alpha, V2.ptr());
204 norms_2(*V1, mags1());
206 mags1[i] *= ST::magnitude(alpha);
207 norms_2(*V2, mags2());
208 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
209 "norms_2(alpha*V1)", mags1(),
210 "alpha*norms_2(V1)", mags2(),
211 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
217 if(out) *out <<
"\n"<<tc<<
") scaleUpdate(a,V1,V2.ptr());\n";
221 assign(a.
ptr(), two);
222 assign(V2.ptr(), four);
223 scaleUpdate(*a, *V1, V2.
ptr());
224 norms_2(*V2, mags1());
225 if (!testMaxErrors<Scalar>(
226 "norms_2(*V2)", mags1(),
227 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
233 if(out) *out <<
"\n"<<tc<<
") update(a,V1,V2.ptr());\n";
236 Scalar alpha = as<Scalar>(1.2345);
237 assign(V2.ptr(), three);
238 assign(V3.ptr(), *V1);
239 scale(alpha, V3.ptr());
241 update(alpha, *V1, V2.
ptr());
242 norms_2(*V2, mags1());
243 norms_2(*V3, mags2());
244 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
245 "norms_2(*V2)", mags1(),
246 "norms_2(*V3)", mags2(),
247 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
253 if(out) *out <<
"\n"<<tc<<
") update(alpha,beta,*V1,V2.ptr());\n";
258 alpha[i] = as<Scalar>(i+1);
259 Scalar beta = as<Scalar>(1.2345);
260 assign(V2.ptr(), three);
261 assign(V3.ptr(), *V1);
262 scale(beta, V3.ptr());
264 scale(alpha[i], V3->col(i).ptr());
267 update(alphaView, beta, *V1, V2.
ptr());
268 norms_2(*V2, mags1());
269 norms_2(*V3, mags2());
270 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
271 "norms_2(*V2)", mags1(),
272 "norms_2(*V3)", mags2(),
273 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
279 if(out) *out <<
"\n"<<tc<<
") update(*V1,alpha,beta,V2.ptr());\n";
284 alpha[i] = as<Scalar>(i+1);
285 Scalar beta = as<Scalar>(1.2345);
286 assign(V2.ptr(), three);
287 assign(V3.ptr(), *V2);
288 scale(beta, V3.ptr());
290 scale(alpha[i], V3->col(i).ptr());
293 update(*V1, alphaView, beta, V2.
ptr());
294 norms_2(*V2, mags1());
295 norms_2(*V3, mags2());
296 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
297 "norms_2(*V2)", mags1(),
298 "norms_2(*V3)", mags2(),
299 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
305 if(out) *out <<
"\n"<<tc<<
") linear_combination({alpha,beta,gamma},{V1.ptr(),V2.ptr(),V3.ptr()},0.0,V4.ptr());\n";
308 Scalar alpha = two, beta = -three, gamma = three;
310 assign(V2.ptr(), two);
311 assign(V3.ptr(), four);
312 linear_combination<Scalar>(
313 tuple<Scalar>(alpha, beta, gamma),
317 norms_2(*V4, mags1());
319 mags2[i] = ST::magnitude(two * ST::squareroot(as<Scalar>(n)));
320 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
321 "norms_2(*V4)", mags1(),
322 "2.0*sqrt(n)", mags2(),
323 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
328 if(out) *out <<
"\n"<<tc<<
") linear_combination({alpha,beta,gamma},{V1.ptr(),V2.ptr(),V3.ptr()},0.5,V4.ptr());\n";
331 Scalar alpha = two, beta = -three, gamma = three;
333 assign(V2.ptr(), two);
334 assign(V3.ptr(), four);
335 assign(V4.
ptr(), -four);
336 linear_combination<Scalar>(
337 tuple<Scalar>(alpha, beta, gamma),
341 norms_2(*V4, mags1());
342 if (!testMaxErrors<Scalar>(
343 "norms_2(*V4)", mags1(),
344 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
350 if(out) *out <<
"\n"<<tc<<
") Vt_S(V1.ptr(),alpha);\n";
353 Scalar alpha = as<Scalar>(1.2345);
354 assign(V2.ptr(), *V1);
355 Vt_S(V2.ptr(), alpha);
356 norms_2(*V1, mags1());
358 mags1[i] *= ST::magnitude(alpha);
359 norms_2(*V2, mags2());
360 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
361 "norms_2(alpha*V1)", mags1(),
362 "alpha*norms_2(V1)", mags2(),
363 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
369 if(out) *out <<
"\n"<<tc<<
") Vp_S(V2.ptr(),alpha);\n";
372 assign(V2.ptr(), *V1);
374 norms_2(*V2, mags1());
375 if (!testMaxErrors<Scalar>(
376 "norms_2(V2)", mags1(),
377 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
383 if(out) *out <<
"\n"<<tc<<
") Vp_V(V2.ptr(),*V1);\n";
386 assign(V2.ptr(), two);
388 norms_2(*V2, mags1());
389 if (!testMaxErrors<Scalar>(
390 "norms_2(V2)", mags1(),
391 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
398 if(out) *out <<
"\n"<<tc<<
") V_VpV(V3.ptr(),*V1,*V2);\n";
401 assign(V2.ptr(), two);
402 V_VpV(V3.ptr(), *V1, *V2);
403 norms_2(*V3, mags1());
404 if (!testMaxErrors<Scalar>(
405 "norms_2(V3)", mags1(),
406 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
413 if(out) *out <<
"\n"<<tc<<
") V_VmV(V3.ptr(),*V1,*V2);\n";
416 assign(V2.ptr(), -two);
417 V_VmV(V3.ptr(), *V1, *V2);
418 norms_2(*V3, mags1());
419 if (!testMaxErrors<Scalar>(
420 "norms_2(V3)", mags1(),
421 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
428 if(out) *out <<
"\n"<<tc<<
") V_StVpV(V3.ptr(),alpha,*V1,*V2);\n";
431 Scalar alpha = as<Scalar>(1.2345);
432 assign(V2.ptr(), three);
433 V_StVpV(V3.ptr(), alpha, *V1, *V2);
434 scale(alpha, V1.ptr());
436 V_VmV(V3.ptr(), *V2, *V3);
437 norms_2(*V3, mags1());
438 if (!testMaxErrors<Scalar>(
439 "norms_2(V3)", mags1(),
440 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
447 <<
"\n*** Leaving MultiVectorStdOpsTester<"<<ST::name()<<
">::checkStdOps(...) ...\n";
455 #endif // THYRA_MULTI_VECTOR_STD_OPS_TESTER_HPP
MultiVectorStdOpsTester(const ScalarMag &warning_tol=0, const ScalarMag &error_tol=0, const int num_mv_cols=4)
Abstract interface for objects that represent a space for vectors.
bool checkStdOps(const VectorSpaceBase< Scalar > &vecSpc, std::ostream *out=0, const bool &dumpAll=false)
Run the tests using a vector space.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
virtual std::string description() const
TypeTo as(const TypeFrom &t)
virtual Ordinal dim() const =0
Return the dimension of the vector space.