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 namespace Intrepid {
58 
62 template<class Scalar>
64 
65  public:
66 
74  static void absval(Scalar* absArray, const Scalar* inArray, const int size);
75 
76 
83  static void absval(Scalar* inoutArray, const int size);
84 
85 
95  template<class ArrayAbs, class ArrayIn>
96  static void absval(ArrayAbs & absArray, const ArrayIn & inArray);
97 
98 
103  template<class ArrayInOut>
104  static void absval(ArrayInOut & inoutAbsArray);
105 
106 
114  static Scalar vectorNorm(const Scalar* inVec, const int dim, const ENorm normType);
115 
116 
126  template<class ArrayIn>
127  static Scalar vectorNorm(const ArrayIn & inVec, const ENorm normType);
128 
129 
143  template<class ArrayNorm, class ArrayIn>
144  static void vectorNorm(ArrayNorm & normArray, const ArrayIn & inVecs, const ENorm normType);
145 
146 
154  static void transpose(Scalar* transposeMat, const Scalar* inMat, const int dim);
155 
156 
171  template<class ArrayTranspose, class ArrayIn>
172  static void transpose(ArrayTranspose & transposeMats, const ArrayIn & inMats);
173 
174 
182  static void inverse(Scalar* inverseMat, const Scalar* inMat, const int dim);
183 
184 
200  template<class ArrayInverse, class ArrayIn>
201  static void inverse(ArrayInverse & inverseMats, const ArrayIn & inMats);
202 
203 
210  static Scalar det(const Scalar* inMat, const int dim);
211 
212 
222  template<class ArrayIn>
223  static Scalar det(const ArrayIn & inMat);
224 
225 
240  template<class ArrayDet, class ArrayIn>
241  static void det(ArrayDet & detArray, const ArrayIn & inMats);
242 
243 
253  static void add(Scalar* sumArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
254 
255 
264  static void add(Scalar* inoutSumArray, const Scalar* inArray, const int size);
265 
266 
278  template<class ArraySum, class ArrayIn1, class ArrayIn2>
279  static void add(ArraySum & sumArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
280 
281 
292  template<class ArraySum, class ArrayIn>
293  static void add(ArraySum & inoutSumArray, const ArrayIn & inArray);
294 
295 
305  static void subtract(Scalar* diffArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
306 
307 
316  static void subtract(Scalar* inoutDiffArray, const Scalar* inArray, const int size);
317 
318 
330  template<class ArrayDiff, class ArrayIn1, class ArrayIn2>
331  static void subtract(ArrayDiff & diffArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
332 
333 
344  template<class ArrayDiff, class ArrayIn>
345  static void subtract(ArrayDiff & inoutDiffArray, const ArrayIn & inArray);
346 
347 
357  static void scale(Scalar* scaledArray, const Scalar* inArray, const int size, const Scalar scalar);
358 
359 
368  static void scale(Scalar* inoutScaledArray, const int size, const Scalar scalar);
369 
370 
382  template<class ArrayScaled, class ArrayIn>
383  static void scale(ArrayScaled & scaledArray, const ArrayIn & inArray, const Scalar scalar);
384 
385 
392  template<class ArrayScaled>
393  static void scale(ArrayScaled & inoutScaledArray, const Scalar scalar);
394 
395 
403  static Scalar dot(const Scalar* inArray1, const Scalar* inArray2, const int size);
404 
405 
416  template<class ArrayVec1, class ArrayVec2>
417  static Scalar dot(const ArrayVec1 & inVec1, const ArrayVec2 & inVec2);
418 
419 
433  template<class ArrayDot, class ArrayVec1, class ArrayVec2>
434  static void dot(ArrayDot & dotArray, const ArrayVec1 & inVecs1, const ArrayVec2 & inVecs2);
435 
436 
449  static void matvec(Scalar* matVec, const Scalar* inMat, const Scalar* inVec, const int dim);
450 
451 
470  template<class ArrayMatVec, class ArrayMat, class ArrayVec>
471  static void matvec(ArrayMatVec & matVecs, const ArrayMat & inMats, const ArrayVec & inVecs);
472 
473 
487  template<class ArrayVecProd, class ArrayIn1, class ArrayIn2>
488  static void vecprod(ArrayVecProd & vecProd, const ArrayIn1 & inLeft, const ArrayIn2 & inRight);
489 
490 
491 
492 }; // class RealSpaceTools
493 
494 } // end namespace Intrepid
495 
496 // include templated definitions
498 
499 #endif
Implementation of basic linear algebra functionality in Euclidean space.
static void matvec(Scalar *matVec, const Scalar *inMat, const Scalar *inVec, const int dim)
Matrix-vector left multiply using contiguous data: matVec = inMat * inVec.
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 Scalar dot(const Scalar *inArray1, const Scalar *inArray2, const int size)
Computes dot product of contiguous data inArray1 and inArray2 of size size.
Contains definitions of custom data types in Intrepid.
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 void absval(Scalar *absArray, const Scalar *inArray, const int size)
Computes absolute value of contiguous input data inArray of size size.
static void transpose(Scalar *transposeMat, const Scalar *inMat, const int dim)
Computes transpose of the square matrix inMat of size dim by dim.
static Scalar vectorNorm(const Scalar *inVec, const int dim, const ENorm normType)
Computes norm (1, 2, infinity) of the vector inVec of size dim.
static void inverse(Scalar *inverseMat, const Scalar *inMat, const int dim)
Computes inverse of the square matrix inMat of size dim by dim.
static void vecprod(ArrayVecProd &vecProd, const ArrayIn1 &inLeft, const ArrayIn2 &inRight)
Vector product using multidimensional arrays: vecProd = inVecLeft x inVecRight
Definition file for utility classes providing basic linear algebra functionality. ...
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 Scalar det(const Scalar *inMat, const int dim)
Computes determinant of the square matrix inMat of size dim by dim.