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_Rank.hpp>
59namespace Intrepid {
60
64template<class Scalar>
66
67 public:
68
76 static void absval(Scalar* absArray, const Scalar* inArray, const int size);
77
78
85 static void absval(Scalar* inoutArray, const int size);
86
87
97 template<class ArrayAbs, class ArrayIn>
98 static void absval(ArrayAbs & absArray, const ArrayIn & inArray);
99
100
105 template<class ArrayInOut>
106 static void absval(ArrayInOut & inoutAbsArray);
107
108
116 static Scalar vectorNorm(const Scalar* inVec, const size_t dim, const ENorm normType);
117
118
128 template<class ArrayIn>
129 static Scalar vectorNorm(const ArrayIn & inVec, const ENorm normType);
130
131
145 template<class ArrayNorm, class ArrayIn>
146 static void vectorNorm(ArrayNorm & normArray, const ArrayIn & inVecs, const ENorm normType);
147
148 /* template<class ArrayNorm, class ArrayIn>
149 static void vectorNormTemp(ArrayNorm & normArray, const ArrayIn & inVecs, const ENorm normType);
150*/
158 static void transpose(Scalar* transposeMat, const Scalar* inMat, const size_t dim);
159
160 /* template<class ArrayTranspose, class ArrayIn>
161 static void transpose(ArrayTranspose transposeMat, const ArrayIn inMat, const size_t dim);*/
176 template<class ArrayTranspose, class ArrayIn>
177 static void transpose(ArrayTranspose & transposeMats, const ArrayIn & inMats);
178
179 /* template<class ArrayTranspose, class ArrayIn>
180 static void transposeTemp(ArrayTranspose & transposeMats, const ArrayIn & inMats);*/
188 static void inverse(Scalar* inverseMat, const Scalar* inMat, const size_t dim);
189
190
206 template<class ArrayInverse, class ArrayIn>
207 static void inverse(ArrayInverse & inverseMats, const ArrayIn & inMats);
208
209
210 static Scalar det(const Scalar* inMat, const size_t 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 template<class ArrayDet, class ArrayIn, int matRank>
254 static void add(Scalar* sumArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
255
256
265 static void add(Scalar* inoutSumArray, const Scalar* inArray, const int size);
266
267
279 template<class ArraySum, class ArrayIn1, class ArrayIn2>
280 static void add(ArraySum & sumArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
281
282
293 template<class ArraySum, class ArrayIn>
294 static void add(ArraySum & inoutSumArray, const ArrayIn & inArray);
295
296
306 static void subtract(Scalar* diffArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
307
308
317 static void subtract(Scalar* inoutDiffArray, const Scalar* inArray, const int size);
318
319
331 template<class ArrayDiff, class ArrayIn1, class ArrayIn2>
332 static void subtract(ArrayDiff & diffArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
333
334
345 template<class ArrayDiff, class ArrayIn>
346 static void subtract(ArrayDiff & inoutDiffArray, const ArrayIn & inArray);
347
348 template<class ArrayDiff, class ArrayIn>
349 static void subtractTemp(ArrayDiff & inoutDiffArray, const ArrayIn & inArray);
359 static void scale(Scalar* scaledArray, const Scalar* inArray, const int size, const Scalar scalar);
360
361
370 static void scale(Scalar* inoutScaledArray, const int size, const Scalar scalar);
371
372
384 template<class ArrayScaled, class ArrayIn>
385 static void scale(ArrayScaled & scaledArray, const ArrayIn & inArray, const Scalar scalar);
386
387
394 template<class ArrayScaled>
395 static void scale(ArrayScaled & inoutScaledArray, const Scalar scalar);
396
397
405 static Scalar dot(const Scalar* inArray1, const Scalar* inArray2, const int size);
406
407
418 template<class ArrayVec1, class ArrayVec2>
419 static Scalar dot(const ArrayVec1 & inVec1, const ArrayVec2 & inVec2);
420
421
435 template<class ArrayDot, class ArrayVec1, class ArrayVec2>
436 static void dot(ArrayDot & dotArray, const ArrayVec1 & inVecs1, const ArrayVec2 & inVecs2);
437
438
451 static void matvec(Scalar* matVec, const Scalar* inMat, const Scalar* inVec, const size_t dim);
452
453
472 template<class ArrayMatVec, class ArrayMat, class ArrayVec>
473 static void matvec(ArrayMatVec & matVecs, const ArrayMat & inMats, const ArrayVec & inVecs);
474
475
489 template<class ArrayVecProd, class ArrayIn1, class ArrayIn2>
490 static void vecprod(ArrayVecProd & vecProd, const ArrayIn1 & inLeft, const ArrayIn2 & inRight);
491
492 /* template<class ArrayVecProd, class ArrayIn1, class ArrayIn2>
493 static void vecprodTemp(ArrayVecProd & vecProd, const ArrayIn1 & inLeft, const ArrayIn2 & inRight); */
494
495}; // class RealSpaceTools
496
497} // end namespace Intrepid
498
499// include templated definitions
501
502#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.