Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test
UnitTest
Stokhos_SacadoPCEUnitTest.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Stokhos Package
5
// Copyright (2009) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
namespace
SacadoPCEUnitTest
{
43
44
// Common setup for unit tests
45
template
<
typename
PCEType>
46
struct
UnitTestSetup
{
47
48
typedef
PCEType
pce_type
;
49
typedef
Stokhos::OrthogPolyApprox<int,double>
opa_type
;
50
double
rtol
,
atol
;
51
double
crtol
,
catol
;
52
int
sz
;
53
Teuchos::RCP<const Stokhos::CompletePolynomialBasis<int,double> >
basis
;
54
Teuchos::RCP<const Stokhos::Quadrature<int,double> >
quad
;
55
Teuchos::RCP<Stokhos::Sparse3Tensor<int,double> >
Cijk
;
56
Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion<int,double> >
exp
;
57
pce_type
x
,
y
,
u
,
u2
,
cx
,
cu
,
cu2
,
sx
,
su
,
su2
;
58
double
a
;
59
60
UnitTestSetup
() {
61
rtol
= 1e-4;
62
atol
= 1e-5;
63
crtol
= 1e-12;
64
catol
= 1e-12;
65
a
= 3.1;
66
const
int
d = 2;
67
const
int
p = 7;
68
69
// Create product basis
70
Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<int,double> > > bases(d);
71
for
(
int
i=0; i<d; i++)
72
bases[i] =
73
Teuchos::rcp(
new
Stokhos::LegendreBasis<int,double>
(p));
74
basis
=
75
Teuchos::rcp(
new
Stokhos::CompletePolynomialBasis<int,double>
(bases));
76
77
// Tensor product quadrature
78
quad
=
79
Teuchos::rcp(
new
Stokhos::TensorProductQuadrature<int,double>
(
basis
));
80
81
// Triple product tensor
82
Cijk
=
basis
->computeTripleProductTensor();
83
84
// Quadrature expansion
85
exp
=
86
Teuchos::rcp(
new
Stokhos::QuadOrthogPolyExpansion<int,double>
(
basis
,
Cijk
,
quad
));
87
88
// Create approximation
89
sz
=
basis
->size();
90
x
.reset(
exp
);
91
y
.reset(
exp
);
92
u
.reset(
exp
);
93
u2
.reset(
exp
);
94
cx
.reset(
exp
, 1);
95
x
.term(0, 0) = 1.0;
96
cx
.term(0, 0) =
a
;
97
cu
.reset(
exp
);
98
cu2
.reset(
exp
, 1);
99
sx
.reset(
exp
, d+1);
100
su
.reset(
exp
, d+1);
101
su2
.reset(
exp
, d+1);
102
for
(
int
i=0; i<d; i++) {
103
x
.term(i, 1) = 0.1;
104
sx
.term(i, 1) = 0.0;
105
}
106
y
.term(0, 0) = 2.0;
107
for
(
int
i=0; i<d; i++)
108
y
.term(i, 1) = 0.25;
109
}
110
};
111
112
typedef
UnitTestSetup<pce_type>
UTS
;
113
UTS
setup
;
114
115
TEUCHOS_UNIT_TEST
( Stokhos_PCE, UMinus) {
116
UTS::pce_type
v = std::sin(
setup
.x);
117
UTS::pce_type
u = -v;
118
UTS::opa_type
u_opa(
setup
.basis);
119
setup
.exp->unaryMinus(u_opa, v.getOrthogPolyApprox());
120
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
121
u_opa,
"u_opa"
,
122
setup
.rtol,
setup
.atol, out);
123
}
124
125
#define UNARY_UNIT_TEST(OP) \
126
TEUCHOS_UNIT_TEST( Stokhos_PCE, OP) { \
127
UTS::pce_type u = OP(setup.x); \
128
UTS::opa_type u_opa(setup.basis); \
129
setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
130
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
131
u_opa, "u_opa", \
132
setup.rtol, setup.atol, out); \
133
} \
134
TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_const) { \
135
UTS::pce_type u = OP(setup.cx); \
136
UTS::opa_type u_opa(setup.basis); \
137
setup.exp->OP(u_opa, setup.cx.getOrthogPolyApprox()); \
138
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
139
u_opa, "u_opa", \
140
setup.rtol, setup.atol, out); \
141
} \
142
TEUCHOS_UNIT_TEST( Stokhos_PCE, OP##_resize) { \
143
UTS::pce_type u; \
144
u = OP(setup.x); \
145
UTS::opa_type u_opa(setup.basis); \
146
setup.exp->OP(u_opa, setup.x.getOrthogPolyApprox()); \
147
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
148
u_opa, "u_opa", \
149
setup.rtol, setup.atol, out); \
150
}
151
152
UNARY_UNIT_TEST
(
exp
)
153
UNARY_UNIT_TEST
(log)
154
UNARY_UNIT_TEST
(
log10
)
155
UNARY_UNIT_TEST
(
sqrt
)
156
UNARY_UNIT_TEST
(
cbrt
)
157
UNARY_UNIT_TEST
(
sin
)
158
UNARY_UNIT_TEST
(
cos
)
159
UNARY_UNIT_TEST
(
tan
)
160
UNARY_UNIT_TEST
(
sinh
)
161
UNARY_UNIT_TEST
(
cosh
)
162
UNARY_UNIT_TEST
(
tanh
)
163
UNARY_UNIT_TEST
(
asin
)
164
UNARY_UNIT_TEST
(
acos
)
165
UNARY_UNIT_TEST
(
atan
)
166
UNARY_UNIT_TEST
(
asinh
)
167
UNARY_UNIT_TEST
(
acosh
)
168
UNARY_UNIT_TEST
(
atanh
)
169
170
#define BINARY_UNIT_TEST(OP, EXPOP) \
171
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP) { \
172
UTS::pce_type v = std::sin(setup.x); \
173
UTS::pce_type w = std::cos(setup.x); \
174
UTS::pce_type u = OP(v,w); \
175
UTS::opa_type u_opa(setup.basis); \
176
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
177
w.getOrthogPolyApprox()); \
178
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
179
u_opa, "u_opa", \
180
setup.rtol, setup.atol, out); \
181
} \
182
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const) { \
183
UTS::pce_type w = std::cos(setup.x); \
184
UTS::pce_type u = OP(setup.a, w); \
185
UTS::opa_type u_opa(setup.basis); \
186
setup.exp->EXPOP(u_opa, setup.a, \
187
w.getOrthogPolyApprox()); \
188
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
189
u_opa, "u_opa", \
190
setup.rtol, setup.atol, out); \
191
} \
192
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const) { \
193
UTS::pce_type v = std::sin(setup.x); \
194
UTS::pce_type u = OP(v, setup.a); \
195
UTS::opa_type u_opa(setup.basis); \
196
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
197
setup.a); \
198
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
199
u_opa, "u_opa", \
200
setup.rtol, setup.atol, out); \
201
} \
202
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_both_const) { \
203
UTS::pce_type u = OP(setup.cx, setup.cx); \
204
UTS::opa_type u_opa(setup.basis); \
205
setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
206
setup.cx.getOrthogPolyApprox()); \
207
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
208
u_opa, "u_opa", \
209
setup.rtol, setup.atol, out); \
210
} \
211
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const2) { \
212
UTS::pce_type w = std::cos(setup.x); \
213
UTS::pce_type u = OP(setup.cx, w); \
214
UTS::opa_type u_opa(setup.basis); \
215
setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
216
w.getOrthogPolyApprox()); \
217
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
218
u_opa, "u_opa", \
219
setup.rtol, setup.atol, out); \
220
} \
221
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const2) { \
222
UTS::pce_type v = std::sin(setup.x); \
223
UTS::pce_type u = OP(v, setup.cx); \
224
UTS::opa_type u_opa(setup.basis); \
225
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
226
setup.cx.getOrthogPolyApprox()); \
227
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
228
u_opa, "u_opa", \
229
setup.rtol, setup.atol, out); \
230
} \
231
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_resize) { \
232
UTS::pce_type v = std::sin(setup.x); \
233
UTS::pce_type w = std::cos(setup.x); \
234
UTS::pce_type u; \
235
u = OP(v, w); \
236
UTS::opa_type u_opa(setup.basis); \
237
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
238
w.getOrthogPolyApprox()); \
239
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
240
u_opa, "u_opa", \
241
setup.rtol, setup.atol, out); \
242
} \
243
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_const_resize) { \
244
UTS::pce_type w = std::cos(setup.x); \
245
UTS::pce_type u; \
246
u = OP(setup.a, w); \
247
UTS::opa_type u_opa(setup.basis); \
248
setup.exp->EXPOP(u_opa, setup.a, \
249
w.getOrthogPolyApprox()); \
250
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
251
u_opa, "u_opa", \
252
setup.rtol, setup.atol, out); \
253
} \
254
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_const_resize) { \
255
UTS::pce_type v = std::sin(setup.x); \
256
UTS::pce_type u; \
257
u = OP(v, setup.a); \
258
UTS::opa_type u_opa(setup.basis); \
259
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
260
setup.a); \
261
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
262
u_opa, "u_opa", \
263
setup.rtol, setup.atol, out); \
264
} \
265
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short) { \
266
UTS::pce_type w = std::cos(setup.x); \
267
UTS::pce_type u = OP(setup.sx, w); \
268
UTS::opa_type u_opa(setup.basis); \
269
setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
270
w.getOrthogPolyApprox()); \
271
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
272
u_opa, "u_opa", \
273
setup.rtol, setup.atol, out); \
274
} \
275
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short) { \
276
UTS::pce_type v = std::sin(setup.x); \
277
UTS::pce_type u = OP(v, setup.sx); \
278
UTS::opa_type u_opa(setup.basis); \
279
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
280
setup.sx.getOrthogPolyApprox()); \
281
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
282
u_opa, "u_opa", \
283
setup.rtol, setup.atol, out); \
284
} \
285
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_both_short) { \
286
UTS::pce_type u = OP(setup.sx, setup.sx); \
287
UTS::opa_type u_opa(setup.basis); \
288
setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
289
setup.sx.getOrthogPolyApprox()); \
290
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
291
u_opa, "u_opa", \
292
setup.rtol, setup.atol, out); \
293
} \
294
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_resize) { \
295
UTS::pce_type w = std::cos(setup.x); \
296
UTS::pce_type u; \
297
u = OP(setup.sx, w); \
298
UTS::opa_type u_opa(setup.basis); \
299
setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
300
w.getOrthogPolyApprox()); \
301
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
302
u_opa, "u_opa", \
303
setup.rtol, setup.atol, out); \
304
} \
305
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_resize) { \
306
UTS::pce_type v = std::sin(setup.x); \
307
UTS::pce_type u; \
308
u = OP(v, setup.sx); \
309
UTS::opa_type u_opa(setup.basis); \
310
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox(), \
311
setup.sx.getOrthogPolyApprox()); \
312
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
313
u_opa, "u_opa", \
314
setup.rtol, setup.atol, out); \
315
} \
316
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_right_const) { \
317
UTS::pce_type u = OP(setup.sx, setup.a); \
318
UTS::opa_type u_opa(setup.basis); \
319
setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
320
setup.a); \
321
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
322
u_opa, "u_opa", \
323
setup.rtol, setup.atol, out); \
324
} \
325
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_left_const) { \
326
UTS::pce_type u = OP(setup.a, setup.sx); \
327
UTS::opa_type u_opa(setup.basis); \
328
setup.exp->EXPOP(u_opa, setup.a, \
329
setup.sx.getOrthogPolyApprox()); \
330
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
331
u_opa, "u_opa", \
332
setup.rtol, setup.atol, out); \
333
} \
334
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_left_short_right_const2) { \
335
UTS::pce_type u = OP(setup.sx, setup.cx); \
336
UTS::opa_type u_opa(setup.basis); \
337
setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox(), \
338
setup.cx.getOrthogPolyApprox()); \
339
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
340
u_opa, "u_opa", \
341
setup.rtol, setup.atol, out); \
342
} \
343
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_right_short_left_const2) { \
344
UTS::pce_type u = OP(setup.cx, setup.sx); \
345
UTS::opa_type u_opa(setup.basis); \
346
setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox(), \
347
setup.sx.getOrthogPolyApprox()); \
348
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
349
u_opa, "u_opa", \
350
setup.rtol, setup.atol, out); \
351
}
352
353
BINARY_UNIT_TEST
(
operator
+, plus)
354
BINARY_UNIT_TEST
(
operator
-, minus)
355
BINARY_UNIT_TEST
(
operator
*, times)
356
BINARY_UNIT_TEST
(
operator
/, divide)
357
358
#define OPASSIGN_UNIT_TEST(OP, EXPOP) \
359
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP) { \
360
UTS::pce_type v = std::sin(setup.x); \
361
UTS::pce_type u = std::cos(setup.x); \
362
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
363
u OP v; \
364
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
365
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
366
u_opa, "u_opa", \
367
setup.rtol, setup.atol, out); \
368
} \
369
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_const) { \
370
UTS::pce_type u = std::cos(setup.x); \
371
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
372
u OP setup.a; \
373
setup.exp->EXPOP(u_opa, setup.a); \
374
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
375
u_opa, "u_opa", \
376
setup.rtol, setup.atol, out); \
377
} \
378
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_const2) { \
379
UTS::pce_type u = std::cos(setup.x); \
380
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
381
u OP setup.cx; \
382
setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
383
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
384
u_opa, "u_opa", \
385
setup.rtol, setup.atol, out); \
386
} \
387
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_resize) { \
388
UTS::pce_type v = std::sin(setup.x); \
389
UTS::pce_type u = setup.a; \
390
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
391
u OP v; \
392
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
393
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
394
u_opa, "u_opa", \
395
setup.rtol, setup.atol, out); \
396
} \
397
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short) { \
398
UTS::pce_type u = std::cos(setup.x); \
399
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
400
u OP setup.sx; \
401
setup.exp->EXPOP(u_opa, setup.sx.getOrthogPolyApprox()); \
402
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
403
u_opa, "u_opa", \
404
setup.rtol, setup.atol, out); \
405
} \
406
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_resize) { \
407
UTS::pce_type u = setup.sx; \
408
UTS::pce_type v = std::cos(setup.x); \
409
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
410
u OP v; \
411
setup.exp->EXPOP(u_opa, v.getOrthogPolyApprox()); \
412
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
413
u_opa, "u_opa", \
414
setup.rtol, setup.atol, out); \
415
} \
416
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const) { \
417
UTS::pce_type u = setup.sx; \
418
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
419
u OP setup.a; \
420
setup.exp->EXPOP(u_opa, setup.a); \
421
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
422
u_opa, "u_opa", \
423
setup.rtol, setup.atol, out); \
424
} \
425
TEUCHOS_UNIT_TEST( Stokhos_PCE, EXPOP##_short_const2) { \
426
UTS::pce_type u = setup.sx; \
427
UTS::opa_type u_opa = u.getOrthogPolyApprox(); \
428
u OP setup.cx; \
429
setup.exp->EXPOP(u_opa, setup.cx.getOrthogPolyApprox()); \
430
success = Stokhos::comparePCEs(u.getOrthogPolyApprox(), "u", \
431
u_opa, "u_opa", \
432
setup.rtol, setup.atol, out); \
433
}
434
435
OPASSIGN_UNIT_TEST
(+=, plusEqual)
436
OPASSIGN_UNIT_TEST
(-=, minusEqual)
437
OPASSIGN_UNIT_TEST
(*=, timesEqual)
438
OPASSIGN_UNIT_TEST
(/=, divideEqual)
439
440
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy) {
441
UTS::pce_type
u = std::sin(
setup
.x);
442
UTS::pce_type
v = std::cos(
setup
.x);
443
UTS::pce_type
w = std::exp(
setup
.x);
444
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
445
UTS::opa_type
t_opa(
setup
.basis);
446
u += v*w;
447
setup
.exp->times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
448
setup
.exp->plusEqual(u_opa, t_opa);
449
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
450
u_opa,
"u_opa"
,
451
setup
.rtol,
setup
.atol, out);
452
}
453
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_resize) {
454
UTS::pce_type
u =
setup
.cx;
455
UTS::pce_type
v = std::cos(
setup
.x);
456
UTS::pce_type
w = std::exp(
setup
.x);
457
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
458
UTS::opa_type
t_opa(
setup
.basis);
459
u += v*w;
460
setup
.exp->times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
461
setup
.exp->plusEqual(u_opa, t_opa);
462
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
463
u_opa,
"u_opa"
,
464
setup
.rtol,
setup
.atol, out);
465
}
466
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_resize2) {
467
UTS::pce_type
u =
setup
.sx;
468
UTS::pce_type
v = std::cos(
setup
.x);
469
UTS::pce_type
w = std::exp(
setup
.x);
470
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
471
UTS::opa_type
t_opa(
setup
.basis);
472
u += v*w;
473
setup
.exp->times(t_opa, v.getOrthogPolyApprox(), w.getOrthogPolyApprox());
474
setup
.exp->plusEqual(u_opa, t_opa);
475
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
476
u_opa,
"u_opa"
,
477
setup
.rtol,
setup
.atol, out);
478
}
479
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_const) {
480
UTS::pce_type
u = std::sin(
setup
.x);
481
UTS::pce_type
w = std::exp(
setup
.x);
482
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
483
UTS::opa_type
t_opa(
setup
.basis);
484
u +=
setup
.a*w;
485
setup
.exp->times(t_opa,
setup
.a, w.getOrthogPolyApprox());
486
setup
.exp->plusEqual(u_opa, t_opa);
487
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
488
u_opa,
"u_opa"
,
489
setup
.rtol,
setup
.atol, out);
490
}
491
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_const2) {
492
UTS::pce_type
u = std::sin(
setup
.x);
493
UTS::pce_type
w = std::exp(
setup
.x);
494
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
495
UTS::opa_type
t_opa(
setup
.basis);
496
u +=
setup
.cx*w;
497
setup
.exp->times(t_opa,
setup
.cx.getOrthogPolyApprox(),
498
w.getOrthogPolyApprox());
499
setup
.exp->plusEqual(u_opa, t_opa);
500
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
501
u_opa,
"u_opa"
,
502
setup
.rtol,
setup
.atol, out);
503
}
504
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_short) {
505
UTS::pce_type
u = std::sin(
setup
.x);
506
UTS::pce_type
w = std::exp(
setup
.x);
507
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
508
UTS::opa_type
t_opa(
setup
.basis);
509
u +=
setup
.sx*w;
510
setup
.exp->times(t_opa,
setup
.sx.getOrthogPolyApprox(),
511
w.getOrthogPolyApprox());
512
setup
.exp->plusEqual(u_opa, t_opa);
513
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
514
u_opa,
"u_opa"
,
515
setup
.rtol,
setup
.atol, out);
516
}
517
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_short_const) {
518
UTS::pce_type
u = std::sin(
setup
.x);
519
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
520
UTS::opa_type
t_opa(
setup
.basis);
521
u +=
setup
.sx*
setup
.a;
522
setup
.exp->times(t_opa,
setup
.sx.getOrthogPolyApprox(),
523
setup
.a);
524
setup
.exp->plusEqual(u_opa, t_opa);
525
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
526
u_opa,
"u_opa"
,
527
setup
.rtol,
setup
.atol, out);
528
}
529
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_short_const2) {
530
UTS::pce_type
u = std::sin(
setup
.x);
531
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
532
UTS::opa_type
t_opa(
setup
.basis);
533
u +=
setup
.sx*
setup
.cx;
534
setup
.exp->times(t_opa,
setup
.sx.getOrthogPolyApprox(),
535
setup
.cx.getOrthogPolyApprox());
536
setup
.exp->plusEqual(u_opa, t_opa);
537
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
538
u_opa,
"u_opa"
,
539
setup
.rtol,
setup
.atol, out);
540
}
541
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_resize_const) {
542
UTS::pce_type
u =
setup
.cx;
543
UTS::pce_type
w = std::exp(
setup
.x);
544
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
545
UTS::opa_type
t_opa(
setup
.basis);
546
u +=
setup
.a*w;
547
setup
.exp->times(t_opa,
setup
.a, w.getOrthogPolyApprox());
548
setup
.exp->plusEqual(u_opa, t_opa);
549
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
550
u_opa,
"u_opa"
,
551
setup
.rtol,
setup
.atol, out);
552
}
553
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_resize_const2) {
554
UTS::pce_type
u =
setup
.cx;
555
UTS::pce_type
w = std::exp(
setup
.x);
556
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
557
UTS::opa_type
t_opa(
setup
.basis);
558
u +=
setup
.cx*w;
559
setup
.exp->times(t_opa,
setup
.cx.getOrthogPolyApprox(),
560
w.getOrthogPolyApprox());
561
setup
.exp->plusEqual(u_opa, t_opa);
562
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
563
u_opa,
"u_opa"
,
564
setup
.rtol,
setup
.atol, out);
565
}
566
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_short_resize_const) {
567
UTS::pce_type
u =
setup
.sx;
568
UTS::pce_type
w = std::exp(
setup
.x);
569
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
570
UTS::opa_type
t_opa(
setup
.basis);
571
u +=
setup
.a*w;
572
setup
.exp->times(t_opa,
setup
.a, w.getOrthogPolyApprox());
573
setup
.exp->plusEqual(u_opa, t_opa);
574
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
575
u_opa,
"u_opa"
,
576
setup
.rtol,
setup
.atol, out);
577
}
578
TEUCHOS_UNIT_TEST
( Stokhos_PCE, saxpy_short_resize_const2) {
579
UTS::pce_type
u =
setup
.sx;
580
UTS::pce_type
w = std::exp(
setup
.x);
581
UTS::opa_type
u_opa = u.getOrthogPolyApprox();
582
UTS::opa_type
t_opa(
setup
.basis);
583
u +=
setup
.cx*w;
584
setup
.exp->times(t_opa,
setup
.cx.getOrthogPolyApprox(),
585
w.getOrthogPolyApprox());
586
setup
.exp->plusEqual(u_opa, t_opa);
587
success =
Stokhos::comparePCEs
(u.getOrthogPolyApprox(),
"u"
,
588
u_opa,
"u_opa"
,
589
setup
.rtol,
setup
.atol, out);
590
}
591
}
asinh
asinh(expr.val())
tan
tan(expr.val())
cos
cos(expr.val())
cosh
cosh(expr.val())
acos
acos(expr.val())
sin
sin(expr.val())
sinh
sinh(expr.val())
cbrt
cbrt(expr.val())
log10
log10(expr.val())
exp
exp(expr.val())
atan
atan(expr.val())
acosh
acosh(expr.val())
sqrt
sqrt(expr.val())
tanh
tanh(expr.val())
atanh
atanh(expr.val())
asin
asin(expr.val())
UNARY_UNIT_TEST
#define UNARY_UNIT_TEST(VEC, SCALAR_T, OP, OPNAME, USING_OP)
Definition
Stokhos_SacadoMPVectorUnitTest.cpp:97
OPASSIGN_UNIT_TEST
#define OPASSIGN_UNIT_TEST(VEC, SCALAR_T, OP, OPNAME)
Definition
Stokhos_SacadoMPVectorUnitTest.cpp:352
BINARY_UNIT_TEST
#define BINARY_UNIT_TEST(VEC, SCALAR_T, OP, OPNAME)
Definition
Stokhos_SacadoMPVectorUnitTest.cpp:136
PCEType
Sacado::UQ::PCE< storage_type > PCEType
Definition
Stokhos_SacadoUQPCECommTests.cpp:162
Stokhos::CompletePolynomialBasis
Multivariate orthogonal polynomial basis generated from a total-order complete-polynomial tensor prod...
Definition
Stokhos_CompletePolynomialBasis.hpp:74
Stokhos::LegendreBasis
Legendre polynomial basis.
Definition
Stokhos_LegendreBasis.hpp:68
Stokhos::OrthogPolyApprox
Class to store coefficients of a projection onto an orthogonal polynomial basis.
Definition
Stokhos_OrthogPolyApprox.hpp:63
Stokhos::QuadOrthogPolyExpansion
Orthogonal polynomial expansions based on numerical quadrature.
Definition
Stokhos_QuadOrthogPolyExpansion.hpp:63
Stokhos::TensorProductQuadrature
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules.
Definition
Stokhos_TensorProductQuadrature.hpp:58
SacadoPCEUnitTest
Definition
Stokhos_SacadoPCEUnitTest.hpp:42
SacadoPCEUnitTest::setup
UTS setup
Definition
Stokhos_SacadoPCEUnitTest.hpp:113
SacadoPCEUnitTest::TEUCHOS_UNIT_TEST
TEUCHOS_UNIT_TEST(Stokhos_PCE, UMinus)
Definition
Stokhos_SacadoPCEUnitTest.hpp:115
SacadoPCEUnitTest::UTS
UnitTestSetup< pce_type > UTS
Definition
Stokhos_SacadoPCEUnitTest.hpp:112
Stokhos::comparePCEs
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)
Definition
Stokhos_SacadoUQPCEUnitTest.cpp:59
SacadoPCEUnitTest::UnitTestSetup
Definition
Stokhos_SacadoPCEUnitTest.hpp:46
SacadoPCEUnitTest::UnitTestSetup< pce_type >::atol
double atol
Definition
Stokhos_SacadoPCEUnitTest.hpp:50
SacadoPCEUnitTest::UnitTestSetup::opa_type
Stokhos::OrthogPolyApprox< int, double > opa_type
Definition
Stokhos_SacadoPCEUnitTest.hpp:49
SacadoPCEUnitTest::UnitTestSetup::pce_type
PCEType pce_type
Definition
Stokhos_SacadoPCEUnitTest.hpp:48
SacadoPCEUnitTest::UnitTestSetup< pce_type >::quad
Teuchos::RCP< const Stokhos::Quadrature< int, double > > quad
Definition
Stokhos_SacadoPCEUnitTest.hpp:54
SacadoPCEUnitTest::UnitTestSetup< pce_type >::cu2
pce_type cu2
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::cx
pce_type cx
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::su
pce_type su
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::exp
Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion< int, double > > exp
Definition
Stokhos_SacadoPCEUnitTest.hpp:56
SacadoPCEUnitTest::UnitTestSetup< pce_type >::y
pce_type y
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::Cijk
Teuchos::RCP< Stokhos::Sparse3Tensor< int, double > > Cijk
Definition
Stokhos_SacadoPCEUnitTest.hpp:55
SacadoPCEUnitTest::UnitTestSetup< pce_type >::x
pce_type x
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::su2
pce_type su2
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::basis
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< int, double > > basis
Definition
Stokhos_SacadoPCEUnitTest.hpp:53
SacadoPCEUnitTest::UnitTestSetup< pce_type >::sx
pce_type sx
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup::UnitTestSetup
UnitTestSetup()
Definition
Stokhos_SacadoPCEUnitTest.hpp:60
SacadoPCEUnitTest::UnitTestSetup< pce_type >::sz
int sz
Definition
Stokhos_SacadoPCEUnitTest.hpp:52
SacadoPCEUnitTest::UnitTestSetup< pce_type >::catol
double catol
Definition
Stokhos_SacadoPCEUnitTest.hpp:51
SacadoPCEUnitTest::UnitTestSetup< pce_type >::cu
pce_type cu
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::crtol
double crtol
Definition
Stokhos_SacadoPCEUnitTest.hpp:51
SacadoPCEUnitTest::UnitTestSetup< pce_type >::rtol
double rtol
Definition
Stokhos_SacadoPCEUnitTest.hpp:50
SacadoPCEUnitTest::UnitTestSetup< pce_type >::opa_type
Stokhos::OrthogPolyApprox< ordinal_type, value_type > opa_type
Definition
Stokhos_SacadoUQPCEUnitTest.cpp:118
SacadoPCEUnitTest::UnitTestSetup< pce_type >::u
pce_type u
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
SacadoPCEUnitTest::UnitTestSetup< pce_type >::a
double a
Definition
Stokhos_SacadoPCEUnitTest.hpp:58
SacadoPCEUnitTest::UnitTestSetup< pce_type >::u2
pce_type u2
Definition
Stokhos_SacadoPCEUnitTest.hpp:57
Generated by
1.17.0