Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BlasArray.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File BlasArray.hpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: wrapper of functions around standard BLAS routines
33 // using Array's as calling arguments
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_BLASARRAY_HPP
38 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_BLASARRAY_HPP
39 
42 
43 // Translations for using Fortran version of blas
44 namespace Blas
45 {
46 
47  extern "C"
48  {
49  // -- BLAS Level 1:
50  void F77NAME(dcopy) (const int& n, const double *x, const int& incx,
51  double *y, const int& incy);
52  void F77NAME(daxpy) (const int& n, const double& alpha, const double *x,
53  const int& incx, const double *y, const int& incy);
54  double F77NAME(ddot) (const int& n, const double *x, const int& incx,
55  const double *y, const int& incy);
56  }
57 
58 #ifdef NEKTAR_USING_BLAS
59  static inline void Dcopy (const int& n, const Nektar::Array <Nektar::OneD, const double> &x, const int& incx, Nektar::Array<Nektar::OneD,double> &y, const int& incy)
60  {
61  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
62  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
63 
64  F77NAME(dcopy)(n,&x[0],incx,&y[0],incy);
65  }
66 
67  /// \brief BLAS level 1: y = alpha \a x plus \a y
68  static inline void Daxpy (const int& n, const double& alpha, const Nektar::Array <Nektar::OneD,const double> &x, const int& incx, Nektar::Array<Nektar::OneD,double> &y, const int& incy)
69  {
70  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
71  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
72 
73  F77NAME(daxpy)(n,alpha,&x[0],incx,&y[0],incy);
74  }
75 
76  /// \brief BLAS level 1: output = \f$ x^T y \f$
77  static inline double Ddot (const int& n, const Nektar::Array <Nektar::OneD,const double> &x, const int& incx,
78  const Nektar::Array <Nektar::OneD,const double> &y, const int& incy)
79  {
80  return F77NAME(ddot)(n,&x[0],incx,&y[0],incy);
81  }
82 #endif // NEKTAR_USING BLAS
83 }
84 #endif // NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_BLASARRAY_HPP
85 
86 /***
87 $Log: BlasArray.hpp,v $
88 Revision 1.5 2008/05/10 18:27:32 sherwin
89 Modifications necessary for QuadExp Unified DG Solver
90 
91 Revision 1.4 2008/04/30 02:55:51 bnelson
92 Fixed gcc compiler warning.
93 
94 Revision 1.3 2008/04/06 05:55:11 bnelson
95 Changed ConstArray to Array<const>
96 
97 Revision 1.2 2008/03/12 15:22:45 pvos
98 Clean up of the code
99 
100 Revision 1.1 2008/02/28 09:57:08 sherwin
101 Added array version of some routines
102 
103 **/
void F77NAME() dcopy(const int &n, const double *x, const int &incx, double *y, const int &incy)
#define F77NAME(x)
Fortran routines need an underscore.
Definition: TransF77.hpp:47
double F77NAME() ddot(const int &n, const double *x, const int &incx, const double *y, const int &incy)
void F77NAME() daxpy(const int &n, const double &alpha, const double *x, const int &incx, const double *y, const int &incy)
T Ddot(int n, const Array< OneD, const T > &w, const int incw, const Array< OneD, const T > &x, const int incx, const Array< OneD, const int > &y, const int incy)
Definition: VmathArray.hpp:434
Definition: Blas.hpp:43
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191