Intrepid2
Intrepid2_RealSpaceTools.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 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 Kyungjoo Kim (kyukim@sandia.gov), or
38 // Mauro Perego (mperego@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
49 #ifndef __INTREPID2_REALSPACETOOLS_HPP__
50 #define __INTREPID2_REALSPACETOOLS_HPP__
51 
52 #include "Intrepid2_ConfigDefs.hpp"
53 
54 #include "Intrepid2_Types.hpp"
55 #include "Intrepid2_Utils.hpp"
56 
57 #include "Kokkos_Core.hpp"
58 
59 namespace Intrepid2 {
60 
78  template<typename ExecSpaceType = void>
80  public:
81 
82  struct Serial {
92  template<typename inVecValueType, class ...inVecProperties>
93  KOKKOS_INLINE_FUNCTION
94  static inVecValueType
95  vectorNorm( const Kokkos::DynRankView<inVecValueType,inVecProperties...> inVec,
96  const ENorm normType );
97 
107  template<typename inMatValueType, class ...inMatProperties>
108  KOKKOS_INLINE_FUNCTION
109  static inMatValueType
110  det( const Kokkos::DynRankView<inMatValueType,inMatProperties...> inMat );
111 
122  template<typename inVec1ValueType, class ...inVec1Properties,
123  typename inVec2ValueType, class ...inVec2Properties>
124  KOKKOS_INLINE_FUNCTION
125  static inVec1ValueType
126  dot( const Kokkos::DynRankView<inVec1ValueType,inVec1Properties...> inVec1,
127  const Kokkos::DynRankView<inVec2ValueType,inVec2Properties...> inVec2 );
128 
129  };
130 
137  template<typename outputValueType, class ...outputProperties,
138  typename inputValueType, class ...inputProperties>
139  static void
140  extractScalarValues( Kokkos::DynRankView<outputValueType,outputProperties...> output,
141  const Kokkos::DynRankView<inputValueType, inputProperties...> input );
142 
153  template<typename outputValueType, class ...outputProperties,
154  typename inputValueType, class ...inputProperties>
155  static void
156  clone( Kokkos::DynRankView<outputValueType,outputProperties...> output,
157  const Kokkos::DynRankView<inputValueType,inputProperties...> input );
158 
168  template<typename absArrayValueType, class ...absArrayProperties,
169  typename inArrayValueType, class ...inArrayProperties>
170  static void
171  absval( Kokkos::DynRankView<absArrayValueType,absArrayProperties...> absArray,
172  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray );
173 
174 
179  template<typename inoutArrayValueType, class ...inoutArrayProperties>
180  static void
181  absval( Kokkos::DynRankView<inoutArrayValueType,inoutArrayProperties...> inoutArray );
182 
183 
197  template<typename normArrayValueType, class ...normArrayProperties,
198  typename inVecValueType, class ...inVecProperties>
199  static void
200  vectorNorm( Kokkos::DynRankView<normArrayValueType,normArrayProperties...> normArray,
201  const Kokkos::DynRankView<inVecValueType, inVecProperties...> inVecs,
202  const ENorm normType );
203 
218  template<typename transposeMatValueType, class ...transposeMatProperties,
219  typename inMatValueType, class ...inMatProperties>
220  static void
221  transpose( Kokkos::DynRankView<transposeMatValueType,transposeMatProperties...> transposeMats,
222  const Kokkos::DynRankView<inMatValueType, inMatProperties...> inMats );
223 
239  template<typename inverseMatValueType, class ...inverseMatProperties,
240  typename inMatValueType, class ...inMatProperties>
241  static void
242  inverse( Kokkos::DynRankView<inverseMatValueType,inverseMatProperties...> inverseMats,
243  const Kokkos::DynRankView<inMatValueType, inMatProperties...> inMats );
244 
245 
260  template<typename detArrayValueType, class ...detArrayProperties,
261  typename inMatValueType, class ...inMatProperties>
262  static void
263  det( Kokkos::DynRankView<detArrayValueType,detArrayProperties...> detArray,
264  const Kokkos::DynRankView<inMatValueType, inMatProperties...> inMats );
265 
277  template<typename sumArrayValueType, class ...sumArrayProperties,
278  typename inArray1ValueType, class ...inArray1Properties,
279  typename inArray2ValueType, class ...inArray2Properties>
280  static void
281  add( Kokkos::DynRankView<sumArrayValueType,sumArrayProperties...> sumArray,
282  const Kokkos::DynRankView<inArray1ValueType,inArray1Properties...> inArray1,
283  const Kokkos::DynRankView<inArray2ValueType,inArray2Properties...> inArray2 );
284 
295  template<typename inoutSumArrayValueType, class ...inoutSumArrayProperties,
296  typename inArrayValueType, class ...inArrayProperties>
297  static void
298  add( Kokkos::DynRankView<inoutSumArrayValueType,inoutSumArrayProperties...> inoutSumArray,
299  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray );
300 
312  template<typename diffArrayValueType, class ...diffArrayProperties,
313  typename inArray1ValueType, class ...inArray1Properties,
314  typename inArray2ValueType, class ...inArray2Properties>
315  static void
316  subtract( Kokkos::DynRankView<diffArrayValueType,diffArrayProperties...> diffArray,
317  const Kokkos::DynRankView<inArray1ValueType, inArray1Properties...> inArray1,
318  const Kokkos::DynRankView<inArray2ValueType, inArray2Properties...> inArray2 );
319 
330  template<typename inoutDiffArrayValueType, class ...inoutDiffArrayProperties,
331  typename inArrayValueType, class ...inArrayProperties>
332  static void
333  subtract( Kokkos::DynRankView<inoutDiffArrayValueType,inoutDiffArrayProperties...> diffArray,
334  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray );
335 
347  template<typename ValueType,
348  typename scaledArrayValueType, class ...scaledArrayProperties,
349  typename inArrayValueType, class ...inArrayProperties>
350  static void
351  scale( Kokkos::DynRankView<scaledArrayValueType,scaledArrayProperties...> scaledArray,
352  const Kokkos::DynRankView<inArrayValueType, inArrayProperties...> inArray,
353  const ValueType alpha );
354 
361  template<typename ValueType,
362  typename inoutScaledArrayValueType, class ...inoutScaledArrayProperties>
363  static void
364  scale( Kokkos::DynRankView<inoutScaledArrayValueType,inoutScaledArrayProperties...> inoutScaledArray,
365  const ValueType alpha );
366 
367 
381  template<typename dotArrayValueType, class ...dotArrayProperties,
382  typename inVec1ValueType, class ...inVec1Properties,
383  typename inVec2ValueType, class ...inVec2Properties>
384  static void
385  dot( Kokkos::DynRankView<dotArrayValueType,dotArrayProperties...> dotArray,
386  const Kokkos::DynRankView<inVec1ValueType, inVec1Properties...> inVecs1,
387  const Kokkos::DynRankView<inVec2ValueType, inVec2Properties...> inVecs2 );
388 
407  template<typename matVecValueType, class ...matVecProperties,
408  typename inMatValueType, class ...inMatProperties,
409  typename inVecValueType, class ...inVecProperties>
410  static void
411  matvec( Kokkos::DynRankView<matVecValueType,matVecProperties...> matVecs,
412  const Kokkos::DynRankView<inMatValueType, inMatProperties...> inMats,
413  const Kokkos::DynRankView<inVecValueType, inVecProperties...> inVecs );
414 
428  template<typename vecProdValueType, class ...vecProdProperties,
429  typename inLeftValueType, class ...inLeftProperties,
430  typename inRightValueType, class ...inRightProperties>
431  static void
432  vecprod( Kokkos::DynRankView<vecProdValueType,vecProdProperties...> vecProd,
433  const Kokkos::DynRankView<inLeftValueType, inLeftProperties...> inLeft,
434  const Kokkos::DynRankView<inRightValueType,inRightProperties...> inRight );
435 
436  }; // class RealSpaceTools
437 
438 } // end namespace Intrepid2
439 
440 // include templated definitions
442 
443 #endif
static void extractScalarValues(Kokkos::DynRankView< outputValueType, outputProperties...> output, const Kokkos::DynRankView< inputValueType, inputProperties...> input)
Extract scalar type values from Sacado-based array.
static void vectorNorm(Kokkos::DynRankView< normArrayValueType, normArrayProperties...> normArray, const Kokkos::DynRankView< inVecValueType, inVecProperties...> inVecs, const ENorm normType)
Computes norms (1, 2, infinity) of vectors stored in a array of total rank 2 (array of vectors)...
static void scale(Kokkos::DynRankView< scaledArrayValueType, scaledArrayProperties...> scaledArray, const Kokkos::DynRankView< inArrayValueType, inArrayProperties...> inArray, const ValueType alpha)
Multiplies array inArray by the scalar scalar (componentwise): scaledArray = scalar * inArray...
static void dot(Kokkos::DynRankView< dotArrayValueType, dotArrayProperties...> dotArray, const Kokkos::DynRankView< inVec1ValueType, inVec1Properties...> inVecs1, const Kokkos::DynRankView< inVec2ValueType, inVec2Properties...> inVecs2)
Computes dot product of vectors stored in an array of total rank 2 (array of vectors), indexed by (i0, D), or 3 (array of arrays of vectors), indexed by (i0, i1, D).
static KOKKOS_INLINE_FUNCTION inMatValueType det(const Kokkos::DynRankView< inMatValueType, inMatProperties...> inMat)
Computes determinant of a single square matrix stored in an array of rank 2.
static KOKKOS_INLINE_FUNCTION inVecValueType vectorNorm(const Kokkos::DynRankView< inVecValueType, inVecProperties...> inVec, const ENorm normType)
Computes norm (1, 2, infinity) of a single vector stored in an array of rank 1.
Header function for Intrepid2::Util class and other utility functions.
static void matvec(Kokkos::DynRankView< matVecValueType, matVecProperties...> matVecs, const Kokkos::DynRankView< inMatValueType, inMatProperties...> inMats, const Kokkos::DynRankView< inVecValueType, inVecProperties...> inVecs)
Matrix-vector left multiply using multidimensional arrays: matVec = inMat * inVec.
static void det(Kokkos::DynRankView< detArrayValueType, detArrayProperties...> detArray, const Kokkos::DynRankView< inMatValueType, inMatProperties...> inMats)
Computes determinants of matrices stored in an array of total rank 3 (array of matrices), indexed by (i0, D, D), or 4 (array of arrays of matrices), indexed by (i0, i1, D, D).
static void inverse(Kokkos::DynRankView< inverseMatValueType, inverseMatProperties...> inverseMats, const Kokkos::DynRankView< inMatValueType, inMatProperties...> inMats)
Computes inverses of nonsingular matrices stored in an array of total rank 2 (single matrix)...
static void absval(Kokkos::DynRankView< absArrayValueType, absArrayProperties...> absArray, const Kokkos::DynRankView< inArrayValueType, inArrayProperties...> inArray)
Computes absolute value of an array.
static KOKKOS_INLINE_FUNCTION inVec1ValueType dot(const Kokkos::DynRankView< inVec1ValueType, inVec1Properties...> inVec1, const Kokkos::DynRankView< inVec2ValueType, inVec2Properties...> inVec2)
Computes dot product of two vectors stored in arrays of rank 1.
static void vecprod(Kokkos::DynRankView< vecProdValueType, vecProdProperties...> vecProd, const Kokkos::DynRankView< inLeftValueType, inLeftProperties...> inLeft, const Kokkos::DynRankView< inRightValueType, inRightProperties...> inRight)
Vector product using multidimensional arrays: vecProd = inVecLeft x inVecRight
static void transpose(Kokkos::DynRankView< transposeMatValueType, transposeMatProperties...> transposeMats, const Kokkos::DynRankView< inMatValueType, inMatProperties...> inMats)
Computes transposes of square matrices stored in an array of total rank 2 (single matrix)...
Contains definitions of custom data types in Intrepid2.
static void clone(Kokkos::DynRankView< outputValueType, outputProperties...> output, const Kokkos::DynRankView< inputValueType, inputProperties...> input)
Clone input array.
static void add(Kokkos::DynRankView< sumArrayValueType, sumArrayProperties...> sumArray, const Kokkos::DynRankView< inArray1ValueType, inArray1Properties...> inArray1, const Kokkos::DynRankView< inArray2ValueType, inArray2Properties...> inArray2)
Adds arrays inArray1 and inArray2: sumArray = inArray1 + inArray2.
Implementation of basic linear algebra functionality in Euclidean space.
Definition file for utility classes providing basic linear algebra functionality. ...
static void subtract(Kokkos::DynRankView< diffArrayValueType, diffArrayProperties...> diffArray, const Kokkos::DynRankView< inArray1ValueType, inArray1Properties...> inArray1, const Kokkos::DynRankView< inArray2ValueType, inArray2Properties...> inArray2)
Subtracts inArray2 from inArray1: diffArray = inArray1 - inArray2.