Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_SacadoPCEUnitTest.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 
11 namespace SacadoPCEUnitTest {
12 
13  // Common setup for unit tests
14  template <typename PCEType>
15  struct UnitTestSetup {
16 
17  typedef PCEType pce_type;
19  double rtol, atol;
20  double crtol, catol;
21  int sz;
26  pce_type x, y, u, u2, cx, cu, cu2, sx, su, su2;
27  double a;
28 
30  rtol = 1e-4;
31  atol = 1e-5;
32  crtol = 1e-12;
33  catol = 1e-12;
34  a = 3.1;
35  const int d = 2;
36  const int p = 7;
37 
38  // Create product basis
40  for (int i=0; i<d; i++)
41  bases[i] =
43  basis =
45 
46  // Tensor product quadrature
47  quad =
49 
50  // Triple product tensor
52 
53  // Quadrature expansion
54  exp =
56 
57  // Create approximation
58  sz = basis->size();
59  x.reset(exp);
60  y.reset(exp);
61  u.reset(exp);
62  u2.reset(exp);
63  cx.reset(exp, 1);
64  x.term(0, 0) = 1.0;
65  cx.term(0, 0) = a;
66  cu.reset(exp);
67  cu2.reset(exp, 1);
68  sx.reset(exp, d+1);
69  su.reset(exp, d+1);
70  su2.reset(exp, d+1);
71  for (int i=0; i<d; i++) {
72  x.term(i, 1) = 0.1;
73  sx.term(i, 1) = 0.0;
74  }
75  y.term(0, 0) = 2.0;
76  for (int i=0; i<d; i++)
77  y.term(i, 1) = 0.25;
78  }
79  };
80 
83 
84  TEUCHOS_UNIT_TEST( Stokhos_PCE, UMinus) {
86  UTS::pce_type u = -v;
87  UTS::opa_type u_opa(setup.basis);
88  setup.exp->unaryMinus(u_opa, v.getOrthogPolyApprox());
89  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
90  u_opa, "u_opa",
91  setup.rtol, setup.atol, out);
92  }
93 
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", \
100  u_opa, "u_opa", \
101  setup.rtol, setup.atol, out); \
102  } \
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", \
108  u_opa, "u_opa", \
109  setup.rtol, setup.atol, out); \
110  } \
111  TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_resize) { \
112  UTS::pce_type u; \
113  u = OP(setup.x); \
114  UTS::opa_type u_opa(setup.basis); \
115  setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
116  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
117  u_opa, "u_opa", \
118  setup.rtol, setup.atol, out); \
119  }
120 
138 
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", \
148  u_opa, "u_opa", \
149  setup.rtol, setup.atol, out); \
150  } \
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", \
158  u_opa, "u_opa", \
159  setup.rtol, setup.atol, out); \
160  } \
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(), \
166  setup.a); \
167  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
168  u_opa, "u_opa", \
169  setup.rtol, setup.atol, out); \
170  } \
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", \
177  u_opa, "u_opa", \
178  setup.rtol, setup.atol, out); \
179  } \
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", \
187  u_opa, "u_opa", \
188  setup.rtol, setup.atol, out); \
189  } \
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", \
197  u_opa, "u_opa", \
198  setup.rtol, setup.atol, out); \
199  } \
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); \
203  UTS::pce_type u; \
204  u = OP(v, w); \
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", \
209  u_opa, "u_opa", \
210  setup.rtol, setup.atol, out); \
211  } \
212  TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const_resize) { \
213  UTS::pce_type w = std::cos(setup.x); \
214  UTS::pce_type u; \
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", \
220  u_opa, "u_opa", \
221  setup.rtol, setup.atol, out); \
222  } \
223  TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const_resize) { \
224  UTS::pce_type v = std::sin(setup.x); \
225  UTS::pce_type u; \
226  u = OP(v, setup.a); \
227  UTS::opa_type u_opa(setup.basis); \
228  setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
229  setup.a); \
230  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
231  u_opa, "u_opa", \
232  setup.rtol, setup.atol, out); \
233  } \
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", \
241  u_opa, "u_opa", \
242  setup.rtol, setup.atol, out); \
243  } \
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", \
251  u_opa, "u_opa", \
252  setup.rtol, setup.atol, out); \
253  } \
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", \
260  u_opa, "u_opa", \
261  setup.rtol, setup.atol, out); \
262  } \
263 TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_resize) { \
264  UTS::pce_type w = std::cos(setup.x); \
265  UTS::pce_type u; \
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", \
271  u_opa, "u_opa", \
272  setup.rtol, setup.atol, out); \
273  } \
274  TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_resize) { \
275  UTS::pce_type v = std::sin(setup.x); \
276  UTS::pce_type u; \
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", \
282  u_opa, "u_opa", \
283  setup.rtol, setup.atol, out); \
284  } \
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(), \
289  setup.a); \
290  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
291  u_opa, "u_opa", \
292  setup.rtol, setup.atol, out); \
293  } \
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", \
300  u_opa, "u_opa", \
301  setup.rtol, setup.atol, out); \
302  } \
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", \
309  u_opa, "u_opa", \
310  setup.rtol, setup.atol, out); \
311  } \
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", \
318  u_opa, "u_opa", \
319  setup.rtol, setup.atol, out); \
320  }
321 
322  BINARY_UNIT_TEST(operator+, plus)
323  BINARY_UNIT_TEST(operator-, minus)
324  BINARY_UNIT_TEST(operator*, times)
325  BINARY_UNIT_TEST(operator/, divide)
326 
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(); \
332  u OP v; \
333  setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
334  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
335  u_opa, "u_opa", \
336  setup.rtol, setup.atol, out); \
337  } \
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(); \
341  u OP setup.a; \
342  setup.exp->EXPOP(u_opa, setup.a); \
343  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
344  u_opa, "u_opa", \
345  setup.rtol, setup.atol, out); \
346  } \
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(); \
350  u OP setup.cx; \
351  setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
352  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
353  u_opa, "u_opa", \
354  setup.rtol, setup.atol, out); \
355  } \
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(); \
360  u OP v; \
361  setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
362  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
363  u_opa, "u_opa", \
364  setup.rtol, setup.atol, out); \
365  } \
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(); \
369  u OP setup.sx; \
370  setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox()); \
371  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
372  u_opa, "u_opa", \
373  setup.rtol, setup.atol, out); \
374  } \
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(); \
379  u OP v; \
380  setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
381  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
382  u_opa, "u_opa", \
383  setup.rtol, setup.atol, out); \
384  } \
385  TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const) { \
386  UTS::pce_type u = setup.sx; \
387  UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
388  u OP setup.a; \
389  setup.exp->EXPOP(u_opa, setup.a); \
390  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
391  u_opa, "u_opa", \
392  setup.rtol, setup.atol, out); \
393  } \
394  TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const2) { \
395  UTS::pce_type u = setup.sx; \
396  UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
397  u OP setup.cx; \
398  setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
399  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
400  u_opa, "u_opa", \
401  setup.rtol, setup.atol, out); \
402  }
403 
404  OPASSIGN_UNIT_TEST(+=, plusEqual)
405  OPASSIGN_UNIT_TEST(-=, minusEqual)
406  OPASSIGN_UNIT_TEST(*=, timesEqual)
407  OPASSIGN_UNIT_TEST(/=, divideEqual)
408 
409  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy) {
413  UTS::opa_type u_opa = u.getOrthogPolyApprox();
414  UTS::opa_type t_opa(setup.basis);
415  u += v*w;
416  setup.exp->times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
417  setup.exp->plusEqual(u_opa, t_opa);
418  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
419  u_opa, "u_opa",
420  setup.rtol, setup.atol, out);
421  }
422  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_resize) {
423  UTS::pce_type u = setup.cx;
426  UTS::opa_type u_opa = u.getOrthogPolyApprox();
427  UTS::opa_type t_opa(setup.basis);
428  u += v*w;
429  setup.exp->times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
430  setup.exp->plusEqual(u_opa, t_opa);
431  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
432  u_opa, "u_opa",
433  setup.rtol, setup.atol, out);
434  }
435  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_resize2) {
436  UTS::pce_type u = setup.sx;
439  UTS::opa_type u_opa = u.getOrthogPolyApprox();
440  UTS::opa_type t_opa(setup.basis);
441  u += v*w;
442  setup.exp->times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
443  setup.exp->plusEqual(u_opa, t_opa);
444  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
445  u_opa, "u_opa",
446  setup.rtol, setup.atol, out);
447  }
448  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_const) {
451  UTS::opa_type u_opa = u.getOrthogPolyApprox();
452  UTS::opa_type t_opa(setup.basis);
453  u += setup.a*w;
454  setup.exp->times(t_opa, setup.a, w.getOrthogPolyApprox());
455  setup.exp->plusEqual(u_opa, t_opa);
456  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
457  u_opa, "u_opa",
458  setup.rtol, setup.atol, out);
459  }
460  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_const2) {
463  UTS::opa_type u_opa = u.getOrthogPolyApprox();
464  UTS::opa_type t_opa(setup.basis);
465  u += setup.cx*w;
466  setup.exp->times(t_opa, setup.cx.getOrthogPolyApprox(),
467  w.getOrthogPolyApprox());
468  setup.exp->plusEqual(u_opa, t_opa);
469  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
470  u_opa, "u_opa",
471  setup.rtol, setup.atol, out);
472  }
473  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_short) {
476  UTS::opa_type u_opa = u.getOrthogPolyApprox();
477  UTS::opa_type t_opa(setup.basis);
478  u += setup.sx*w;
479  setup.exp->times(t_opa, setup.sx.getOrthogPolyApprox(),
480  w.getOrthogPolyApprox());
481  setup.exp->plusEqual(u_opa, t_opa);
482  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
483  u_opa, "u_opa",
484  setup.rtol, setup.atol, out);
485  }
486  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_short_const) {
488  UTS::opa_type u_opa = u.getOrthogPolyApprox();
489  UTS::opa_type t_opa(setup.basis);
490  u += setup.sx*setup.a;
491  setup.exp->times(t_opa, setup.sx.getOrthogPolyApprox(),
492  setup.a);
493  setup.exp->plusEqual(u_opa, t_opa);
494  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
495  u_opa, "u_opa",
496  setup.rtol, setup.atol, out);
497  }
498  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_short_const2) {
500  UTS::opa_type u_opa = u.getOrthogPolyApprox();
501  UTS::opa_type t_opa(setup.basis);
502  u += setup.sx*setup.cx;
503  setup.exp->times(t_opa, setup.sx.getOrthogPolyApprox(),
504  setup.cx.getOrthogPolyApprox());
505  setup.exp->plusEqual(u_opa, t_opa);
506  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
507  u_opa, "u_opa",
508  setup.rtol, setup.atol, out);
509  }
510  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_resize_const) {
511  UTS::pce_type u = setup.cx;
513  UTS::opa_type u_opa = u.getOrthogPolyApprox();
514  UTS::opa_type t_opa(setup.basis);
515  u += setup.a*w;
516  setup.exp->times(t_opa, setup.a, w.getOrthogPolyApprox());
517  setup.exp->plusEqual(u_opa, t_opa);
518  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
519  u_opa, "u_opa",
520  setup.rtol, setup.atol, out);
521  }
522  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_resize_const2) {
523  UTS::pce_type u = setup.cx;
525  UTS::opa_type u_opa = u.getOrthogPolyApprox();
526  UTS::opa_type t_opa(setup.basis);
527  u += setup.cx*w;
528  setup.exp->times(t_opa, setup.cx.getOrthogPolyApprox(),
529  w.getOrthogPolyApprox());
530  setup.exp->plusEqual(u_opa, t_opa);
531  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
532  u_opa, "u_opa",
533  setup.rtol, setup.atol, out);
534  }
535  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_short_resize_const) {
536  UTS::pce_type u = setup.sx;
538  UTS::opa_type u_opa = u.getOrthogPolyApprox();
539  UTS::opa_type t_opa(setup.basis);
540  u += setup.a*w;
541  setup.exp->times(t_opa, setup.a, w.getOrthogPolyApprox());
542  setup.exp->plusEqual(u_opa, t_opa);
543  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
544  u_opa, "u_opa",
545  setup.rtol, setup.atol, out);
546  }
547  TEUCHOS_UNIT_TEST( Stokhos_PCE, saxpy_short_resize_const2) {
548  UTS::pce_type u = setup.sx;
550  UTS::opa_type u_opa = u.getOrthogPolyApprox();
551  UTS::opa_type t_opa(setup.basis);
552  u += setup.cx*w;
553  setup.exp->times(t_opa, setup.cx.getOrthogPolyApprox(),
554  w.getOrthogPolyApprox());
555  setup.exp->plusEqual(u_opa, t_opa);
556  success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u",
557  u_opa, "u_opa",
558  setup.rtol, setup.atol, out);
559  }
560 }
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)
atanh(expr.val())
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)
asinh(expr.val())
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.
acosh(expr.val())
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...