52 #include "Teuchos_oblackholestream.hpp"
53 #include "Teuchos_RCP.hpp"
54 #include "Teuchos_ScalarTraits.hpp"
55 #include "Teuchos_GlobalMPISession.hpp"
56 #include <Kokkos_Core.hpp>
59 using namespace Intrepid;
61 #define INTREPID_TEST_COMMAND( S ) \
66 catch (std::logic_error err) { \
67 *outStream << "Expected Error ----------------------------------------------------------------\n"; \
68 *outStream << err.what() << '\n'; \
69 *outStream << "-------------------------------------------------------------------------------" << "\n\n"; \
74 int main(
int argc,
char *argv[]) {
76 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
80 int iprint = argc - 1;
81 Teuchos::RCP<std::ostream> outStream;
82 Teuchos::oblackholestream bhs;
84 outStream = Teuchos::rcp(&std::cout,
false);
86 outStream = Teuchos::rcp(&bhs,
false);
89 Teuchos::oblackholestream oldFormatState;
90 oldFormatState.copyfmt(std::cout);
93 <<
"===============================================================================\n" \
95 <<
"| Unit Test (ArrayTools) |\n" \
97 <<
"| 1) Array operations: dot multiply |\n" \
99 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov) or |\n" \
100 <<
"| Denis Ridzal (dridzal@sandia.gov). |\n" \
102 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
103 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
105 <<
"===============================================================================\n";
109 #ifdef HAVE_INTREPID_DEBUG
110 int beginThrowNumber = Teuchos::TestForException_getThrowNumber();
111 int endThrowNumber = beginThrowNumber + 36;
115 #ifdef HAVE_INTREPID_DEBUG
120 <<
"===============================================================================\n"\
121 <<
"| TEST 1: exceptions |\n"\
122 <<
"===============================================================================\n";
126 #ifdef HAVE_INTREPID_DEBUG
145 *outStream <<
"-> dotMultiplyDataField:\n";
152 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataField<
double>(a_10_2_2, a_10_2_2_3, a_10_2_2_2_2) );
153 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataField<
double>(a_2_2_2, a_10_2_2_2, a_10_2_2_2_2) );
154 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataField<
double>(a_10_3_2, a_10_2_2_2, a_10_2_2_2_2) );
155 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataField<
double>(a_10_2_3, a_10_2_2_2, a_10_2_2_2_2) );
156 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataField<
double>(a_10_2_2, a_10_2_2_2, a_10_2_2_2_2) );
157 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataField<
double>(a_10_2_2, a_10_1_2_2, a_10_2_2_2_2) );
171 *outStream <<
"-> dotMultiplyDataData:\n";
178 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataData<
double>(a_10_2, a_10_2_2_2, a_10_2_2_3) );
183 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataData<
double>(a_10_2, a_10_2_2_2, a_10_2_2_2) );
186 INTREPID_TEST_COMMAND( atools.
dotMultiplyDataData<
double>(a_10_2, a_10_1_2_2, a_10_2_2_2) );
205 catch (std::logic_error err) {
206 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
207 *outStream << err.what() <<
'\n';
208 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
212 #ifdef HAVE_INTREPID_DEBUG
213 if (Teuchos::TestForException_getThrowNumber() != endThrowNumber)
218 <<
"===============================================================================\n"\
219 <<
"| TEST 2: correctness of math operations |\n"\
220 <<
"===============================================================================\n";
222 outStream->precision(20);
226 *outStream <<
"\n************ Checking dotMultiplyDataField, (branch 1) ************\n";
228 int c=5, p=9, f=7, d1=6, d2=14;
230 Kokkos::View<double***> in_c_f_p(
"in_c_f_p", c, f, p);
231 Kokkos::View<double****> in_c_f_p_d(
"in_c_f_p_d", c, f, p, d1);
232 Kokkos::View<double*****> in_c_f_p_d_d(
"in_c_f_p_d_d", c, f, p, d1, d2);
233 Kokkos::View<double**> data_c_p(
"data_c_p", c, p);
234 Kokkos::View<double***> data_c_p_d(
"data_c_p_d", c, p, d1);
235 Kokkos::View<double****> data_c_p_d_d(
"data_c_p_d_d", c, p, d1, d2);
236 Kokkos::View<double**> data_c_1(
"data_c_1", c, 1);
237 Kokkos::View<double***> data_c_1_d(
"data_c_1_d", c, 1, d1);
238 Kokkos::View<double****> data_c_1_d_d(
"data_c_1_d_d", c, 1, d1, d2);
239 Kokkos::View<double***> out_c_f_p(
"out_c_f_p", c, f, p);
240 Kokkos::View<double***> outSM_c_f_p(
"outSM_c_f_p", c, f, p);
241 Kokkos::View<double***> outDM_c_f_p(
"outDM_c_f_p", c, f, p);
242 double zero = INTREPID_TOL*10000.0;
245 for (
unsigned int i=0; i<in_c_f_p.dimension(0); i++)
246 for (
unsigned int j=0; j<in_c_f_p.dimension(1); j++)
247 for (
unsigned int k=0; k<in_c_f_p.dimension(2); k++)
248 in_c_f_p(i,j,k) = Teuchos::ScalarTraits<double>::random();
252 int previous_value=-1;
253 for (
unsigned int i=0; i<in_c_f_p_d.dimension(0); i++)
254 for (
unsigned int j=0; j<in_c_f_p_d.dimension(1); j++)
255 for (
unsigned int k=0; k<in_c_f_p_d.dimension(2); k++)
256 for (
unsigned int l=0; l<in_c_f_p_d.dimension(3); l++){
257 if(previous_value==1){
258 in_c_f_p_d(i,j,k,l) = -1;
261 in_c_f_p_d(i,j,k,l) = 1;
267 for (
unsigned int i=0; i<in_c_f_p_d_d.dimension(0); i++)
268 for (
unsigned int j=0; j<in_c_f_p_d_d.dimension(1); j++)
269 for (
unsigned int k=0; k<in_c_f_p_d_d.dimension(2); k++)
270 for (
unsigned int l=0; l<in_c_f_p_d_d.dimension(3); l++)
271 for (
unsigned int m=0; m<in_c_f_p_d_d.dimension(4); m++)
272 in_c_f_p_d_d(i,j,k,l,m)=1.0;
275 for (
unsigned int i=0; i<data_c_p.dimension(0); i++)
276 for (
unsigned int j=0; j<data_c_p.dimension(1); j++){
277 data_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
281 for (
unsigned int i=0; i<data_c_1.dimension(0); i++)
282 for (
unsigned int j=0; j<data_c_1.dimension(1); j++){
283 data_c_1(i,j) = Teuchos::ScalarTraits<double>::random();
287 for (
unsigned int i=0; i<data_c_p_d.dimension(0); i++)
288 for (
unsigned int j=0; j<data_c_p_d.dimension(1); j++)
289 for (
unsigned int k=0; k<data_c_p_d.dimension(2); k++)
290 data_c_p_d(i,j,k) = 1.0;
294 for (
unsigned int i=0; i<data_c_1_d.dimension(0); i++)
295 for (
unsigned int j=0; j<data_c_1_d.dimension(1); j++)
296 for (
unsigned int k=0; k<data_c_1_d.dimension(2); k++)
297 data_c_1_d(i,j,k) = 1.0;
301 for (
unsigned int i=0; i<data_c_p_d_d.dimension(0); i++)
302 for (
unsigned int j=0; j<data_c_p_d_d.dimension(1); j++)
303 for (
unsigned int k=0; k<data_c_p_d_d.dimension(2); k++)
304 for (
unsigned int l=0; l<data_c_p_d_d.dimension(3); l++)
305 data_c_p_d_d(i,j,k,l)=1.0;
309 for (
unsigned int i=0; i<data_c_1_d_d.dimension(0); i++)
310 for (
unsigned int j=0; j<data_c_1_d_d.dimension(1); j++)
311 for (
unsigned int k=0; k<data_c_1_d_d.dimension(2); k++)
312 for (
unsigned int l=0; l<data_c_1_d_d.dimension(3); l++)
313 data_c_1_d_d(i,j,k,l)=1.0;
316 art::scalarMultiplyDataField<double>(outSM_c_f_p, data_c_p, in_c_f_p);
317 art::dotMultiplyDataField<double>(outDM_c_f_p, data_c_p, in_c_f_p);
318 rst::subtract(out_c_f_p, outSM_c_f_p, outDM_c_f_p);
319 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
320 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (1): check dot multiply for scalars vs. scalar multiply\n\n";
323 art::dotMultiplyDataField<double>(out_c_f_p, data_c_p_d, in_c_f_p_d);
324 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
325 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (2): check dot multiply of orthogonal vectors\n\n";
328 art::dotMultiplyDataField<double>(out_c_f_p, data_c_p_d_d, in_c_f_p_d_d);
329 if ((rst::vectorNorm(out_c_f_p, NORM_INF) - d1*d2) > zero) {
330 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (3): check dot multiply for tensors of 1s\n\n";
333 art::scalarMultiplyDataField<double>(outSM_c_f_p, data_c_1, in_c_f_p);
334 art::dotMultiplyDataField<double>(outDM_c_f_p, data_c_1, in_c_f_p);
335 rst::subtract(out_c_f_p, outSM_c_f_p, outDM_c_f_p);
336 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
337 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (4): check dot multiply for scalars vs. scalar multiply\n\n";
340 art::dotMultiplyDataField<double>(out_c_f_p, data_c_1_d, in_c_f_p_d);
341 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
342 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (5): check dot multiply of orthogonal vectors\n\n";
345 art::dotMultiplyDataField<double>(out_c_f_p, data_c_1_d_d, in_c_f_p_d_d);
346 if ((rst::vectorNorm(out_c_f_p, NORM_INF) - d1*d2) > zero) {
347 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (6): check dot multiply for tensors of 1s\n\n";
353 *outStream <<
"\n************ Checking dotMultiplyDataField, (branch 2) ************\n";
355 int c=5, p=9, f=7, d1=6, d2=14;
357 Kokkos::View<double**> in_f_p(
"in_f_p", f, p);
358 Kokkos::View<double***> in_f_p_d(
"in_f_p_d", f, p, d1);
359 Kokkos::View<double****> in_f_p_d_d(
"in_f_p_d_d", f, p, d1, d2);
360 Kokkos::View<double**> data_c_p(
"data_c_p", c, p);
361 Kokkos::View<double***> data_c_p_d(
"data_c_p_d", c, p, d1);
362 Kokkos::View<double****> data_c_p_d_d(
"data_c_p_d_d", c, p, d1, d2);
363 Kokkos::View<double**> data_c_1(
"data_c_1", c, 1);
364 Kokkos::View<double***> data_c_1_d(
"data_c_1_d", c, 1, d1);
365 Kokkos::View<double****> data_c_1_d_d(
"data_c_1_d_d", c, 1, d1, d2);
366 Kokkos::View<double***> out_c_f_p(
"out_c_f_p", c, f, p);
367 Kokkos::View<double***> outSM_c_f_p(
"outSM_c_f_p", c, f, p);
368 Kokkos::View<double***> outDM_c_f_p(
"outDM_c_f_p", c, f, p);
369 double zero = INTREPID_TOL*10000.0;
372 for (
unsigned int i=0; i<in_f_p.dimension(0); i++)
373 for (
unsigned int j=0; j<in_f_p.dimension(1); j++){
374 in_f_p(i,j) = Teuchos::ScalarTraits<double>::random();
378 int previous_value=-1;
379 for (
unsigned int i=0; i<in_f_p_d.dimension(0); i++)
380 for (
unsigned int j=0; j<in_f_p_d.dimension(1); j++)
381 for (
unsigned int k=0; k<in_f_p_d.dimension(2); k++){
382 if(previous_value==1){
383 in_f_p_d(i,j,k) = -1;
392 for (
unsigned int i=0; i<in_f_p_d_d.dimension(0); i++)
393 for (
unsigned int j=0; j<in_f_p_d_d.dimension(1); j++)
394 for (
unsigned int k=0; k<in_f_p_d_d.dimension(2); k++)
395 for (
unsigned int l=0; l<in_f_p_d_d.dimension(3); l++)
396 in_f_p_d_d(i,j,k,l) = 1.0;
399 for (
unsigned int i=0; i<data_c_p.dimension(0); i++)
400 for (
unsigned int j=0; j<data_c_p.dimension(1); j++){
401 data_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
405 for (
unsigned int i=0; i<data_c_1.dimension(0); i++)
406 for (
unsigned int j=0; j<data_c_1.dimension(1); j++){
407 data_c_1(i,j) = Teuchos::ScalarTraits<double>::random();
411 for (
unsigned int i=0; i<data_c_p_d.dimension(0); i++)
412 for (
unsigned int j=0; j<data_c_p_d.dimension(1); j++)
413 for (
unsigned int k=0; k<data_c_p_d.dimension(2); k++)
414 data_c_p_d(i,j,k) = 1.0;
417 for (
unsigned int i=0; i<data_c_1_d.dimension(0); i++)
418 for (
unsigned int j=0; j<data_c_1_d.dimension(1); j++)
419 for (
unsigned int k=0; k<data_c_1_d.dimension(2); k++)
420 data_c_1_d(i,j,k) = 1.0;
423 for (
unsigned int i=0; i<data_c_p_d_d.dimension(0); i++)
424 for (
unsigned int j=0; j<data_c_p_d_d.dimension(1); j++)
425 for (
unsigned int k=0; k<data_c_p_d_d.dimension(2); k++)
426 for (
unsigned int l=0; l<data_c_p_d_d.dimension(3); l++)
427 data_c_p_d_d(i,j,k,l)=1.0;
430 for (
unsigned int i=0; i<data_c_1_d_d.dimension(0); i++)
431 for (
unsigned int j=0; j<data_c_1_d_d.dimension(1); j++)
432 for (
unsigned int k=0; k<data_c_1_d_d.dimension(2); k++)
433 for (
unsigned int l=0; l<data_c_1_d_d.dimension(3); l++)
434 data_c_1_d_d(i,j,k,l)=1.0;
436 art::scalarMultiplyDataField<double>(outSM_c_f_p, data_c_p, in_f_p);
437 art::dotMultiplyDataField<double>(outDM_c_f_p, data_c_p, in_f_p);
438 rst::subtract(out_c_f_p, outSM_c_f_p, outDM_c_f_p);
439 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
440 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (7): check dot multiply for scalars vs. scalar multiply\n\n";
443 art::dotMultiplyDataField<double>(out_c_f_p, data_c_p_d, in_f_p_d);
444 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
445 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (8): check dot multiply of orthogonal vectors\n\n";
448 art::dotMultiplyDataField<double>(out_c_f_p, data_c_p_d_d, in_f_p_d_d);
449 if ((rst::vectorNorm(out_c_f_p, NORM_INF) - d1*d2) > zero) {
450 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (9): check dot multiply for tensors of 1s\n\n";
453 art::scalarMultiplyDataField<double>(outSM_c_f_p, data_c_1, in_f_p);
454 art::dotMultiplyDataField<double>(outDM_c_f_p, data_c_1, in_f_p);
455 rst::subtract(out_c_f_p, outSM_c_f_p, outDM_c_f_p);
456 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
457 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (10): check dot multiply for scalars vs. scalar multiply\n\n";
460 art::dotMultiplyDataField<double>(out_c_f_p, data_c_1_d, in_f_p_d);
461 if (rst::vectorNorm(out_c_f_p, NORM_ONE) > zero) {
462 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (11): check dot multiply of orthogonal vectors\n\n";
465 art::dotMultiplyDataField<double>(out_c_f_p, data_c_1_d_d, in_f_p_d_d);
466 if ((rst::vectorNorm(out_c_f_p, NORM_INF) - d1*d2) > zero) {
467 *outStream <<
"\n\nINCORRECT dotMultiplyDataField (12): check dot multiply for tensors of 1s\n\n";
473 *outStream <<
"\n************ Checking dotMultiplyDataData, (branch 1) ************\n";
475 int c=5, p=9, d1=6, d2=14;
477 Kokkos::View<double**> in_c_p(
"in_c_p", c, p);
478 Kokkos::View<double***> in_c_p_d(
"in_c_p_d", c, p, d1);
479 Kokkos::View<double****> in_c_p_d_d(
"in_c_p_d_d", c, p, d1, d2);
480 Kokkos::View<double**> data_c_p(
"data_c_p", c, p);
481 Kokkos::View<double***> data_c_p_d(
"data_c_p_d", c, p, d1);
482 Kokkos::View<double****> data_c_p_d_d(
"data_c_p_d_d", c, p, d1, d2);
483 Kokkos::View<double**> data_c_1(
"data_c_1", c, 1);
484 Kokkos::View<double***> data_c_1_d(
"data_c_1_d", c, 1, d1);
485 Kokkos::View<double****> data_c_1_d_d(
"data_c_1_d_d", c, 1, d1, d2);
486 Kokkos::View<double**> out_c_p(
"out_c_p", c, p);
487 Kokkos::View<double**> outSM_c_p(
"outSM_c_p", c, p);
488 Kokkos::View<double**> outDM_c_p(
"outDM_c_p", c, p);
489 double zero = INTREPID_TOL*10000.0;
492 for (
unsigned int i=0; i<in_c_p.dimension(0); i++)
493 for (
unsigned int j=0; j<in_c_p.dimension(1); j++){
494 in_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
498 int previous_value=-1;
499 for (
unsigned int i=0; i<in_c_p_d.dimension(0); i++)
500 for (
unsigned int j=0; j<in_c_p_d.dimension(1); j++)
501 for (
unsigned int k=0; k<in_c_p_d.dimension(2); k++){
502 if(previous_value==1){
503 in_c_p_d(i,j,k) = -1;
512 for (
unsigned int i=0; i<in_c_p_d_d.dimension(0); i++)
513 for (
unsigned int j=0; j<in_c_p_d_d.dimension(1); j++)
514 for (
unsigned int k=0; k<in_c_p_d_d.dimension(2); k++)
515 for (
unsigned int l=0; l<in_c_p_d_d.dimension(3); l++)
516 in_c_p_d_d(i,j,k,l) = 1.0;
519 for (
unsigned int i=0; i<data_c_p.dimension(0); i++)
520 for (
unsigned int j=0; j<data_c_p.dimension(1); j++){
521 data_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
524 for (
unsigned int i=0; i<data_c_1.dimension(0); i++)
525 for (
unsigned int j=0; j<data_c_1.dimension(1); j++){
526 data_c_1(i,j) = Teuchos::ScalarTraits<double>::random();
529 for (
unsigned int i=0; i<data_c_p_d.dimension(0); i++)
530 for (
unsigned int j=0; j<data_c_p_d.dimension(1); j++)
531 for (
unsigned int k=0; k<data_c_p_d.dimension(2); k++)
532 data_c_p_d(i,j,k) = 1.0;
534 for (
unsigned int i=0; i<data_c_1_d.dimension(0); i++)
535 for (
unsigned int j=0; j<data_c_1_d.dimension(1); j++)
536 for (
unsigned int k=0; k<data_c_1_d.dimension(2); k++)
537 data_c_1_d(i,j,k) = 1.0;
539 for (
unsigned int i=0; i<data_c_p_d_d.dimension(0); i++)
540 for (
unsigned int j=0; j<data_c_p_d_d.dimension(1); j++)
541 for (
unsigned int k=0; k<data_c_p_d_d.dimension(2); k++)
542 for (
unsigned int l=0; l<data_c_p_d_d.dimension(3); l++)
543 data_c_p_d_d(i,j,k,l)=1.0;
546 for (
unsigned int i=0; i<data_c_1_d_d.dimension(0); i++)
547 for (
unsigned int j=0; j<data_c_1_d_d.dimension(1); j++)
548 for (
unsigned int k=0; k<data_c_1_d_d.dimension(2); k++)
549 for (
unsigned int l=0; l<data_c_1_d_d.dimension(3); l++)
550 data_c_1_d_d(i,j,k,l)=1.0;
553 art::scalarMultiplyDataData<double>(outSM_c_p, data_c_p, in_c_p);
554 art::dotMultiplyDataData<double>(outDM_c_p, data_c_p, in_c_p);
555 rst::subtract(out_c_p, outSM_c_p, outDM_c_p);
556 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
557 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (1): check dot multiply for scalars vs. scalar multiply\n\n";
560 art::dotMultiplyDataData<double>(out_c_p, data_c_p_d, in_c_p_d);
561 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
562 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (2): check dot multiply of orthogonal vectors\n\n";
565 art::dotMultiplyDataData<double>(out_c_p, data_c_p_d_d, in_c_p_d_d);
566 if ((rst::vectorNorm(out_c_p, NORM_INF) - d1*d2) > zero) {
567 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (3): check dot multiply for tensors of 1s\n\n";
570 art::scalarMultiplyDataData<double>(outSM_c_p, data_c_1, in_c_p);
571 art::dotMultiplyDataData<double>(outDM_c_p, data_c_1, in_c_p);
572 rst::subtract(out_c_p, outSM_c_p, outDM_c_p);
573 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
574 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (4): check dot multiply for scalars vs. scalar multiply\n\n";
577 art::dotMultiplyDataData<double>(out_c_p, data_c_1_d, in_c_p_d);
578 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
579 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (5): check dot multiply of orthogonal vectors\n\n";
582 art::dotMultiplyDataData<double>(out_c_p, data_c_1_d_d, in_c_p_d_d);
583 if ((rst::vectorNorm(out_c_p, NORM_INF) - d1*d2) > zero) {
584 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (6): check dot multiply for tensors of 1s\n\n";
590 *outStream <<
"\n************ Checking dotMultiplyDataData, (branch 2) ************\n";
592 int c=5, p=9, d1=6, d2=14;
594 Kokkos::View<double*> in_p(
"in_p", p);
595 Kokkos::View<double**> in_p_d(
"in_p_d", p, d1);
596 Kokkos::View<double***> in_p_d_d(
"in_p_d_d", p, d1, d2);
597 Kokkos::View<double**> data_c_p(
"data_c_p", c, p);
598 Kokkos::View<double***> data_c_p_d(
"data_c_p_d", c, p, d1);
599 Kokkos::View<double****> data_c_p_d_d(
"data_c_p_d_d", c, p, d1, d2);
600 Kokkos::View<double**> data_c_1(
"data_c_1", c, 1);
601 Kokkos::View<double***> data_c_1_d(
"data_c_1_d", c, 1, d1);
602 Kokkos::View<double****> data_c_1_d_d(
"data_c_1_d_d", c, 1, d1, d2);
603 Kokkos::View<double**> out_c_p(
"out_c_p", c, p);
604 Kokkos::View<double**> outSM_c_p(
"outSM_c_p", c, p);
605 Kokkos::View<double**> outDM_c_p(
"outDM_c_p", c, p);
606 double zero = INTREPID_TOL*10000.0;
609 for (
unsigned int i=0; i<in_p.dimension(0); i++){
610 in_p(i) = Teuchos::ScalarTraits<double>::random();
614 int previous_value=-1;
615 for (
unsigned int i=0; i<in_p_d.dimension(0); i++)
616 for (
unsigned int j=0; j<in_p_d.dimension(1); j++){
617 if(previous_value==1){
627 for (
unsigned int i=0; i<in_p_d_d.dimension(0); i++)
628 for (
unsigned int j=0; j<in_p_d_d.dimension(1); j++)
629 for (
unsigned int k=0; k<in_p_d_d.dimension(2); k++){
630 in_p_d_d(i,j,k) = 1.0;
634 for (
unsigned int i=0; i<data_c_p.dimension(0); i++)
635 for (
unsigned int j=0; j<data_c_p.dimension(1); j++){
636 data_c_p(i,j) = Teuchos::ScalarTraits<double>::random();
639 for (
unsigned int i=0; i<data_c_1.dimension(0); i++)
640 for (
unsigned int j=0; j<data_c_1.dimension(1); j++){
641 data_c_1(i,j) = Teuchos::ScalarTraits<double>::random();
645 for (
unsigned int i=0; i<data_c_p_d.dimension(0); i++)
646 for (
unsigned int j=0; j<data_c_p_d.dimension(1); j++)
647 for (
unsigned int k=0; k<data_c_p_d.dimension(2); k++)
648 data_c_p_d(i,j,k) = 1.0;
651 for (
unsigned int i=0; i<data_c_1_d.dimension(0); i++)
652 for (
unsigned int j=0; j<data_c_1_d.dimension(1); j++)
653 for (
unsigned int k=0; k<data_c_1_d.dimension(2); k++)
654 data_c_1_d(i,j,k) = 1.0;
656 for (
unsigned int i=0; i<data_c_p_d_d.dimension(0); i++)
657 for (
unsigned int j=0; j<data_c_p_d_d.dimension(1); j++)
658 for (
unsigned int k=0; k<data_c_p_d_d.dimension(2); k++)
659 for (
unsigned int l=0; l<data_c_p_d_d.dimension(3); l++)
660 data_c_p_d_d(i,j,k,l)=1.0;
662 for (
unsigned int i=0; i<data_c_1_d_d.dimension(0); i++)
663 for (
unsigned int j=0; j<data_c_1_d_d.dimension(1); j++)
664 for (
unsigned int k=0; k<data_c_1_d_d.dimension(2); k++)
665 for (
unsigned int l=0; l<data_c_1_d_d.dimension(3); l++)
666 data_c_1_d_d(i,j,k,l)=1.0;
669 art::scalarMultiplyDataData<double>(outSM_c_p, data_c_p, in_p);
670 art::dotMultiplyDataData<double>(outDM_c_p, data_c_p, in_p);
671 rst::subtract(out_c_p, outSM_c_p, outDM_c_p);
672 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
673 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (7): check dot multiply for scalars vs. scalar multiply\n\n";
676 art::dotMultiplyDataData<double>(out_c_p, data_c_p_d, in_p_d);
677 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
678 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (8): check dot multiply of orthogonal vectors\n\n";
681 art::dotMultiplyDataData<double>(out_c_p, data_c_p_d_d, in_p_d_d);
682 if ((rst::vectorNorm(out_c_p, NORM_INF) - d1*d2) > zero) {
683 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (9): check dot multiply for tensors of 1s\n\n";
686 art::scalarMultiplyDataData<double>(outSM_c_p, data_c_1, in_p);
687 art::dotMultiplyDataData<double>(outDM_c_p, data_c_1, in_p);
688 rst::subtract(out_c_p, outSM_c_p, outDM_c_p);
689 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
690 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (10): check dot multiply for scalars vs. scalar multiply\n\n";
693 art::dotMultiplyDataData<double>(out_c_p, data_c_1_d, in_p_d);
694 if (rst::vectorNorm(out_c_p, NORM_ONE) > zero) {
695 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (11): check dot multiply of orthogonal vectors\n\n";
698 art::dotMultiplyDataData<double>(out_c_p, data_c_1_d_d, in_p_d_d);
699 if ((rst::vectorNorm(out_c_p, NORM_INF) - d1*d2) > zero) {
700 *outStream <<
"\n\nINCORRECT dotMultiplyDataData (12): check dot multiply for tensors of 1s\n\n";
707 catch (std::logic_error err) {
708 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
709 *outStream << err.what() <<
'\n';
710 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
716 std::cout <<
"End Result: TEST FAILED\n";
718 std::cout <<
"End Result: TEST PASSED\n";
721 std::cout.copyfmt(oldFormatState);
Header file for utility class to provide multidimensional containers.