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>
78 *out <<
"\n*** Entering MultiVectorStdOpsTester<"<<ST::name()<<
">::checkStdOps(...) ...\n"
79 <<
"using a \'" << vecSpc.
description() <<
"\' object ...\n";
82 if(out) *out <<
"\nvecSpc.dim() = " << vecSpc.
dim() << std::endl;
87 two = as<Scalar>(2.0),
88 three = as<Scalar>(3.0),
89 four = as<Scalar>(4.0);
93 if(out) *out <<
"\nCreating MultiVectorBase objects V1, V2, and V3 ...\n";
95 V1 = createMembers(vecSpc,num_mv_cols()),
96 V2 = createMembers(vecSpc,num_mv_cols()),
97 V3 = createMembers(vecSpc,num_mv_cols());
99 if(out) *out <<
"\nassign(V1.ptr(),-2.0);\n";
100 assign(V1.
ptr(),Scalar(-two));
108 if(out) *out <<
"\n"<<tc<<
") sums(*V1);\n";
111 sums(*V1, scalars1());
113 scalars2[i] = -two*as<Scalar>(vecSpc.
dim());
114 if (!testRelErrors<Scalar, Scalar, ScalarMag>(
115 "sums(*V1)", scalars1(),
116 "-2.0*n", scalars2(),
117 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
123 if(out) *out <<
"\n"<<tc<<
") norms_1(*V1);\n";
126 norms_1(*V1, mags1());
128 mags2[i] = ST::magnitude(two)*as<ScalarMag>(vecSpc.
dim());
129 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
130 "norms_1(*V1)", mags1(),
132 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
138 if(out) *out <<
"\n"<<tc<<
") norms_2(*V1);\n";
141 norms_2(*V1, mags1());
143 mags2[i] = ST::magnitude(two * ST::squareroot(as<Scalar>(n)));
144 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
145 "norms_2(*V1)", mags1(),
146 "2.0*sqrt(n)", mags2(),
147 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
153 if(out) *out <<
"\n"<<tc<<
") norms_inf(*V1);\n";
156 norms_inf(*V1, mags1());
158 mags2[i] = ST::magnitude(two);
159 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
160 "norms_inf(*V1)", mags1(),
162 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
168 if(out) *out <<
"\n"<<tc<<
") assign(V2.ptr(), alpha);\n";
171 assign(V2.ptr(), three);
172 norms_2(*V2, mags1());
174 mags2[i] = ST::magnitude(three * ST::squareroot(as<Scalar>(n)));
175 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
176 "norms_2(*V2)", mags1(),
177 "3.0*sqrt(n)", mags2(),
178 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
184 if(out) *out <<
"\n"<<tc<<
") assign(V2.ptr(), *V1);\n";
186 assign(V2.ptr(), *V1);
187 norms_2(*V1, mags1());
188 norms_2(*V2, mags2());
189 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
190 "norms_2(*V1)", mags1(),
191 "norms_2(*V2)", mags2(),
192 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
197 if(out) *out <<
"\n"<<tc<<
") scale(alpha,V2.ptr());\n";
200 Scalar alpha = as<Scalar>(1.2345);
201 assign(V2.ptr(), *V1);
202 scale(alpha, V2.ptr());
203 norms_2(*V1, mags1());
205 mags1[i] *= ST::magnitude(alpha);
206 norms_2(*V2, mags2());
207 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
208 "norms_2(alpha*V1)", mags1(),
209 "alpha*norms_2(V1)", mags2(),
210 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
216 if(out) *out <<
"\n"<<tc<<
") scaleUpdate(a,V1,V2.ptr());\n";
220 assign(a.
ptr(), two);
221 assign(V2.ptr(), four);
222 scaleUpdate(*a, *V1, V2.
ptr());
223 norms_2(*V2, mags1());
224 if (!testMaxErrors<Scalar>(
225 "norms_2(*V2)", mags1(),
226 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
232 if(out) *out <<
"\n"<<tc<<
") update(a,V1,V2.ptr());\n";
235 Scalar alpha = as<Scalar>(1.2345);
236 assign(V2.ptr(), three);
237 assign(V3.ptr(), *V1);
238 scale(alpha, V3.ptr());
240 update(alpha, *V1, V2.
ptr());
241 norms_2(*V2, mags1());
242 norms_2(*V3, mags2());
243 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
244 "norms_2(*V2)", mags1(),
245 "norms_2(*V3)", mags2(),
246 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
252 if(out) *out <<
"\n"<<tc<<
") update(alpha,beta,*V1,V2.ptr());\n";
257 alpha[i] = as<Scalar>(i+1);
258 Scalar beta = as<Scalar>(1.2345);
259 assign(V2.ptr(), three);
260 assign(V3.ptr(), *V1);
261 scale(beta, V3.ptr());
263 scale(alpha[i], V3->col(i).ptr());
266 update(alphaView, beta, *V1, V2.
ptr());
267 norms_2(*V2, mags1());
268 norms_2(*V3, mags2());
269 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
270 "norms_2(*V2)", mags1(),
271 "norms_2(*V3)", mags2(),
272 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
278 if(out) *out <<
"\n"<<tc<<
") update(*V1,alpha,beta,V2.ptr());\n";
283 alpha[i] = as<Scalar>(i+1);
284 Scalar beta = as<Scalar>(1.2345);
285 assign(V2.ptr(), three);
286 assign(V3.ptr(), *V2);
287 scale(beta, V3.ptr());
289 scale(alpha[i], V3->col(i).ptr());
292 update(*V1, alphaView, beta, V2.
ptr());
293 norms_2(*V2, mags1());
294 norms_2(*V3, mags2());
295 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
296 "norms_2(*V2)", mags1(),
297 "norms_2(*V3)", mags2(),
298 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
304 if(out) *out <<
"\n"<<tc<<
") linear_combination({alpha,beta,gamma},{V1.ptr(),V2.ptr(),V3.ptr()},0.0,V4.ptr());\n";
307 Scalar alpha = two, beta = -three, gamma = three;
309 assign(V2.ptr(), two);
310 assign(V3.ptr(), four);
311 linear_combination<Scalar>(
312 tuple<Scalar>(alpha, beta, gamma),
316 norms_2(*V4, mags1());
318 mags2[i] = ST::magnitude(two * ST::squareroot(as<Scalar>(n)));
319 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
320 "norms_2(*V4)", mags1(),
321 "2.0*sqrt(n)", mags2(),
322 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
327 if(out) *out <<
"\n"<<tc<<
") linear_combination({alpha,beta,gamma},{V1.ptr(),V2.ptr(),V3.ptr()},0.5,V4.ptr());\n";
330 Scalar alpha = two, beta = -three, gamma = three;
332 assign(V2.ptr(), two);
333 assign(V3.ptr(), four);
334 assign(V4.
ptr(), -four);
335 linear_combination<Scalar>(
336 tuple<Scalar>(alpha, beta, gamma),
340 norms_2(*V4, mags1());
341 if (!testMaxErrors<Scalar>(
342 "norms_2(*V4)", mags1(),
343 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
349 if(out) *out <<
"\n"<<tc<<
") Vt_S(V1.ptr(),alpha);\n";
352 Scalar alpha = as<Scalar>(1.2345);
353 assign(V2.ptr(), *V1);
354 Vt_S(V2.ptr(), alpha);
355 norms_2(*V1, mags1());
357 mags1[i] *= ST::magnitude(alpha);
358 norms_2(*V2, mags2());
359 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
360 "norms_2(alpha*V1)", mags1(),
361 "alpha*norms_2(V1)", mags2(),
362 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
368 if(out) *out <<
"\n"<<tc<<
") Vp_S(V2.ptr(),alpha);\n";
371 assign(V2.ptr(), *V1);
373 norms_2(*V2, mags1());
374 if (!testMaxErrors<Scalar>(
375 "norms_2(V2)", mags1(),
376 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
382 if(out) *out <<
"\n"<<tc<<
") Vp_V(V2.ptr(),*V1);\n";
385 assign(V2.ptr(), two);
387 norms_2(*V2, mags1());
388 if (!testMaxErrors<Scalar>(
389 "norms_2(V2)", mags1(),
390 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
397 if(out) *out <<
"\n"<<tc<<
") V_VpV(V3.ptr(),*V1,*V2);\n";
400 assign(V2.ptr(), two);
401 V_VpV(V3.ptr(), *V1, *V2);
402 norms_2(*V3, mags1());
403 if (!testMaxErrors<Scalar>(
404 "norms_2(V3)", mags1(),
405 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
412 if(out) *out <<
"\n"<<tc<<
") V_VmV(V3.ptr(),*V1,*V2);\n";
415 assign(V2.ptr(), -two);
416 V_VmV(V3.ptr(), *V1, *V2);
417 norms_2(*V3, mags1());
418 if (!testMaxErrors<Scalar>(
419 "norms_2(V3)", mags1(),
420 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
427 if(out) *out <<
"\n"<<tc<<
") V_StVpV(V3.ptr(),alpha,*V1,*V2);\n";
430 Scalar alpha = as<Scalar>(1.2345);
431 assign(V2.ptr(), three);
432 V_StVpV(V3.ptr(), alpha, *V1, *V2);
433 scale(alpha, V1.ptr());
435 V_VmV(V3.ptr(), *V2, *V3);
436 norms_2(*V3, mags1());
437 if (!testMaxErrors<Scalar>(
438 "norms_2(V3)", mags1(),
439 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
446 <<
"\n*** Leaving MultiVectorStdOpsTester<"<<ST::name()<<
">::checkStdOps(...) ...\n";
454 #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.