blas_wrapper.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2008-2011 Conrad Sanderson
00003 // 
00004 // This file is part of the Armadillo C++ library.
00005 // It is provided without any warranty of fitness
00006 // for any purpose. You can redistribute this file
00007 // and/or modify it under the terms of the GNU
00008 // Lesser General Public License (LGPL) as published
00009 // by the Free Software Foundation, either version 3
00010 // of the License or (at your option) any later version.
00011 // (see http://www.opensource.org/licenses for more info)
00012 
00013 
00014 
00015 #ifdef ARMA_USE_BLAS
00016 
00017 
00019 namespace blas
00020   {
00021   
00022   
00023   template<typename eT>
00024   inline
00025   eT
00026   dot(const uword n_elem, const eT* x, const eT* y)
00027     {
00028     arma_ignore(n_elem);
00029     arma_ignore(x);
00030     arma_ignore(y);
00031     
00032     return eT(0);
00033     }
00034   
00035   
00036   
00037   template<>
00038   inline
00039   float
00040   dot(const uword n_elem, const float* x, const float* y)
00041     {
00042     blas_int n   = blas_int(n_elem);
00043     blas_int inc = blas_int(1);
00044     
00045     return arma_fortran(arma_sdot)(&n, x, &inc, y, &inc);
00046     }
00047   
00048   
00049   
00050   template<>
00051   inline
00052   double
00053   dot(const uword n_elem, const double* x, const double* y)
00054     {
00055     blas_int n   = blas_int(n_elem);
00056     blas_int inc = blas_int(1);
00057     
00058     return arma_fortran(arma_ddot)(&n, x, &inc, y, &inc);
00059     }
00060   
00061   
00062   
00063   template<typename eT>
00064   inline
00065   void
00066   gemv(const char* transA, const blas_int* m, const blas_int* n, const eT* alpha, const eT* A, const blas_int* ldA, const eT* x, const blas_int* incx, const eT* beta, eT* y, const blas_int* incy)
00067     {
00068     arma_type_check((is_supported_blas_type<eT>::value == false));
00069     
00070     if(is_float<eT>::value == true)
00071       {
00072       typedef float T;
00073       arma_fortran(arma_sgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
00074       }
00075     else
00076     if(is_double<eT>::value == true)
00077       {
00078       typedef double T;
00079       arma_fortran(arma_dgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
00080       }
00081     else
00082     if(is_supported_complex_float<eT>::value == true)
00083       {
00084       typedef std::complex<float> T;
00085       arma_fortran(arma_cgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
00086       }
00087     else
00088     if(is_supported_complex_double<eT>::value == true)
00089       {
00090       typedef std::complex<double> T;
00091       arma_fortran(arma_zgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
00092       }
00093     
00094     }
00095   
00096   
00097   
00098   template<typename eT>
00099   inline
00100   void
00101   gemm(const char* transA, const char* transB, const blas_int* m, const blas_int* n, const blas_int* k, const eT* alpha, const eT* A, const blas_int* ldA, const eT* B, const blas_int* ldB, const eT* beta, eT* C, const blas_int* ldC)
00102     {
00103     arma_type_check((is_supported_blas_type<eT>::value == false));
00104     
00105     if(is_float<eT>::value == true)
00106       {
00107       typedef float T;
00108       arma_fortran(arma_sgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
00109       }
00110     else
00111     if(is_double<eT>::value == true)
00112       {
00113       typedef double T;
00114       arma_fortran(arma_dgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
00115       }
00116     else
00117     if(is_supported_complex_float<eT>::value == true)
00118       {
00119       typedef std::complex<float> T;
00120       arma_fortran(arma_cgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
00121       }
00122     else
00123     if(is_supported_complex_double<eT>::value == true)
00124       {
00125       typedef std::complex<double> T;
00126       arma_fortran(arma_zgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
00127       }
00128     
00129     }
00130   
00131   }
00132 
00133 
00134 #endif


armadillo_matrix
Author(s): Conrad Sanderson - NICTA (www.nicta.com.au), (Wrapper by Sjoerd van den Dries)
autogenerated on Tue Jan 7 2014 11:42:03