Intrepid
Intrepid_RealSpaceTools.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Pavel Bochev (pbboche@sandia.gov)
38 // Denis Ridzal (dridzal@sandia.gov), or
39 // Kara Peterson (kjpeter@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 #ifndef INTREPID_REALSPACETOOLS_HPP
50 #define INTREPID_REALSPACETOOLS_HPP
51 
52 #include "Intrepid_ConfigDefs.hpp"
53 #include "Intrepid_Types.hpp"
54 #include "Teuchos_oblackholestream.hpp"
55 #include "Teuchos_Assert.hpp"
56 
57 
58 #include <Intrepid_KokkosRank.hpp>
59 #ifdef INTREPID_OLD_KOKKOS_CODE
60 #include "Kokkos_Core.hpp"
61 #endif
62 namespace Intrepid {
63 
67 template<class Scalar>
69 
70  public:
71 
79  static void absval(Scalar* absArray, const Scalar* inArray, const int size);
80 
81 
88  static void absval(Scalar* inoutArray, const int size);
89 
90 
100  template<class ArrayAbs, class ArrayIn>
101  static void absval(ArrayAbs & absArray, const ArrayIn & inArray);
102 
103 
108  template<class ArrayInOut>
109  static void absval(ArrayInOut & inoutAbsArray);
110 
111 
119  static Scalar vectorNorm(const Scalar* inVec, const size_t dim, const ENorm normType);
120 
121 
131  template<class ArrayIn>
132  static Scalar vectorNorm(const ArrayIn & inVec, const ENorm normType);
133 
134 
148  template<class ArrayNorm, class ArrayIn>
149  static void vectorNorm(ArrayNorm & normArray, const ArrayIn & inVecs, const ENorm normType);
150 
151  /* template<class ArrayNorm, class ArrayIn>
152  static void vectorNormTemp(ArrayNorm & normArray, const ArrayIn & inVecs, const ENorm normType);
153 */
161  static void transpose(Scalar* transposeMat, const Scalar* inMat, const size_t dim);
162 
163  /* template<class ArrayTranspose, class ArrayIn>
164  static void transpose(ArrayTranspose transposeMat, const ArrayIn inMat, const size_t dim);*/
179  template<class ArrayTranspose, class ArrayIn>
180  static void transpose(ArrayTranspose & transposeMats, const ArrayIn & inMats);
181 
182  /* template<class ArrayTranspose, class ArrayIn>
183  static void transposeTemp(ArrayTranspose & transposeMats, const ArrayIn & inMats);*/
191  static void inverse(Scalar* inverseMat, const Scalar* inMat, const size_t dim);
192 
193 
209  template<class ArrayInverse, class ArrayIn>
210  static void inverse(ArrayInverse & inverseMats, const ArrayIn & inMats);
211 
212 
213  static Scalar det(const Scalar* inMat, const size_t dim);
214 
215 
225  template<class ArrayIn>
226  static Scalar det(const ArrayIn & inMat);
227 
228 
243  template<class ArrayDet, class ArrayIn>
244  static void det(ArrayDet & detArray, const ArrayIn & inMats);
245 
246 /* #ifdef INTREPID_OLD_KOKKOS_CODE
247  template<class ArrayDet, class ArrayIn>
248  static void detTemp(ArrayDet & inverseMats, const ArrayIn & inMats);
249  #endif
250  */
251  template<class ArrayDet, class ArrayIn, int matRank>
252  struct detTempSpec;
262  static void add(Scalar* sumArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
263 
264 
273  static void add(Scalar* inoutSumArray, const Scalar* inArray, const int size);
274 
275 
287  template<class ArraySum, class ArrayIn1, class ArrayIn2>
288  static void add(ArraySum & sumArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
289 
290 
301  template<class ArraySum, class ArrayIn>
302  static void add(ArraySum & inoutSumArray, const ArrayIn & inArray);
303 
304 
314  static void subtract(Scalar* diffArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
315 
316 
325  static void subtract(Scalar* inoutDiffArray, const Scalar* inArray, const int size);
326 
327 
339  template<class ArrayDiff, class ArrayIn1, class ArrayIn2>
340  static void subtract(ArrayDiff & diffArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
341 
342 
353  template<class ArrayDiff, class ArrayIn>
354  static void subtract(ArrayDiff & inoutDiffArray, const ArrayIn & inArray);
355 
356  template<class ArrayDiff, class ArrayIn>
357  static void subtractTemp(ArrayDiff & inoutDiffArray, const ArrayIn & inArray);
367  static void scale(Scalar* scaledArray, const Scalar* inArray, const int size, const Scalar scalar);
368 
369 
378  static void scale(Scalar* inoutScaledArray, const int size, const Scalar scalar);
379 
380 
392  template<class ArrayScaled, class ArrayIn>
393  static void scale(ArrayScaled & scaledArray, const ArrayIn & inArray, const Scalar scalar);
394 
395 
402  template<class ArrayScaled>
403  static void scale(ArrayScaled & inoutScaledArray, const Scalar scalar);
404 
405 
413  static Scalar dot(const Scalar* inArray1, const Scalar* inArray2, const int size);
414 
415 
426  template<class ArrayVec1, class ArrayVec2>
427  static Scalar dot(const ArrayVec1 & inVec1, const ArrayVec2 & inVec2);
428 
429 
443  template<class ArrayDot, class ArrayVec1, class ArrayVec2>
444  static void dot(ArrayDot & dotArray, const ArrayVec1 & inVecs1, const ArrayVec2 & inVecs2);
445 
446 
459  static void matvec(Scalar* matVec, const Scalar* inMat, const Scalar* inVec, const size_t dim);
460 
461 
480  template<class ArrayMatVec, class ArrayMat, class ArrayVec>
481  static void matvec(ArrayMatVec & matVecs, const ArrayMat & inMats, const ArrayVec & inVecs);
482 
483 
497  template<class ArrayVecProd, class ArrayIn1, class ArrayIn2>
498  static void vecprod(ArrayVecProd & vecProd, const ArrayIn1 & inLeft, const ArrayIn2 & inRight);
499 
500  /* template<class ArrayVecProd, class ArrayIn1, class ArrayIn2>
501  static void vecprodTemp(ArrayVecProd & vecProd, const ArrayIn1 & inLeft, const ArrayIn2 & inRight); */
502 
503 }; // class RealSpaceTools
504 
505 } // end namespace Intrepid
506 
507 // include templated definitions
509 
510 //#include <Intrepid_RealSpaceToolsDef_Kokkos.hpp>
511 #endif
Definition file for utility classes providing basic linear algebra functionality.
Contains definitions of custom data types in Intrepid.
Implementation of basic linear algebra functionality in Euclidean space.
static void subtract(Scalar *diffArray, const Scalar *inArray1, const Scalar *inArray2, const int size)
Subtracts contiguous data inArray2 from inArray1 of size size: diffArray = inArray1 - inArray2.
static void inverse(Scalar *inverseMat, const Scalar *inMat, const size_t dim)
Computes inverse of the square matrix inMat of size dim by dim.
static Scalar dot(const Scalar *inArray1, const Scalar *inArray2, const int size)
Computes dot product of contiguous data inArray1 and inArray2 of size size.
static void matvec(Scalar *matVec, const Scalar *inMat, const Scalar *inVec, const size_t dim)
Matrix-vector left multiply using contiguous data: matVec = inMat * inVec.
static void vecprod(ArrayVecProd &vecProd, const ArrayIn1 &inLeft, const ArrayIn2 &inRight)
Vector product using multidimensional arrays: vecProd = inVecLeft x inVecRight
static void scale(Scalar *scaledArray, const Scalar *inArray, const int size, const Scalar scalar)
Multiplies contiguous data inArray of size size by a scalar (componentwise): scaledArray = scalar * ...
static Scalar vectorNorm(const Scalar *inVec, const size_t dim, const ENorm normType)
Computes norm (1, 2, infinity) of the vector inVec of size dim.
static void add(Scalar *sumArray, const Scalar *inArray1, const Scalar *inArray2, const int size)
Adds contiguous data inArray1 and inArray2 of size size: sumArray = inArray1 + inArray2.
static void transpose(Scalar *transposeMat, const Scalar *inMat, const size_t dim)
Computes transpose of the square matrix inMat of size dim by dim.
static void absval(Scalar *absArray, const Scalar *inArray, const int size)
Computes absolute value of contiguous input data inArray of size size.