This file is indexed.

/usr/include/trilinos/Intrepid_ArrayTools.hpp is in libtrilinos-intrepid-dev 12.4.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
// @HEADER
// ************************************************************************
//
//                           Intrepid Package
//                 Copyright (2007) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Pavel Bochev  (pbboche@sandia.gov)
//                    Denis Ridzal  (dridzal@sandia.gov), or
//                    Kara Peterson (kjpeter@sandia.gov)
//
// ************************************************************************
// @HEADER

/** \file   Intrepid_ArrayTools.hpp
    \brief  Header file for utility class to provide array tools,
            such as tensor contractions, etc.
    \author Created by P. Bochev and D. Ridzal.
*/

#ifndef INTREPID_ARRAYTOOLS_HPP
#define INTREPID_ARRAYTOOLS_HPP

#include "Intrepid_ConfigDefs.hpp"
#include "Intrepid_Types.hpp"
#include "Teuchos_BLAS.hpp"
#include "Teuchos_Assert.hpp"
#include <KokkosRank.hpp>
#ifdef HAVE_INTREPID_KOKKOSCORE
#include "Kokkos_Core.hpp"
#include <impl/Kokkos_Timer.hpp>
#endif

namespace Intrepid {
  
  /** \class Intrepid::ArrayTools
      \brief Utility class that provides methods for higher-order algebraic
             manipulation of user-defined arrays, such as tensor contractions.
             For low-order operations, see Intrepid::RealSpaceTools.
  */

  class ArrayTools {
  public:

    /** \brief Contracts the "point" dimension P of two rank-3 containers with
               dimensions (C,L,P) and (C,R,P), and returns the result in a
               rank-3 container with dimensions (C,L,R).

               For a fixed index "C", (C,L,R) represents a rectangular L X R matrix
               where L and R may be different.
        \code
          C - num. integration domains       dim0 in both input containers
          L - num. "left" fields             dim1 in "left" container
          R - num. "right" fields            dim1 in "right" container
          P - num. integration points        dim2 in both input containers
        \endcode

        \param  outputFields   [out] - Output array.
        \param  leftFields      [in] - Left input array.
        \param  rightFields     [in] - Right input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
 /*       template<class Scalar, class ArrayOutFields, class ArrayInFieldsLeft, class ArrayInFieldsRight>
    static void contractFieldFieldScalarTemp(ArrayOutFields &            outputFields,
                                         const ArrayInFieldsLeft &   leftFields,
                                         const ArrayInFieldsRight &  rightFields,
                                         const ECompEngine           compEngine,
                                         const bool                  sumInto = false);

*/
    /** \brief Contracts the "point" and "space" dimensions P and D1 of two rank-4
               containers with dimensions (C,L,P,D1) and (C,R,P,D1), and returns the
               result in a rank-3 container with dimensions (C,L,R).

               For a fixed index "C", (C,L,R) represents a rectangular L X R matrix
               where L and R may be different.
        \code
          C - num. integration domains       dim0 in both input containers
          L - num. "left" fields             dim1 in "left" container
          R - num. "right" fields            dim1 in "right" container
          P - num. integration points        dim2 in both input containers
          D1- vector dimension               dim3 in both input containers
        \endcode

        \param  outputFields   [out] - Output array.
        \param  leftFields      [in] - Left input array.
        \param  rightFields     [in] - Right input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
 /*   template<class Scalar, class ArrayOutFields, class ArrayInFieldsLeft, class ArrayInFieldsRight>
    static void contractFieldFieldVectorTemp(ArrayOutFields &            outputFields,
                                         const ArrayInFieldsLeft &   leftFields,
                                         const ArrayInFieldsRight &  rightFields,
                                         const ECompEngine           compEngine,
                                         const bool                  sumInto = false);
*/
    
    /** \brief Contracts the "point" and "space" dimensions P, D1, and D2 of two rank-5
               containers with dimensions (C,L,P,D1,D2) and (C,R,P,D1,D2), and returns
               the result in a rank-3 container with dimensions (C,L,R).

               For a fixed index "C", (C,L,R) represents a rectangular L X R matrix
               where L and R may be different.
        \code
          C - num. integration domains       dim0 in both input containers
          L - num. "left" fields             dim1 in "left" container
          R - num. "right" fields            dim1 in "right" container
          P - num. integration points        dim2 in both input containers
          D1- vector dimension               dim3 in both input containers
          D2- 2nd tensor dimension           dim4 in both input containers
        \endcode

        \param  outputFields   [out] - Output array.
        \param  leftFields      [in] - Left input array.
        \param  rightFields     [in] - Right input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    /*
    template<class Scalar, class ArrayOutFields, class ArrayInFieldsLeft, class ArrayInFieldsRight>
    static void contractFieldFieldTensorTemp(ArrayOutFields &            outputFields,
                                         const ArrayInFieldsLeft &   leftFields,
                                         const ArrayInFieldsRight &  rightFields,
                                         const ECompEngine           compEngine,
                                         const bool                  sumInto = false);
    */
    
    /** \brief Contracts the "point" dimensions P of a rank-3 containers and
               a rank-2 container with dimensions (C,F,P) and (C,P), respectively,
               and returns the result in a rank-2 container with dimensions (C,F).

               For a fixed index "C", (C,F) represents a (column) vector of length F.
        \code
          C - num. integration domains       dim0 in both input containers
          F - num. fields                    dim1 in fields input container
          P - num. integration points        dim2 in fields input container and dim1 in scalar data container
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    
    /*
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void contractDataFieldScalarTemp(ArrayOutFields &       outputFields,
                                        const ArrayInData &    inputData,
                                        const ArrayInFields &  inputFields,
                                        const ECompEngine      compEngine,
                                        const bool             sumInto = false);
*/

    /** \brief Contracts the "point" and "space" dimensions P and D of a rank-4 container and
               a rank-3 container with dimensions (C,F,P,D) and (C,P,D), respectively,
               and returns the result in a rank-2 container with dimensions (C,F).

               For a fixed index "C", (C,F) represents a (column) vector of length F.
        \code
          C - num. integration domains                dim0 in both input containers
          F - num. fields                             dim1 in fields input container
          P - num. integration points                 dim2 in fields input container and dim1 in vector data container
          D - spatial (vector) dimension index        dim3 in fields input container and dim2 in vector data container
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    /*
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void contractDataFieldVectorTemp(ArrayOutFields &       outputFields,
                                        const ArrayInData &    inputData,
                                        const ArrayInFields &  inputFields,
                                        const ECompEngine      compEngine,
                                        const bool             sumInto = false);
*/
    
    /** \brief Contracts the "point" and "space" dimensions P, D1 and D2 of a rank-5 container and
               a rank-4 container with dimensions (C,F,P,D1,D2) and (C,P,D1,D2), respectively,
               and returns the result in a rank-2 container with dimensions (C,F).

               For a fixed index "C", (C,F) represents a (column) vector of length F.
        \code
          C  - num. integration domains                       dim0 in both input containers
          F  - num. fields                                    dim1 in fields input container
          P  - num. integration points                        dim2 in fields input container and dim1 in tensor data container
          D1 - first spatial (tensor) dimension index         dim3 in fields input container and dim2 in tensor data container
          D2 - second spatial (tensor) dimension index        dim4 in fields input container and dim3 in tensor data container
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    /*
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void contractDataFieldTensorTemp(ArrayOutFields &       outputFields,
                                        const ArrayInData &    inputData,
                                        const ArrayInFields &  inputFields,
                                        const ECompEngine      compEngine,
                                        const bool             sumInto = false);

*/
    /** \brief Contracts the "point" dimensions P of rank-2 containers
               with dimensions (C,P), and returns the result in a rank-1 container
               with dimensions (C).

        \code
          C - num. integration domains       dim0 in both input containers
          P - num. integration points        dim1 in both input containers
        \endcode

        \param  outputData     [out] - Output data array.
        \param  inputDataLeft   [in] - Left data input array.
        \param  inputDataRight  [in] - Right data input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    /*
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void contractDataDataScalarTemp(ArrayOutData &            outputData,
                                       const ArrayInDataLeft &   inputDataLeft,
                                       const ArrayInDataRight &  inputDataRight,
                                       const ECompEngine         compEngine,
                                       const bool                sumInto = false);
*/

    /** \brief Contracts the "point" and "space" dimensions P and D of rank-3 containers
               with dimensions (C,P,D) and returns the result in a rank-1 container with dimensions (C).

        \code
          C - num. integration domains                dim0 in both input containers
          P - num. integration points                 dim1 in both input containers
          D - spatial (vector) dimension index        dim2 in both input containers
        \endcode

        \param  outputData     [out] - Output data array.
        \param  inputDataLeft   [in] - Left data input array.
        \param  inputDataRight  [in] - Right data input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
 /*   template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void contractDataDataVectorTemp(ArrayOutData &            outputData,
                                       const ArrayInDataLeft &   inputDataLeft,
                                       const ArrayInDataRight &  inputDataRight,
                                       const ECompEngine         compEngine,
                                       const bool                sumInto = false);

*/
    /** \brief Contracts the "point" and "space" dimensions P, D1 and D2 of rank-4 containers
               with dimensions (C,P,D1,D2) and returns the result in a rank-1 container with dimensions (C).

        \code
          C - num. integration domains                     dim0 in both input containers
          P - num. integration points                      dim1 in both input containers
          D1 - first spatial (tensor) dimension index      dim2 in both input containers
          D2 - second spatial (tensor) dimension index     dim3 in both input containers
        \endcode

        \param  outputData     [out] - Output data array.
        \param  inputDataLeft   [in] - Left data input array.
        \param  inputDataRight  [in] - Right data input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
   /* template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void contractDataDataTensorTemp(ArrayOutData &            outputData,
                                       const ArrayInDataLeft &   inputDataLeft,
                                       const ArrayInDataRight &  inputDataRight,
                                       const ECompEngine         compEngine,
                                       const bool                sumInto = false);
*/

    /** \brief There are two use cases:
               (1) multiplies a rank-3, 4, or 5 container \a <b>inputFields</b> with dimensions (C,F,P),
               (C,F,P,D1) or (C,F,P,D1,D2), representing the values of a set of scalar, vector
               or tensor fields, by the values in a rank-2 container \a <b>inputData</b> indexed by (C,P),
               representing the values of scalar data, OR
               (2) multiplies a rank-2, 3, or 4 container \a <b>inputFields</b> with dimensions (F,P),
               (F,P,D1) or (F,P,D1,D2), representing the values of a scalar, vector or a
               tensor field, by the values in a rank-2 container \a <b>inputData</b> indexed by (C,P),
               representing the values of scalar data;
               the output value container \a <b>outputFields</b> is indexed by (C,F,P), (C,F,P,D1)
               or (C,F,P,D1,D2), regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains               
          F  - num. fields                            
          P  - num. integration points                
          D1 - first spatial (tensor) dimension index 
          D2 - second spatial (tensor) dimension index
        \endcode

        \note   The argument <var><b>inputFields</b></var> can be changed!
                This enables in-place multiplication.

        \param  outputFields   [out] - Output (product) fields array.
        \param  inputData       [in] - Data (multiplying) array.
        \param  inputFields     [in] - Input (being multiplied) fields array.
        \param  reciprocal      [in] - If TRUE, <b>divides</b> input fields by the data
                                       (instead of multiplying). Default: FALSE.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInFieldsLeft, class ArrayInFieldsRight>
    static void contractFieldFieldScalar(ArrayOutFields &            outputFields,
                                         const ArrayInFieldsLeft &   leftFields,
                                         const ArrayInFieldsRight &  rightFields,
                                         const ECompEngine           compEngine,
                                         const bool                  sumInto = false);


    /** \brief Contracts the "point" and "space" dimensions P and D1 of two rank-4
               containers with dimensions (C,L,P,D1) and (C,R,P,D1), and returns the
               result in a rank-3 container with dimensions (C,L,R).

               For a fixed index "C", (C,L,R) represents a rectangular L X R matrix
               where L and R may be different.
        \code
          C - num. integration domains       dim0 in both input containers
          L - num. "left" fields             dim1 in "left" container
          R - num. "right" fields            dim1 in "right" container
          P - num. integration points        dim2 in both input containers
          D1- vector dimension               dim3 in both input containers
        \endcode

        \param  outputFields   [out] - Output array.
        \param  leftFields      [in] - Left input array.
        \param  rightFields     [in] - Right input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutFields, class ArrayInFieldsLeft, class ArrayInFieldsRight>
    static void contractFieldFieldVector(ArrayOutFields &            outputFields,
                                         const ArrayInFieldsLeft &   leftFields,
                                         const ArrayInFieldsRight &  rightFields,
                                         const ECompEngine           compEngine,
                                         const bool                  sumInto = false);

    
    /** \brief Contracts the "point" and "space" dimensions P, D1, and D2 of two rank-5
               containers with dimensions (C,L,P,D1,D2) and (C,R,P,D1,D2), and returns
               the result in a rank-3 container with dimensions (C,L,R).

               For a fixed index "C", (C,L,R) represents a rectangular L X R matrix
               where L and R may be different.
        \code
          C - num. integration domains       dim0 in both input containers
          L - num. "left" fields             dim1 in "left" container
          R - num. "right" fields            dim1 in "right" container
          P - num. integration points        dim2 in both input containers
          D1- vector dimension               dim3 in both input containers
          D2- 2nd tensor dimension           dim4 in both input containers
        \endcode

        \param  outputFields   [out] - Output array.
        \param  leftFields      [in] - Left input array.
        \param  rightFields     [in] - Right input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutFields, class ArrayInFieldsLeft, class ArrayInFieldsRight>
    static void contractFieldFieldTensor(ArrayOutFields &            outputFields,
                                         const ArrayInFieldsLeft &   leftFields,
                                         const ArrayInFieldsRight &  rightFields,
                                         const ECompEngine           compEngine,
                                         const bool                  sumInto = false);
    
    
    /** \brief Contracts the "point" dimensions P of a rank-3 containers and
               a rank-2 container with dimensions (C,F,P) and (C,P), respectively,
               and returns the result in a rank-2 container with dimensions (C,F).

               For a fixed index "C", (C,F) represents a (column) vector of length F.
        \code
          C - num. integration domains       dim0 in both input containers
          F - num. fields                    dim1 in fields input container
          P - num. integration points        dim2 in fields input container and dim1 in scalar data container
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void contractDataFieldScalar(ArrayOutFields &       outputFields,
                                        const ArrayInData &    inputData,
                                        const ArrayInFields &  inputFields,
                                        const ECompEngine      compEngine,
                                        const bool             sumInto = false);


    /** \brief Contracts the "point" and "space" dimensions P and D of a rank-4 container and
               a rank-3 container with dimensions (C,F,P,D) and (C,P,D), respectively,
               and returns the result in a rank-2 container with dimensions (C,F).

               For a fixed index "C", (C,F) represents a (column) vector of length F.
        \code
          C - num. integration domains                dim0 in both input containers
          F - num. fields                             dim1 in fields input container
          P - num. integration points                 dim2 in fields input container and dim1 in vector data container
          D - spatial (vector) dimension index        dim3 in fields input container and dim2 in vector data container
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void contractDataFieldVector(ArrayOutFields &       outputFields,
                                        const ArrayInData &    inputData,
                                        const ArrayInFields &  inputFields,
                                        const ECompEngine      compEngine,
                                        const bool             sumInto = false);

    
    /** \brief Contracts the "point" and "space" dimensions P, D1 and D2 of a rank-5 container and
               a rank-4 container with dimensions (C,F,P,D1,D2) and (C,P,D1,D2), respectively,
               and returns the result in a rank-2 container with dimensions (C,F).

               For a fixed index "C", (C,F) represents a (column) vector of length F.
        \code
          C  - num. integration domains                       dim0 in both input containers
          F  - num. fields                                    dim1 in fields input container
          P  - num. integration points                        dim2 in fields input container and dim1 in tensor data container
          D1 - first spatial (tensor) dimension index         dim3 in fields input container and dim2 in tensor data container
          D2 - second spatial (tensor) dimension index        dim4 in fields input container and dim3 in tensor data container
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void contractDataFieldTensor(ArrayOutFields &       outputFields,
                                        const ArrayInData &    inputData,
                                        const ArrayInFields &  inputFields,
                                        const ECompEngine      compEngine,
                                        const bool             sumInto = false);


    /** \brief Contracts the "point" dimensions P of rank-2 containers
               with dimensions (C,P), and returns the result in a rank-1 container
               with dimensions (C).

        \code
          C - num. integration domains       dim0 in both input containers
          P - num. integration points        dim1 in both input containers
        \endcode

        \param  outputData     [out] - Output data array.
        \param  inputDataLeft   [in] - Left data input array.
        \param  inputDataRight  [in] - Right data input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void contractDataDataScalar(ArrayOutData &            outputData,
                                       const ArrayInDataLeft &   inputDataLeft,
                                       const ArrayInDataRight &  inputDataRight,
                                       const ECompEngine         compEngine,
                                       const bool                sumInto = false);


    /** \brief Contracts the "point" and "space" dimensions P and D of rank-3 containers
               with dimensions (C,P,D) and returns the result in a rank-1 container with dimensions (C).

        \code
          C - num. integration domains                dim0 in both input containers
          P - num. integration points                 dim1 in both input containers
          D - spatial (vector) dimension index        dim2 in both input containers
        \endcode

        \param  outputData     [out] - Output data array.
        \param  inputDataLeft   [in] - Left data input array.
        \param  inputDataRight  [in] - Right data input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void contractDataDataVector(ArrayOutData &            outputData,
                                       const ArrayInDataLeft &   inputDataLeft,
                                       const ArrayInDataRight &  inputDataRight,
                                       const ECompEngine         compEngine,
                                       const bool                sumInto = false);


    /** \brief Contracts the "point" and "space" dimensions P, D1 and D2 of rank-4 containers
               with dimensions (C,P,D1,D2) and returns the result in a rank-1 container with dimensions (C).

        \code
          C - num. integration domains                     dim0 in both input containers
          P - num. integration points                      dim1 in both input containers
          D1 - first spatial (tensor) dimension index      dim2 in both input containers
          D2 - second spatial (tensor) dimension index     dim3 in both input containers
        \endcode

        \param  outputData     [out] - Output data array.
        \param  inputDataLeft   [in] - Left data input array.
        \param  inputDataRight  [in] - Right data input array.
        \param  compEngine      [in] - Computational engine.
        \param  sumInto         [in] - If TRUE, sum into given output array,
                                       otherwise overwrite it. Default: FALSE. 
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void contractDataDataTensor(ArrayOutData &            outputData,
                                       const ArrayInDataLeft &   inputDataLeft,
                                       const ArrayInDataRight &  inputDataRight,
                                       const ECompEngine         compEngine,
                                       const bool                sumInto = false);


    /** \brief There are two use cases:
               (1) multiplies a rank-3, 4, or 5 container \a <b>inputFields</b> with dimensions (C,F,P),
               (C,F,P,D1) or (C,F,P,D1,D2), representing the values of a set of scalar, vector
               or tensor fields, by the values in a rank-2 container \a <b>inputData</b> indexed by (C,P),
               representing the values of scalar data, OR
               (2) multiplies a rank-2, 3, or 4 container \a <b>inputFields</b> with dimensions (F,P),
               (F,P,D1) or (F,P,D1,D2), representing the values of a scalar, vector or a
               tensor field, by the values in a rank-2 container \a <b>inputData</b> indexed by (C,P),
               representing the values of scalar data;
               the output value container \a <b>outputFields</b> is indexed by (C,F,P), (C,F,P,D1)
               or (C,F,P,D1,D2), regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains               
          F  - num. fields                            
          P  - num. integration points                
          D1 - first spatial (tensor) dimension index 
          D2 - second spatial (tensor) dimension index
        \endcode

        \note   The argument <var><b>inputFields</b></var> can be changed!
                This enables in-place multiplication.

        \param  outputFields   [out] - Output (product) fields array.
        \param  inputData       [in] - Data (multiplying) array.
        \param  inputFields     [in] - Input (being multiplied) fields array.
        \param  reciprocal      [in] - If TRUE, <b>divides</b> input fields by the data
                                       (instead of multiplying). Default: FALSE.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void scalarMultiplyDataField(ArrayOutFields &     outputFields,
                                        const ArrayInData &  inputData,
                                        const ArrayInFields &      inputFields,
                                        const bool           reciprocal = false);

   template<class ArrayOutFields, class ArrayInData, class ArrayInFields, class Layout, class MemorySpace,int infieldRank,int outfieldRank>
	struct scalarMultiplyDataField2;
	/*
 
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void scalarMultiplyDataFieldTemp(ArrayOutFields &     outputFields,
                                         const ArrayInData &  inputData,
                                         ArrayInFields &      inputFields,
                                         const bool           reciprocal=false);*/
    /** \brief There are two use cases:
               (1) multiplies a rank-2, 3, or 4 container \a <b>inputDataRight</b> with dimensions (C,P),
               (C,P,D1) or (C,P,D1,D2), representing the values of a set of scalar, vector
               or tensor data, by the values in a rank-2 container \a <b>inputDataLeft</b> indexed by (C,P),
               representing the values of scalar data, OR
               (2) multiplies a rank-1, 2, or 3 container \a <b>inputDataRight</b> with dimensions (P),
               (P,D1) or (P,D1,D2), representing the values of scalar, vector or
               tensor data, by the values in a rank-2 container \a <b>inputDataLeft</b> indexed by (C,P),
               representing the values of scalar data;
               the output value container \a <b>outputData</b> is indexed by (C,P), (C,P,D1) or (C,P,D1,D2),
               regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains               
          P  - num. integration points                
          D1 - first spatial (tensor) dimension index 
          D2 - second spatial (tensor) dimension index
        \endcode

        \note   The arguments <var><b>inputDataLeft</b></var>, <var><b>inputDataRight</b></var> can be changed!
                This enables in-place multiplication.

        \param  outputData      [out] - Output data array.
        \param  inputDataLeft    [in] - Left (multiplying) data array.
        \param  inputDataRight   [in] - Right (being multiplied) data array.
        \param  reciprocal       [in] - If TRUE, <b>divides</b> input fields by the data
                                        (instead of multiplying). Default: FALSE.
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void scalarMultiplyDataData(ArrayOutData &           outputData,
                                       const ArrayInDataLeft &        inputDataLeft,
                                       const ArrayInDataRight &       inputDataRight,
                                       const bool               reciprocal = false);
	
    /** \brief There are two use cases:
               (1) dot product of a rank-3, 4 or 5 container \a <b>inputFields</b> with dimensions (C,F,P)
               (C,F,P,D1) or (C,F,P,D1,D2), representing the values of a set of scalar, vector
               or tensor fields, by the values in a rank-2, 3 or 4 container \a <b>inputData</b> indexed by
               (C,P), (C,P,D1), or (C,P,D1,D2) representing the values of scalar, vector or
               tensor data, OR
               (2) dot product of a rank-2, 3 or 4 container \a <b>inputFields</b> with dimensions (F,P),
               (F,P,D1) or (F,P,D1,D2), representing the values of a scalar, vector or tensor
               field, by the values in a rank-2 container \a <b>inputData</b> indexed by (C,P), (C,P,D1) or
               (C,P,D1,D2), representing the values of scalar, vector or tensor data;
               the output value container \a <b>outputFields</b> is indexed by (C,F,P),
               regardless of which of the two use cases is considered.

               For input fields containers without a dimension index, this operation reduces to
               scalar multiplication.
        \code
          C  - num. integration domains
          F  - num. fields
          P  - num. integration points
          D1 - first spatial (tensor) dimension index
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  outputFields   [out] - Output (dot product) fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
    */
    
    template<class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight, class Layout, class MemorySpace,int invalRank,int outvalRank>
	struct scalarMultiplyDataData2;
	/*
    template<class Scalar,class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
        static void scalarMultiplyDataDataTemp(ArrayOutData &     outputData,
                                               ArrayInDataLeft &  inputDataLeft,
                                               ArrayInDataRight & inputDataRight,
                                               const bool               reciprocal=false);*/
#ifdef HAVE_INTREPID_KOKKOSCORE
/*
    template<class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight, class Layout, class MemorySpace>
        static void scalarMultiplyDataDataTemp(Kokkos::View<ArrayOutData,Layout,MemorySpace> &     outputData,
                                               Kokkos::View<ArrayInDataLeft,Layout,MemorySpace> &  inputDataLeft,
                                               Kokkos::View<ArrayInDataRight,Layout,MemorySpace> & inputDataRight,
                                               const bool                                           reciprocal=false);
*/                                
    template<class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight, class Layout, class MemorySpace,int invalRank,int outvalRank>
	struct scalarMultiplyDataData2Kokkos;

#endif

    /** \brief There are two use cases:
               (1) dot product of a rank-3, 4 or 5 container \a <b>inputFields</b> with dimensions (C,F,P)
               (C,F,P,D1) or (C,F,P,D1,D2), representing the values of a set of scalar, vector
               or tensor fields, by the values in a rank-2, 3 or 4 container \a <b>inputData</b> indexed by
               (C,P), (C,P,D1), or (C,P,D1,D2) representing the values of scalar, vector or
               tensor data, OR
               (2) dot product of a rank-2, 3 or 4 container \a <b>inputFields</b> with dimensions (F,P),
               (F,P,D1) or (F,P,D1,D2), representing the values of a scalar, vector or tensor
               field, by the values in a rank-2 container \a <b>inputData</b> indexed by (C,P), (C,P,D1) or
               (C,P,D1,D2), representing the values of scalar, vector or tensor data;
               the output value container \a <b>outputFields</b> is indexed by (C,F,P),
               regardless of which of the two use cases is considered.

               For input fields containers without a dimension index, this operation reduces to
               scalar multiplication.
        \code
          C  - num. integration domains
          F  - num. fields
          P  - num. integration points
          D1 - first spatial (tensor) dimension index
          D2 - second spatial (tensor) dimension index
        \endcode>

        \param  outputData   [out] - Output (dot product) data array.
        \param  inputDataRight      [in] - Data array Right.
        \param  inputDataLeft     	[in] - Data Array Left.
       	\param	invalRank			[in] - rank inputDataRight
		\param	outvalRank			[in] - rank output
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void dotMultiplyDataField(ArrayOutFields &       outputFields,
                                     const ArrayInData &    inputDataLeft,
                                     const ArrayInFields &  inputFields);


    /** \brief There are two use cases:
               (1) dot product of a rank-2, 3 or 4 container \a <b>inputDataRight</b> with dimensions (C,P)
               (C,P,D1) or (C,P,D1,D2), representing the values of a scalar, vector or a
               tensor set of data, by the values in a rank-2, 3 or 4 container \a <b>inputDataLeft</b> indexed by
               (C,P), (C,P,D1), or (C,P,D1,D2) representing the values of scalar, vector or
               tensor data, OR
               (2) dot product of a rank-2, 3 or 4 container \a <b>inputDataRight</b> with dimensions (P),
               (P,D1) or (P,D1,D2), representing the values of scalar, vector or tensor
               data, by the values in a rank-2 container \a <b>inputDataLeft</b> indexed by (C,P), (C,P,D1) or
               (C,P,D1,D2), representing the values of scalar, vector, or tensor data;
               the output value container \a <b>outputData</b> is indexed by (C,P),
               regardless of which of the two use cases is considered.

               For input fields containers without a dimension index, this operation reduces to
               scalar multiplication.
        \code
          C  - num. integration domains
          P  - num. integration points
          D1 - first spatial (tensor) dimension index
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  outputData      [out] - Output (dot product) data array.
        \param  inputDataLeft    [in] - Left input data array.
        \param  inputDataRight   [in] - Right input data array.
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void dotMultiplyDataData(ArrayOutData &            outputData,
                                    const ArrayInDataLeft &   inputDataLeft,
                                    const ArrayInDataRight &  inputDataRight);


    /** \brief There are two use cases:
               (1) cross product of a rank-4 container \a <b>inputFields</b> with dimensions (C,F,P,D),
               representing the values of a set of vector fields, on the left by the values in a rank-3
               container \a <b>inputData</b> indexed by (C,P,D), representing the values of vector data, OR
               (2) cross product of a rank-3 container \a <b>inputFields</b> with dimensions (F,P,D),
               representing the values of a vector field, on the left by the values in a rank-3 container
               \a <b>inputData</b> indexed by (C,P,D), representing the values of vector data;
               the output value container \a <b>outputFields</b> is indexed by (C,F,P,D) in 3D (vector output)
               and by (C,F,P) in 2D (scalar output), regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains
          F  - num. fields
          P  - num. integration points
          D  - spatial dimension of vector data and vector fields
        \endcode

        \param  outputFields   [out] - Output (cross product) fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void crossProductDataField(ArrayOutFields &       outputFields,
                                      const ArrayInData &    inputData,
                                      const ArrayInFields &  inputFields);


    /** \brief There are two use cases:
               (1) cross product of a rank-3 container \a <b>inputDataRight</b> with dimensions (C,P,D),
               representing the values of a set of vector data, on the left by the values in a rank-3
               container \a <b>inputDataLeft</b> indexed by (C,P,D) representing the values of vector data, OR
               (2) cross product of a rank-2 container \a <b>inputDataRight</b> with dimensions (P,D),
               representing the values of vector data, on the left by the values in a rank-3 container
               \a <b>inputDataLeft</b> indexed by (C,P,D), representing the values of vector data;
               the output value container \a <b>outputData</b> is indexed by (C,P,D) in 3D (vector output) and by
               (C,P) in 2D (scalar output), regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains
          P  - num. integration points
          D  - spatial dimension of vector data and vector fields
        \endcode

        \param  outputData      [out] - Output (cross product) data array.
        \param  inputDataLeft    [in] - Left input data array.
        \param  inputDataRight   [in] - Right input data array.
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void crossProductDataData(ArrayOutData &            outputData,
                                     const ArrayInDataLeft &   inputDataLeft,
                                     const ArrayInDataRight &  inputDataRight);


    /** \brief There are two use cases:
               (1) outer product of a rank-4 container \a <b>inputFields</b> with dimensions (C,F,P,D),
               representing the values of a set of vector fields, on the left by the values in a rank-3
               container \a <b>inputData</b> indexed by (C,P,D), representing the values of vector data, OR
               (2) outer product of a rank-3 container \a <b>inputFields</b> with dimensions (F,P,D),
               representing the values of a vector field, on the left by the values in a rank-3 container
               \a <b>inputData</b> indexed by (C,P,D), representing the values of vector data;
               the output value container \a <b>outputFields</b> is indexed by (C,F,P,D,D),
               regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains
          F  - num. fields
          P  - num. integration points
          D1 - first spatial (tensor) dimension index
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  outputFields   [out] - Output (outer product) fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void outerProductDataField(ArrayOutFields &       outputFields,
                                      const ArrayInData &    inputData,
                                      const ArrayInFields &  inputFields);


    /** \brief There are two use cases:
               (1) outer product of a rank-3 container \a <b>inputDataRight</b> with dimensions (C,P,D),
               representing the values of a set of vector data, on the left by the values in a rank-3
               container \a <b>inputDataLeft</b> indexed by (C,P,D) representing the values of vector data, OR
               (2) outer product of a rank-2 container \a <b>inputDataRight</b> with dimensions (P,D),
               representing the values of vector data, on the left by the values in a rank-3 container
               \a <b>inputDataLeft</b> indexed by (C,P,D), representing the values of vector data;
               the output value container \a <b>outputData</b> is indexed by (C,P,D,D),
               regardless of which of the two use cases is considered.

        \code
          C  - num. integration domains
          P  - num. integration points
          D1 - first spatial (tensor) dimension index
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  outputData      [out] - Output (outer product) data array.
        \param  inputDataLeft    [in] - Left input data array.
        \param  inputDataRight   [in] - Right input data array.
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void outerProductDataData(ArrayOutData &            outputData,
                                     const ArrayInDataLeft &   inputDataLeft,
                                     const ArrayInDataRight &  inputDataRight);


    /** \brief There are two use cases:
               (1) matrix-vector product of a rank-4 container \a <b>inputFields</b> with dimensions (C,F,P,D),
               representing the values of a set of vector fields, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputData</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data, OR
               (2) matrix-vector product of a rank-3 container \a <b>inputFields</b> with dimensions (F,P,D),
               representing the values of a vector field, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputData</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data; the output value container \a <b>outputFields</b> is 
               indexed by (C,F,P,D), regardless of which of the two use cases is considered.

        \remarks 
               The rank of <b>inputData</b> implicitly defines the type of tensor data:
               \li rank = 2 corresponds to a constant diagonal tensor \f$ diag(a,\ldots,a) \f$
               \li rank = 3 corresponds to a nonconstant diagonal tensor \f$ diag(a_1,\ldots,a_d) \f$
               \li rank = 4 corresponds to a full tensor \f$ \{a_{ij}\}\f$  
      
        \note  It is assumed that all tensors are square! 
      
        \note  The method is defined for spatial dimensions D = 1, 2, 3

        \code
          C    - num. integration domains
          F    - num. fields
          P    - num. integration points
          D    - spatial dimension
          D1*  - first tensor dimensions, equals the spatial dimension D
          D2** - second tensor dimension, equals the spatial dimension D
        \endcode

        \param  outputFields   [out] - Output (matrix-vector product) fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  transpose       [in] - If 'T', use transposed tensor; if 'N', no transpose. Default: 'N'.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void matvecProductDataField(ArrayOutFields &       outputFields,
                                       const ArrayInData &    inputData,
                                       const ArrayInFields &  inputFields,
                                       const char             transpose = 'N');
                                       /*
   template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void matvecProductDataFieldTemp(ArrayOutFields &       outputFields,
                                       const ArrayInData &    inputData,
                                       const ArrayInFields &  inputFields,
                                       const char             transpose = 'N');
    */

    /** \brief There are two use cases:
               (1) matrix-vector product of a rank-3 container \a <b>inputDataRight</b> with dimensions (C,P,D),
               representing the values of a set of vector data, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputDataLeft</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data, OR
               (2) matrix-vector product of a rank-2 container \a <b>inputDataRight</b> with dimensions (P,D),
               representing the values of vector data, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputDataLeft</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data; the output value container \a <b>outputData</b> 
               is indexed by (C,P,D), regardless of which of the two use cases is considered.
      
        \remarks 
              The rank of <b>inputDataLeft</b> implicitly defines the type of tensor data:
              \li rank = 2 corresponds to a constant diagonal tensor \f$ diag(a,\ldots,a) \f$
              \li rank = 3 corresponds to a nonconstant diagonal tensor \f$ diag(a_1,\ldots,a_d) \f$
              \li rank = 4 corresponds to a full tensor \f$ \{a_{ij}\}\f$  
      
        \note   It is assumed that all tensors are square!
      
        \code
          C    - num. integration domains
          P    - num. integration points
          D    - spatial dimension
          D1*  - first tensor dimensions, equals the spatial dimension D
          D2** - second tensor dimension, equals the spatial dimension D
        \endcode

        \param  outputData      [out] - Output (matrix-vector product) data array.
        \param  inputDataLeft    [in] - Left input data array.
        \param  inputDataRight   [in] - Right input data array.
        \param  transpose        [in] - If 'T', use transposed tensor; if 'N', no transpose. Default: 'N'.
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void matvecProductDataData(ArrayOutData &            outputData,
                                      const ArrayInDataLeft &   inputDataLeft,
                                      const ArrayInDataRight &  inputDataRight,
                                      const char                transpose = 'N');
                                      /*
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void matvecProductDataDataTemp(ArrayOutData &            outputData,
                                      const ArrayInDataLeft &   inputDataLeft,
                                      const ArrayInDataRight &  inputDataRight,
                                      const char                transpose = 'N');   
    */
    
    /** \brief There are two use cases:
               (1) matrix-matrix product of a rank-5 container \a <b>inputFields</b> with dimensions (C,F,P,D1,D2),
               representing the values of a set of tensor fields, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputData</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data, OR
               (2) matrix-matrix product of a rank-4 container \a <b>inputFields</b> with dimensions (F,P,D1,D2),
               representing the values of a tensor field, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputData</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data; the output value container \a <b>outputFields</b> is 
               indexed by (C,F,P,D1,D2), regardless of which of the two use cases is considered.
  
        \remarks 
               The rank of <b>inputData</b> implicitly defines the type of tensor data:
               \li rank = 2 corresponds to a constant diagonal tensor \f$ diag(a,\ldots,a) \f$
               \li rank = 3 corresponds to a nonconstant diagonal tensor \f$ diag(a_1,\ldots,a_d) \f$
               \li rank = 4 corresponds to a full tensor \f$ \{a_{ij}\}\f$  
      
        \note  It is assumed that all tensors are square! 
      
        \note  The method is defined for spatial dimensions D = 1, 2, 3
      
        \code
          C    - num. integration domains
          F    - num. fields
          P    - num. integration points
          D1*  - first spatial (tensor) dimension index
          D2** - second spatial (tensor) dimension index
        \endcode

        \param  outputFields   [out] - Output (matrix-matrix product) fields array.
        \param  inputData       [in] - Data array.
        \param  inputFields     [in] - Input fields array.
        \param  transpose       [in] - If 'T', use transposed tensor; if 'N', no transpose. Default: 'N'.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void matmatProductDataField(ArrayOutFields &       outputFields,
                                       const ArrayInData &    inputData,
                                       const ArrayInFields &  inputFields,
                                       const char             transpose = 'N');

    

    /** \brief There are two use cases:
               (1) matrix-matrix product of a rank-4 container \a <b>inputDataRight</b> with dimensions (C,P,D1,D2),
               representing the values of a set of tensor data, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputDataLeft</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data, OR
               (2) matrix-matrix product of a rank-3 container \a <b>inputDataRight</b> with dimensions (P,D1,D2),
               representing the values of tensor data, on the left by the values in a rank-2, 3, or 4 
               container \a <b>inputDataLeft</b> indexed by (C,P), (C,P,D1) or (C,P,D1,D2), respectively, 
               representing the values of tensor data; the output value container \a <b>outputData</b> 
               is indexed by (C,P,D1,D2), regardless of which of the two use cases is considered.
      
        \remarks 
               The rank of <b>inputData</b> implicitly defines the type of tensor data:
               \li rank = 2 corresponds to a constant diagonal tensor \f$ diag(a,\ldots,a) \f$
               \li rank = 3 corresponds to a nonconstant diagonal tensor \f$ diag(a_1,\ldots,a_d) \f$
               \li rank = 4 corresponds to a full tensor \f$ \{a_{ij}\}\f$  
      
        \note  It is assumed that all tensors are square! 
      
        \note  The method is defined for spatial dimensions D = 1, 2, 3
      
        \code
          C    - num. integration domains
          P    - num. integration points
          D1*  - first spatial (tensor) dimension index
          D2** - second spatial (tensor) dimension index
        \endcode

        \param  outputData      [out] - Output (matrix-vector product) data array.
        \param  inputDataLeft    [in] - Left input data array.
        \param  inputDataRight   [in] - Right input data array.
        \param  transpose        [in] - If 'T', use transposed tensor; if 'N', no transpose. Default: 'N'.
    */
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void matmatProductDataData(ArrayOutData &            outputData,
                                      const ArrayInDataLeft &   inputDataLeft,
                                      const ArrayInDataRight &  inputDataRight,
                                      const char                transpose = 'N');

   template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight,int inleftrank,int inrankright>
   struct matmatProductDataDataTempSpecLeft;

 template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight,int inrightrank>
   struct matmatProductDataDataTempSpecRight;
   /*
    template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
    static void matmatProductDataDataTemp(ArrayOutData &            outputData,
                                      const ArrayInDataLeft &   inputDataLeft,
                                      const ArrayInDataRight &  inputDataRight,
                                      const char                transpose = 'N');    */
    /** \brief Replicates a rank-2, 3, or 4 container with dimensions (F,P),
               (F,P,D1) or (F,P,D1,D2), representing the values of a scalar, vector or a
               tensor field, into an output value container of size (C,F,P),
               (C,F,P,D1) or (C,F,P,D1,D2).

        \code
          C  - num. integration domains               
          F  - num. fields                            
          P  - num. integration points                
          D1 - first spatial (tensor) dimension index 
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputFields     [in] - Input fields array.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInFields>
    static void cloneFields(ArrayOutFields &       outputFields,
                            const ArrayInFields &  inputFields);
                            
                            
    template<class ArrayOutFields, class ArrayInFields, class Layout, class MemorySpace,int invalRank,int outvalRank>
	struct cloneFields2;
	/*
	template<class Scalar,class ArrayOutFields, class ArrayInFields>
	static void cloneFieldsTemp(ArrayOutFields &       outputFields,
                            const ArrayInFields &  inputFields);
*/
    /** \brief Multiplies a rank-2, 3, or 4 container with dimensions (F,P),
               (F,P,D1) or (F,P,D1,D2), representing the values of a scalar, vector or a
               tensor field, F-componentwise with a scalar container indexed by (C,F),
               and stores the result in an output value container of size (C,F,P),
               (C,F,P,D1) or (C,F,P,D1,D2).

        \code
          C  - num. integration domains               
          F  - num. fields                            
          P  - num. integration points                
          D1 - first spatial (tensor) dimension index 
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  outputFields   [out] - Output fields array.
        \param  inputFactors    [in] - Input field factors array.
        \param  inputFields     [in] - Input fields array.
    */
    template<class Scalar, class ArrayOutFields, class ArrayInFactors, class ArrayInFields>
    static void cloneScaleFields(ArrayOutFields &        outputFields,
                                 const ArrayInFactors &  inputFactors,
                                 const ArrayInFields &   inputFields);


    /** \brief Multiplies, in place, a rank-2, 3, or 4 container with dimensions (C,F,P),
               (C,F,P,D1) or (C,F,P,D1,D2), representing the values of a scalar, vector or a
               tensor field, F-componentwise with a scalar container indexed by (C,F).

        \code
          C  - num. integration domains               
          F  - num. fields                            
          P  - num. integration points                
          D1 - first spatial (tensor) dimension index 
          D2 - second spatial (tensor) dimension index
        \endcode

        \param  inoutFields    [in/out] - Input / output fields array.
        \param  inputFactors       [in] - Scaling field factors array.
    */
    template<class Scalar, class ArrayInOutFields, class ArrayInFactors>
    static void scaleFields(ArrayInOutFields &      inoutFields,
                            const ArrayInFactors &  inputFactors);


  }; // end class ArrayTools

} // end namespace Intrepid

// include templated definitions
// #ifdef HAVE_INTREPID_KOKKOSCORE
// #include <Intrepid_ArrayToolsDefScalar_Kokkos.hpp>
// #endif
#include <Intrepid_ArrayToolsDefContractions.hpp>
#include <Intrepid_ArrayToolsDefScalar.hpp>
#include <Intrepid_ArrayToolsDefDot.hpp>
#include <Intrepid_ArrayToolsDefTensor.hpp>
#include <Intrepid_ArrayToolsDefCloneScale.hpp>

#endif