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 // $Id$
2 // $Source$
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Stokhos Package
7 // Copyright (2009) Sandia Corporation
8 //
9 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10 // license for use of this work by or on behalf of the U.S. Government.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
40 //
41 // ***********************************************************************
42 // @HEADER
43 
48 
49 #include "Stokhos.hpp"
51 
52 namespace AlgebraicExpansionUnitTest {
53 
54  // Common setup for unit tests
55  template <typename OrdinalType, typename ValueType>
56  struct UnitTestSetup {
57  ValueType rtol, atol;
58  ValueType crtol, catol;
59  OrdinalType sz;
66  ValueType a;
67 
69  rtol = 1e-4;
70  atol = 1e-5;
71  crtol = 1e-12;
72  catol = 1e-12;
73  a = 3.1;
74  const OrdinalType d = 2;
75  const OrdinalType p = 7;
76 
77  // Create product basis
79  for (OrdinalType i=0; i<d; i++)
80  bases[i] =
82  basis =
84 
85  // Tensor product quadrature
86  quad =
88 
89  // Triple product tensor
92 
93  // Algebraic expansion
94  exp =
96  exp_linear =
98 
99  // Quadrature expansion
100  qexp =
102 
103  // Create approximation
104  sz = basis->size();
105  x.reset(basis);
106  y.reset(basis);
107  u.reset(basis);
108  u2.reset(basis);
109  cx.reset(basis, 1);
110  x.term(0, 0) = 1.0;
111  cx.term(0, 0) = a;
112  cu.reset(basis);
113  cu2.reset(basis, 1);
114  sx.reset(basis, d+1);
115  su.reset(basis, d+1);
116  su2.reset(basis, d+1);
117  for (OrdinalType i=0; i<d; i++) {
118  x.term(i, 1) = 0.1;
119  sx.term(i, 1) = 0.0;
120  }
121  y.term(0, 0) = 2.0;
122  for (OrdinalType i=0; i<d; i++)
123  y.term(i, 1) = 0.25;
124  }
125 
126  template <class Func>
129  {
130  // Quadrature data
131  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
133  quad->getQuadPoints();
136  OrdinalType nqp = weights.size();
137 
138  // Initialize
139  for (OrdinalType i=0; i<c.size(); i++)
140  c[i] = 0.0;
141 
142  // Compute PCE via quadrature
143  Func func;
144  for (OrdinalType k=0; k<nqp; k++) {
145  ValueType val = a.evaluate(points[k], values[k]);
146  val = func(val);
147  for (int i=0; i<c.size(); i++)
148  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
149  }
150  }
151 
152  template <class Func>
156  {
157  // Quadrature data
158  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
160  quad->getQuadPoints();
163  OrdinalType nqp = weights.size();
164 
165  // Initialize
166  for (OrdinalType i=0; i<c.size(); i++)
167  c[i] = 0.0;
168 
169  // Compute PCE via quadrature
170  Func func;
171  for (OrdinalType k=0; k<nqp; k++) {
172  ValueType val1 = a.evaluate(points[k], values[k]);
173  ValueType val2 = b.evaluate(points[k], values[k]);
174  ValueType val = func(val1, val2);
175  for (int i=0; i<c.size(); i++)
176  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
177  }
178  }
179 
180  template <class Func>
183  ValueType a,
185  {
186  // Quadrature data
187  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
189  quad->getQuadPoints();
192  OrdinalType nqp = weights.size();
193 
194  // Initialize
195  for (OrdinalType i=0; i<c.size(); i++)
196  c[i] = 0.0;
197 
198  // Compute PCE via quadrature
199  Func func;
200  for (OrdinalType k=0; k<nqp; k++) {
201  ValueType val2 = b.evaluate(points[k], values[k]);
202  ValueType val = func(a, val2);
203  for (int i=0; i<c.size(); i++)
204  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
205  }
206  }
207 
208  template <class Func>
212  ValueType b)
213  {
214  // Quadrature data
215  const Teuchos::Array<ValueType>& weights = quad->getQuadWeights();
217  quad->getQuadPoints();
220  OrdinalType nqp = weights.size();
221 
222  // Initialize
223  for (OrdinalType i=0; i<c.size(); i++)
224  c[i] = 0.0;
225 
226  // Compute PCE via quadrature
227  Func func;
228  for (OrdinalType k=0; k<nqp; k++) {
229  ValueType val1 = a.evaluate(points[k], values[k]);
230  ValueType val = func(val1, b);
231  for (int i=0; i<c.size(); i++)
232  c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
233  }
234  }
235 
236  };
237 
239 
240  struct UMinusFunc {
241  double operator() (double a) const { return -a; }
242  };
243 
244  struct ASinhFunc {
245  double operator() (double a) const {
246  return std::log(a+std::sqrt(a*a+1.0));
247  }
248  };
249  struct ACoshFunc {
250  double operator() (double a) const {
251  return std::log(a+std::sqrt(a*a-1.0));
252  }
253  };
254  struct ATanhFunc {
255  double operator() (double a) const {
256  return 0.5*std::log((1.0+a)/(1.0-a));
257  }
258  };
259 
260  struct PlusFunc {
261  double operator() (double a, double b) const { return a + b; }
262  };
263  struct MinusFunc {
264  double operator() (double a, double b) const { return a - b; }
265  };
266  struct TimesFunc {
267  double operator() (double a, double b) const { return a * b; }
268  };
269  struct DivideFunc {
270  double operator() (double a, double b) const { return a / b; }
271  };
272 
273  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, UMinus ) {
275  setup.qexp->sin(v, setup.x);
276  setup.exp->unaryMinus(setup.u, v);
277  setup.computePCE1<UMinusFunc>(setup.u2, v);
278  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
279  setup.rtol, setup.atol, out);
280  }
281  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ExpConst ) {
282  setup.exp->exp(setup.cu, setup.cx);
283  setup.cu2[0] = std::exp(setup.cx[0]);
284  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
285  setup.crtol, setup.catol, out);
286  }
287  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, LogConst ) {
288  setup.exp->log(setup.cu, setup.cx);
289  setup.cu2[0] = std::log(setup.cx[0]);
290  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
291  setup.crtol, setup.catol, out);
292  }
293  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Log10Const ) {
294  setup.exp->log10(setup.cu, setup.cx);
295  setup.cu2[0] = std::log10(setup.cx[0]);
296  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
297  setup.crtol, setup.catol, out);
298  }
299  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, SqrtConst ) {
300  setup.exp->sqrt(setup.cu, setup.cx);
301  setup.cu2[0] = std::sqrt(setup.cx[0]);
302  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
303  setup.crtol, setup.catol, out);
304  }
305  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, CbrtConst ) {
306  setup.exp->cbrt(setup.cu, setup.cx);
307  setup.cu2[0] = std::cbrt(setup.cx[0]);
308  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
309  setup.crtol, setup.catol, out);
310  }
311  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, SinConst ) {
312  setup.exp->sin(setup.cu, setup.cx);
313  setup.cu2[0] = std::sin(setup.cx[0]);
314  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
315  setup.crtol, setup.catol, out);
316  }
317  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, CosConst ) {
318  setup.exp->cos(setup.cu, setup.cx);
319  setup.cu2[0] = std::cos(setup.cx[0]);
320  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
321  setup.crtol, setup.catol, out);
322  }
323  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TanConst ) {
324  setup.exp->tan(setup.cu, setup.cx);
325  setup.cu2[0] = std::tan(setup.cx[0]);
326  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
327  setup.crtol, setup.catol, out);
328  }
329  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, SinhConst ) {
330  setup.exp->sinh(setup.cu, setup.cx);
331  setup.cu2[0] = std::sinh(setup.cx[0]);
332  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
333  setup.crtol, setup.catol, out);
334  }
335  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, CoshConst ) {
336  setup.exp->cosh(setup.cu, setup.cx);
337  setup.cu2[0] = std::cosh(setup.cx[0]);
338  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
339  setup.crtol, setup.catol, out);
340  }
341  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TanhConst ) {
342  setup.exp->tanh(setup.cu, setup.cx);
343  setup.cu2[0] = std::tanh(setup.cx[0]);
344  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
345  setup.crtol, setup.catol, out);
346  }
347  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ASinConst ) {
348  setup.exp->asin(setup.cu, setup.cx);
349  setup.cu2[0] = std::asin(setup.cx[0]);
350  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
351  setup.crtol, setup.catol, out);
352  }
353  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ACosConst ) {
354  setup.exp->acos(setup.cu, setup.cx);
355  setup.cu2[0] = std::acos(setup.cx[0]);
356  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
357  setup.crtol, setup.catol, out);
358  }
359  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ATanConst ) {
360  setup.exp->atan(setup.cu, setup.cx);
361  setup.cu2[0] = std::atan(setup.cx[0]);
362  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
363  setup.crtol, setup.catol, out);
364  }
365  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ASinhConst ) {
366  ASinhFunc f;
367  setup.exp->asinh(setup.cu, setup.cx);
368  setup.cu2[0] = f(setup.cx[0]);
369  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
370  setup.crtol, setup.catol, out);
371  }
372  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ACoshConst ) {
373  ACoshFunc f;
374  setup.exp->acosh(setup.cu, setup.cx);
375  setup.cu2[0] = f(setup.cx[0]);
376  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
377  setup.crtol, setup.catol, out);
378  }
379  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, ATanhConst ) {
380  ATanhFunc f;
381  setup.exp->atanh(setup.cu, setup.cx);
382  setup.cu2[0] = f(setup.cx[0]);
383  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
384  setup.crtol, setup.catol, out);
385  }
386 
387  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Plus ) {
389  setup.qexp->sin(v, setup.x);
390  setup.qexp->cos(w, setup.y);
391  setup.exp->plus(setup.u, v, w);
392  setup.computePCE2<PlusFunc>(setup.u2, v, w);
393  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
394  setup.rtol, setup.atol, out);
395  }
396  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLC ) {
398  setup.qexp->sin(v, setup.x);
399  setup.exp->plus(setup.u, setup.a, v);
400  setup.computePCE2LC<PlusFunc>(setup.u2, setup.a, v);
401  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
402  setup.rtol, setup.atol, out);
403  }
404  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRC ) {
406  setup.qexp->sin(v, setup.x);
407  setup.exp->plus(setup.u, v, setup.a);
408  setup.computePCE2RC<PlusFunc>(setup.u2, v, setup.a);
409  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
410  setup.rtol, setup.atol, out);
411  }
412  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusCC ) {
413  setup.exp->plus(setup.cu, setup.cx, setup.cx);
414  setup.computePCE2<PlusFunc>(setup.cu2, setup.cx, setup.cx);
415  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
416  setup.rtol, setup.atol, out);
417  }
418  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLC2 ) {
420  setup.qexp->sin(v, setup.x);
421  setup.exp->plus(setup.u, setup.cx, v);
422  setup.computePCE2LC<PlusFunc>(setup.u2, setup.cx[0], v);
423  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
424  setup.rtol, setup.atol, out);
425  }
426  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRC2 ) {
428  setup.qexp->sin(v, setup.x);
429  setup.exp->plus(setup.u, v, setup.cx);
430  setup.computePCE2RC<PlusFunc>(setup.u2, v, setup.cx[0]);
431  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
432  setup.rtol, setup.atol, out);
433  }
434  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusResize ) {
437  setup.qexp->sin(v, setup.x);
438  setup.qexp->cos(w, setup.y);
439  setup.exp->plus(ru, v, w);
440  setup.computePCE2<PlusFunc>(setup.u2, v, w);
441  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
442  setup.rtol, setup.atol, out);
443  }
444  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLCResize ) {
447  setup.qexp->sin(v, setup.x);
448  setup.exp->plus(ru, setup.a, v);
449  setup.computePCE2LC<PlusFunc>(setup.u2, setup.a, v);
450  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
451  setup.rtol, setup.atol, out);
452  }
453  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRCResize ) {
456  setup.qexp->sin(v, setup.x);
457  setup.exp->plus(ru, v, setup.a);
458  setup.computePCE2RC<PlusFunc>(setup.u2, v, setup.a);
459  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
460  setup.rtol, setup.atol, out);
461  }
462  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLS ) {
464  setup.qexp->sin(v, setup.x);
465  setup.exp->plus(setup.u, setup.sx, v);
466  setup.computePCE2<PlusFunc>(setup.u2, setup.sx, v);
467  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
468  setup.rtol, setup.atol, out);
469  }
470  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRS ) {
472  setup.qexp->sin(v, setup.x);
473  setup.exp->plus(setup.u, v, setup.sx);
474  setup.computePCE2<PlusFunc>(setup.u2, v, setup.sx);
475  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
476  setup.rtol, setup.atol, out);
477  }
478  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLSRC ) {
479  setup.exp->plus(setup.su, setup.sx, setup.a);
480  setup.computePCE2RC<PlusFunc>(setup.su2, setup.sx, setup.a);
481  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
482  setup.rtol, setup.atol, out);
483  }
484  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRSLC ) {
485  setup.exp->plus(setup.su, setup.a, setup.sx);
486  setup.computePCE2LC<PlusFunc>(setup.su2, setup.a, setup.sx);
487  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
488  setup.rtol, setup.atol, out);
489  }
490  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusLSRC2 ) {
491  setup.exp->plus(setup.su, setup.sx, setup.cx);
492  setup.computePCE2<PlusFunc>(setup.su2, setup.sx, setup.cx);
493  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
494  setup.rtol, setup.atol, out);
495  }
496  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusRSLC2 ) {
497  setup.exp->plus(setup.su, setup.cx, setup.sx);
498  setup.computePCE2<PlusFunc>(setup.su2, setup.cx, setup.sx);
499  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
500  setup.rtol, setup.atol, out);
501  }
502 
503  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Minus ) {
505  setup.qexp->sin(v, setup.x);
506  setup.qexp->cos(w, setup.y);
507  setup.exp->minus(setup.u, v, w);
508  setup.computePCE2<MinusFunc>(setup.u2, v, w);
509  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
510  setup.rtol, setup.atol, out);
511  }
512  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLC ) {
514  setup.qexp->sin(v, setup.x);
515  setup.exp->minus(setup.u, setup.a, v);
516  setup.computePCE2LC<MinusFunc>(setup.u2, setup.a, v);
517  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
518  setup.rtol, setup.atol, out);
519  }
520  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRC ) {
522  setup.qexp->sin(v, setup.x);
523  setup.exp->minus(setup.u, v, setup.a);
524  setup.computePCE2RC<MinusFunc>(setup.u2, v, setup.a);
525  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
526  setup.rtol, setup.atol, out);
527  }
528  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusCC ) {
529  setup.exp->minus(setup.cu, setup.cx, setup.cx);
530  setup.computePCE2<MinusFunc>(setup.cu2, setup.cx, setup.cx);
531  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
532  setup.rtol, setup.atol, out);
533  }
534  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLC2 ) {
536  setup.qexp->sin(v, setup.x);
537  setup.exp->minus(setup.u, setup.cx, v);
538  setup.computePCE2LC<MinusFunc>(setup.u2, setup.cx[0], v);
539  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
540  setup.rtol, setup.atol, out);
541  }
542  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRC2 ) {
544  setup.qexp->sin(v, setup.x);
545  setup.exp->minus(setup.u, v, setup.cx);
546  setup.computePCE2RC<MinusFunc>(setup.u2, v, setup.cx[0]);
547  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
548  setup.rtol, setup.atol, out);
549  }
550  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusResize ) {
553  setup.qexp->sin(v, setup.x);
554  setup.qexp->cos(w, setup.y);
555  setup.exp->minus(ru, v, w);
556  setup.computePCE2<MinusFunc>(setup.u2, v, w);
557  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
558  setup.rtol, setup.atol, out);
559  }
560  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLCResize ) {
563  setup.qexp->sin(v, setup.x);
564  setup.exp->minus(ru, setup.a, v);
565  setup.computePCE2LC<MinusFunc>(setup.u2, setup.a, v);
566  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
567  setup.rtol, setup.atol, out);
568  }
569  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRCResize ) {
572  setup.qexp->sin(v, setup.x);
573  setup.exp->minus(ru, v, setup.a);
574  setup.computePCE2RC<MinusFunc>(setup.u2, v, setup.a);
575  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
576  setup.rtol, setup.atol, out);
577  }
578  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLS ) {
580  setup.qexp->sin(v, setup.x);
581  setup.exp->minus(setup.u, setup.sx, v);
582  setup.computePCE2<MinusFunc>(setup.u2, setup.sx, v);
583  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
584  setup.rtol, setup.atol, out);
585  }
586  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRS ) {
588  setup.qexp->sin(v, setup.x);
589  setup.exp->minus(setup.u, v, setup.sx);
590  setup.computePCE2<MinusFunc>(setup.u2, v, setup.sx);
591  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
592  setup.rtol, setup.atol, out);
593  }
594  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLSRC ) {
595  setup.exp->minus(setup.su, setup.sx, setup.a);
596  setup.computePCE2RC<MinusFunc>(setup.su2, setup.sx, setup.a);
597  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
598  setup.rtol, setup.atol, out);
599  }
600  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRSLC ) {
601  setup.exp->minus(setup.su, setup.a, setup.sx);
602  setup.computePCE2LC<MinusFunc>(setup.su2, setup.a, setup.sx);
603  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
604  setup.rtol, setup.atol, out);
605  }
606  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusLSRC2 ) {
607  setup.exp->minus(setup.su, setup.sx, setup.cx);
608  setup.computePCE2<MinusFunc>(setup.su2, setup.sx, setup.cx);
609  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
610  setup.rtol, setup.atol, out);
611  }
612  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusRSLC2 ) {
613  setup.exp->minus(setup.su, setup.cx, setup.sx);
614  setup.computePCE2<MinusFunc>(setup.su2, setup.cx, setup.sx);
615  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
616  setup.rtol, setup.atol, out);
617  }
618 
619  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, Times ) {
621  setup.qexp->sin(v, setup.x);
622  setup.qexp->cos(w, setup.y);
623  setup.exp->times(setup.u, v, w);
624  setup.computePCE2<TimesFunc>(setup.u2, v, w);
625  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
626  setup.rtol, setup.atol, out);
627  }
628  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLC ) {
630  setup.qexp->sin(v, setup.x);
631  setup.exp->times(setup.u, setup.a, v);
632  setup.computePCE2LC<TimesFunc>(setup.u2, setup.a, v);
633  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
634  setup.rtol, setup.atol, out);
635  }
636  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRC ) {
638  setup.qexp->sin(v, setup.x);
639  setup.exp->times(setup.u, v, setup.a);
640  setup.computePCE2RC<TimesFunc>(setup.u2, v, setup.a);
641  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
642  setup.rtol, setup.atol, out);
643  }
644  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesCC ) {
645  setup.exp->times(setup.cu, setup.cx, setup.cx);
646  setup.computePCE2<TimesFunc>(setup.cu2, setup.cx, setup.cx);
647  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
648  setup.rtol, setup.atol, out);
649  }
650  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLC2 ) {
652  setup.qexp->sin(v, setup.x);
653  setup.exp->times(setup.u, setup.cx, v);
654  setup.computePCE2LC<TimesFunc>(setup.u2, setup.cx[0], v);
655  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
656  setup.rtol, setup.atol, out);
657  }
658  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRC2 ) {
660  setup.qexp->sin(v, setup.x);
661  setup.exp->times(setup.u, v, setup.cx);
662  setup.computePCE2RC<TimesFunc>(setup.u2, v, setup.cx[0]);
663  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
664  setup.rtol, setup.atol, out);
665  }
666  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesResize ) {
669  setup.qexp->sin(v, setup.x);
670  setup.qexp->cos(w, setup.y);
671  setup.exp->times(ru, v, w);
672  setup.computePCE2<TimesFunc>(setup.u2, v, w);
673  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
674  setup.rtol, setup.atol, out);
675  }
676  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLCResize ) {
679  setup.qexp->sin(v, setup.x);
680  setup.exp->times(ru, setup.a, v);
681  setup.computePCE2LC<TimesFunc>(setup.u2, setup.a, v);
682  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
683  setup.rtol, setup.atol, out);
684  }
685  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRCResize ) {
688  setup.qexp->sin(v, setup.x);
689  setup.exp->times(ru, v, setup.a);
690  setup.computePCE2RC<TimesFunc>(setup.u2, v, setup.a);
691  success = Stokhos::comparePCEs(ru, "ru", setup.u2, "u2",
692  setup.rtol, setup.atol, out);
693  }
694  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLS ) {
696  setup.qexp->sin(v, setup.x);
697  setup.exp->times(setup.u, setup.sx, v);
698  setup.computePCE2<TimesFunc>(setup.u2, setup.sx, v);
699  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
700  setup.rtol, setup.atol, out);
701  }
702  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRS ) {
704  setup.qexp->sin(v, setup.x);
705  setup.exp->times(setup.u, v, setup.sx);
706  setup.computePCE2<TimesFunc>(setup.u2, v, setup.sx);
707  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
708  setup.rtol, setup.atol, out);
709  }
710  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLSLinear ) {
712  setup.qexp->sin(v, setup.x);
713  setup.exp_linear->times(setup.u, setup.sx, v);
714  setup.computePCE2<TimesFunc>(setup.u2, setup.sx, v);
715  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
716  setup.rtol, setup.atol, out);
717  }
718  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRSLinear ) {
720  setup.qexp->sin(v, setup.x);
721  setup.exp_linear->times(setup.u, v, setup.sx);
722  setup.computePCE2<TimesFunc>(setup.u2, v, setup.sx);
723  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
724  setup.rtol, setup.atol, out);
725  }
726  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLSRC ) {
727  setup.exp->times(setup.su, setup.sx, setup.a);
728  setup.computePCE2RC<TimesFunc>(setup.su2, setup.sx, setup.a);
729  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
730  setup.rtol, setup.atol, out);
731  }
732  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRSLC ) {
733  setup.exp->times(setup.su, setup.a, setup.sx);
734  setup.computePCE2LC<TimesFunc>(setup.su2, setup.a, setup.sx);
735  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
736  setup.rtol, setup.atol, out);
737  }
738  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesLSRC2 ) {
739  setup.exp->times(setup.su, setup.sx, setup.cx);
740  setup.computePCE2<TimesFunc>(setup.su2, setup.sx, setup.cx);
741  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
742  setup.rtol, setup.atol, out);
743  }
744  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesRSLC2 ) {
745  setup.exp->times(setup.su, setup.cx, setup.sx);
746  setup.computePCE2<TimesFunc>(setup.su2, setup.cx, setup.sx);
747  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
748  setup.rtol, setup.atol, out);
749  }
750 
751 
752  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideRC ) {
754  setup.qexp->sin(v, setup.x);
755  setup.exp->divide(setup.u, v, setup.a);
756  setup.computePCE2RC<DivideFunc>(setup.u2, v, setup.a);
757  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
758  setup.rtol, setup.atol, out);
759  }
760  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideCC ) {
761  setup.exp->divide(setup.cu, setup.cx, setup.cx);
762  setup.computePCE2<DivideFunc>(setup.cu2, setup.cx, setup.cx);
763  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
764  setup.rtol, setup.atol, out);
765  }
766  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideRC2 ) {
768  setup.qexp->sin(v, setup.x);
769  setup.exp->divide(setup.u, v, setup.cx);
770  setup.computePCE2RC<DivideFunc>(setup.u2, v, setup.cx[0]);
771  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
772  setup.rtol, setup.atol, out);
773  }
774  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideRCResize ) {
777  setup.qexp->sin(v, setup.x);
778  setup.exp->divide(ru, v, setup.a);
779  setup.computePCE2RC<DivideFunc>(setup.u2, v, setup.a);
780  success = Stokhos::comparePCEs(ru, "u", setup.u2, "u2",
781  setup.rtol, setup.atol, out);
782  }
783  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideLSRC ) {
784  setup.exp->divide(setup.su, setup.sx, setup.a);
785  setup.computePCE2RC<DivideFunc>(setup.su2, setup.sx, setup.a);
786  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
787  setup.rtol, setup.atol, out);
788  }
789  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideLSRC2 ) {
790  setup.exp->divide(setup.su, setup.sx, setup.cx);
791  setup.computePCE2<DivideFunc>(setup.su2, setup.sx, setup.cx);
792  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
793  setup.rtol, setup.atol, out);
794  }
795 
796  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PowConst ) {
797  setup.exp->pow(setup.cu, setup.cx, setup.cx);
798  setup.cu2[0] = std::pow(setup.cx[0], setup.cx[0]);
799  success = Stokhos::comparePCEs(setup.cu, "cu", setup.cu2, "cu2",
800  setup.crtol, setup.catol, out);
801  }
802 
803  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqual ) {
805  setup.qexp->sin(v, setup.x);
806  setup.qexp->cos(setup.u, setup.x);
807  setup.computePCE2<PlusFunc>(setup.u2, setup.u, v);
808  setup.exp->plusEqual(setup.u, v);
809  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
810  setup.rtol, setup.atol, out);
811  }
812  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualC ) {
813  setup.qexp->cos(setup.u, setup.x);
814  setup.computePCE2RC<PlusFunc>(setup.u2, setup.u, setup.a);
815  setup.exp->plusEqual(setup.u, setup.a);
816  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
817  setup.rtol, setup.atol, out);
818  }
819  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualC2 ) {
820  setup.qexp->cos(setup.u, setup.x);
821  setup.computePCE2RC<PlusFunc>(setup.u2, setup.u, setup.cx[0]);
822  setup.exp->plusEqual(setup.u, setup.cx);
823  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
824  setup.rtol, setup.atol, out);
825  }
826  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualResize ) {
829  setup.qexp->sin(v, setup.x);
830  setup.exp->plusEqual(ru, v);
831  success = Stokhos::comparePCEs(ru, "ru", v, "v",
832  setup.rtol, setup.atol, out);
833  }
834  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualS ) {
835  setup.qexp->cos(setup.u, setup.x);
836  setup.computePCE2<PlusFunc>(setup.u2, setup.u, setup.sx);
837  setup.exp->plusEqual(setup.u, setup.sx);
838  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
839  setup.rtol, setup.atol, out);
840  }
841  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualSC ) {
842  setup.su = setup.sx;
843  setup.computePCE2RC<PlusFunc>(setup.su2, setup.su, setup.a);
844  setup.exp->plusEqual(setup.su, setup.a);
845  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
846  setup.rtol, setup.atol, out);
847  }
848  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, PlusEqualSC2 ) {
849  setup.su = setup.sx;
850  setup.computePCE2<PlusFunc>(setup.su2, setup.su, setup.cx);
851  setup.exp->plusEqual(setup.su, setup.cx);
852  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
853  setup.rtol, setup.atol, out);
854  }
855 
856  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqual ) {
858  setup.qexp->sin(v, setup.x);
859  setup.qexp->cos(setup.u, setup.x);
860  setup.computePCE2<MinusFunc>(setup.u2, setup.u, v);
861  setup.exp->minusEqual(setup.u, v);
862  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
863  setup.rtol, setup.atol, out);
864  }
865  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualC ) {
866  setup.qexp->cos(setup.u, setup.x);
867  setup.computePCE2RC<MinusFunc>(setup.u2, setup.u, setup.a);
868  setup.exp->minusEqual(setup.u, setup.a);
869  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
870  setup.rtol, setup.atol, out);
871  }
872  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualC2 ) {
873  setup.qexp->cos(setup.u, setup.x);
874  setup.computePCE2RC<MinusFunc>(setup.u2, setup.u, setup.cx[0]);
875  setup.exp->minusEqual(setup.u, setup.cx);
876  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
877  setup.rtol, setup.atol, out);
878  }
879  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualResize ) {
882  setup.qexp->sin(v, setup.x);
883  setup.exp->minusEqual(ru, v);
884  setup.exp->unaryMinus(v, v);
885  success = Stokhos::comparePCEs(ru, "ru", v, "v",
886  setup.rtol, setup.atol, out);
887  }
888  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualS ) {
889  setup.qexp->cos(setup.u, setup.x);
890  setup.computePCE2<MinusFunc>(setup.u2, setup.u, setup.sx);
891  setup.exp->minusEqual(setup.u, setup.sx);
892  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
893  setup.rtol, setup.atol, out);
894  }
895  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualSC ) {
896  setup.su = setup.sx;
897  setup.computePCE2RC<MinusFunc>(setup.su2, setup.su, setup.a);
898  setup.exp->minusEqual(setup.su, setup.a);
899  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
900  setup.rtol, setup.atol, out);
901  }
902  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, MinusEqualSC2 ) {
903  setup.su = setup.sx;
904  setup.computePCE2<MinusFunc>(setup.su2, setup.su, setup.cx);
905  setup.exp->minusEqual(setup.su, setup.cx);
906  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
907  setup.rtol, setup.atol, out);
908  }
909 
910  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqual ) {
912  setup.qexp->sin(v, setup.x);
913  setup.qexp->cos(setup.u, setup.x);
914  setup.computePCE2<TimesFunc>(setup.u2, setup.u, v);
915  setup.exp->timesEqual(setup.u, v);
916  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
917  setup.rtol, setup.atol, out);
918  }
919  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualC ) {
920  setup.qexp->cos(setup.u, setup.x);
921  setup.computePCE2RC<TimesFunc>(setup.u2, setup.u, setup.a);
922  setup.exp->timesEqual(setup.u, setup.a);
923  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
924  setup.rtol, setup.atol, out);
925  }
926  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualC2 ) {
927  setup.qexp->cos(setup.u, setup.x);
928  setup.computePCE2RC<TimesFunc>(setup.u2, setup.u, setup.cx[0]);
929  setup.exp->timesEqual(setup.u, setup.cx);
930  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
931  setup.rtol, setup.atol, out);
932  }
933  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualResize ) {
935  setup.qexp->sin(v, setup.x);
936  setup.su = setup.sx;
937  setup.computePCE2<TimesFunc>(setup.u2, setup.su, v);
938  setup.exp->timesEqual(setup.su, v);
939  success = Stokhos::comparePCEs(setup.su, "su", setup.u2, "u2",
940  setup.rtol, setup.atol, out);
941  }
942  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualS ) {
943  setup.qexp->cos(setup.u, setup.x);
944  setup.computePCE2<TimesFunc>(setup.u2, setup.u, setup.sx);
945  setup.exp->timesEqual(setup.u, setup.sx);
946  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
947  setup.rtol, setup.atol, out);
948  }
949  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualSLinear ) {
950  setup.qexp->cos(setup.u, setup.x);
951  setup.computePCE2<TimesFunc>(setup.u2, setup.u, setup.sx);
952  setup.exp_linear->timesEqual(setup.u, setup.sx);
953  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
954  setup.rtol, setup.atol, out);
955  }
956  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualSC ) {
957  setup.su = setup.sx;
958  setup.computePCE2RC<TimesFunc>(setup.su2, setup.su, setup.a);
959  setup.exp->timesEqual(setup.su, setup.a);
960  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
961  setup.rtol, setup.atol, out);
962  }
963  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, TimesEqualSC2 ) {
964  setup.su = setup.sx;
965  setup.computePCE2<TimesFunc>(setup.su2, setup.su, setup.cx);
966  setup.exp->timesEqual(setup.su, setup.cx);
967  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
968  setup.rtol, setup.atol, out);
969  }
970 
971  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualC ) {
972  setup.qexp->cos(setup.u, setup.x);
973  setup.computePCE2RC<DivideFunc>(setup.u2, setup.u, setup.a);
974  setup.exp->divideEqual(setup.u, setup.a);
975  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
976  setup.rtol, setup.atol, out);
977  }
978  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualC2 ) {
979  setup.qexp->cos(setup.u, setup.x);
980  setup.computePCE2RC<DivideFunc>(setup.u2, setup.u, setup.cx[0]);
981  setup.exp->divideEqual(setup.u, setup.cx);
982  success = Stokhos::comparePCEs(setup.u, "u", setup.u2, "u2",
983  setup.rtol, setup.atol, out);
984  }
985  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualSC ) {
986  setup.su = setup.sx;
987  setup.computePCE2RC<DivideFunc>(setup.su2, setup.su, setup.a);
988  setup.exp->divideEqual(setup.su, setup.a);
989  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
990  setup.rtol, setup.atol, out);
991  }
992  TEUCHOS_UNIT_TEST( Stokhos_AlgebraicExpansion, DivideEqualSC2 ) {
993  setup.su = setup.sx;
994  setup.computePCE2<DivideFunc>(setup.su2, setup.su, setup.cx);
995  setup.exp->divideEqual(setup.su, setup.cx);
996  success = Stokhos::comparePCEs(setup.su, "su", setup.su2, "su2",
997  setup.rtol, setup.atol, out);
998  }
999 
1000  // Not testing atan2(), max(), min(), abs(), fabs() since these are
1001  // not smooth functions
1002 
1003 }
1004 
1005 int main( int argc, char* argv[] ) {
1006  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
1008 }
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