42 namespace SacadoPCEUnitTest {
45 template <
typename PCEType>
71 for (
int i=0; i<d; i++)
102 for (
int i=0; i<d; i++) {
107 for (
int i=0; i<d; i++)
125 #define UNARY_UNIT_TEST(OP) \
126 TEUCHOS_UNIT_TEST( Stokhos_PCE, OP) { \
127 UTS::pce_type u = OP(setup.x); \
128 UTS::opa_type u_opa(setup.basis); \
129 setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
130 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
132 setup.rtol, setup.atol, out); \
134 TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_const) { \
135 UTS::pce_type u = OP(setup.cx); \
136 UTS::opa_type u_opa(setup.basis); \
137 setup.exp->OP(u_opa, setup.cx.getOrthogPolyApprox()); \
138 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
140 setup.rtol, setup.atol, out); \
142 TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_resize) { \
145 UTS::opa_type u_opa(setup.basis); \
146 setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
147 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
149 setup.rtol, setup.atol, out); \
170 #define BINARY_UNIT_TEST(OP, EXPOP) \
171 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP) { \
172 UTS::pce_type v = std::sin(setup.x); \
173 UTS::pce_type w = std::cos(setup.x); \
174 UTS::pce_type u = OP(v,w); \
175 UTS::opa_type u_opa(setup.basis); \
176 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
177 w.getOrthogPolyApprox()); \
178 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
180 setup.rtol, setup.atol, out); \
182 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const) { \
183 UTS::pce_type w = std::cos(setup.x); \
184 UTS::pce_type u = OP(setup.a, w); \
185 UTS::opa_type u_opa(setup.basis); \
186 setup.exp->EXPOP(u_opa, setup.a, \
187 w.getOrthogPolyApprox()); \
188 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
190 setup.rtol, setup.atol, out); \
192 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const) { \
193 UTS::pce_type v = std::sin(setup.x); \
194 UTS::pce_type u = OP(v, setup.a); \
195 UTS::opa_type u_opa(setup.basis); \
196 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
198 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
200 setup.rtol, setup.atol, out); \
202 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_both_const) { \
203 UTS::pce_type u = OP(setup.cx, setup.cx); \
204 UTS::opa_type u_opa(setup.basis); \
205 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
206 setup.cx.getOrthogPolyApprox()); \
207 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
209 setup.rtol, setup.atol, out); \
211 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const2) { \
212 UTS::pce_type w = std::cos(setup.x); \
213 UTS::pce_type u = OP(setup.cx, w); \
214 UTS::opa_type u_opa(setup.basis); \
215 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
216 w.getOrthogPolyApprox()); \
217 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
219 setup.rtol, setup.atol, out); \
221 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const2) { \
222 UTS::pce_type v = std::sin(setup.x); \
223 UTS::pce_type u = OP(v, setup.cx); \
224 UTS::opa_type u_opa(setup.basis); \
225 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
226 setup.cx.getOrthogPolyApprox()); \
227 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
229 setup.rtol, setup.atol, out); \
231 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_resize) { \
232 UTS::pce_type v = std::sin(setup.x); \
233 UTS::pce_type w = std::cos(setup.x); \
236 UTS::opa_type u_opa(setup.basis); \
237 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
238 w.getOrthogPolyApprox()); \
239 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
241 setup.rtol, setup.atol, out); \
243 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const_resize) { \
244 UTS::pce_type w = std::cos(setup.x); \
246 u = OP(setup.a, w); \
247 UTS::opa_type u_opa(setup.basis); \
248 setup.exp->EXPOP(u_opa, setup.a, \
249 w.getOrthogPolyApprox()); \
250 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
252 setup.rtol, setup.atol, out); \
254 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const_resize) { \
255 UTS::pce_type v = std::sin(setup.x); \
257 u = OP(v, setup.a); \
258 UTS::opa_type u_opa(setup.basis); \
259 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
261 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
263 setup.rtol, setup.atol, out); \
265 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short) { \
266 UTS::pce_type w = std::cos(setup.x); \
267 UTS::pce_type u = OP(setup.sx, w); \
268 UTS::opa_type u_opa(setup.basis); \
269 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
270 w.getOrthogPolyApprox()); \
271 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
273 setup.rtol, setup.atol, out); \
275 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short) { \
276 UTS::pce_type v = std::sin(setup.x); \
277 UTS::pce_type u = OP(v, setup.sx); \
278 UTS::opa_type u_opa(setup.basis); \
279 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
280 setup.sx.getOrthogPolyApprox()); \
281 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
283 setup.rtol, setup.atol, out); \
285 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_both_short) { \
286 UTS::pce_type u = OP(setup.sx, setup.sx); \
287 UTS::opa_type u_opa(setup.basis); \
288 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
289 setup.sx.getOrthogPolyApprox()); \
290 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
292 setup.rtol, setup.atol, out); \
294 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_resize) { \
295 UTS::pce_type w = std::cos(setup.x); \
297 u = OP(setup.sx, w); \
298 UTS::opa_type u_opa(setup.basis); \
299 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
300 w.getOrthogPolyApprox()); \
301 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
303 setup.rtol, setup.atol, out); \
305 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_resize) { \
306 UTS::pce_type v = std::sin(setup.x); \
308 u = OP(v, setup.sx); \
309 UTS::opa_type u_opa(setup.basis); \
310 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
311 setup.sx.getOrthogPolyApprox()); \
312 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
314 setup.rtol, setup.atol, out); \
316 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_right_const) { \
317 UTS::pce_type u = OP(setup.sx, setup.a); \
318 UTS::opa_type u_opa(setup.basis); \
319 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
321 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
323 setup.rtol, setup.atol, out); \
325 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_left_const) { \
326 UTS::pce_type u = OP(setup.a, setup.sx); \
327 UTS::opa_type u_opa(setup.basis); \
328 setup.exp->EXPOP(u_opa, setup.a, \
329 setup.sx.getOrthogPolyApprox()); \
330 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
332 setup.rtol, setup.atol, out); \
334 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_right_const2) { \
335 UTS::pce_type u = OP(setup.sx, setup.cx); \
336 UTS::opa_type u_opa(setup.basis); \
337 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
338 setup.cx.getOrthogPolyApprox()); \
339 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
341 setup.rtol, setup.atol, out); \
343 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_left_const2) { \
344 UTS::pce_type u = OP(setup.cx, setup.sx); \
345 UTS::opa_type u_opa(setup.basis); \
346 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
347 setup.sx.getOrthogPolyApprox()); \
348 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
350 setup.rtol, setup.atol, out); \
358 #define OPASSIGN_UNIT_TEST(OP, EXPOP) \
359 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP) { \
360 UTS::pce_type v = std::sin(setup.x); \
361 UTS::pce_type u = std::cos(setup.x); \
362 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
364 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
365 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
367 setup.rtol, setup.atol, out); \
369 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_const) { \
370 UTS::pce_type u = std::cos(setup.x); \
371 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
373 setup.exp->EXPOP(u_opa, setup.a); \
374 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
376 setup.rtol, setup.atol, out); \
378 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_const2) { \
379 UTS::pce_type u = std::cos(setup.x); \
380 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
382 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
383 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
385 setup.rtol, setup.atol, out); \
387 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_resize) { \
388 UTS::pce_type v = std::sin(setup.x); \
389 UTS::pce_type u = setup.a; \
390 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
392 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
393 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
395 setup.rtol, setup.atol, out); \
397 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short) { \
398 UTS::pce_type u = std::cos(setup.x); \
399 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
401 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox()); \
402 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
404 setup.rtol, setup.atol, out); \
406 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_resize) { \
407 UTS::pce_type u = setup.sx; \
408 UTS::pce_type v = std::cos(setup.x); \
409 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
411 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
412 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
414 setup.rtol, setup.atol, out); \
416 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const) { \
417 UTS::pce_type u = setup.sx; \
418 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
420 setup.exp->EXPOP(u_opa, setup.a); \
421 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
423 setup.rtol, setup.atol, out); \
425 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const2) { \
426 UTS::pce_type u = setup.sx; \
427 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
429 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
430 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
432 setup.rtol, setup.atol, out); \
437 OPASSIGN_UNIT_TEST(*=, timesEqual)
438 OPASSIGN_UNIT_TEST(/=, divideEqual)
447 setup.
exp->
times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
460 setup.
exp->
times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
473 setup.
exp->
times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
498 w.getOrthogPolyApprox());
511 w.getOrthogPolyApprox());
535 setup.
cx.getOrthogPolyApprox());
560 w.getOrthogPolyApprox());
585 w.getOrthogPolyApprox());
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
#define BINARY_UNIT_TEST(OP, EXPOP)
#define OPASSIGN_UNIT_TEST(OP, EXPOP)
void times(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
Teuchos::RCP< const Stokhos::Quadrature< int, double > > quad
Stokhos::OrthogPolyApprox< int, double > opa_type
bool comparePCEs(const PCEType &a1, const std::string &a1_name, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
Teuchos::RCP< Stokhos::Sparse3Tensor< int, double > > Cijk
void saxpy(const scalar_type &alpha, Teuchos::SerialDenseVector< ordinal_type, scalar_type > &x, const scalar_type &beta, const Teuchos::SerialDenseVector< ordinal_type, scalar_type > &y)
Overwrite x with alpha*x + beta*y.
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
void plusEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
UnitTestSetup< pce_type > UTS
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(Stokhos_PCE, UMinus)
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
#define UNARY_UNIT_TEST(OP)
Legendre polynomial basis.
virtual ordinal_type size() const
Return total size of basis.
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion< int, double > > exp
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< int, double > > basis
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
void unaryMinus(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...