10 #ifndef THYRA_MULTI_VECTOR_STD_OPS_TESTER_HPP
11 #define THYRA_MULTI_VECTOR_STD_OPS_TESTER_HPP
13 #include "Thyra_MultiVectorStdOpsTester_decl.hpp"
14 #include "Thyra_MultiVectorStdOps.hpp"
15 #include "Thyra_VectorStdOps.hpp"
16 #include "Thyra_TestingTools.hpp"
22 template <
class Scalar>
26 ,
const int num_mv_cols_in
28 :warning_tol_(warning_tol_in)
29 ,error_tol_(error_tol_in)
30 ,num_mv_cols_(num_mv_cols_in)
33 template <
class Scalar>
46 *out <<
"\n*** Entering MultiVectorStdOpsTester<"<<ST::name()<<
">::checkStdOps(...) ...\n"
47 <<
"using a \'" << vecSpc.
description() <<
"\' object ...\n";
50 if(out) *out <<
"\nvecSpc.dim() = " << vecSpc.
dim() << std::endl;
55 two = as<Scalar>(2.0),
56 three = as<Scalar>(3.0),
57 four = as<Scalar>(4.0);
61 if(out) *out <<
"\nCreating MultiVectorBase objects V1, V2, and V3 ...\n";
63 V1 = createMembers(vecSpc,num_mv_cols()),
64 V2 = createMembers(vecSpc,num_mv_cols()),
65 V3 = createMembers(vecSpc,num_mv_cols());
67 if(out) *out <<
"\nassign(V1.ptr(),-2.0);\n";
68 assign(V1.
ptr(),Scalar(-two));
76 if(out) *out <<
"\n"<<tc<<
") sums(*V1);\n";
79 sums(*V1, scalars1());
81 scalars2[i] = -two*as<Scalar>(vecSpc.
dim());
82 if (!testRelErrors<Scalar, Scalar, ScalarMag>(
83 "sums(*V1)", scalars1(),
85 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
91 if(out) *out <<
"\n"<<tc<<
") norms_1(*V1);\n";
94 norms_1(*V1, mags1());
96 mags2[i] = ST::magnitude(two)*as<ScalarMag>(vecSpc.
dim());
97 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
98 "norms_1(*V1)", mags1(),
100 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
106 if(out) *out <<
"\n"<<tc<<
") norms_2(*V1);\n";
109 norms_2(*V1, mags1());
111 mags2[i] = ST::magnitude(two * ST::squareroot(as<Scalar>(n)));
112 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
113 "norms_2(*V1)", mags1(),
114 "2.0*sqrt(n)", mags2(),
115 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
121 if(out) *out <<
"\n"<<tc<<
") norms_inf(*V1);\n";
124 norms_inf(*V1, mags1());
126 mags2[i] = ST::magnitude(two);
127 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
128 "norms_inf(*V1)", mags1(),
130 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
136 if(out) *out <<
"\n"<<tc<<
") assign(V2.ptr(), alpha);\n";
139 assign(V2.ptr(), three);
140 norms_2(*V2, mags1());
142 mags2[i] = ST::magnitude(three * ST::squareroot(as<Scalar>(n)));
143 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
144 "norms_2(*V2)", mags1(),
145 "3.0*sqrt(n)", mags2(),
146 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
152 if(out) *out <<
"\n"<<tc<<
") assign(V2.ptr(), *V1);\n";
154 assign(V2.ptr(), *V1);
155 norms_2(*V1, mags1());
156 norms_2(*V2, mags2());
157 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
158 "norms_2(*V1)", mags1(),
159 "norms_2(*V2)", mags2(),
160 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
165 if(out) *out <<
"\n"<<tc<<
") scale(alpha,V2.ptr());\n";
168 Scalar alpha = as<Scalar>(1.2345);
169 assign(V2.ptr(), *V1);
170 scale(alpha, V2.ptr());
171 norms_2(*V1, mags1());
173 mags1[i] *= ST::magnitude(alpha);
174 norms_2(*V2, mags2());
175 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
176 "norms_2(alpha*V1)", mags1(),
177 "alpha*norms_2(V1)", mags2(),
178 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
184 if(out) *out <<
"\n"<<tc<<
") scaleUpdate(a,V1,V2.ptr());\n";
188 assign(a.
ptr(), two);
189 assign(V2.ptr(), four);
190 scaleUpdate(*a, *V1, V2.
ptr());
191 norms_2(*V2, mags1());
192 if (!testMaxErrors<Scalar>(
193 "norms_2(*V2)", mags1(),
194 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
200 if(out) *out <<
"\n"<<tc<<
") update(a,V1,V2.ptr());\n";
203 Scalar alpha = as<Scalar>(1.2345);
204 assign(V2.ptr(), three);
205 assign(V3.ptr(), *V1);
206 scale(alpha, V3.ptr());
208 update(alpha, *V1, V2.
ptr());
209 norms_2(*V2, mags1());
210 norms_2(*V3, mags2());
211 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
212 "norms_2(*V2)", mags1(),
213 "norms_2(*V3)", mags2(),
214 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
220 if(out) *out <<
"\n"<<tc<<
") update(alpha,beta,*V1,V2.ptr());\n";
225 alpha[i] = as<Scalar>(i+1);
226 Scalar beta = as<Scalar>(1.2345);
227 assign(V2.ptr(), three);
228 assign(V3.ptr(), *V1);
229 scale(beta, V3.ptr());
231 scale(alpha[i], V3->col(i).ptr());
234 update(alphaView, beta, *V1, V2.
ptr());
235 norms_2(*V2, mags1());
236 norms_2(*V3, mags2());
237 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
238 "norms_2(*V2)", mags1(),
239 "norms_2(*V3)", mags2(),
240 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
246 if(out) *out <<
"\n"<<tc<<
") update(*V1,alpha,beta,V2.ptr());\n";
251 alpha[i] = as<Scalar>(i+1);
252 Scalar beta = as<Scalar>(1.2345);
253 assign(V2.ptr(), three);
254 assign(V3.ptr(), *V2);
255 scale(beta, V3.ptr());
257 scale(alpha[i], V3->col(i).ptr());
260 update(*V1, alphaView, beta, V2.
ptr());
261 norms_2(*V2, mags1());
262 norms_2(*V3, mags2());
263 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
264 "norms_2(*V2)", mags1(),
265 "norms_2(*V3)", mags2(),
266 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
272 if(out) *out <<
"\n"<<tc<<
") linear_combination({alpha,beta,gamma},{V1.ptr(),V2.ptr(),V3.ptr()},0.0,V4.ptr());\n";
275 Scalar alpha = two, beta = -three, gamma = three;
277 assign(V2.ptr(), two);
278 assign(V3.ptr(), four);
279 linear_combination<Scalar>(
280 tuple<Scalar>(alpha, beta, gamma),
284 norms_2(*V4, mags1());
286 mags2[i] = ST::magnitude(two * ST::squareroot(as<Scalar>(n)));
287 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
288 "norms_2(*V4)", mags1(),
289 "2.0*sqrt(n)", mags2(),
290 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
295 if(out) *out <<
"\n"<<tc<<
") linear_combination({alpha,beta,gamma},{V1.ptr(),V2.ptr(),V3.ptr()},0.5,V4.ptr());\n";
298 Scalar alpha = two, beta = -three, gamma = three;
300 assign(V2.ptr(), two);
301 assign(V3.ptr(), four);
302 assign(V4.
ptr(), -four);
303 linear_combination<Scalar>(
304 tuple<Scalar>(alpha, beta, gamma),
308 norms_2(*V4, mags1());
309 if (!testMaxErrors<Scalar>(
310 "norms_2(*V4)", mags1(),
311 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
317 if(out) *out <<
"\n"<<tc<<
") Vt_S(V1.ptr(),alpha);\n";
320 Scalar alpha = as<Scalar>(1.2345);
321 assign(V2.ptr(), *V1);
322 Vt_S(V2.ptr(), alpha);
323 norms_2(*V1, mags1());
325 mags1[i] *= ST::magnitude(alpha);
326 norms_2(*V2, mags2());
327 if (!testRelErrors<ScalarMag, ScalarMag, ScalarMag>(
328 "norms_2(alpha*V1)", mags1(),
329 "alpha*norms_2(V1)", mags2(),
330 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
336 if(out) *out <<
"\n"<<tc<<
") Vp_S(V2.ptr(),alpha);\n";
339 assign(V2.ptr(), *V1);
341 norms_2(*V2, mags1());
342 if (!testMaxErrors<Scalar>(
343 "norms_2(V2)", mags1(),
344 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
350 if(out) *out <<
"\n"<<tc<<
") Vp_V(V2.ptr(),*V1);\n";
353 assign(V2.ptr(), two);
355 norms_2(*V2, mags1());
356 if (!testMaxErrors<Scalar>(
357 "norms_2(V2)", mags1(),
358 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
365 if(out) *out <<
"\n"<<tc<<
") V_VpV(V3.ptr(),*V1,*V2);\n";
368 assign(V2.ptr(), two);
369 V_VpV(V3.ptr(), *V1, *V2);
370 norms_2(*V3, mags1());
371 if (!testMaxErrors<Scalar>(
372 "norms_2(V3)", mags1(),
373 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
380 if(out) *out <<
"\n"<<tc<<
") V_VmV(V3.ptr(),*V1,*V2);\n";
383 assign(V2.ptr(), -two);
384 V_VmV(V3.ptr(), *V1, *V2);
385 norms_2(*V3, mags1());
386 if (!testMaxErrors<Scalar>(
387 "norms_2(V3)", mags1(),
388 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
395 if(out) *out <<
"\n"<<tc<<
") V_StVpV(V3.ptr(),alpha,*V1,*V2);\n";
398 Scalar alpha = as<Scalar>(1.2345);
399 assign(V2.ptr(), three);
400 V_StVpV(V3.ptr(), alpha, *V1, *V2);
401 scale(alpha, V1.ptr());
403 V_VmV(V3.ptr(), *V2, *V3);
404 norms_2(*V3, mags1());
405 if (!testMaxErrors<Scalar>(
406 "norms_2(V3)", mags1(),
407 "error_tol", error_tol(),
"warning_tol", warning_tol(), ptr(out)
414 <<
"\n*** Leaving MultiVectorStdOpsTester<"<<ST::name()<<
">::checkStdOps(...) ...\n";
422 #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.