11 namespace SacadoPCEUnitTest {
14 template <
typename PCEType>
40 for (
int i=0; i<d; i++)
71 for (
int i=0; i<d; i++) {
76 for (
int i=0; i<d; i++)
94 #define UNARY_UNIT_TEST(OP) \
95 TEUCHOS_UNIT_TEST( Stokhos_PCE, OP) { \
96 UTS::pce_type u = OP(setup.x); \
97 UTS::opa_type u_opa(setup.basis); \
98 setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
99 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
101 setup.rtol, setup.atol, out); \
103 TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_const) { \
104 UTS::pce_type u = OP(setup.cx); \
105 UTS::opa_type u_opa(setup.basis); \
106 setup.exp->OP(u_opa, setup.cx.getOrthogPolyApprox()); \
107 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
109 setup.rtol, setup.atol, out); \
111 TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_resize) { \
114 UTS::opa_type u_opa(setup.basis); \
115 setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
116 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
118 setup.rtol, setup.atol, out); \
139 #define BINARY_UNIT_TEST(OP, EXPOP) \
140 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP) { \
141 UTS::pce_type v = std::sin(setup.x); \
142 UTS::pce_type w = std::cos(setup.x); \
143 UTS::pce_type u = OP(v,w); \
144 UTS::opa_type u_opa(setup.basis); \
145 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
146 w.getOrthogPolyApprox()); \
147 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
149 setup.rtol, setup.atol, out); \
151 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const) { \
152 UTS::pce_type w = std::cos(setup.x); \
153 UTS::pce_type u = OP(setup.a, w); \
154 UTS::opa_type u_opa(setup.basis); \
155 setup.exp->EXPOP(u_opa, setup.a, \
156 w.getOrthogPolyApprox()); \
157 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
159 setup.rtol, setup.atol, out); \
161 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const) { \
162 UTS::pce_type v = std::sin(setup.x); \
163 UTS::pce_type u = OP(v, setup.a); \
164 UTS::opa_type u_opa(setup.basis); \
165 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
167 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
169 setup.rtol, setup.atol, out); \
171 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_both_const) { \
172 UTS::pce_type u = OP(setup.cx, setup.cx); \
173 UTS::opa_type u_opa(setup.basis); \
174 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
175 setup.cx.getOrthogPolyApprox()); \
176 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
178 setup.rtol, setup.atol, out); \
180 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const2) { \
181 UTS::pce_type w = std::cos(setup.x); \
182 UTS::pce_type u = OP(setup.cx, w); \
183 UTS::opa_type u_opa(setup.basis); \
184 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
185 w.getOrthogPolyApprox()); \
186 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
188 setup.rtol, setup.atol, out); \
190 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const2) { \
191 UTS::pce_type v = std::sin(setup.x); \
192 UTS::pce_type u = OP(v, setup.cx); \
193 UTS::opa_type u_opa(setup.basis); \
194 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
195 setup.cx.getOrthogPolyApprox()); \
196 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
198 setup.rtol, setup.atol, out); \
200 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_resize) { \
201 UTS::pce_type v = std::sin(setup.x); \
202 UTS::pce_type w = std::cos(setup.x); \
205 UTS::opa_type u_opa(setup.basis); \
206 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
207 w.getOrthogPolyApprox()); \
208 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
210 setup.rtol, setup.atol, out); \
212 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const_resize) { \
213 UTS::pce_type w = std::cos(setup.x); \
215 u = OP(setup.a, w); \
216 UTS::opa_type u_opa(setup.basis); \
217 setup.exp->EXPOP(u_opa, setup.a, \
218 w.getOrthogPolyApprox()); \
219 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
221 setup.rtol, setup.atol, out); \
223 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const_resize) { \
224 UTS::pce_type v = std::sin(setup.x); \
226 u = OP(v, setup.a); \
227 UTS::opa_type u_opa(setup.basis); \
228 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
230 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
232 setup.rtol, setup.atol, out); \
234 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short) { \
235 UTS::pce_type w = std::cos(setup.x); \
236 UTS::pce_type u = OP(setup.sx, w); \
237 UTS::opa_type u_opa(setup.basis); \
238 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
239 w.getOrthogPolyApprox()); \
240 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
242 setup.rtol, setup.atol, out); \
244 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short) { \
245 UTS::pce_type v = std::sin(setup.x); \
246 UTS::pce_type u = OP(v, setup.sx); \
247 UTS::opa_type u_opa(setup.basis); \
248 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
249 setup.sx.getOrthogPolyApprox()); \
250 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
252 setup.rtol, setup.atol, out); \
254 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_both_short) { \
255 UTS::pce_type u = OP(setup.sx, setup.sx); \
256 UTS::opa_type u_opa(setup.basis); \
257 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
258 setup.sx.getOrthogPolyApprox()); \
259 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
261 setup.rtol, setup.atol, out); \
263 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_resize) { \
264 UTS::pce_type w = std::cos(setup.x); \
266 u = OP(setup.sx, w); \
267 UTS::opa_type u_opa(setup.basis); \
268 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
269 w.getOrthogPolyApprox()); \
270 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
272 setup.rtol, setup.atol, out); \
274 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_resize) { \
275 UTS::pce_type v = std::sin(setup.x); \
277 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##_left_short_right_const) { \
286 UTS::pce_type u = OP(setup.sx, setup.a); \
287 UTS::opa_type u_opa(setup.basis); \
288 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
290 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
292 setup.rtol, setup.atol, out); \
294 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_left_const) { \
295 UTS::pce_type u = OP(setup.a, setup.sx); \
296 UTS::opa_type u_opa(setup.basis); \
297 setup.exp->EXPOP(u_opa, setup.a, \
298 setup.sx.getOrthogPolyApprox()); \
299 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
301 setup.rtol, setup.atol, out); \
303 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_right_const2) { \
304 UTS::pce_type u = OP(setup.sx, setup.cx); \
305 UTS::opa_type u_opa(setup.basis); \
306 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
307 setup.cx.getOrthogPolyApprox()); \
308 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
310 setup.rtol, setup.atol, out); \
312 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_left_const2) { \
313 UTS::pce_type u = OP(setup.cx, setup.sx); \
314 UTS::opa_type u_opa(setup.basis); \
315 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
316 setup.sx.getOrthogPolyApprox()); \
317 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
319 setup.rtol, setup.atol, out); \
327 #define OPASSIGN_UNIT_TEST(OP, EXPOP) \
328 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP) { \
329 UTS::pce_type v = std::sin(setup.x); \
330 UTS::pce_type u = std::cos(setup.x); \
331 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
333 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
334 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
336 setup.rtol, setup.atol, out); \
338 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_const) { \
339 UTS::pce_type u = std::cos(setup.x); \
340 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
342 setup.exp->EXPOP(u_opa, setup.a); \
343 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
345 setup.rtol, setup.atol, out); \
347 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_const2) { \
348 UTS::pce_type u = std::cos(setup.x); \
349 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
351 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
352 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
354 setup.rtol, setup.atol, out); \
356 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_resize) { \
357 UTS::pce_type v = std::sin(setup.x); \
358 UTS::pce_type u = setup.a; \
359 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
361 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
362 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
364 setup.rtol, setup.atol, out); \
366 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short) { \
367 UTS::pce_type u = std::cos(setup.x); \
368 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
370 setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox()); \
371 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
373 setup.rtol, setup.atol, out); \
375 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_resize) { \
376 UTS::pce_type u = setup.sx; \
377 UTS::pce_type v = std::cos(setup.x); \
378 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
380 setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
381 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
383 setup.rtol, setup.atol, out); \
385 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const) { \
386 UTS::pce_type u = setup.sx; \
387 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
389 setup.exp->EXPOP(u_opa, setup.a); \
390 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
392 setup.rtol, setup.atol, out); \
394 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const2) { \
395 UTS::pce_type u = setup.sx; \
396 UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
398 setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
399 success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
401 setup.rtol, setup.atol, out); \
406 OPASSIGN_UNIT_TEST(*=, timesEqual)
407 OPASSIGN_UNIT_TEST(/=, divideEqual)
416 setup.
exp->
times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
429 setup.
exp->
times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
442 setup.
exp->
times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
467 w.getOrthogPolyApprox());
480 w.getOrthogPolyApprox());
504 setup.
cx.getOrthogPolyApprox());
529 w.getOrthogPolyApprox());
554 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...