Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_AlgebraicExpansionUnitTest.cpp
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 
14 
15 #include "Stokhos.hpp"
17 
18 namespace AlgebraicExpansionUnitTest {
19 
20  // Common setup for unit tests
21  template <typename OrdinalType, typename ValueType>
22  struct UnitTestSetup {
23  ValueType rtol, atol;
24  ValueType crtol, catol;
25  OrdinalType sz;
32  ValueType a;
33 
35  rtol = 1e-4;
36  atol = 1e-5;
37  crtol = 1e-12;
38  catol = 1e-12;
39  a = 3.1;
40  const OrdinalType d = 2;
41  const OrdinalType p = 7;
42 
43  // Create product basis
45  for (OrdinalType i=0; i<d; i++)
46  bases[i] =
48  basis =
50 
51  // Tensor product quadrature
52  quad =
54 
55  // Triple product tensor
58 
59  // Algebraic expansion
60  exp =
62  exp_linear =
64 
65  // Quadrature expansion
66  qexp =
68 
69  // Create approximation
70  sz = basis->size();
71  x.reset(basis);
72  y.reset(basis);
73  u.reset(basis);
74  u2.reset(basis);
75  cx.reset(basis, 1);
76  x.term(0, 0) = 1.0;
77  cx.term(0, 0) = a;
78  cu.reset(basis);
79  cu2.reset(basis, 1);
80  sx.reset(basis, d+1);
81  su.reset(basis, d+1);
82  su2.reset(basis, d+1);
83  for (OrdinalType i=0; i<d; i++) {
84  x.term(i, 1) = 0.1;
85  sx.term(i, 1) = 0.0;
86  }
87  y.term(0, 0) = 2.0;
88  for (OrdinalType i=0; i<d; i++)
89  y.term(i, 1) = 0.25;
90  }
91 
92  template <class Func>
95  {
96  // Quadrature data
97  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
102  OrdinalType nqp = weights.size();
103 
104  // Initialize
105  for (OrdinalType i=0; i<c.size(); i++)
106  c[i] = 0.0;
107 
108  // Compute PCE via quadrature
109  Func func;
110  for (OrdinalType k=0; k<nqp; k++) {
111  ValueType val = a.evaluate(points[k], values[k]);
112  val = func(val);
113  for (int i=0; i<c.size(); i++)
114  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
115  }
116  }
117 
118  template <class Func>
122  {
123  // Quadrature data
124  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
126  quad->getQuadPoints();
129  OrdinalType nqp = weights.size();
130 
131  // Initialize
132  for (OrdinalType i=0; i<c.size(); i++)
133  c[i] = 0.0;
134 
135  // Compute PCE via quadrature
136  Func func;
137  for (OrdinalType k=0; k<nqp; k++) {
138  ValueType val1 = a.evaluate(points[k], values[k]);
139  ValueType val2 = b.evaluate(points[k], values[k]);
140  ValueType val = func(val1, val2);
141  for (int i=0; i<c.size(); i++)
142  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
143  }
144  }
145 
146  template <class Func>
149  ValueType a,
151  {
152  // Quadrature data
153  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
155  quad->getQuadPoints();
158  OrdinalType nqp = weights.size();
159 
160  // Initialize
161  for (OrdinalType i=0; i<c.size(); i++)
162  c[i] = 0.0;
163 
164  // Compute PCE via quadrature
165  Func func;
166  for (OrdinalType k=0; k<nqp; k++) {
167  ValueType val2 = b.evaluate(points[k], values[k]);
168  ValueType val = func(a, val2);
169  for (int i=0; i<c.size(); i++)
170  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
171  }
172  }
173 
174  template <class Func>
178  ValueType b)
179  {
180  // Quadrature data
181  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
183  quad->getQuadPoints();
186  OrdinalType nqp = weights.size();
187 
188  // Initialize
189  for (OrdinalType i=0; i<c.size(); i++)
190  c[i] = 0.0;
191 
192  // Compute PCE via quadrature
193  Func func;
194  for (OrdinalType k=0; k<nqp; k++) {
195  ValueType val1 = a.evaluate(points[k], values[k]);
196  ValueType val = func(val1, b);
197  for (int i=0; i<c.size(); i++)
198  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
199  }
200  }
201 
202  };
203 
205 
206  struct UMinusFunc {
207  double operator() (double a) const { return -a; }
208  };
209 
210  struct ASinhFunc {
211  double operator() (double a) const {
212  return std::log(a+std::sqrt(a*a+1.0));
213  }
214  };
215  struct ACoshFunc {
216  double operator() (double a) const {
217  return std::log(a+std::sqrt(a*a-1.0));
218  }
219  };
220  struct ATanhFunc {
221  double operator() (double a) const {
222  return 0.5*std::log((1.0+a)/(1.0-a));
223  }
224  };
225 
226  struct PlusFunc {
227  double operator() (double a, double b) const { return a + b; }
228  };
229  struct MinusFunc {
230  double operator() (double a, double b) const { return a - b; }
231  };
232  struct TimesFunc {
233  double operator() (double a, double b) const { return a * b; }
234  };
235  struct DivideFunc {
236  double operator() (double a, double b) const { return a / b; }
237  };
238 
239  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, UMinus ) {
241  setup.qexp->sin(v, setup.x);
242  setup.exp->unaryMinus(setup.u, v);
243  setup.computePCE1<UMinusFunc>(setup.u2, v);
244  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
245  setup.rtol, setup.atol, out);
246  }
247  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ExpConst ) {
248  setup.exp->exp(setup.cu, setup.cx);
249  setup.cu2[0] = std::exp(setup.cx[0]);
250  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
251  setup.crtol, setup.catol, out);
252  }
253  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, LogConst ) {
254  setup.exp->log(setup.cu, setup.cx);
255  setup.cu2[0] = std::log(setup.cx[0]);
256  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
257  setup.crtol, setup.catol, out);
258  }
259  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Log10Const ) {
260  setup.exp->log10(setup.cu, setup.cx);
261  setup.cu2[0] = std::log10(setup.cx[0]);
262  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
263  setup.crtol, setup.catol, out);
264  }
265  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, SqrtConst ) {
266  setup.exp->sqrt(setup.cu, setup.cx);
267  setup.cu2[0] = std::sqrt(setup.cx[0]);
268  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
269  setup.crtol, setup.catol, out);
270  }
271  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, CbrtConst ) {
272  setup.exp->cbrt(setup.cu, setup.cx);
273  setup.cu2[0] = std::cbrt(setup.cx[0]);
274  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
275  setup.crtol, setup.catol, out);
276  }
277  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, SinConst ) {
278  setup.exp->sin(setup.cu, setup.cx);
279  setup.cu2[0] = std::sin(setup.cx[0]);
280  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
281  setup.crtol, setup.catol, out);
282  }
283  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, CosConst ) {
284  setup.exp->cos(setup.cu, setup.cx);
285  setup.cu2[0] = std::cos(setup.cx[0]);
286  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
287  setup.crtol, setup.catol, out);
288  }
289  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TanConst ) {
290  setup.exp->tan(setup.cu, setup.cx);
291  setup.cu2[0] = std::tan(setup.cx[0]);
292  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
293  setup.crtol, setup.catol, out);
294  }
295  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, SinhConst ) {
296  setup.exp->sinh(setup.cu, setup.cx);
297  setup.cu2[0] = std::sinh(setup.cx[0]);
298  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
299  setup.crtol, setup.catol, out);
300  }
301  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, CoshConst ) {
302  setup.exp->cosh(setup.cu, setup.cx);
303  setup.cu2[0] = std::cosh(setup.cx[0]);
304  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
305  setup.crtol, setup.catol, out);
306  }
307  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TanhConst ) {
308  setup.exp->tanh(setup.cu, setup.cx);
309  setup.cu2[0] = std::tanh(setup.cx[0]);
310  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
311  setup.crtol, setup.catol, out);
312  }
313  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ASinConst ) {
314  setup.exp->asin(setup.cu, setup.cx);
315  setup.cu2[0] = std::asin(setup.cx[0]);
316  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
317  setup.crtol, setup.catol, out);
318  }
319  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ACosConst ) {
320  setup.exp->acos(setup.cu, setup.cx);
321  setup.cu2[0] = std::acos(setup.cx[0]);
322  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
323  setup.crtol, setup.catol, out);
324  }
325  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ATanConst ) {
326  setup.exp->atan(setup.cu, setup.cx);
327  setup.cu2[0] = std::atan(setup.cx[0]);
328  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
329  setup.crtol, setup.catol, out);
330  }
331  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ASinhConst ) {
332  ASinhFunc f;
333  setup.exp->asinh(setup.cu, setup.cx);
334  setup.cu2[0] = f(setup.cx[0]);
335  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
336  setup.crtol, setup.catol, out);
337  }
338  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ACoshConst ) {
339  ACoshFunc f;
340  setup.exp->acosh(setup.cu, setup.cx);
341  setup.cu2[0] = f(setup.cx[0]);
342  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
343  setup.crtol, setup.catol, out);
344  }
345  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ATanhConst ) {
346  ATanhFunc f;
347  setup.exp->atanh(setup.cu, setup.cx);
348  setup.cu2[0] = f(setup.cx[0]);
349  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
350  setup.crtol, setup.catol, out);
351  }
352 
353  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Plus ) {
355  setup.qexp->sin(v, setup.x);
356  setup.qexp->cos(w, setup.y);
357  setup.exp->plus(setup.u, v, w);
358  setup.computePCE2<PlusFunc>(setup.u2, v, w);
359  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
360  setup.rtol, setup.atol, out);
361  }
362  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLC ) {
364  setup.qexp->sin(v, setup.x);
365  setup.exp->plus(setup.u, setup.a, v);
366  setup.computePCE2LC<PlusFunc>(setup.u2, setup.a, v);
367  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
368  setup.rtol, setup.atol, out);
369  }
370  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRC ) {
372  setup.qexp->sin(v, setup.x);
373  setup.exp->plus(setup.u, v, setup.a);
374  setup.computePCE2RC<PlusFunc>(setup.u2, v, setup.a);
375  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
376  setup.rtol, setup.atol, out);
377  }
378  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusCC ) {
379  setup.exp->plus(setup.cu, setup.cx, setup.cx);
380  setup.computePCE2<PlusFunc>(setup.cu2, setup.cx, setup.cx);
381  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
382  setup.rtol, setup.atol, out);
383  }
384  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLC2 ) {
386  setup.qexp->sin(v, setup.x);
387  setup.exp->plus(setup.u, setup.cx, v);
388  setup.computePCE2LC<PlusFunc>(setup.u2, setup.cx[0], v);
389  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
390  setup.rtol, setup.atol, out);
391  }
392  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRC2 ) {
394  setup.qexp->sin(v, setup.x);
395  setup.exp->plus(setup.u, v, setup.cx);
396  setup.computePCE2RC<PlusFunc>(setup.u2, v, setup.cx[0]);
397  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
398  setup.rtol, setup.atol, out);
399  }
400  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusResize ) {
403  setup.qexp->sin(v, setup.x);
404  setup.qexp->cos(w, setup.y);
405  setup.exp->plus(ru, v, w);
406  setup.computePCE2<PlusFunc>(setup.u2, v, w);
407  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
408  setup.rtol, setup.atol, out);
409  }
410  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLCResize ) {
413  setup.qexp->sin(v, setup.x);
414  setup.exp->plus(ru, setup.a, v);
415  setup.computePCE2LC<PlusFunc>(setup.u2, setup.a, v);
416  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
417  setup.rtol, setup.atol, out);
418  }
419  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRCResize ) {
422  setup.qexp->sin(v, setup.x);
423  setup.exp->plus(ru, v, setup.a);
424  setup.computePCE2RC<PlusFunc>(setup.u2, v, setup.a);
425  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
426  setup.rtol, setup.atol, out);
427  }
428  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLS ) {
430  setup.qexp->sin(v, setup.x);
431  setup.exp->plus(setup.u, setup.sx, v);
432  setup.computePCE2<PlusFunc>(setup.u2, setup.sx, v);
433  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
434  setup.rtol, setup.atol, out);
435  }
436  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRS ) {
438  setup.qexp->sin(v, setup.x);
439  setup.exp->plus(setup.u, v, setup.sx);
440  setup.computePCE2<PlusFunc>(setup.u2, v, setup.sx);
441  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
442  setup.rtol, setup.atol, out);
443  }
444  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLSRC ) {
445  setup.exp->plus(setup.su, setup.sx, setup.a);
446  setup.computePCE2RC<PlusFunc>(setup.su2, setup.sx, setup.a);
447  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
448  setup.rtol, setup.atol, out);
449  }
450  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRSLC ) {
451  setup.exp->plus(setup.su, setup.a, setup.sx);
452  setup.computePCE2LC<PlusFunc>(setup.su2, setup.a, setup.sx);
453  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
454  setup.rtol, setup.atol, out);
455  }
456  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLSRC2 ) {
457  setup.exp->plus(setup.su, setup.sx, setup.cx);
458  setup.computePCE2<PlusFunc>(setup.su2, setup.sx, setup.cx);
459  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
460  setup.rtol, setup.atol, out);
461  }
462  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRSLC2 ) {
463  setup.exp->plus(setup.su, setup.cx, setup.sx);
464  setup.computePCE2<PlusFunc>(setup.su2, setup.cx, setup.sx);
465  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
466  setup.rtol, setup.atol, out);
467  }
468 
469  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Minus ) {
471  setup.qexp->sin(v, setup.x);
472  setup.qexp->cos(w, setup.y);
473  setup.exp->minus(setup.u, v, w);
474  setup.computePCE2<MinusFunc>(setup.u2, v, w);
475  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
476  setup.rtol, setup.atol, out);
477  }
478  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLC ) {
480  setup.qexp->sin(v, setup.x);
481  setup.exp->minus(setup.u, setup.a, v);
482  setup.computePCE2LC<MinusFunc>(setup.u2, setup.a, v);
483  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
484  setup.rtol, setup.atol, out);
485  }
486  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRC ) {
488  setup.qexp->sin(v, setup.x);
489  setup.exp->minus(setup.u, v, setup.a);
490  setup.computePCE2RC<MinusFunc>(setup.u2, v, setup.a);
491  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
492  setup.rtol, setup.atol, out);
493  }
494  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusCC ) {
495  setup.exp->minus(setup.cu, setup.cx, setup.cx);
496  setup.computePCE2<MinusFunc>(setup.cu2, setup.cx, setup.cx);
497  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
498  setup.rtol, setup.atol, out);
499  }
500  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLC2 ) {
502  setup.qexp->sin(v, setup.x);
503  setup.exp->minus(setup.u, setup.cx, v);
504  setup.computePCE2LC<MinusFunc>(setup.u2, setup.cx[0], v);
505  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
506  setup.rtol, setup.atol, out);
507  }
508  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRC2 ) {
510  setup.qexp->sin(v, setup.x);
511  setup.exp->minus(setup.u, v, setup.cx);
512  setup.computePCE2RC<MinusFunc>(setup.u2, v, setup.cx[0]);
513  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
514  setup.rtol, setup.atol, out);
515  }
516  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusResize ) {
519  setup.qexp->sin(v, setup.x);
520  setup.qexp->cos(w, setup.y);
521  setup.exp->minus(ru, v, w);
522  setup.computePCE2<MinusFunc>(setup.u2, v, w);
523  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
524  setup.rtol, setup.atol, out);
525  }
526  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLCResize ) {
529  setup.qexp->sin(v, setup.x);
530  setup.exp->minus(ru, setup.a, v);
531  setup.computePCE2LC<MinusFunc>(setup.u2, setup.a, v);
532  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
533  setup.rtol, setup.atol, out);
534  }
535  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRCResize ) {
538  setup.qexp->sin(v, setup.x);
539  setup.exp->minus(ru, v, setup.a);
540  setup.computePCE2RC<MinusFunc>(setup.u2, v, setup.a);
541  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
542  setup.rtol, setup.atol, out);
543  }
544  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLS ) {
546  setup.qexp->sin(v, setup.x);
547  setup.exp->minus(setup.u, setup.sx, v);
548  setup.computePCE2<MinusFunc>(setup.u2, setup.sx, v);
549  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
550  setup.rtol, setup.atol, out);
551  }
552  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRS ) {
554  setup.qexp->sin(v, setup.x);
555  setup.exp->minus(setup.u, v, setup.sx);
556  setup.computePCE2<MinusFunc>(setup.u2, v, setup.sx);
557  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
558  setup.rtol, setup.atol, out);
559  }
560  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLSRC ) {
561  setup.exp->minus(setup.su, setup.sx, setup.a);
562  setup.computePCE2RC<MinusFunc>(setup.su2, setup.sx, setup.a);
563  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
564  setup.rtol, setup.atol, out);
565  }
566  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRSLC ) {
567  setup.exp->minus(setup.su, setup.a, setup.sx);
568  setup.computePCE2LC<MinusFunc>(setup.su2, setup.a, setup.sx);
569  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
570  setup.rtol, setup.atol, out);
571  }
572  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLSRC2 ) {
573  setup.exp->minus(setup.su, setup.sx, setup.cx);
574  setup.computePCE2<MinusFunc>(setup.su2, setup.sx, setup.cx);
575  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
576  setup.rtol, setup.atol, out);
577  }
578  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRSLC2 ) {
579  setup.exp->minus(setup.su, setup.cx, setup.sx);
580  setup.computePCE2<MinusFunc>(setup.su2, setup.cx, setup.sx);
581  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
582  setup.rtol, setup.atol, out);
583  }
584 
585  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Times ) {
587  setup.qexp->sin(v, setup.x);
588  setup.qexp->cos(w, setup.y);
589  setup.exp->times(setup.u, v, w);
590  setup.computePCE2<TimesFunc>(setup.u2, v, w);
591  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
592  setup.rtol, setup.atol, out);
593  }
594  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLC ) {
596  setup.qexp->sin(v, setup.x);
597  setup.exp->times(setup.u, setup.a, v);
598  setup.computePCE2LC<TimesFunc>(setup.u2, setup.a, v);
599  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
600  setup.rtol, setup.atol, out);
601  }
602  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRC ) {
604  setup.qexp->sin(v, setup.x);
605  setup.exp->times(setup.u, v, setup.a);
606  setup.computePCE2RC<TimesFunc>(setup.u2, v, setup.a);
607  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
608  setup.rtol, setup.atol, out);
609  }
610  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesCC ) {
611  setup.exp->times(setup.cu, setup.cx, setup.cx);
612  setup.computePCE2<TimesFunc>(setup.cu2, setup.cx, setup.cx);
613  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
614  setup.rtol, setup.atol, out);
615  }
616  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLC2 ) {
618  setup.qexp->sin(v, setup.x);
619  setup.exp->times(setup.u, setup.cx, v);
620  setup.computePCE2LC<TimesFunc>(setup.u2, setup.cx[0], v);
621  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
622  setup.rtol, setup.atol, out);
623  }
624  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRC2 ) {
626  setup.qexp->sin(v, setup.x);
627  setup.exp->times(setup.u, v, setup.cx);
628  setup.computePCE2RC<TimesFunc>(setup.u2, v, setup.cx[0]);
629  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
630  setup.rtol, setup.atol, out);
631  }
632  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesResize ) {
635  setup.qexp->sin(v, setup.x);
636  setup.qexp->cos(w, setup.y);
637  setup.exp->times(ru, v, w);
638  setup.computePCE2<TimesFunc>(setup.u2, v, w);
639  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
640  setup.rtol, setup.atol, out);
641  }
642  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLCResize ) {
645  setup.qexp->sin(v, setup.x);
646  setup.exp->times(ru, setup.a, v);
647  setup.computePCE2LC<TimesFunc>(setup.u2, setup.a, v);
648  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
649  setup.rtol, setup.atol, out);
650  }
651  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRCResize ) {
654  setup.qexp->sin(v, setup.x);
655  setup.exp->times(ru, v, setup.a);
656  setup.computePCE2RC<TimesFunc>(setup.u2, v, setup.a);
657  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
658  setup.rtol, setup.atol, out);
659  }
660  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLS ) {
662  setup.qexp->sin(v, setup.x);
663  setup.exp->times(setup.u, setup.sx, v);
664  setup.computePCE2<TimesFunc>(setup.u2, setup.sx, v);
665  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
666  setup.rtol, setup.atol, out);
667  }
668  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRS ) {
670  setup.qexp->sin(v, setup.x);
671  setup.exp->times(setup.u, v, setup.sx);
672  setup.computePCE2<TimesFunc>(setup.u2, v, setup.sx);
673  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
674  setup.rtol, setup.atol, out);
675  }
676  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLSLinear ) {
678  setup.qexp->sin(v, setup.x);
679  setup.exp_linear->times(setup.u, setup.sx, v);
680  setup.computePCE2<TimesFunc>(setup.u2, setup.sx, v);
681  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
682  setup.rtol, setup.atol, out);
683  }
684  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRSLinear ) {
686  setup.qexp->sin(v, setup.x);
687  setup.exp_linear->times(setup.u, v, setup.sx);
688  setup.computePCE2<TimesFunc>(setup.u2, v, setup.sx);
689  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
690  setup.rtol, setup.atol, out);
691  }
692  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLSRC ) {
693  setup.exp->times(setup.su, setup.sx, setup.a);
694  setup.computePCE2RC<TimesFunc>(setup.su2, setup.sx, setup.a);
695  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
696  setup.rtol, setup.atol, out);
697  }
698  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRSLC ) {
699  setup.exp->times(setup.su, setup.a, setup.sx);
700  setup.computePCE2LC<TimesFunc>(setup.su2, setup.a, setup.sx);
701  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
702  setup.rtol, setup.atol, out);
703  }
704  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLSRC2 ) {
705  setup.exp->times(setup.su, setup.sx, setup.cx);
706  setup.computePCE2<TimesFunc>(setup.su2, setup.sx, setup.cx);
707  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
708  setup.rtol, setup.atol, out);
709  }
710  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRSLC2 ) {
711  setup.exp->times(setup.su, setup.cx, setup.sx);
712  setup.computePCE2<TimesFunc>(setup.su2, setup.cx, setup.sx);
713  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
714  setup.rtol, setup.atol, out);
715  }
716 
717 
718  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideRC ) {
720  setup.qexp->sin(v, setup.x);
721  setup.exp->divide(setup.u, v, setup.a);
722  setup.computePCE2RC<DivideFunc>(setup.u2, v, setup.a);
723  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
724  setup.rtol, setup.atol, out);
725  }
726  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideCC ) {
727  setup.exp->divide(setup.cu, setup.cx, setup.cx);
728  setup.computePCE2<DivideFunc>(setup.cu2, setup.cx, setup.cx);
729  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
730  setup.rtol, setup.atol, out);
731  }
732  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideRC2 ) {
734  setup.qexp->sin(v, setup.x);
735  setup.exp->divide(setup.u, v, setup.cx);
736  setup.computePCE2RC<DivideFunc>(setup.u2, v, setup.cx[0]);
737  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
738  setup.rtol, setup.atol, out);
739  }
740  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideRCResize ) {
743  setup.qexp->sin(v, setup.x);
744  setup.exp->divide(ru, v, setup.a);
745  setup.computePCE2RC<DivideFunc>(setup.u2, v, setup.a);
746  success = Stokhos::comparePCEs(ru, "u", setup.u2, "u2",
747  setup.rtol, setup.atol, out);
748  }
749  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideLSRC ) {
750  setup.exp->divide(setup.su, setup.sx, setup.a);
751  setup.computePCE2RC<DivideFunc>(setup.su2, setup.sx, setup.a);
752  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
753  setup.rtol, setup.atol, out);
754  }
755  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideLSRC2 ) {
756  setup.exp->divide(setup.su, setup.sx, setup.cx);
757  setup.computePCE2<DivideFunc>(setup.su2, setup.sx, setup.cx);
758  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
759  setup.rtol, setup.atol, out);
760  }
761 
762  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PowConst ) {
763  setup.exp->pow(setup.cu, setup.cx, setup.cx);
764  setup.cu2[0] = std::pow(setup.cx[0], setup.cx[0]);
765  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
766  setup.crtol, setup.catol, out);
767  }
768 
769  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqual ) {
771  setup.qexp->sin(v, setup.x);
772  setup.qexp->cos(setup.u, setup.x);
773  setup.computePCE2<PlusFunc>(setup.u2, setup.u, v);
774  setup.exp->plusEqual(setup.u, v);
775  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
776  setup.rtol, setup.atol, out);
777  }
778  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualC ) {
779  setup.qexp->cos(setup.u, setup.x);
780  setup.computePCE2RC<PlusFunc>(setup.u2, setup.u, setup.a);
781  setup.exp->plusEqual(setup.u, setup.a);
782  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
783  setup.rtol, setup.atol, out);
784  }
785  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualC2 ) {
786  setup.qexp->cos(setup.u, setup.x);
787  setup.computePCE2RC<PlusFunc>(setup.u2, setup.u, setup.cx[0]);
788  setup.exp->plusEqual(setup.u, setup.cx);
789  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
790  setup.rtol, setup.atol, out);
791  }
792  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualResize ) {
795  setup.qexp->sin(v, setup.x);
796  setup.exp->plusEqual(ru, v);
797  success = Stokhos::comparePCEs(ru, "ru", v, "v",
798  setup.rtol, setup.atol, out);
799  }
800  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualS ) {
801  setup.qexp->cos(setup.u, setup.x);
802  setup.computePCE2<PlusFunc>(setup.u2, setup.u, setup.sx);
803  setup.exp->plusEqual(setup.u, setup.sx);
804  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
805  setup.rtol, setup.atol, out);
806  }
807  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualSC ) {
808  setup.su = setup.sx;
809  setup.computePCE2RC<PlusFunc>(setup.su2, setup.su, setup.a);
810  setup.exp->plusEqual(setup.su, setup.a);
811  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
812  setup.rtol, setup.atol, out);
813  }
814  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualSC2 ) {
815  setup.su = setup.sx;
816  setup.computePCE2<PlusFunc>(setup.su2, setup.su, setup.cx);
817  setup.exp->plusEqual(setup.su, setup.cx);
818  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
819  setup.rtol, setup.atol, out);
820  }
821 
822  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqual ) {
824  setup.qexp->sin(v, setup.x);
825  setup.qexp->cos(setup.u, setup.x);
826  setup.computePCE2<MinusFunc>(setup.u2, setup.u, v);
827  setup.exp->minusEqual(setup.u, v);
828  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
829  setup.rtol, setup.atol, out);
830  }
831  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualC ) {
832  setup.qexp->cos(setup.u, setup.x);
833  setup.computePCE2RC<MinusFunc>(setup.u2, setup.u, setup.a);
834  setup.exp->minusEqual(setup.u, setup.a);
835  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
836  setup.rtol, setup.atol, out);
837  }
838  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualC2 ) {
839  setup.qexp->cos(setup.u, setup.x);
840  setup.computePCE2RC<MinusFunc>(setup.u2, setup.u, setup.cx[0]);
841  setup.exp->minusEqual(setup.u, setup.cx);
842  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
843  setup.rtol, setup.atol, out);
844  }
845  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualResize ) {
848  setup.qexp->sin(v, setup.x);
849  setup.exp->minusEqual(ru, v);
850  setup.exp->unaryMinus(v, v);
851  success = Stokhos::comparePCEs(ru, "ru", v, "v",
852  setup.rtol, setup.atol, out);
853  }
854  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualS ) {
855  setup.qexp->cos(setup.u, setup.x);
856  setup.computePCE2<MinusFunc>(setup.u2, setup.u, setup.sx);
857  setup.exp->minusEqual(setup.u, setup.sx);
858  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
859  setup.rtol, setup.atol, out);
860  }
861  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualSC ) {
862  setup.su = setup.sx;
863  setup.computePCE2RC<MinusFunc>(setup.su2, setup.su, setup.a);
864  setup.exp->minusEqual(setup.su, setup.a);
865  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
866  setup.rtol, setup.atol, out);
867  }
868  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualSC2 ) {
869  setup.su = setup.sx;
870  setup.computePCE2<MinusFunc>(setup.su2, setup.su, setup.cx);
871  setup.exp->minusEqual(setup.su, setup.cx);
872  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
873  setup.rtol, setup.atol, out);
874  }
875 
876  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqual ) {
878  setup.qexp->sin(v, setup.x);
879  setup.qexp->cos(setup.u, setup.x);
880  setup.computePCE2<TimesFunc>(setup.u2, setup.u, v);
881  setup.exp->timesEqual(setup.u, v);
882  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
883  setup.rtol, setup.atol, out);
884  }
885  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualC ) {
886  setup.qexp->cos(setup.u, setup.x);
887  setup.computePCE2RC<TimesFunc>(setup.u2, setup.u, setup.a);
888  setup.exp->timesEqual(setup.u, setup.a);
889  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
890  setup.rtol, setup.atol, out);
891  }
892  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualC2 ) {
893  setup.qexp->cos(setup.u, setup.x);
894  setup.computePCE2RC<TimesFunc>(setup.u2, setup.u, setup.cx[0]);
895  setup.exp->timesEqual(setup.u, setup.cx);
896  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
897  setup.rtol, setup.atol, out);
898  }
899  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualResize ) {
901  setup.qexp->sin(v, setup.x);
902  setup.su = setup.sx;
903  setup.computePCE2<TimesFunc>(setup.u2, setup.su, v);
904  setup.exp->timesEqual(setup.su, v);
905  success = Stokhos::comparePCEs(setup.su, "su", setup.u2, "u2",
906  setup.rtol, setup.atol, out);
907  }
908  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualS ) {
909  setup.qexp->cos(setup.u, setup.x);
910  setup.computePCE2<TimesFunc>(setup.u2, setup.u, setup.sx);
911  setup.exp->timesEqual(setup.u, setup.sx);
912  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
913  setup.rtol, setup.atol, out);
914  }
915  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualSLinear ) {
916  setup.qexp->cos(setup.u, setup.x);
917  setup.computePCE2<TimesFunc>(setup.u2, setup.u, setup.sx);
918  setup.exp_linear->timesEqual(setup.u, setup.sx);
919  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
920  setup.rtol, setup.atol, out);
921  }
922  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualSC ) {
923  setup.su = setup.sx;
924  setup.computePCE2RC<TimesFunc>(setup.su2, setup.su, setup.a);
925  setup.exp->timesEqual(setup.su, setup.a);
926  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
927  setup.rtol, setup.atol, out);
928  }
929  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualSC2 ) {
930  setup.su = setup.sx;
931  setup.computePCE2<TimesFunc>(setup.su2, setup.su, setup.cx);
932  setup.exp->timesEqual(setup.su, setup.cx);
933  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
934  setup.rtol, setup.atol, out);
935  }
936 
937  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualC ) {
938  setup.qexp->cos(setup.u, setup.x);
939  setup.computePCE2RC<DivideFunc>(setup.u2, setup.u, setup.a);
940  setup.exp->divideEqual(setup.u, setup.a);
941  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
942  setup.rtol, setup.atol, out);
943  }
944  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualC2 ) {
945  setup.qexp->cos(setup.u, setup.x);
946  setup.computePCE2RC<DivideFunc>(setup.u2, setup.u, setup.cx[0]);
947  setup.exp->divideEqual(setup.u, setup.cx);
948  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
949  setup.rtol, setup.atol, out);
950  }
951  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualSC ) {
952  setup.su = setup.sx;
953  setup.computePCE2RC<DivideFunc>(setup.su2, setup.su, setup.a);
954  setup.exp->divideEqual(setup.su, setup.a);
955  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
956  setup.rtol, setup.atol, out);
957  }
958  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualSC2 ) {
959  setup.su = setup.sx;
960  setup.computePCE2<DivideFunc>(setup.su2, setup.su, setup.cx);
961  setup.exp->divideEqual(setup.su, setup.cx);
962  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
963  setup.rtol, setup.atol, out);
964  }
965 
966  // Not testing atan2(), max(), min(), abs(), fabs() since these are
967  // not smooth functions
968 
969 }
970 
971 int main( int argc, char* argv[] ) {
972  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
974 }
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > cu2
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
Teuchos::RCP< Stokhos::AlgebraicOrthogPolyExpansion< OrdinalType, ValueType > > exp
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
TEUCHOS_UNIT_TEST(Stokhos_AlgebraicExpansion, UMinus)
value_type evaluate(const Teuchos::Array< value_type > &point) const
Evaluate polynomial approximation at a point.
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > cu
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeLinearTripleProductTensor() const
Compute linear triple product tensor where k = 0,1,..,d.
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< OrdinalType, ValueType > > basis
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > su2
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > cx
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > su
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > sx
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)
virtual const Teuchos::Array< Teuchos::Array< value_type > > & getBasisAtQuadPoints() const =0
Get values of basis at quadrature points.
void computePCE2LC(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, ValueType a, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > > qexp
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
virtual const Teuchos::Array< value_type > & getQuadWeights() const =0
Get quadrature weights.
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > u2
virtual const Teuchos::Array< Teuchos::Array< value_type > > & getQuadPoints() const =0
Get quadrature points.
Teuchos::RCP< Stokhos::Sparse3Tensor< int, double > > Cijk
static int runUnitTestsFromMain(int argc, char *argv[])
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &new_basis, ordinal_type sz=0)
Reset to a new basis.
void computePCE2(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &b)
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)
Teuchos::RCP< Stokhos::Sparse3Tensor< int, double > > Cijk_linear
int main(int argc, char **argv)
expr val()
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > u
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
void computePCE1(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a)
size_type size() const
virtual ordinal_type size() const
Return total size of basis.
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
ordinal_type size() const
Return size.
Teuchos::RCP< const Stokhos::Quadrature< OrdinalType, ValueType > > quad
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > x
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
virtual const Teuchos::Array< value_type > & norm_squared() const
Return array storing norm-squared of each basis polynomial.
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
void computePCE2RC(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a, ValueType b)
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...
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > y
reference term(ordinal_type dimension, ordinal_type order)
Get coefficient term for given dimension and order.
Teuchos::RCP< Stokhos::AlgebraicOrthogPolyExpansion< OrdinalType, ValueType > > exp_linear