16 #ifndef __INTREPID2_ARRAYTOOLS_DEF_TENSOR_HPP__
17 #define __INTREPID2_ARRAYTOOLS_DEF_TENSOR_HPP__
21 namespace FunctorArrayTools {
25 template <
typename OutputViewType,
typename leftInputViewType,
typename rightInputViewType >
27 OutputViewType _output;
28 const leftInputViewType _leftInput;
29 const rightInputViewType _rightInput;
30 const bool _hasField, _isCrossProd3D;
32 KOKKOS_INLINE_FUNCTION
34 leftInputViewType leftInput_,
35 rightInputViewType rightInput_,
37 const bool isCrossProd3D_)
38 : _output(output_), _leftInput(leftInput_), _rightInput(rightInput_),
39 _hasField(hasField_), _isCrossProd3D(isCrossProd3D_) {}
41 KOKKOS_INLINE_FUNCTION
42 void operator()(
const size_type iter)
const {
43 size_type cell, field(0), point;
44 size_type rightRank = _rightInput.rank();
47 unrollIndex( cell, field, point,
53 unrollIndex( cell, point,
58 auto result = ( _hasField ? Kokkos::subview(_output, cell, field, point, Kokkos::ALL()) :
59 Kokkos::subview(_output, cell, point, Kokkos::ALL()));
61 auto left = Kokkos::subview(_leftInput, cell, point, Kokkos::ALL());
63 auto right = (rightRank == 2 + size_type(_hasField)) ?
64 ( _hasField ? Kokkos::subview(_rightInput, field, point, Kokkos::ALL()) :
65 Kokkos::subview(_rightInput, point, Kokkos::ALL())) :
66 ( _hasField ? Kokkos::subview(_rightInput, cell, field, point, Kokkos::ALL()) :
67 Kokkos::subview(_rightInput, cell, point, Kokkos::ALL()));
71 result(0) = left(1)*right(2) - left(2)*right(1);
72 result(1) = left(2)*right(0) - left(0)*right(2);
73 result(2) = left(0)*right(1) - left(1)*right(0);
75 result(0) = left(0)*right(1) - left(1)*right(0);
81 template<
typename DeviceType>
82 template<
typename outputValueType,
class ...outputProperties,
83 typename leftInputValueType,
class ...leftInputProperties,
84 typename rightInputValueType,
class ...rightInputProperties>
87 crossProduct( Kokkos::DynRankView<outputValueType, outputProperties...> output,
88 const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInput,
89 const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInput,
90 const bool hasField ) {
92 typedef Kokkos::DynRankView<outputValueType, outputProperties...> OutputViewType;
93 typedef const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInputViewType;
94 typedef const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInputViewType;
97 const size_type loopSize = ( hasField ? output.extent(0)*output.extent(1)*output.extent(2) :
98 output.extent(0)*output.extent(1) );
99 const bool isCrossProd3D = (leftInput.extent(2) == 3);
100 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
101 Kokkos::parallel_for( policy, FunctorType(output, leftInput, rightInput, hasField, isCrossProd3D) );
106 template<
typename DeviceType>
107 template<
typename outputFieldValueType,
class ...outputFieldProperties,
108 typename inputDataValueType,
class ...inputDataProperties,
109 typename inputFieldValueType,
class ...inputFieldProperties>
113 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
114 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields ) {
116 #ifdef HAVE_INTREPID2_DEBUG
125 INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 3, std::invalid_argument,
126 ">>> ERROR (ArrayTools::crossProductDataField): inputData must have rank 3");
127 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(2) < 2 || inputData.extent(2) > 3, std::invalid_argument,
128 ">>> ERROR (ArrayTools::crossProductDataField): inputData dimension(2) must be 2 or 3");
131 INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() < 3 || inputFields.rank() > 4, std::invalid_argument,
132 ">>> ERROR (ArrayTools::crossProductDataField): inputFields must have rank 3 or 4" );
133 INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(inputFields.rank()-1) < 2 ||
134 inputFields.extent(inputFields.rank()-1) > 3, std::invalid_argument,
135 ">>> ERROR (ArrayTools::crossProductDataField): inputFields dimension (rank-1) must have rank 2 or 3" );
138 INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != inputData.extent(2)+1, std::invalid_argument,
139 ">>> ERROR (ArrayTools::crossProductDataField): outputFields rank must match to inputData dimension(2)+1");
148 if (inputFields.rank() == 4) {
150 const size_type f1[] = { 0, 1, 2 }, f2[] = { 0, 2, 3 };
151 for (size_type i=0; i<3; ++i) {
152 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
153 ">>> ERROR (ArrayTools::crossProductDataField): inputData dimension does not match with inputFields");
157 const size_type f1[] = { 1, 2 }, f2[] = { 1, 2 };
158 for (size_type i=0; i<2; ++i) {
159 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
160 ">>> ERROR (ArrayTools::crossProductDataField): inputData dimension does not match with inputFields");
166 if (inputData.extent(2) == 2) {
169 const size_type f1[] = { 0, 2 }, f2[] = { 0, 1 };
170 for (size_type i=0; i<2; ++i) {
171 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
172 ">>> ERROR (ArrayTools::crossProductDataField): outputFields dimension does not match with inputData");
176 const size_type f1[] = { 0, 2, 3 }, f2[] = { 0, 1, 2 };
177 for (size_type i=0; i<3; ++i) {
178 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
179 ">>> ERROR (ArrayTools::crossProductDataField): outputFields dimension does not match with inputData");
185 if (inputData.extent(2) == 2) {
187 if (inputFields.rank() == 4) {
189 const size_type f1[] = { 0, 1, 2 }, f2[] = { 0, 1, 2 };
190 for (size_type i=0; i<3; ++i) {
191 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
192 ">>> ERROR (ArrayTools::crossProductDataField): outputFields dimension does not match with inputFields");
196 const size_type f1[] = { 1, 2 }, f2[] = { 0, 1 };
197 for (size_type i=0; i<2; ++i) {
198 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
199 ">>> ERROR (ArrayTools::crossProductDataField): outputFields dimension does not match with inputFields");
204 if (inputFields.rank() == 4) {
206 for (size_type i=0; i<outputFields.rank(); ++i) {
207 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(i) != inputFields.extent(i), std::invalid_argument,
208 ">>> ERROR (ArrayTools::crossProductDataField): outputFields dimension does not match with inputFields");
212 const size_type f1[] = { 1, 2, 3 }, f2[] = { 0, 1, 2 };
213 for (size_type i=0; i<3; ++i) {
214 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
215 ">>> ERROR (ArrayTools::crossProductDataField): outputFields dimension does not match with inputFields");
229 template<
typename DeviceType>
230 template<
typename outputDataValueType,
class ...outputDataProperties,
231 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
232 typename inputDataRightValueType,
class ...inputDataRightProperties>
236 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
237 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight ) {
239 #ifdef HAVE_INTREPID2_DEBUG
248 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 3, std::invalid_argument,
249 ">>> ERROR (ArrayTools::crossProductDataData): inputDataLeft must have rank 3");
250 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) < 2 || inputDataLeft.extent(2) > 3, std::invalid_argument,
251 ">>> ERROR (ArrayTools::crossProductDataData): inputDataLeft dimension(2) must be 2 or 3");
254 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() < 2 || inputDataRight.rank() > 3, std::invalid_argument,
255 ">>> ERROR (ArrayTools::crossProductDataData): inputDataRight must have rank 2 or 3" );
256 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.extent(inputDataRight.rank()-1) < 2 ||
257 inputDataRight.extent(inputDataRight.rank()-1) > 3, std::invalid_argument,
258 ">>> ERROR (ArrayTools::crossProductDataData): inputDataRight dimension (rank-1) must have rank 2 or 3" );
261 INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != inputDataLeft.extent(2), std::invalid_argument,
262 ">>> ERROR (ArrayTools::crossProductDataData): outputData rank must match to inputDataLeft dimension(2)");
271 if (inputDataRight.rank() == 3) {
273 for (size_type i=0; i<inputDataLeft.rank(); ++i) {
274 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(i) != inputDataRight.extent(i), std::invalid_argument,
275 ">>> ERROR (ArrayTools::crossProductDataData): inputDataLeft dimension does not match to inputDataRight");
280 const size_type f1[] = { 1, 2 }, f2[] = { 0, 1 };
281 for (size_type i=0; i<2; ++i) {
282 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
283 ">>> ERROR (ArrayTools::crossProductDataData): inputDataLeft dimension does not match to inputDataRight");
289 if (inputDataLeft.extent(2) == 2) {
291 const size_type f1[] = { 1, 2 }, f2[] = { 0, 1 };
292 for (size_type i=0; i<2; ++i) {
293 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != outputData.extent(f2[i]), std::invalid_argument,
294 ">>> ERROR (ArrayTools::crossProductDataData): inputDataLeft dimension does not match to outputData");
298 for (size_type i=0; i<inputDataLeft.rank(); ++i) {
299 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(i) != outputData.extent(i), std::invalid_argument,
300 ">>> ERROR (ArrayTools::crossProductDataData): inputDataLeft dimension does not match to outputData");
306 if (inputDataLeft.extent(2) == 2) {
308 if (inputDataRight.rank() == 3) {
310 const size_type f1[] = { 0, 1 }, f2[] = { 0, 1 };
311 for (size_type i=0; i<2; ++i) {
312 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
313 ">>> ERROR (ArrayTools::crossProductDataData): outputData dimension does not match to inputDataRight");
317 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(1) != inputDataRight.extent(0), std::invalid_argument,
318 ">>> ERROR (ArrayTools::crossProductDataData): outputData dimension does not match to inputDataRight");
322 if (inputDataRight.rank() == 3) {
324 for (size_type i=0; i<outputData.rank(); ++i) {
325 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(i) != inputDataRight.extent(i), std::invalid_argument,
326 ">>> ERROR (ArrayTools::crossProductDataData): outputData dimension does not match to inputDataRight");
330 const size_type f1[] = { 1, 2 }, f2[] = { 0, 1 };
331 for (size_type i=0; i<2; ++i) {
332 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
333 ">>> ERROR (ArrayTools::crossProductDataData): outputData dimension does not match to inputDataRight");
347 namespace FunctorArrayTools {
351 template <
typename OutputViewType,
typename leftInputViewType,
typename rightInputViewType >
353 OutputViewType _output;
354 const leftInputViewType _leftInput;
355 const rightInputViewType _rightInput;
356 const bool _hasField;
358 KOKKOS_INLINE_FUNCTION
360 leftInputViewType leftInput_,
361 rightInputViewType rightInput_,
362 const bool hasField_)
363 : _output(output_), _leftInput(leftInput_), _rightInput(rightInput_),
364 _hasField(hasField_) {}
366 KOKKOS_INLINE_FUNCTION
367 void operator()(
const size_type iter)
const {
368 size_type cell, field(0), point;
369 size_type rightRank = _rightInput.rank();
372 unrollIndex( cell, field, point,
378 unrollIndex( cell, point,
383 auto result = ( _hasField ? Kokkos::subview(_output, cell, field, point, Kokkos::ALL(), Kokkos::ALL()) :
384 Kokkos::subview(_output, cell, point, Kokkos::ALL(), Kokkos::ALL()));
386 auto left = Kokkos::subview(_leftInput, cell, point, Kokkos::ALL());
388 auto right = (rightRank == 2 + size_type(_hasField)) ?
389 ( _hasField ? Kokkos::subview(_rightInput, field, point, Kokkos::ALL()) :
390 Kokkos::subview(_rightInput, point, Kokkos::ALL())) :
391 ( _hasField ? Kokkos::subview(_rightInput, cell, field, point, Kokkos::ALL()) :
392 Kokkos::subview(_rightInput, cell, point, Kokkos::ALL()));
394 const ordinal_type iend = result.extent(0);
395 const ordinal_type jend = result.extent(1);
396 for (ordinal_type i=0; i<iend; ++i)
397 for (ordinal_type j=0; j<jend; ++j)
398 result(i, j) = left(i)*right(j);
403 template<
typename DeviceType>
404 template<
typename outputValueType,
class ...outputProperties,
405 typename leftInputValueType,
class ...leftInputProperties,
406 typename rightInputValueType,
class ...rightInputProperties>
409 outerProduct( Kokkos::DynRankView<outputValueType, outputProperties...> output,
410 const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInput,
411 const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInput,
412 const bool hasField ) {
414 typedef Kokkos::DynRankView<outputValueType, outputProperties...> OutputViewType;
415 typedef const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInputViewType;
416 typedef const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInputViewType;
419 const size_type loopSize = ( hasField ? output.extent(0)*output.extent(1)*output.extent(2) :
420 output.extent(0)*output.extent(1) );
421 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
422 Kokkos::parallel_for( policy, FunctorType(output, leftInput, rightInput, hasField) );
426 template<
typename DeviceType>
427 template<
typename outputFieldValueType,
class ...outputFieldProperties,
428 typename inputDataValueType,
class ...inputDataProperties,
429 typename inputFieldValueType,
class ...inputFieldProperties>
433 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
434 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields ) {
436 #ifdef HAVE_INTREPID2_DEBUG
445 INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 3, std::invalid_argument,
446 ">>> ERROR (ArrayTools::outerProductDataField): inputData must have rank 3");
447 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(2) < 2 || inputData.extent(2) > 3, std::invalid_argument,
448 ">>> ERROR (ArrayTools::outerProductDataField): inputData dimension(2) must be 2 or 3");
451 INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() < 3 || inputFields.rank() > 4, std::invalid_argument,
452 ">>> ERROR (ArrayTools::outerProductDataField): inputFields must have rank 3 or 4" );
453 INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(inputFields.rank()-1) < 2 ||
454 inputFields.extent(inputFields.rank()-1) < 3, std::invalid_argument,
455 ">>> ERROR (ArrayTools::outerProductDataField): inputFields dimension (rank-1) must have rank 2 or 3" );
458 INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 5, std::invalid_argument,
459 ">>> ERROR (ArrayTools::outerProductDataField): outputFields must have rank 5");
460 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(3) < 2 ||
461 outputFields.extent(3) > 3, std::invalid_argument,
462 ">>> ERROR (ArrayTools::outerProductDataField): outputFields dimension(3) must be 2 or 3");
463 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(4) < 2 ||
464 outputFields.extent(4) > 3, std::invalid_argument,
465 ">>> ERROR (ArrayTools::outerProductDataField): outputFields dimension(4) must be 2 or 3");
476 const size_type f1[] = { 0, 2, 3, 4 }, f2[] = { 0, 1, 2, 2 };
477 for (size_type i=0; i<4; ++i) {
478 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
479 ">>> ERROR (ArrayTools::outerProductDataField): outputFields dimension does not match with inputData");
486 if (inputFields.rank() == 4) {
489 const size_type f1[] = { 0, 1, 2 }, f2[] = { 0, 2, 3 };
490 for (size_type i=0; i<3; ++i) {
491 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
492 ">>> ERROR (ArrayTools::outerProductDataField): inputData dimension does not match with inputFields");
498 const size_type f1[] = { 0, 1, 2, 3, 4 }, f2[] = { 0, 1, 2, 3, 3 };
499 for (size_type i=0; i<5; ++i) {
500 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
501 ">>> ERROR (ArrayTools::outerProductDataField): outputFields dimension does not match with inputFields");
507 const size_type f1[] = { 1, 2 }, f2[] = { 1, 2 };
508 for (size_type i=0; i<2; ++i) {
509 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
510 ">>> ERROR (ArrayTools::outerProductDataField): inputData dimension does not match with inputFields");
516 const size_type f1[] = { 1, 2, 3, 4 }, f2[] = { 0, 1, 2, 2 };
517 for (size_type i=0; i<4; ++i) {
518 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
519 ">>> ERROR (ArrayTools::outerProductDataField): outputFields dimension does not match with inputFields");
533 template<
typename DeviceType>
534 template<
typename outputDataValueType,
class ...outputDataProperties,
535 typename inputDataLeftValuetype,
class ...inputDataLeftProperties,
536 typename inputDataRightValueType,
class ...inputDataRightProperties>
540 const Kokkos::DynRankView<inputDataLeftValuetype, inputDataLeftProperties...> inputDataLeft,
541 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight ) {
543 #ifdef HAVE_INTREPID2_DEBUG
552 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 3, std::invalid_argument,
553 ">>> ERROR (ArrayTools::outerProductDataField): inputDataLeft must have rank 3");
554 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) < 2 || inputDataLeft.extent(2) > 3, std::invalid_argument,
555 ">>> ERROR (ArrayTools::outerProductDataField): inputDataLeft dimension(2) must be 2 or 3");
558 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() < 2 || inputDataRight.rank() > 3, std::invalid_argument,
559 ">>> ERROR (ArrayTools::outerProductDataField): inputDataRight must have rank 2 or 3" );
560 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.extent(inputDataRight.rank()-1) < 2 ||
561 inputDataRight.extent(inputDataRight.rank()-1) < 3, std::invalid_argument,
562 ">>> ERROR (ArrayTools::outerProductDataField): inputDataRight dimension (rank-1) must have rank 2 or 3" );
565 INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 4, std::invalid_argument,
566 ">>> ERROR (ArrayTools::outerProductDataField): outputData must have rank 5");
567 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(2) < 2 ||
568 outputData.extent(2) > 3, std::invalid_argument,
569 ">>> ERROR (ArrayTools::outerProductDataField): outputData dimension(3) must be 2 or 3");
570 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(3) < 2 ||
571 outputData.extent(3) > 3, std::invalid_argument,
572 ">>> ERROR (ArrayTools::outerProductDataField): outputData dimension(4) must be 2 or 3");
583 const size_type f1[] = { 0, 1, 2, 3 }, f2[] = { 0, 1, 2, 2 };
584 for (size_type i=0; i<4; ++i) {
585 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataLeft.extent(f2[i]), std::invalid_argument,
586 ">>> ERROR (ArrayTools::outerProductDataField): outputData dimension does not match with inputDataLeft");
593 if (inputDataRight.rank() == 3) {
595 for (size_type i=0; i<inputDataLeft.rank(); ++i) {
596 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(i) != inputDataRight.extent(i), std::invalid_argument,
597 ">>> ERROR (ArrayTools::outerProductDataField): inputDataLeft dimension does not match with inputDataRight");
602 const size_type f1[] = { 0, 1, 2, 3 }, f2[] = { 0, 1, 2, 2 };
603 for (size_type i=0; i<4; ++i) {
604 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
605 ">>> ERROR (ArrayTools::outerProductDataField): outputData dimension does not match with inputDataRight");
611 const size_type f1[] = { 1, 2 }, f2[] = { 0, 1 };
612 for (size_type i=0; i<2; ++i) {
613 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
614 ">>> ERROR (ArrayTools::outerProductDataField): inputDataLeft dimension does not match with inputDataRight");
620 const size_type f1[] = { 1, 2, 3 }, f2[] = { 0, 1, 1 };
621 for (size_type i=0; i<3; ++i) {
622 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
623 ">>> ERROR (ArrayTools::outerProductDataField): outputData dimension does not match with inputDataRight");
637 namespace FunctorArrayTools {
641 template <
typename OutputViewType,
642 typename leftInputViewType,
643 typename rightInputViewType,
644 ordinal_type leftInputRank,
645 ordinal_type rightInputRank,
649 OutputViewType _output;
650 const leftInputViewType _leftInput;
651 const rightInputViewType _rightInput;
653 const ordinal_type _iend;
654 const ordinal_type _jend;
656 using value_type =
typename OutputViewType::value_type;
658 KOKKOS_INLINE_FUNCTION
660 leftInputViewType leftInput_,
661 rightInputViewType rightInput_)
662 : _output(output_), _leftInput(leftInput_), _rightInput(rightInput_),
663 _iend(output_.extent_int(rank(output_)-1)), _jend(rightInput_.extent_int(rightInputRank-1))
667 KOKKOS_INLINE_FUNCTION
668 void operator()(
const ordinal_type cl,
669 const ordinal_type bf,
670 const ordinal_type pt)
const
672 apply_matvec_product(cl, bf, pt);
675 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
676 KOKKOS_FORCEINLINE_FUNCTION
677 typename std::enable_if_t<l==4 && r==4 && hf, void>
678 apply_matvec_product(
const ordinal_type &cl,
679 const ordinal_type &bf,
680 const ordinal_type &pt)
const {
681 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
683 for (ordinal_type i=0;i<_iend;++i) {
685 for (ordinal_type j=0;j<_jend;++j)
686 tmp += _leftInput(cl,lpt, j,i)*_rightInput(cl,bf,pt, j);
687 _output(cl,bf,pt, i) = tmp;
690 for (ordinal_type i=0;i<_iend;++i) {
692 for (ordinal_type j=0;j<_jend;++j)
693 tmp += _leftInput(cl,lpt, i,j)*_rightInput(cl,bf,pt, j);
694 _output(cl,bf,pt, i) = tmp;
699 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
700 KOKKOS_FORCEINLINE_FUNCTION
701 typename std::enable_if_t<l==4 && r==3 && hf, void>
702 apply_matvec_product(
const ordinal_type &cl,
703 const ordinal_type &bf,
704 const ordinal_type &pt)
const {
705 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
707 for (ordinal_type i=0;i<_iend;++i) {
709 for (ordinal_type j=0;j<_jend;++j)
710 tmp += _leftInput(cl,lpt, j,i)*_rightInput(bf,pt, j);
711 _output(cl,bf,pt, i) = tmp;
714 for (ordinal_type i=0;i<_iend;++i) {
716 for (ordinal_type j=0;j<_jend;++j)
717 tmp += _leftInput(cl,lpt, i,j)*_rightInput(bf,pt, j);
718 _output(cl,bf,pt, i) = tmp;
723 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
724 KOKKOS_FORCEINLINE_FUNCTION
725 typename std::enable_if_t<l==3 && r==4 && hf, void>
726 apply_matvec_product(
const ordinal_type &cl,
727 const ordinal_type &bf,
728 const ordinal_type &pt)
const {
729 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
730 for (ordinal_type i=0;i<_iend;++i)
731 _output(cl,bf,pt, i) = _leftInput(cl,lpt, i)*_rightInput(cl,bf,pt, i);
734 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
735 KOKKOS_FORCEINLINE_FUNCTION
736 typename std::enable_if_t<l==3 && r==3 && hf, void>
737 apply_matvec_product(
const ordinal_type &cl,
738 const ordinal_type &bf,
739 const ordinal_type &pt)
const {
740 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
741 for (ordinal_type i=0;i<_iend;++i)
742 _output(cl,bf,pt, i) = _leftInput(cl,lpt, i)*_rightInput(bf,pt, i);
745 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
746 KOKKOS_FORCEINLINE_FUNCTION
747 typename std::enable_if_t<l==2 && r==4 && hf, void>
748 apply_matvec_product(
const ordinal_type &cl,
749 const ordinal_type &bf,
750 const ordinal_type &pt)
const {
751 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
752 const value_type & val = _leftInput(cl,lpt);
753 for (ordinal_type i=0;i<_iend;++i) {
754 _output(cl,bf,pt, i) = val*_rightInput(cl,bf,pt, i);
758 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
759 KOKKOS_FORCEINLINE_FUNCTION
760 typename std::enable_if_t<l==2 && r==3 && hf, void>
761 apply_matvec_product(
const ordinal_type &cl,
762 const ordinal_type &bf,
763 const ordinal_type &pt)
const {
764 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
765 const value_type & val = _leftInput(cl,lpt);
766 for (ordinal_type i=0;i<_iend;++i) {
767 _output(cl,bf,pt, i) = val*_rightInput(bf,pt, i);
772 KOKKOS_INLINE_FUNCTION
773 void operator()(
const ordinal_type cl,
774 const ordinal_type pt)
const
776 apply_matvec_product(cl, pt);
779 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
780 KOKKOS_FORCEINLINE_FUNCTION
781 typename std::enable_if_t<l==4 && r==3 && !hf, void>
782 apply_matvec_product(
const ordinal_type &cl,
783 const ordinal_type &pt)
const {
784 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
786 for (ordinal_type i=0;i<_iend;++i) {
788 for (ordinal_type j=0;j<_jend;++j)
789 tmp += _leftInput(cl,lpt, j,i)*_rightInput(cl,pt, j);
790 _output(cl,pt, i) = tmp;
793 for (ordinal_type i=0;i<_iend;++i) {
795 for (ordinal_type j=0;j<_jend;++j)
796 tmp += _leftInput(cl,lpt, i,j)*_rightInput(cl,pt, j);
797 _output(cl,pt, i) = tmp;
802 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
803 KOKKOS_FORCEINLINE_FUNCTION
804 typename std::enable_if_t<l==4 && r==2 && !hf, void>
805 apply_matvec_product(
const ordinal_type &cl,
806 const ordinal_type &pt)
const {
807 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
809 for (ordinal_type i=0;i<_iend;++i) {
811 for (ordinal_type j=0;j<_jend;++j)
812 tmp += _leftInput(cl,lpt, j,i)*_rightInput(pt, j);
813 _output(cl,pt, i) = tmp;
816 for (ordinal_type i=0;i<_iend;++i) {
818 for (ordinal_type j=0;j<_jend;++j)
819 tmp += _leftInput(cl,lpt, i,j)*_rightInput(pt, j);
820 _output(cl,pt, i) = tmp;
825 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
826 KOKKOS_FORCEINLINE_FUNCTION
827 typename std::enable_if_t<l==3 && r==3 && !hf, void>
828 apply_matvec_product(
const ordinal_type &cl,
829 const ordinal_type &pt)
const {
830 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
831 for (ordinal_type i=0;i<_iend;++i)
832 _output(cl,pt, i) = _leftInput(cl,lpt, i)*_rightInput(cl,pt, i);
835 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
836 KOKKOS_FORCEINLINE_FUNCTION
837 typename std::enable_if_t<l==3 && r==2 && !hf, void>
838 apply_matvec_product(
const ordinal_type &cl,
839 const ordinal_type &pt)
const {
840 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
841 for (ordinal_type i=0;i<_iend;++i)
842 _output(cl,pt, i) = _leftInput(cl,lpt, i)*_rightInput(pt, i);
845 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
846 KOKKOS_FORCEINLINE_FUNCTION
847 typename std::enable_if_t<l==2 && r==3 && !hf, void>
848 apply_matvec_product(
const ordinal_type &cl,
849 const ordinal_type &pt)
const {
850 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
851 const value_type & val = _leftInput(cl,lpt);
852 for (ordinal_type i=0;i<_iend;++i) {
853 _output(cl,pt, i) = val*_rightInput(cl,pt, i);
857 template <ordinal_type l=leftInputRank, ordinal_type r=rightInputRank,
bool hf=hasField>
858 KOKKOS_FORCEINLINE_FUNCTION
859 typename std::enable_if_t<l==2 && r==2 && !hf, void>
860 apply_matvec_product(
const ordinal_type &cl,
861 const ordinal_type &pt)
const {
862 const auto lpt = (_leftInput.extent(1) == 1 ? size_type(0) : pt);
863 const value_type & val = _leftInput(cl,lpt);
864 for (ordinal_type i=0;i<_iend;++i) {
865 _output(cl,pt, i) = val*_rightInput(pt, i);
871 template<
typename DeviceType>
872 template<
typename outputValueType,
class ...outputProperties,
873 typename leftInputValueType,
class ...leftInputProperties,
874 typename rightInputValueType,
class ...rightInputProperties>
877 matvecProduct( Kokkos::DynRankView<outputValueType, outputProperties...> output,
878 const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInput,
879 const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInput,
881 const bool isTranspose ) {
883 using Output = Kokkos::DynRankView<outputValueType, outputProperties...>;
884 using Left =
const Kokkos::DynRankView<leftInputValueType, leftInputProperties...>;
885 using Right =
const Kokkos::DynRankView<rightInputValueType,rightInputProperties...>;
913 const ordinal_type l = leftInput.rank();
914 const ordinal_type r = rightInput.rank();
916 using range_policy2 = Kokkos::MDRangePolicy< ExecSpaceType, Kokkos::Rank<2>, Kokkos::IndexType<ordinal_type> >;
917 range_policy2 policy2( { 0, 0 }, { output.extent(0), output.extent(1) } );
919 using range_policy3 = Kokkos::MDRangePolicy< ExecSpaceType, Kokkos::Rank<3>, Kokkos::IndexType<ordinal_type> >;
920 range_policy3 policy3( { 0, 0, 0 }, { output.extent(0), output.extent(1), output.extent(2) } );
923 const ordinal_type lr = l * 10 + r;
924 const auto &ov = output;
925 const auto &lv = leftInput;
926 const auto &rv = rightInput;
937 case 4: { FT44TT f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
break;
938 default: { FT43TT f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
945 case 4: { FT44TF f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
break;
946 default: { FT43TF f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
954 case 34: { FT34TF f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
break;
955 case 33: { FT33TF f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
break;
956 case 24: { FT24TF f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
break;
957 default: { FT23TF f(ov,lv,rv); Kokkos::parallel_for( policy3, f ); }
970 case 3: { FT43FT f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
break;
971 default: { FT42FT f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
978 case 3: { FT43FF f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
break;
979 default: { FT42FF f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
987 case 33: { FT33FF f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
break;
988 case 32: { FT32FF f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
break;
989 case 23: { FT23FF f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
break;
990 default: { FT22FF f(ov,lv,rv); Kokkos::parallel_for( policy2, f ); }
996 template<
typename DeviceType>
997 template<
typename outputFieldValueType,
class ...outputFieldProperties,
998 typename inputDataValueType,
class ...inputDataProperties,
999 typename inputFieldValueType,
class ...inputFieldProperties>
1002 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
1003 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
1004 const char transpose ) {
1006 #ifdef HAVE_INTREPID2_DEBUG
1015 INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() < 2 || inputData.rank() > 4, std::invalid_argument,
1016 ">>> ERROR (ArrayTools::matvecProductDataField): inputData must have rank 2,3 or 4" );
1017 if (inputData.rank() > 2) {
1018 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(2) < 1 ||
1019 inputData.extent(2) > 3, std::invalid_argument,
1020 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension(2) must be 1,2 or 3");
1022 if (inputData.rank() == 4) {
1023 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(3) < 1 ||
1024 inputData.extent(3) > 3, std::invalid_argument,
1025 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension(3) must be 1,2 or 3");
1029 INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() < 3 ||
1030 inputFields.rank() > 4, std::invalid_argument,
1031 ">>> ERROR (ArrayTools::matvecProductDataField): inputFields must have rank 3 or 4" );
1032 INTREPID2_TEST_FOR_EXCEPTION( (inputFields.rank()-1) < 1 ||
1033 (inputFields.rank()-1) > 3, std::invalid_argument,
1034 ">>> ERROR (ArrayTools::matvecProductDataField): inputFields dimension(rank-1) must be 1,2, or 3" );
1037 INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 4, std::invalid_argument,
1038 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields must have rank 4" );
1039 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(3) < 1 ||
1040 outputFields.extent(3) > 3, std::invalid_argument,
1041 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension(3) must be 1,2 or 3" );
1054 if (inputData.extent(1) > 1) {
1055 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != inputData.extent(1), std::invalid_argument,
1056 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension(2) must match to inputData dimension(1)" );
1058 if (inputData.rank() == 2) {
1059 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputData.extent(0), std::invalid_argument,
1060 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension(0) must match to inputData dimension(0)" );
1062 if (inputData.rank() == 3) {
1063 const size_type f1[] = { 0, 3 }, f2[] = { 0, 2 };
1064 for (size_type i=0; i<2; ++i) {
1065 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
1066 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension does not match to inputData dimension" );
1069 if (inputData.rank() == 4) {
1070 const size_type f1[] = { 0, 3, 3 }, f2[] = { 0, 2, 3 };
1071 for (size_type i=0; i<3; ++i) {
1072 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
1073 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension does not match to inputData dimension" );
1080 if (inputFields.rank() == 4) {
1082 if (inputData.extent(1) > 1) {
1083 INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(2) != inputData.extent(1), std::invalid_argument,
1084 ">>> ERROR (ArrayTools::matvecProductDataField): inputFields dimension (2) does not match to inputData dimension (1)" );
1086 if (inputData.rank() == 2) {
1087 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(0) != inputFields.extent(0), std::invalid_argument,
1088 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension (0) does not match to inputFields dimension (0)" );
1090 if (inputData.rank() == 3) {
1091 const size_type f1[] = { 0, 2 }, f2[] = { 0, 3 };
1092 for (size_type i=0; i<2; ++i) {
1093 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1094 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension does not match to inputFields dimension" );
1097 if (inputData.rank() == 4) {
1098 const size_type f1[] = { 0, 2, 3 }, f2[] = { 0, 3, 3 };
1099 for (size_type i=0; i<3; ++i) {
1100 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1101 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension does not match to inputFields dimension" );
1106 for (size_type i=0; i<outputFields.rank(); ++i) {
1107 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(i) != inputFields.extent(i), std::invalid_argument,
1108 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension does not match to inputFields dimension" );
1112 if (inputData.extent(1) > 1) {
1113 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(1), std::invalid_argument,
1114 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension(1) does not match to inputFields dimension (1)" );
1116 if (inputData.rank() == 3) {
1117 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(2) != inputFields.extent(2), std::invalid_argument,
1118 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension(2) does not match to inputFields dimension (2)" );
1120 if (inputData.rank() == 4) {
1121 const size_type f1[] = { 2, 3 }, f2[] = { 2, 2 };
1122 for (size_type i=0; i<2; ++i) {
1123 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1124 ">>> ERROR (ArrayTools::matvecProductDataField): inputData dimension does not match to inputFields dimension" );
1130 const size_type f1[] = { 1, 2, 3 }, f2[] = { 0, 1, 2 };
1131 for (size_type i=0; i<3; ++i) {
1132 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1133 ">>> ERROR (ArrayTools::matvecProductDataField): outputFields dimension does not match to inputFields dimension" );
1144 transpose ==
't' || transpose ==
'T' );
1149 template<
typename DeviceType>
1150 template<
typename outputDataValueType,
class ...outputDataProperties,
1151 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
1152 typename inputDataRightValueType,
class ...inputDataRightProperties>
1156 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
1157 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
1158 const char transpose ) {
1160 #ifdef HAVE_INTREPID2_DEBUG
1169 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() < 2 ||
1170 inputDataLeft.rank() > 4, std::invalid_argument,
1171 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft must have rank 2,3 or 4" );
1173 if (inputDataLeft.rank() > 2) {
1174 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) < 1 ||
1175 inputDataLeft.extent(2) > 3, std::invalid_argument,
1176 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension(2) must be 1, 2 or 3");
1178 if (inputDataLeft.rank() == 4) {
1179 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(3) < 1 ||
1180 inputDataLeft.extent(3) > 3, std::invalid_argument,
1181 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension(3) must be 1, 2 or 3");
1185 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() < 2 ||
1186 inputDataRight.rank() > 3, std::invalid_argument,
1187 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataRight must have rank 2 or 3" );
1188 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.extent(inputDataRight.rank()-1) < 1 ||
1189 inputDataRight.extent(inputDataRight.rank()-1) > 3, std::invalid_argument,
1190 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataRight dimension (rank-1) must be 1,2 or 3" );
1193 INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 3, std::invalid_argument,
1194 ">>> ERROR (ArrayTools::matvecProductDataData): outputData must have rank 3" );
1195 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(2) < 1 ||
1196 outputData.extent(2) > 3, std::invalid_argument,
1197 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension(2) must be 1, 2 or 3");
1210 if (inputDataLeft.extent(1) > 1) {
1211 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(1) != inputDataLeft.extent(1), std::invalid_argument,
1212 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension(1) muat match inputDataLeft dimension(1)" );
1214 if (inputDataLeft.rank() == 2) {
1215 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataLeft.extent(0), std::invalid_argument,
1216 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension(0) muat match inputDataLeft dimension(0)" );
1218 if (inputDataLeft.rank() == 3) {
1219 const size_type f1[] = { 0, 2 }, f2[] = { 0, 2 };
1220 for (size_type i=0; i<2; ++i) {
1221 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataLeft.extent(f2[i]), std::invalid_argument,
1222 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension muat match inputDataLeft dimension" );
1225 if (inputDataLeft.rank() == 4) {
1226 size_type f1[] = { 0, 2}, f2[] = { 0, 2};
1227 if (transpose) f2[1] = 3;
1228 for (size_type i=0; i<2; ++i) {
1229 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataLeft.extent(f2[i]), std::invalid_argument,
1230 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension muat match inputDataLeft dimension" );
1237 if (inputDataRight.rank() == 3) {
1239 if (inputDataLeft.extent(1) > 1) {
1240 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
1241 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension (1) muat match to inputDataRight dimension (1)" );
1243 if (inputDataLeft.rank() == 2) {
1244 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
1245 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension (0) muat match to inputDataRight dimension (0)" );
1247 if (inputDataLeft.rank() == 3) {
1248 const size_type f1[] = { 0, 2 }, f2[] = { 0, 2 };
1249 for (size_type i=0; i<2; ++i) {
1250 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1251 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension muat match to inputDataRight dimension" );
1254 if (inputDataLeft.rank() == 4) {
1255 size_type f1[] = { 0, 3}, f2[] = { 0, 2};
1256 if (transpose) f1[1] = 2;
1257 for (size_type i=0; i<2; ++i) {
1258 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1259 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension muat match to inputDataRight dimension" );
1264 for (size_type i=0; i<outputData.rank()-1; ++i) {
1265 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(i) != inputDataRight.extent(i), std::invalid_argument,
1266 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension muat match to inputDataRight dimension" );
1270 if (inputDataLeft.extent(1) > 1) {
1271 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(0), std::invalid_argument,
1272 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension (1) does mot match to inputDataright dimension (0)" );
1274 if (inputDataLeft.rank() == 3) {
1275 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(1), std::invalid_argument,
1276 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension (2) does mot match to inputDataright dimension (1)" );
1278 if (inputDataLeft.rank() == 4) {
1279 const size_type f1[] = { 2, 3 }, f2[] = { 1, 1 };
1280 for (size_type i=0; i<2; ++i) {
1281 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1282 ">>> ERROR (ArrayTools::matvecProductDataData): inputDataLeft dimension muat match to inputDataRight dimension" );
1288 const size_type f1[] = { 1, 2 }, f2[] = { 0, 1 };
1289 for (size_type i=0; i<2; ++i) {
1290 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1291 ">>> ERROR (ArrayTools::matvecProductDataData): outputData dimension muat match to inputDataRight dimension" );
1302 transpose ==
't' || transpose ==
'T' );
1306 namespace FunctorArrayTools {
1310 template <
typename OutputViewType,
typename leftInputViewType,
typename rightInputViewType >
1312 OutputViewType _output;
1313 leftInputViewType _leftInput;
1314 rightInputViewType _rightInput;
1315 const bool _hasField, _isTranspose;
1316 typedef typename leftInputViewType::value_type value_type;
1318 KOKKOS_INLINE_FUNCTION
1320 leftInputViewType leftInput_,
1321 rightInputViewType rightInput_,
1322 const bool hasField_,
1323 const bool isTranspose_)
1324 : _output(output_), _leftInput(leftInput_), _rightInput(rightInput_),
1325 _hasField(hasField_), _isTranspose(isTranspose_) {}
1327 KOKKOS_INLINE_FUNCTION
1328 void operator()(
const size_type iter)
const {
1329 size_type cell(0), field(0), point(0);
1330 size_type leftRank = _leftInput.rank();
1331 size_type rightRank = _rightInput.rank();
1334 unrollIndex( cell, field, point,
1340 unrollIndex( cell, point,
1345 auto result = ( _hasField ? Kokkos::subview(_output, cell, field, point, Kokkos::ALL(), Kokkos::ALL()) :
1346 Kokkos::subview(_output, cell, point, Kokkos::ALL(), Kokkos::ALL()));
1348 const auto lpoint = (_leftInput.extent(1) == 1 ? 0 : point);
1349 auto left = ( leftRank == 4 ? Kokkos::subview(_leftInput, cell, lpoint, Kokkos::ALL(), Kokkos::ALL()) :
1350 leftRank == 3 ? Kokkos::subview(_leftInput, cell, lpoint, Kokkos::ALL()) :
1351 Kokkos::subview(_leftInput, cell, lpoint) );
1354 const bool hasCell = (_hasField ? rightRank == 5 : rightRank == 4);
1355 auto right = ( _hasField ? ( hasCell ? Kokkos::subview(_rightInput, cell, field, point, Kokkos::ALL(), Kokkos::ALL()) :
1356 Kokkos::subview(_rightInput, field, point, Kokkos::ALL(), Kokkos::ALL())):
1357 ( hasCell ? Kokkos::subview(_rightInput, cell, point, Kokkos::ALL(), Kokkos::ALL()) :
1358 Kokkos::subview(_rightInput, point, Kokkos::ALL(), Kokkos::ALL())));
1360 const ordinal_type iend = result.extent(0);
1361 const ordinal_type jend = result.extent(1);
1366 const size_type kend = right.extent(0);
1367 for (ordinal_type i=0; i<iend; ++i)
1368 for (ordinal_type j=0; j<jend; ++j) {
1369 result(i, j) = value_type(0);
1370 for (size_type k=0; k<kend; ++k)
1371 result(i, j) += left(k, i) * right(k, j);
1374 const size_type kend = right.extent(0);
1375 for (ordinal_type i=0; i<iend; ++i)
1376 for (ordinal_type j=0; j<jend; ++j) {
1377 result(i, j) = value_type(0);
1378 for (size_type k=0; k<kend; ++k)
1379 result(i, j) += left(i, k) * right(k, j);
1385 for (ordinal_type i=0; i<iend; ++i)
1386 for (ordinal_type j=0; j<jend; ++j)
1387 result(i, j) = left(i) * right(i, j);
1391 for (ordinal_type i=0; i<iend; ++i)
1392 for (ordinal_type j=0; j<jend; ++j)
1393 result(i, j) = left() * right(i, j);
1401 template<
typename DeviceType>
1402 template<
typename outputValueType,
class ...outputProperties,
1403 typename leftInputValueType,
class ...leftInputProperties,
1404 typename rightInputValueType,
class ...rightInputProperties>
1407 matmatProduct( Kokkos::DynRankView<outputValueType, outputProperties...> output,
1408 const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInput,
1409 const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInput,
1410 const bool hasField,
1411 const bool isTranspose ) {
1413 typedef Kokkos::DynRankView<outputValueType, outputProperties...> OutputViewType;
1414 typedef const Kokkos::DynRankView<leftInputValueType, leftInputProperties...> leftInputViewType;
1415 typedef const Kokkos::DynRankView<rightInputValueType,rightInputProperties...> rightInputViewType;
1418 const size_type loopSize = ( hasField ? output.extent(0)*output.extent(1)*output.extent(2) :
1419 output.extent(0)*output.extent(1) );
1420 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
1421 Kokkos::parallel_for( policy, FunctorType(output, leftInput, rightInput, hasField, isTranspose) );
1427 template<
typename DeviceType>
1428 template<
typename outputFieldValueType,
class ...outputFieldProperties,
1429 typename inputDataValueType,
class ...inputDataProperties,
1430 typename inputFieldValueType,
class ...inputFieldProperties>
1434 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
1435 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
1436 const char transpose ) {
1438 #ifdef HAVE_INTREPID2_DEBUG
1447 INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() < 2 ||
1448 inputData.rank() > 4, std::invalid_argument,
1449 ">>> ERROR (ArrayTools::matmatProductDataField): inputData must have rank 2,3 or 4" );
1450 if (inputData.rank() > 2) {
1451 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(2) < 1 ||
1452 inputData.extent(2) > 3, std::invalid_argument,
1453 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension (2) must be 1,2 or 3" );
1455 if (inputData.rank() == 4) {
1456 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(3) < 1 ||
1457 inputData.extent(3) > 3, std::invalid_argument,
1458 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension (3) must be 1,2 or 3" );
1462 INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() < 4 ||
1463 inputFields.rank() > 5, std::invalid_argument,
1464 ">>> ERROR (ArrayTools::matmatProductDataField): inputFields must have rank 4 or 5");
1465 INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(inputFields.rank()-1) < 1 ||
1466 inputFields.extent(inputFields.rank()-1) > 3, std::invalid_argument,
1467 ">>> ERROR (ArrayTools::matmatProductDataField): inputFields dimension (rank-1) must be 1,2 or 3" );
1468 INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(inputFields.rank()-2) < 1 ||
1469 inputFields.extent(inputFields.rank()-2) > 3, std::invalid_argument,
1470 ">>> ERROR (ArrayTools::matmatProductDataField): inputFields dimension (rank-2) must be 1,2 or 3" );
1473 INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 5, std::invalid_argument,
1474 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields must have rank 5" );
1475 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(3) < 1 ||
1476 outputFields.extent(3) > 3, std::invalid_argument,
1477 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension (3) must be 1,2 or 3" );
1478 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(4) < 1 ||
1479 outputFields.extent(4) > 3, std::invalid_argument,
1480 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension (4) must be 1,2 or 3" );
1493 if (inputData.extent(1) > 1) {
1494 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != inputData.extent(1), std::invalid_argument,
1495 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension (2) does not match to inputData dimension (1)" );
1497 if (inputData.rank() == 2) {
1498 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputData.extent(0), std::invalid_argument,
1499 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension (0) does not match to inputData dimension (0)" );
1501 if (inputData.rank() == 3) {
1502 const size_type f1[] = { 0, 3, 4 }, f2[] = { 0, 2, 2 };
1503 for (size_type i=0; i<3; ++i) {
1504 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
1505 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension does not match to inputData dimension" );
1508 if (inputData.rank() == 4) {
1509 const size_type f1[] = { 0, 3, 4 }, f2[] = { 0, 2, 3 };
1510 for (size_type i=0; i<3; ++i) {
1511 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputData.extent(f2[i]), std::invalid_argument,
1512 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension does not match to inputData dimension" );
1519 if (inputFields.rank() == 5) {
1521 if (inputData.extent(1) > 1) {
1522 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2), std::invalid_argument,
1523 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension (1) does not match to inputFields dimension (2)" );
1525 if (inputData.rank() == 2) {
1526 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(0) != inputFields.extent(0), std::invalid_argument,
1527 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension (0) does not match to inputFields dimension (0)" );
1529 if (inputData.rank() == 3) {
1531 const size_type f1[] = { 0, 2, 2 }, f2[] = { 0, 3, 4 };
1532 for (size_type i=0; i<3; ++i) {
1533 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1534 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension does not match to inputFields dimension" );
1537 if (inputData.rank() == 4) {
1538 const size_type f1[] = { 0, 2, 3 }, f2[] = { 0, 3, 4 };
1539 for (size_type i=0; i<3; ++i) {
1540 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1541 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension does not match to inputFields dimension" );
1546 for (size_type i=0; i<outputFields.rank(); ++i) {
1547 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(i) != inputFields.extent(i), std::invalid_argument,
1548 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension does not match to inputFields dimension" );
1552 if (inputData.extent(1) > 1) {
1553 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(1), std::invalid_argument,
1554 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension (1) does not match to inputFields dimension (1)" );
1556 if (inputData.rank() == 3) {
1557 const size_type f1[] = { 2, 2 }, f2[] = { 2, 3 };
1558 for (size_type i=0; i<2; ++i) {
1559 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1560 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension does not match to inputFields dimension" );
1563 if (inputData.rank() == 4) {
1564 const size_type f1[] = { 2, 3 }, f2[] = { 2, 3 };
1565 for (size_type i=0; i<2; ++i) {
1566 INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1567 ">>> ERROR (ArrayTools::matmatProductDataField): inputData dimension does not match to inputFields dimension" );
1573 const size_type f1[] = { 1, 2, 3, 4 }, f2[] = { 0, 1, 2, 3 };
1574 for (size_type i=0; i<4; ++i) {
1575 INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(f1[i]) != inputFields.extent(f2[i]), std::invalid_argument,
1576 ">>> ERROR (ArrayTools::matmatProductDataField): outputFields dimension does not match to inputFields dimension" );
1587 transpose ==
't' || transpose ==
'T' );
1592 template<
typename DeviceType>
1593 template<
typename outputDataValueType,
class ...outputDataProperties,
1594 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
1595 typename inputDataRightValueType,
class ...inputDataRightProperties>
1598 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
1599 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
1600 const char transpose ) {
1602 #ifdef HAVE_INTREPID2_DEBUG
1611 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() < 2 ||
1612 inputDataLeft.rank() > 4, std::invalid_argument,
1613 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataLeft must have rank 2,3 or 4" );
1614 if (inputDataLeft.rank() > 2) {
1615 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) < 1 ||
1616 inputDataLeft.extent(2) > 3, std::invalid_argument,
1617 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataLeft dimension (2) must be 1,2 or 3" );
1619 if (inputDataLeft.rank() == 4) {
1620 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(3) < 1 ||
1621 inputDataLeft.extent(3) > 3, std::invalid_argument,
1622 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataLeft dimension (3) must be 1,2 or 3" );
1626 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() < 3 ||
1627 inputDataRight.rank() > 4, std::invalid_argument,
1628 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataRight must have rank 3 or 4" );
1629 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.extent(inputDataRight.rank()-1) < 1 ||
1630 inputDataRight.extent(inputDataRight.rank()-1) > 3, std::invalid_argument,
1631 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataRight (rank-1) must be 1,2 or 3" );
1632 INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.extent(inputDataRight.rank()-2) < 1 ||
1633 inputDataRight.extent(inputDataRight.rank()-2) > 3, std::invalid_argument,
1634 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataRight (rank-2) must be 1,2 or 3" );
1637 INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 4, std::invalid_argument,
1638 ">>> ERROR (ArrayTools::matmatProductDataData): outputData must have rank 4" );
1639 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(2) < 1 ||
1640 outputData.extent(2) > 3, std::invalid_argument,
1641 ">>> ERROR (ArrayTools::matmatProductDataData): outputData (2) must be 1,2 or 3" );
1642 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(3) < 1 ||
1643 outputData.extent(3) > 3, std::invalid_argument,
1644 ">>> ERROR (ArrayTools::matmatProductDataData): outputData (3) must be 1,2 or 3" );
1657 if (inputDataLeft.extent(1) > 1) {
1658 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(1) != inputDataLeft.extent(1), std::invalid_argument,
1659 ">>> ERROR (ArrayTools::matmatProductDataData): outputData dimension (1) does not match to inputDataLeft dimension (1)" );
1661 if (inputDataLeft.rank() == 2) {
1662 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataLeft.extent(0), std::invalid_argument,
1663 ">>> ERROR (ArrayTools::matmatProductDataData): outputData dimension (0) does not match to inputDataLeft dimension (0)" );
1665 if (inputDataLeft.rank() == 3) {
1666 const size_type f1[] = { 0, 2, 3 }, f2[] = { 0, 2, 2 };
1667 for (size_type i=0; i<3; ++i) {
1668 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataLeft.extent(f2[i]), std::invalid_argument,
1669 ">>> ERROR (ArrayTools::matmatProductDataData): outputData dimension does not match to inputDataLeft dimension" );
1672 if (inputDataLeft.rank() == 4) {
1673 const size_type f1[] = { 0, 2, 3 }, f2[] = { 0, 2, 3 };
1674 for (size_type i=0; i<3; ++i) {
1675 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataLeft.extent(f2[i]), std::invalid_argument,
1676 ">>> ERROR (ArrayTools::matmatProductDataData): outputData dimension does not match to inputDataLeft dimension" );
1683 if (inputDataRight.rank() == 4) {
1685 if (inputDataLeft.extent(1) > 1) {
1686 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
1687 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataLeft dimension (1) does not match to inputDataRight dimension (1)" );
1689 if (inputDataLeft.rank() == 2) {
1690 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
1691 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataLeft dimension (0) does not match to inputDataRight dimension (0)" );
1693 if (inputDataLeft.rank() == 3) {
1694 const size_type f1[] = { 0, 2, 2 }, f2[] = { 0, 2, 3 };
1695 for (size_type i=0; i<3; ++i) {
1696 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1697 ">>> ERROR (ArrayTools::matmatProductDataData): intputDataLeft dimension does not match to inputDataRight dimension" );
1700 if (inputDataLeft.rank() == 4) {
1701 const size_type f1[] = { 0, 2, 3 }, f2[] = { 0, 2, 3 };
1702 for (size_type i=0; i<3; ++i) {
1703 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1704 ">>> ERROR (ArrayTools::matmatProductDataData): intputDataLeft dimension does not match to inputDataRight dimension" );
1709 for (size_type i=0; i< outputData.rank(); ++i) {
1710 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(i) != inputDataRight.extent(i), std::invalid_argument,
1711 ">>> ERROR (ArrayTools::matmatProductDataData): outputData dimension does not match to inputDataRight dimension" );
1715 if (inputDataLeft.extent(1) > 1) {
1716 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(0), std::invalid_argument,
1717 ">>> ERROR (ArrayTools::matmatProductDataData): inputDataLeft dimension (1) does not match to inputDataRight dimension (0)" );
1719 if (inputDataLeft.rank() == 3) {
1720 const size_type f1[] = { 2, 2 }, f2[] = { 1, 2 };
1721 for (size_type i=0; i<2; ++i) {
1722 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1723 ">>> ERROR (ArrayTools::matmatProductDataData): intputDataLeft dimension does not match to inputDataRight dimension" );
1726 if (inputDataLeft.rank() == 4) {
1727 const size_type f1[] = { 2, 3 }, f2[] = { 1, 2 };
1728 for (size_type i=0; i<2; ++i) {
1729 INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1730 ">>> ERROR (ArrayTools::matmatProductDataData): intputDataLeft dimension does not match to inputDataRight dimension" );
1735 const size_type f1[] = { 1, 2, 3 }, f2[] = { 0, 1, 2 };
1736 for (size_type i=0; i<3; ++i) {
1737 INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(f1[i]) != inputDataRight.extent(f2[i]), std::invalid_argument,
1738 ">>> ERROR (ArrayTools::matmatProductDataData): outputData dimension does not match to inputDataRight dimension" );
1749 transpose ==
't' || transpose ==
'T' );