This file is indexed.

/usr/include/trilinos/Intrepid_ArrayTools.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

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
// @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.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or
//                    Denis Ridzal (dridzal@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_TestForException.hpp"

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 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,
                                        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,
                                       ArrayInDataLeft &        inputDataLeft,
                                       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 Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
    static void dotMultiplyDataField(ArrayOutFields &       outputFields,
                                     const ArrayInData &    inputData,
                                     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');

    

    /** \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');
    
    
    
    /** \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');


    
    /** \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);


    /** \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
#include <Intrepid_ArrayToolsDefContractions.hpp>
#include <Intrepid_ArrayToolsDefScalar.hpp>
#include <Intrepid_ArrayToolsDefDot.hpp>
#include <Intrepid_ArrayToolsDefTensor.hpp>
#include <Intrepid_ArrayToolsDefCloneScale.hpp>

#endif