Intrepid
http://trilinos.sandia.gov/packages/docs/r10.10/packages/intrepid/src/Shared/Intrepid_RealSpaceTools.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ************************************************************************
00003 //
00004 //                           Intrepid Package
00005 //                 Copyright (2007) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Pavel Bochev  (pbboche@sandia.gov)
00038 //                    Denis Ridzal  (dridzal@sandia.gov), or
00039 //                    Kara Peterson (kjpeter@sandia.gov)
00040 //
00041 // ************************************************************************
00042 // @HEADER
00043 
00049 #ifndef INTREPID_REALSPACETOOLS_HPP
00050 #define INTREPID_REALSPACETOOLS_HPP
00051 
00052 #include "Intrepid_ConfigDefs.hpp"
00053 #include "Intrepid_Types.hpp"
00054 #include "Teuchos_oblackholestream.hpp"
00055 #include "Teuchos_Assert.hpp"
00056 
00057 namespace Intrepid {
00058   
00062 template<class Scalar>
00063 class RealSpaceTools {
00064     
00065   public:
00066 
00074     static void absval(Scalar* absArray, const Scalar* inArray, const int size);
00075 
00076 
00083     static void absval(Scalar* inoutArray, const int size);
00084 
00085 
00095     template<class ArrayAbs, class ArrayIn>
00096     static void absval(ArrayAbs & absArray, const ArrayIn & inArray);
00097 
00098 
00103     template<class ArrayInOut>
00104     static void absval(ArrayInOut & inoutAbsArray);
00105 
00106 
00114     static Scalar vectorNorm(const Scalar* inVec, const int dim, const ENorm normType);
00115 
00116 
00126     template<class ArrayIn>
00127     static Scalar vectorNorm(const ArrayIn & inVec, const ENorm normType);
00128 
00129 
00143     template<class ArrayNorm, class ArrayIn>
00144     static void vectorNorm(ArrayNorm & normArray, const ArrayIn & inVecs, const ENorm normType);
00145 
00146 
00154     static void transpose(Scalar* transposeMat, const Scalar* inMat, const int dim);
00155 
00156 
00171     template<class ArrayTranspose, class ArrayIn>
00172     static void transpose(ArrayTranspose & transposeMats, const ArrayIn & inMats);
00173 
00174 
00182     static void inverse(Scalar* inverseMat, const Scalar* inMat, const int dim);
00183 
00184 
00200     template<class ArrayInverse, class ArrayIn>
00201     static void inverse(ArrayInverse & inverseMats, const ArrayIn & inMats);
00202 
00203 
00210     static Scalar det(const Scalar* inMat, const int dim);
00211 
00212 
00222     template<class ArrayIn>
00223     static Scalar det(const ArrayIn & inMat);
00224 
00225 
00240     template<class ArrayDet, class ArrayIn>
00241     static void det(ArrayDet & detArray, const ArrayIn & inMats);
00242 
00243 
00253     static void add(Scalar* sumArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
00254 
00255 
00264     static void add(Scalar* inoutSumArray, const Scalar* inArray, const int size);
00265 
00266 
00278     template<class ArraySum, class ArrayIn1, class ArrayIn2>
00279     static void add(ArraySum & sumArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
00280 
00281 
00292     template<class ArraySum, class ArrayIn>
00293     static void add(ArraySum & inoutSumArray, const ArrayIn & inArray);
00294 
00295 
00305     static void subtract(Scalar* diffArray, const Scalar* inArray1, const Scalar* inArray2, const int size);
00306 
00307 
00316     static void subtract(Scalar* inoutDiffArray, const Scalar* inArray, const int size);
00317 
00318 
00330     template<class ArrayDiff, class ArrayIn1, class ArrayIn2>
00331     static void subtract(ArrayDiff & diffArray, const ArrayIn1 & inArray1, const ArrayIn2 & inArray2);
00332 
00333 
00344     template<class ArrayDiff, class ArrayIn>
00345     static void subtract(ArrayDiff & inoutDiffArray, const ArrayIn & inArray);
00346 
00347 
00357     static void scale(Scalar* scaledArray, const Scalar* inArray, const int size, const Scalar scalar);
00358 
00359 
00368     static void scale(Scalar* inoutScaledArray, const int size, const Scalar scalar);
00369 
00370 
00382     template<class ArrayScaled, class ArrayIn>
00383     static void scale(ArrayScaled & scaledArray, const ArrayIn & inArray, const Scalar scalar);
00384 
00385 
00392     template<class ArrayScaled>
00393     static void scale(ArrayScaled & inoutScaledArray, const Scalar scalar);
00394 
00395 
00403     static Scalar dot(const Scalar* inArray1, const Scalar* inArray2, const int size);
00404 
00405 
00416     template<class ArrayVec1, class ArrayVec2>
00417     static Scalar dot(const ArrayVec1 & inVec1, const ArrayVec2 & inVec2);
00418 
00419 
00433     template<class ArrayDot, class ArrayVec1, class ArrayVec2>
00434     static void dot(ArrayDot & dotArray, const ArrayVec1 & inVecs1, const ArrayVec2 & inVecs2);
00435 
00436 
00449     static void matvec(Scalar* matVec, const Scalar* inMat, const Scalar* inVec, const int dim);
00450 
00451 
00470     template<class ArrayMatVec, class ArrayMat, class ArrayVec>
00471     static void matvec(ArrayMatVec & matVecs, const ArrayMat & inMats, const ArrayVec & inVecs);
00472 
00473     
00487     template<class ArrayVecProd, class ArrayIn1, class ArrayIn2>
00488     static void vecprod(ArrayVecProd & vecProd, const ArrayIn1 & inLeft, const ArrayIn2 & inRight);
00489     
00490     
00491     
00492 }; // class RealSpaceTools
00493 
00494 } // end namespace Intrepid
00495 
00496 // include templated definitions
00497 #include <Intrepid_RealSpaceToolsDef.hpp>
00498 
00499 #endif