21 #include "Sacado_Fad_DFad.hpp"
22 #include "Sacado_mpl_apply.hpp"
23 #include "Sacado_Random.hpp"
29 template <
typename PCEType,
typename FadType>
38 typedef typename Sacado::mpl::apply<FadType,PCEType>::type
FadPCEType;
49 for (
int i=0; i<d; i++)
73 template <
typename PCEType>
76 const std::string& tag,
80 bool success = (x.
size() == x2.
size());
81 out << tag <<
" PCE array size test";
86 out <<
": \n\tExpected: " << x.
size() <<
", \n\tGot: " << x2.
size()
90 for (
int i=0; i<x.
size(); i++) {
91 bool success2 = Sacado::IsEqual<PCEType>::eval(x[i], x2[i]);
92 out << tag <<
" PCE array comparison test " << i;
97 out <<
": \n\tExpected: " << x[i] <<
", \n\tGot: " << x2[i] <<
"."
99 success = success && success2;
105 template<
typename Ordinal>
112 out <<
"\nChecking that the above test passed in all processes ...";
113 int thisResult = ( result ? 1 : 0 );
117 const bool passed = sumResult==Teuchos::size(comm);
121 out <<
" (sumResult="<<sumResult<<
"!=numProcs="<<Teuchos::size(comm)<<
") failed\n";
125 #define PCE_COMM_TESTS(PCEType, FadType, PCE, FAD) \
126 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_Broadcast ) { \
127 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
128 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
131 Teuchos::Array<PCEType> x(n), x2(n); \
132 for (int i=0; i<n; i++) { \
133 x[i] = PCEType(setup.exp); \
134 for (int j=0; j<setup.sz; j++) \
135 x[i].fastAccessCoeff(j) = rnd.number(); \
137 if (comm->getRank() == 0) \
139 Teuchos::broadcast(*comm, *setup.pce_serializer, 0, n, &x2[0]); \
140 success = checkPCEArrays(x, x2, std::string(#PCE)+" Broadcast", out); \
141 success = checkResultOnAllProcs(*comm, out, success); \
144 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_GatherAll ) { \
145 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
146 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
149 int size = comm->getSize(); \
150 int rank = comm->getRank(); \
152 Teuchos::Array<PCEType> x(n), x2(N), x3(N); \
153 for (int i=0; i<n; i++) { \
154 x[i] = PCEType(setup.exp); \
155 for (int j=0; j<setup.sz; j++) \
156 x[i].fastAccessCoeff(j) = (rank+1)*(i+1)*(j+1); \
158 for (int j=0; j<size; j++) { \
159 for (int i=0; i<n; i++) { \
160 x3[n*j+i] = PCEType(setup.exp); \
161 for (int k=0; k<setup.sz; k++) \
162 x3[n*j+i].fastAccessCoeff(k) = (j+1)*(i+1)*(k+1); \
165 Teuchos::gatherAll(*comm, *setup.pce_serializer, \
166 n, &x[0], N, &x2[0]); \
167 success = checkPCEArrays(x3, x2, std::string(#PCE)+" Gather All", out); \
168 success = checkResultOnAllProcs(*comm, out, success); \
171 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_SumAll ) { \
172 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
173 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
176 int num_proc = comm->getSize(); \
178 Teuchos::Array<PCEType> x(n), sums(n), sums2(n); \
179 for (int i=0; i<n; i++) { \
180 x[i] = PCEType(setup.exp); \
181 for (int j=0; j<setup.sz; j++) \
182 x[i].fastAccessCoeff(j) = 2.0*(i+1); \
184 for (int i=0; i<n; i++) { \
185 sums[i] = PCEType(setup.exp); \
186 for (int j=0; j<setup.sz; j++) \
187 sums[i].fastAccessCoeff(j) = 2.0*(i+1)*num_proc; \
189 Teuchos::reduceAll(*comm, *setup.pce_serializer, \
190 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
191 success = checkPCEArrays(sums, sums2, \
192 std::string(#PCE)+" Sum All", out); \
193 success = checkResultOnAllProcs(*comm, out, success); \
196 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_MaxAll ) { \
197 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
198 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
201 int rank = comm->getRank(); \
202 int num_proc = comm->getSize(); \
204 Teuchos::Array<PCEType> x(n), maxs(n), maxs2(n); \
205 for (int i=0; i<n; i++) { \
206 x[i] = PCEType(setup.exp); \
207 for (int j=0; j<setup.sz; j++) \
208 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
210 for (int i=0; i<n; i++) { \
211 maxs[i] = PCEType(setup.exp); \
212 for (int j=0; j<setup.sz; j++) \
213 maxs[i].fastAccessCoeff(j) = 2.0*(i+1)*num_proc; \
215 Teuchos::reduceAll(*comm, *setup.pce_serializer, \
216 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
217 success = checkPCEArrays(maxs, maxs2, \
218 std::string(#PCE)+" Max All", out); \
219 success = checkResultOnAllProcs(*comm, out, success); \
222 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_MinAll ) { \
223 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
224 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
227 int rank = comm->getRank(); \
229 Teuchos::Array<PCEType> x(n), mins(n), mins2(n); \
230 for (int i=0; i<n; i++) { \
231 x[i] = PCEType(setup.exp); \
232 for (int j=0; j<setup.sz; j++) \
233 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
235 for (int i=0; i<n; i++) { \
236 mins[i] = PCEType(setup.exp); \
237 for (int j=0; j<setup.sz; j++) \
238 mins[i].fastAccessCoeff(j) = 2.0*(i+1); \
240 Teuchos::reduceAll(*comm, *setup.pce_serializer, \
241 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
242 success = checkPCEArrays(mins, mins2, \
243 std::string(#PCE)+" Min All", out); \
244 success = checkResultOnAllProcs(*comm, out, success); \
247 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_ScanSum ) { \
248 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
249 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
252 int rank = comm->getRank(); \
254 Teuchos::Array<PCEType> x(n), sums(n), sums2(n); \
255 for (int i=0; i<n; i++) { \
256 x[i] = PCEType(setup.exp); \
257 for (int j=0; j<setup.sz; j++) \
258 x[i].fastAccessCoeff(j) = 2.0*(i+1); \
260 for (int i=0; i<n; i++) { \
261 sums[i] = PCEType(setup.exp); \
262 for (int j=0; j<setup.sz; j++) \
263 sums[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
265 Teuchos::scan(*comm, *setup.pce_serializer, \
266 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
267 success = checkPCEArrays(sums, sums2, \
268 std::string(#PCE)+" Scan Sum", out); \
269 success = checkResultOnAllProcs(*comm, out, success); \
272 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_ScanMax ) { \
273 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
274 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
277 int rank = comm->getRank(); \
279 Teuchos::Array<PCEType> x(n), maxs(n), maxs2(n); \
280 for (int i=0; i<n; i++) { \
281 x[i] = PCEType(setup.exp); \
282 for (int j=0; j<setup.sz; j++) \
283 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
285 for (int i=0; i<n; i++) { \
286 maxs[i] = PCEType(setup.exp); \
287 for (int j=0; j<setup.sz; j++) \
288 maxs[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
290 Teuchos::scan(*comm, *setup.pce_serializer, \
291 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
292 success = checkPCEArrays(maxs, maxs2, \
293 std::string(#PCE)+" Scan Max", out); \
294 success = checkResultOnAllProcs(*comm, out, success); \
297 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_ScanMin ) { \
298 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
299 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
302 int rank = comm->getRank(); \
304 Teuchos::Array<PCEType> x(n), mins(n), mins2(n); \
305 for (int i=0; i<n; i++) { \
306 x[i] = PCEType(setup.exp); \
307 for (int j=0; j<setup.sz; j++) \
308 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
310 for (int i=0; i<n; i++) { \
311 mins[i] = PCEType(setup.exp); \
312 for (int j=0; j<setup.sz; j++) \
313 mins[i].fastAccessCoeff(j) = 2.0*(i+1); \
315 Teuchos::scan(*comm, *setup.pce_serializer, \
316 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
317 success = checkPCEArrays(mins, mins2, \
318 std::string(#PCE)+" Scan Min", out); \
319 success = checkResultOnAllProcs(*comm, out, success); \
322 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_SendReceive ) { \
323 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
324 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
326 int num_proc = comm->getSize(); \
327 if (num_proc > 1) { \
328 int rank = comm->getRank(); \
330 Teuchos::Array<PCEType> x(n), x2(n); \
331 for (int i=0; i<n; i++) { \
332 x[i] = PCEType(setup.exp); \
333 for (int j=0; j<setup.sz; j++) \
334 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(j+1); \
338 if (rank == 0) Teuchos::send(*comm, *setup.pce_serializer, \
340 if (rank == 1) Teuchos::receive(*comm, *setup.pce_serializer, \
342 success = checkPCEArrays(x, x2, \
343 std::string(#PCE)+" Send/Receive", out); \
344 success = checkResultOnAllProcs(*comm, out, success); \
350 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_Broadcast ) { \
351 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
352 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
353 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
357 Teuchos::Array<FadPCEType> x(n), x2(n); \
358 for (int i=0; i<n; i++) { \
359 PCEType f(setup.exp); \
360 for (int k=0; k<setup.sz; k++) \
361 f.fastAccessCoeff(k) = rnd.number(); \
362 x[i] = FadPCEType(p, f); \
363 for (int j=0; j<p; j++) { \
364 PCEType g(setup.exp); \
365 for (int k=0; k<setup.sz; k++) \
366 g.fastAccessCoeff(k) = rnd.number(); \
367 x[i].fastAccessDx(j) = g; \
370 if (comm->getRank() == 0) \
372 Teuchos::broadcast(*comm, *setup.fad_pce_serializer, 0, n, &x2[0]); \
373 success = checkPCEArrays(x, x2, \
374 std::string(#FAD)+"<"+#PCE+"> Broadcast", out); \
375 success = checkResultOnAllProcs(*comm, out, success); \
378 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_GatherAll ) { \
379 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
380 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
381 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
385 int size = comm->getSize(); \
386 int rank = comm->getRank(); \
388 Teuchos::Array<FadPCEType> x(n), x2(N), x3(N); \
389 for (int i=0; i<n; i++) { \
390 PCEType f(setup.exp); \
391 for (int k=0; k<setup.sz; k++) \
392 f.fastAccessCoeff(k) = (rank+1)*(i+1)*(k+1); \
393 x[i] = FadPCEType(p, f); \
394 for (int j=0; j<p; j++) { \
395 x[i].fastAccessDx(j) = f; \
398 for (int j=0; j<size; j++) { \
399 for (int i=0; i<n; i++) { \
400 PCEType f(setup.exp); \
401 for (int k=0; k<setup.sz; k++) \
402 f.fastAccessCoeff(k) = (j+1)*(i+1)*(k+1); \
403 x3[n*j+i] = FadPCEType(p, f); \
404 for (int k=0; k<p; k++) \
405 x3[n*j+i].fastAccessDx(k) = f; \
408 Teuchos::gatherAll(*comm, *setup.fad_pce_serializer, \
409 n, &x[0], N, &x2[0]); \
410 success = checkPCEArrays(x3, x2, \
411 std::string(#FAD)+"<"+#PCE+"> Gather All", out); \
412 success = checkResultOnAllProcs(*comm, out, success); \
415 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_SumAll ) { \
416 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
417 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
418 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
422 int num_proc = comm->getSize(); \
424 Teuchos::Array<FadPCEType> x(n), sums(n), sums2(n); \
425 for (int i=0; i<n; i++) { \
426 PCEType f(setup.exp); \
427 for (int k=0; k<setup.sz; k++) \
428 f.fastAccessCoeff(k) = 2.0*(i+1); \
429 x[i] = FadPCEType(p, f); \
430 for (int j=0; j<p; j++) { \
431 PCEType g(setup.exp); \
432 for (int k=0; k<setup.sz; k++) \
433 g.fastAccessCoeff(k) = 2.0*(i+1); \
434 x[i].fastAccessDx(j) = g; \
437 for (int i=0; i<n; i++) { \
438 PCEType f(setup.exp); \
439 for (int k=0; k<setup.sz; k++) \
440 f.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
441 sums[i] = FadPCEType(p, f); \
442 for (int j=0; j<p; j++) { \
443 PCEType g(setup.exp); \
444 for (int k=0; k<setup.sz; k++) \
445 g.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
446 sums[i].fastAccessDx(j) = g; \
449 Teuchos::reduceAll(*comm, *setup.fad_pce_serializer, \
450 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
451 success = checkPCEArrays(sums, sums2, \
452 std::string(#FAD)+"<"+#PCE+"> Sum All", out); \
453 success = checkResultOnAllProcs(*comm, out, success); \
456 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_MaxAll ) { \
457 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
458 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
459 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
463 int rank = comm->getRank(); \
464 int num_proc = comm->getSize(); \
466 Teuchos::Array<FadPCEType> x(n), maxs(n), maxs2(n); \
467 for (int i=0; i<n; i++) { \
468 PCEType f(setup.exp); \
469 for (int k=0; k<setup.sz; k++) \
470 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
471 x[i] = FadPCEType(p, f); \
472 for (int j=0; j<p; j++) { \
473 x[i].fastAccessDx(j) = f; \
476 for (int i=0; i<n; i++) { \
477 PCEType f(setup.exp); \
478 for (int k=0; k<setup.sz; k++) \
479 f.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
480 maxs[i] = FadPCEType(p, f); \
481 for (int j=0; j<p; j++) \
482 maxs[i].fastAccessDx(j) = f; \
484 Teuchos::reduceAll(*comm, *setup.fad_pce_serializer, \
485 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
486 success = checkPCEArrays(maxs, maxs2, \
487 std::string(#FAD)+"<"+#PCE+"> Max All", out); \
488 success = checkResultOnAllProcs(*comm, out, success); \
491 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_MinAll ) { \
492 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
493 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
494 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
498 int rank = comm->getRank(); \
500 Teuchos::Array<FadPCEType> x(n), mins(n), mins2(n); \
501 for (int i=0; i<n; i++) { \
502 PCEType f(setup.exp); \
503 for (int k=0; k<setup.sz; k++) \
504 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
505 x[i] = FadPCEType(p, f); \
506 for (int j=0; j<p; j++) { \
507 x[i].fastAccessDx(j) = f; \
510 for (int i=0; i<n; i++) { \
511 PCEType f(setup.exp); \
512 for (int k=0; k<setup.sz; k++) \
513 f.fastAccessCoeff(k) = 2.0*(i+1); \
514 mins[i] = FadPCEType(p, f); \
515 for (int j=0; j<p; j++) \
516 mins[i].fastAccessDx(j) = f; \
518 Teuchos::reduceAll(*comm, *setup.fad_pce_serializer, \
519 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
520 success = checkPCEArrays(mins, mins2, \
521 std::string(#FAD)+"<"+#PCE+"> Min All", out); \
522 success = checkResultOnAllProcs(*comm, out, success); \
525 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_ScanSum ) { \
526 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
527 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
528 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
532 int rank = comm->getRank(); \
534 Teuchos::Array<FadPCEType> x(n), sums(n), sums2(n); \
535 for (int i=0; i<n; i++) { \
536 PCEType f(setup.exp); \
537 for (int k=0; k<setup.sz; k++) \
538 f.fastAccessCoeff(k) = 2.0*(i+1); \
539 x[i] = FadPCEType(p, f); \
540 for (int j=0; j<p; j++) { \
541 x[i].fastAccessDx(j) = f; \
544 for (int i=0; i<n; i++) { \
545 PCEType f(setup.exp); \
546 for (int k=0; k<setup.sz; k++) \
547 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
548 sums[i] = FadPCEType(p, f); \
549 for (int j=0; j<p; j++) \
550 sums[i].fastAccessDx(j) = f; \
552 Teuchos::scan(*comm, *setup.fad_pce_serializer, \
553 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
554 success = checkPCEArrays(sums, sums2, \
555 std::string(#FAD)+"<"+#PCE+"> Scan Sum", out); \
556 success = checkResultOnAllProcs(*comm, out, success); \
559 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_ScanMax ) { \
560 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
561 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
562 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
566 int rank = comm->getRank(); \
568 Teuchos::Array<FadPCEType> x(n), maxs(n), maxs2(n); \
569 for (int i=0; i<n; i++) { \
570 PCEType f(setup.exp); \
571 for (int k=0; k<setup.sz; k++) \
572 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
573 x[i] = FadPCEType(p, f); \
574 for (int j=0; j<p; j++) { \
575 x[i].fastAccessDx(j) = f; \
578 for (int i=0; i<n; i++) { \
579 PCEType f(setup.exp); \
580 for (int k=0; k<setup.sz; k++) \
581 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
582 maxs[i] = FadPCEType(p, f); \
583 for (int j=0; j<p; j++) \
584 maxs[i].fastAccessDx(j) = f; \
586 Teuchos::scan(*comm, *setup.fad_pce_serializer, \
587 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
588 success = checkPCEArrays(maxs, maxs2, \
589 std::string(#FAD)+"<"+#PCE+"> Scan Max", out); \
590 success = checkResultOnAllProcs(*comm, out, success); \
593 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_ScanMin ) { \
594 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
595 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
596 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
600 int rank = comm->getRank(); \
602 Teuchos::Array<FadPCEType> x(n), mins(n), mins2(n); \
603 for (int i=0; i<n; i++) { \
604 PCEType f(setup.exp); \
605 for (int k=0; k<setup.sz; k++) \
606 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
607 x[i] = FadPCEType(p, f); \
608 for (int j=0; j<p; j++) { \
609 x[i].fastAccessDx(j) = f; \
612 for (int i=0; i<n; i++) { \
613 PCEType f(setup.exp); \
614 for (int k=0; k<setup.sz; k++) \
615 f.fastAccessCoeff(k) = 2.0*(i+1); \
616 mins[i] = FadPCEType(p, f); \
617 for (int j=0; j<p; j++) \
618 mins[i].fastAccessDx(j) = f; \
620 Teuchos::scan(*comm, *setup.fad_pce_serializer, \
621 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
622 success = checkPCEArrays(mins, mins2, \
623 std::string(#FAD)+"<"+#PCE+"> Scan Min", out); \
624 success = checkResultOnAllProcs(*comm, out, success); \
627 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_SendReceive ) { \
628 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
629 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
630 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
632 int num_proc = comm->getSize(); \
633 if (num_proc > 1) { \
634 int rank = comm->getRank(); \
637 Teuchos::Array<FadPCEType> x(n), x2(n); \
638 for (int i=0; i<n; i++) { \
639 PCEType f(setup.exp); \
640 for (int k=0; k<setup.sz; k++) \
641 f.fastAccessCoeff(k) = 2.0*(i+1)*(k+1); \
642 x[i] = FadPCEType(p, f); \
643 for (int j=0; j<p; j++) \
644 x[i].fastAccessDx(j) = f; \
648 if (rank == 0) Teuchos::send(*comm, *setup.fad_pce_serializer, \
650 if (rank == 1) Teuchos::receive(*comm, *setup.fad_pce_serializer, \
652 success = checkPCEArrays(x, x2, \
653 std::string(#FAD)+"<"+#PCE+"> Send/Receive", out); \
654 success = checkResultOnAllProcs(*comm, out, success); \
664 Sacado::Random<double>
rnd;
670 namespace ETPCETest {
671 Sacado::Random<double>
rnd;
Stokhos::StandardStorage< int, double > storage_type
Sacado::ETPCE::OrthogPoly< double, storage_type > pce_type
RCP< FadPCESerializerT > fad_pce_serializer
UnitTestSetup< pce_type, fad_type > setup
RCP< const Stokhos::CompletePolynomialBasis< int, double > > basis
RCP< PCESerializerT > pce_serializer
bool checkPCEArrays(const Teuchos::Array< PCEType > &x, const Teuchos::Array< PCEType > &x2, const std::string &tag, Teuchos::FancyOStream &out)
Teuchos::ValueTypeSerializer< int, FadPCEType > FadPCESerializerT
static int runUnitTestsFromMain(int argc, char *argv[])
#define PCE_COMM_TESTS(PCEType, FadType, PCE, FAD)
Sacado::Fad::DFad< double > fad_type
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Sacado::Random< double > rnd
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
UnitTestSetup< pce_type, fad_type > setup
Sacado::mpl::apply< FadType, PCEType >::type FadPCEType
Legendre polynomial basis.
Sacado::PCE::OrthogPoly< double, storage_type > pce_type
int main(int argc, char **argv)
bool checkResultOnAllProcs(const Teuchos::Comm< Ordinal > &comm, Teuchos::FancyOStream &out, const bool result)
virtual ordinal_type size() const
Return total size of basis.
Sacado::Random< double > rnd
RCP< Stokhos::AlgebraicOrthogPolyExpansion< int, double > > exp
Sacado::Fad::DFad< double > fad_type
RCP< Stokhos::Sparse3Tensor< int, double > > Cijk
Teuchos::ValueTypeSerializer< int, PCEType > PCESerializerT