52 #include "Sacado_Fad_DFad.hpp"
53 #include "Sacado_mpl_apply.hpp"
54 #include "Sacado_Random.hpp"
60 template <
typename PCEType,
typename FadType>
69 typedef typename Sacado::mpl::apply<FadType,PCEType>::type
FadPCEType;
80 for (
int i=0; i<d; i++)
104 template <
typename PCEType>
107 const std::string& tag,
111 bool success = (x.
size() == x2.
size());
112 out << tag <<
" PCE array size test";
117 out <<
": \n\tExpected: " << x.
size() <<
", \n\tGot: " << x2.
size()
121 for (
int i=0; i<x.
size(); i++) {
122 bool success2 = Sacado::IsEqual<PCEType>::eval(x[i], x2[i]);
123 out << tag <<
" PCE array comparison test " << i;
128 out <<
": \n\tExpected: " << x[i] <<
", \n\tGot: " << x2[i] <<
"."
130 success = success && success2;
136 template<
typename Ordinal>
143 out <<
"\nChecking that the above test passed in all processes ...";
144 int thisResult = ( result ? 1 : 0 );
148 const bool passed = sumResult==Teuchos::size(comm);
152 out <<
" (sumResult="<<sumResult<<
"!=numProcs="<<Teuchos::size(comm)<<
") failed\n";
156 #define PCE_COMM_TESTS(PCEType, FadType, PCE, FAD) \
157 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_Broadcast ) { \
158 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
159 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
162 Teuchos::Array<PCEType> x(n), x2(n); \
163 for (int i=0; i<n; i++) { \
164 x[i] = PCEType(setup.exp); \
165 for (int j=0; j<setup.sz; j++) \
166 x[i].fastAccessCoeff(j) = rnd.number(); \
168 if (comm->getRank() == 0) \
170 Teuchos::broadcast(*comm, *setup.pce_serializer, 0, n, &x2[0]); \
171 success = checkPCEArrays(x, x2, std::string(#PCE)+" Broadcast", out); \
172 success = checkResultOnAllProcs(*comm, out, success); \
175 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_GatherAll ) { \
176 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
177 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
180 int size = comm->getSize(); \
181 int rank = comm->getRank(); \
183 Teuchos::Array<PCEType> x(n), x2(N), x3(N); \
184 for (int i=0; i<n; i++) { \
185 x[i] = PCEType(setup.exp); \
186 for (int j=0; j<setup.sz; j++) \
187 x[i].fastAccessCoeff(j) = (rank+1)*(i+1)*(j+1); \
189 for (int j=0; j<size; j++) { \
190 for (int i=0; i<n; i++) { \
191 x3[n*j+i] = PCEType(setup.exp); \
192 for (int k=0; k<setup.sz; k++) \
193 x3[n*j+i].fastAccessCoeff(k) = (j+1)*(i+1)*(k+1); \
196 Teuchos::gatherAll(*comm, *setup.pce_serializer, \
197 n, &x[0], N, &x2[0]); \
198 success = checkPCEArrays(x3, x2, std::string(#PCE)+" Gather All", out); \
199 success = checkResultOnAllProcs(*comm, out, success); \
202 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_SumAll ) { \
203 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
204 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
207 int num_proc = comm->getSize(); \
209 Teuchos::Array<PCEType> x(n), sums(n), sums2(n); \
210 for (int i=0; i<n; i++) { \
211 x[i] = PCEType(setup.exp); \
212 for (int j=0; j<setup.sz; j++) \
213 x[i].fastAccessCoeff(j) = 2.0*(i+1); \
215 for (int i=0; i<n; i++) { \
216 sums[i] = PCEType(setup.exp); \
217 for (int j=0; j<setup.sz; j++) \
218 sums[i].fastAccessCoeff(j) = 2.0*(i+1)*num_proc; \
220 Teuchos::reduceAll(*comm, *setup.pce_serializer, \
221 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
222 success = checkPCEArrays(sums, sums2, \
223 std::string(#PCE)+" Sum All", out); \
224 success = checkResultOnAllProcs(*comm, out, success); \
227 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_MaxAll ) { \
228 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
229 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
232 int rank = comm->getRank(); \
233 int num_proc = comm->getSize(); \
235 Teuchos::Array<PCEType> x(n), maxs(n), maxs2(n); \
236 for (int i=0; i<n; i++) { \
237 x[i] = PCEType(setup.exp); \
238 for (int j=0; j<setup.sz; j++) \
239 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
241 for (int i=0; i<n; i++) { \
242 maxs[i] = PCEType(setup.exp); \
243 for (int j=0; j<setup.sz; j++) \
244 maxs[i].fastAccessCoeff(j) = 2.0*(i+1)*num_proc; \
246 Teuchos::reduceAll(*comm, *setup.pce_serializer, \
247 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
248 success = checkPCEArrays(maxs, maxs2, \
249 std::string(#PCE)+" Max All", out); \
250 success = checkResultOnAllProcs(*comm, out, success); \
253 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_MinAll ) { \
254 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
255 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
258 int rank = comm->getRank(); \
260 Teuchos::Array<PCEType> x(n), mins(n), mins2(n); \
261 for (int i=0; i<n; i++) { \
262 x[i] = PCEType(setup.exp); \
263 for (int j=0; j<setup.sz; j++) \
264 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
266 for (int i=0; i<n; i++) { \
267 mins[i] = PCEType(setup.exp); \
268 for (int j=0; j<setup.sz; j++) \
269 mins[i].fastAccessCoeff(j) = 2.0*(i+1); \
271 Teuchos::reduceAll(*comm, *setup.pce_serializer, \
272 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
273 success = checkPCEArrays(mins, mins2, \
274 std::string(#PCE)+" Min All", out); \
275 success = checkResultOnAllProcs(*comm, out, success); \
278 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_ScanSum ) { \
279 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
280 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
283 int rank = comm->getRank(); \
285 Teuchos::Array<PCEType> x(n), sums(n), sums2(n); \
286 for (int i=0; i<n; i++) { \
287 x[i] = PCEType(setup.exp); \
288 for (int j=0; j<setup.sz; j++) \
289 x[i].fastAccessCoeff(j) = 2.0*(i+1); \
291 for (int i=0; i<n; i++) { \
292 sums[i] = PCEType(setup.exp); \
293 for (int j=0; j<setup.sz; j++) \
294 sums[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
296 Teuchos::scan(*comm, *setup.pce_serializer, \
297 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
298 success = checkPCEArrays(sums, sums2, \
299 std::string(#PCE)+" Scan Sum", out); \
300 success = checkResultOnAllProcs(*comm, out, success); \
303 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_ScanMax ) { \
304 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
305 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
308 int rank = comm->getRank(); \
310 Teuchos::Array<PCEType> x(n), maxs(n), maxs2(n); \
311 for (int i=0; i<n; i++) { \
312 x[i] = PCEType(setup.exp); \
313 for (int j=0; j<setup.sz; j++) \
314 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
316 for (int i=0; i<n; i++) { \
317 maxs[i] = PCEType(setup.exp); \
318 for (int j=0; j<setup.sz; j++) \
319 maxs[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
321 Teuchos::scan(*comm, *setup.pce_serializer, \
322 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
323 success = checkPCEArrays(maxs, maxs2, \
324 std::string(#PCE)+" Scan Max", out); \
325 success = checkResultOnAllProcs(*comm, out, success); \
328 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_ScanMin ) { \
329 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
330 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
333 int rank = comm->getRank(); \
335 Teuchos::Array<PCEType> x(n), mins(n), mins2(n); \
336 for (int i=0; i<n; i++) { \
337 x[i] = PCEType(setup.exp); \
338 for (int j=0; j<setup.sz; j++) \
339 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(rank+1); \
341 for (int i=0; i<n; i++) { \
342 mins[i] = PCEType(setup.exp); \
343 for (int j=0; j<setup.sz; j++) \
344 mins[i].fastAccessCoeff(j) = 2.0*(i+1); \
346 Teuchos::scan(*comm, *setup.pce_serializer, \
347 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
348 success = checkPCEArrays(mins, mins2, \
349 std::string(#PCE)+" Scan Min", out); \
350 success = checkResultOnAllProcs(*comm, out, success); \
353 TEUCHOS_UNIT_TEST( PCE##_Comm, PCE_SendReceive ) { \
354 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
355 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
357 int num_proc = comm->getSize(); \
358 if (num_proc > 1) { \
359 int rank = comm->getRank(); \
361 Teuchos::Array<PCEType> x(n), x2(n); \
362 for (int i=0; i<n; i++) { \
363 x[i] = PCEType(setup.exp); \
364 for (int j=0; j<setup.sz; j++) \
365 x[i].fastAccessCoeff(j) = 2.0*(i+1)*(j+1); \
369 if (rank == 0) Teuchos::send(*comm, *setup.pce_serializer, \
371 if (rank == 1) Teuchos::receive(*comm, *setup.pce_serializer, \
373 success = checkPCEArrays(x, x2, \
374 std::string(#PCE)+" Send/Receive", out); \
375 success = checkResultOnAllProcs(*comm, out, success); \
381 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_Broadcast ) { \
382 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
383 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
384 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
388 Teuchos::Array<FadPCEType> x(n), x2(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) = rnd.number(); \
393 x[i] = FadPCEType(p, f); \
394 for (int j=0; j<p; j++) { \
395 PCEType g(setup.exp); \
396 for (int k=0; k<setup.sz; k++) \
397 g.fastAccessCoeff(k) = rnd.number(); \
398 x[i].fastAccessDx(j) = g; \
401 if (comm->getRank() == 0) \
403 Teuchos::broadcast(*comm, *setup.fad_pce_serializer, 0, n, &x2[0]); \
404 success = checkPCEArrays(x, x2, \
405 std::string(#FAD)+"<"+#PCE+"> Broadcast", out); \
406 success = checkResultOnAllProcs(*comm, out, success); \
409 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_GatherAll ) { \
410 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
411 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
412 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
416 int size = comm->getSize(); \
417 int rank = comm->getRank(); \
419 Teuchos::Array<FadPCEType> x(n), x2(N), x3(N); \
420 for (int i=0; i<n; i++) { \
421 PCEType f(setup.exp); \
422 for (int k=0; k<setup.sz; k++) \
423 f.fastAccessCoeff(k) = (rank+1)*(i+1)*(k+1); \
424 x[i] = FadPCEType(p, f); \
425 for (int j=0; j<p; j++) { \
426 x[i].fastAccessDx(j) = f; \
429 for (int j=0; j<size; j++) { \
430 for (int i=0; i<n; i++) { \
431 PCEType f(setup.exp); \
432 for (int k=0; k<setup.sz; k++) \
433 f.fastAccessCoeff(k) = (j+1)*(i+1)*(k+1); \
434 x3[n*j+i] = FadPCEType(p, f); \
435 for (int k=0; k<p; k++) \
436 x3[n*j+i].fastAccessDx(k) = f; \
439 Teuchos::gatherAll(*comm, *setup.fad_pce_serializer, \
440 n, &x[0], N, &x2[0]); \
441 success = checkPCEArrays(x3, x2, \
442 std::string(#FAD)+"<"+#PCE+"> Gather All", out); \
443 success = checkResultOnAllProcs(*comm, out, success); \
446 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_SumAll ) { \
447 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
448 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
449 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
453 int num_proc = comm->getSize(); \
455 Teuchos::Array<FadPCEType> x(n), sums(n), sums2(n); \
456 for (int i=0; i<n; i++) { \
457 PCEType f(setup.exp); \
458 for (int k=0; k<setup.sz; k++) \
459 f.fastAccessCoeff(k) = 2.0*(i+1); \
460 x[i] = FadPCEType(p, f); \
461 for (int j=0; j<p; j++) { \
462 PCEType g(setup.exp); \
463 for (int k=0; k<setup.sz; k++) \
464 g.fastAccessCoeff(k) = 2.0*(i+1); \
465 x[i].fastAccessDx(j) = g; \
468 for (int i=0; i<n; i++) { \
469 PCEType f(setup.exp); \
470 for (int k=0; k<setup.sz; k++) \
471 f.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
472 sums[i] = FadPCEType(p, f); \
473 for (int j=0; j<p; j++) { \
474 PCEType g(setup.exp); \
475 for (int k=0; k<setup.sz; k++) \
476 g.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
477 sums[i].fastAccessDx(j) = g; \
480 Teuchos::reduceAll(*comm, *setup.fad_pce_serializer, \
481 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
482 success = checkPCEArrays(sums, sums2, \
483 std::string(#FAD)+"<"+#PCE+"> Sum All", out); \
484 success = checkResultOnAllProcs(*comm, out, success); \
487 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_MaxAll ) { \
488 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
489 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
490 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
494 int rank = comm->getRank(); \
495 int num_proc = comm->getSize(); \
497 Teuchos::Array<FadPCEType> x(n), maxs(n), maxs2(n); \
498 for (int i=0; i<n; i++) { \
499 PCEType f(setup.exp); \
500 for (int k=0; k<setup.sz; k++) \
501 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
502 x[i] = FadPCEType(p, f); \
503 for (int j=0; j<p; j++) { \
504 x[i].fastAccessDx(j) = f; \
507 for (int i=0; i<n; i++) { \
508 PCEType f(setup.exp); \
509 for (int k=0; k<setup.sz; k++) \
510 f.fastAccessCoeff(k) = 2.0*(i+1)*num_proc; \
511 maxs[i] = FadPCEType(p, f); \
512 for (int j=0; j<p; j++) \
513 maxs[i].fastAccessDx(j) = f; \
515 Teuchos::reduceAll(*comm, *setup.fad_pce_serializer, \
516 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
517 success = checkPCEArrays(maxs, maxs2, \
518 std::string(#FAD)+"<"+#PCE+"> Max All", out); \
519 success = checkResultOnAllProcs(*comm, out, success); \
522 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_MinAll ) { \
523 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
524 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
525 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
529 int rank = comm->getRank(); \
531 Teuchos::Array<FadPCEType> x(n), mins(n), mins2(n); \
532 for (int i=0; i<n; i++) { \
533 PCEType f(setup.exp); \
534 for (int k=0; k<setup.sz; k++) \
535 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
536 x[i] = FadPCEType(p, f); \
537 for (int j=0; j<p; j++) { \
538 x[i].fastAccessDx(j) = f; \
541 for (int i=0; i<n; i++) { \
542 PCEType f(setup.exp); \
543 for (int k=0; k<setup.sz; k++) \
544 f.fastAccessCoeff(k) = 2.0*(i+1); \
545 mins[i] = FadPCEType(p, f); \
546 for (int j=0; j<p; j++) \
547 mins[i].fastAccessDx(j) = f; \
549 Teuchos::reduceAll(*comm, *setup.fad_pce_serializer, \
550 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
551 success = checkPCEArrays(mins, mins2, \
552 std::string(#FAD)+"<"+#PCE+"> Min All", out); \
553 success = checkResultOnAllProcs(*comm, out, success); \
556 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_ScanSum ) { \
557 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
558 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
559 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
563 int rank = comm->getRank(); \
565 Teuchos::Array<FadPCEType> x(n), sums(n), sums2(n); \
566 for (int i=0; i<n; i++) { \
567 PCEType f(setup.exp); \
568 for (int k=0; k<setup.sz; k++) \
569 f.fastAccessCoeff(k) = 2.0*(i+1); \
570 x[i] = FadPCEType(p, f); \
571 for (int j=0; j<p; j++) { \
572 x[i].fastAccessDx(j) = f; \
575 for (int i=0; i<n; i++) { \
576 PCEType f(setup.exp); \
577 for (int k=0; k<setup.sz; k++) \
578 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
579 sums[i] = FadPCEType(p, f); \
580 for (int j=0; j<p; j++) \
581 sums[i].fastAccessDx(j) = f; \
583 Teuchos::scan(*comm, *setup.fad_pce_serializer, \
584 Teuchos::REDUCE_SUM, n, &x[0], &sums2[0]); \
585 success = checkPCEArrays(sums, sums2, \
586 std::string(#FAD)+"<"+#PCE+"> Scan Sum", out); \
587 success = checkResultOnAllProcs(*comm, out, success); \
590 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_ScanMax ) { \
591 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
592 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
593 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
597 int rank = comm->getRank(); \
599 Teuchos::Array<FadPCEType> x(n), maxs(n), maxs2(n); \
600 for (int i=0; i<n; i++) { \
601 PCEType f(setup.exp); \
602 for (int k=0; k<setup.sz; k++) \
603 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
604 x[i] = FadPCEType(p, f); \
605 for (int j=0; j<p; j++) { \
606 x[i].fastAccessDx(j) = f; \
609 for (int i=0; i<n; i++) { \
610 PCEType f(setup.exp); \
611 for (int k=0; k<setup.sz; k++) \
612 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
613 maxs[i] = FadPCEType(p, f); \
614 for (int j=0; j<p; j++) \
615 maxs[i].fastAccessDx(j) = f; \
617 Teuchos::scan(*comm, *setup.fad_pce_serializer, \
618 Teuchos::REDUCE_MAX, n, &x[0], &maxs2[0]); \
619 success = checkPCEArrays(maxs, maxs2, \
620 std::string(#FAD)+"<"+#PCE+"> Scan Max", out); \
621 success = checkResultOnAllProcs(*comm, out, success); \
624 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_ScanMin ) { \
625 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
626 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
627 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
631 int rank = comm->getRank(); \
633 Teuchos::Array<FadPCEType> x(n), mins(n), mins2(n); \
634 for (int i=0; i<n; i++) { \
635 PCEType f(setup.exp); \
636 for (int k=0; k<setup.sz; k++) \
637 f.fastAccessCoeff(k) = 2.0*(i+1)*(rank+1); \
638 x[i] = FadPCEType(p, f); \
639 for (int j=0; j<p; j++) { \
640 x[i].fastAccessDx(j) = f; \
643 for (int i=0; i<n; i++) { \
644 PCEType f(setup.exp); \
645 for (int k=0; k<setup.sz; k++) \
646 f.fastAccessCoeff(k) = 2.0*(i+1); \
647 mins[i] = FadPCEType(p, f); \
648 for (int j=0; j<p; j++) \
649 mins[i].fastAccessDx(j) = f; \
651 Teuchos::scan(*comm, *setup.fad_pce_serializer, \
652 Teuchos::REDUCE_MIN, n, &x[0], &mins2[0]); \
653 success = checkPCEArrays(mins, mins2, \
654 std::string(#FAD)+"<"+#PCE+"> Scan Min", out); \
655 success = checkResultOnAllProcs(*comm, out, success); \
658 TEUCHOS_UNIT_TEST( PCE##_Comm, FadPCE_SendReceive ) { \
659 typedef Sacado::mpl::apply<FadType,PCEType>::type FadPCEType; \
660 Teuchos::RCP<const Teuchos::Comm<Ordinal> > \
661 comm = Teuchos::DefaultComm<Ordinal>::getComm(); \
663 int num_proc = comm->getSize(); \
664 if (num_proc > 1) { \
665 int rank = comm->getRank(); \
668 Teuchos::Array<FadPCEType> x(n), x2(n); \
669 for (int i=0; i<n; i++) { \
670 PCEType f(setup.exp); \
671 for (int k=0; k<setup.sz; k++) \
672 f.fastAccessCoeff(k) = 2.0*(i+1)*(k+1); \
673 x[i] = FadPCEType(p, f); \
674 for (int j=0; j<p; j++) \
675 x[i].fastAccessDx(j) = f; \
679 if (rank == 0) Teuchos::send(*comm, *setup.fad_pce_serializer, \
681 if (rank == 1) Teuchos::receive(*comm, *setup.fad_pce_serializer, \
683 success = checkPCEArrays(x, x2, \
684 std::string(#FAD)+"<"+#PCE+"> Send/Receive", out); \
685 success = checkResultOnAllProcs(*comm, out, success); \
695 Sacado::Random<double>
rnd;
701 namespace ETPCETest {
702 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