blas_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 #ifdef ARMA_USE_BLAS
00017 
00018 //! \namespace blas namespace for BLAS functions
00019 namespace blas
00020   {
00021   extern "C"
00022     {
00023     void sgemv_(const char* transA, const int* m, const int* n, const float*  alpha, const float*  A, const int* ldA, const float*  x, const int* incx, const float*  beta, float*  y, const int* incy);
00024     void dgemv_(const char* transA, const int* m, const int* n, const double* alpha, const double* A, const int* ldA, const double* x, const int* incx, const double* beta, double* y, const int* incy);
00025     void cgemv_(const char* transA, const int* m, const int* n, const void*   alpha, const void*   A, const int* ldA, const void*   x, const int* incx, const void*   beta, void*   y, const int* incy);
00026     void zgemv_(const char* transA, const int* m, const int* n, const void*   alpha, const void*   A, const int* ldA, const void*   x, const int* incx, const void*   beta, void*   y, const int* incy);
00027     
00028     void sgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const float*  alpha, const float*  A, const int* ldA, const float*  B, const int* ldB, const float*  beta, float*  C, const int* ldC);
00029     void dgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const double* alpha, const double* A, const int* ldA, const double* B, const int* ldB, const double* beta, double* C, const int* ldC);
00030     void cgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const void*   alpha, const void*   A, const int* ldA, const void*   B, const int* ldB, const void*   beta, void*   C, const int* ldC);
00031     void zgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const void*   alpha, const void*   A, const int* ldA, const void*   B, const int* ldB, const void*   beta, void*   C, const int* ldC);
00032 
00033 //     float  sdot_(const int* n, const float*  x, const int* incx, const float*  y, const int* incy);
00034 //     double ddot_(const int* n, const double* x, const int* incx, const double* y, const int* incy);
00035 
00036 //     void   dswap_(const int* n, double* x, const int* incx, double* y, const int* incy);
00037 //     void   dscal_(const int* n, const double* alpha, double* x, const int* incx);
00038 //     void   dcopy_(const int* n, const double* x, const int* incx, double* y, const int* incy);
00039 //     void   daxpy_(const int* n, const double* alpha, const double* x, const int* incx, double* y, const int* incy);
00040 //     void    dger_(const int* m, const int* n, const double* alpha, const double* x, const int* incx, const double* y, const int* incy, double* A, const int* ldA);
00041     }
00042   
00043   
00044   
00045 //   template<typename eT>
00046 //   inline
00047 //   eT
00048 //   dot_(const int* n, const eT* x, const int* incx, const eT* y, const int* incy)
00049 //     {
00050 //     arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
00051 //     
00052 //     if(is_float<eT>::value == true)
00053 //       {
00054 //       typedef float T;
00055 //       return sdot_(n, (const T*)x, incx, (const T*)y, incy);
00056 //       }
00057 //     else
00058 //     if(is_double<eT>::value == true)
00059 //       {
00060 //       typedef double T;
00061 //       return ddot_(n, (const T*)x, incx, (const T*)y, incy);
00062 //       }
00063 //     
00064 //     return eT();  // prevent compiler warnings
00065 //     }
00066   
00067   
00068   
00069   template<typename eT>
00070   inline
00071   void
00072   gemv_(const char* transA, const int* m, const int* n, const eT* alpha, const eT* A, const int* ldA, const eT* x, const int* incx, const eT* beta, eT* y, const int* incy)
00073     {
00074     arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
00075     
00076     if(is_float<eT>::value == true)
00077       {
00078       typedef float T;
00079       sgemv_(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_double<eT>::value == true)
00083       {
00084       typedef double T;
00085       dgemv_(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_float<eT>::value == true)
00089       {
00090       typedef std::complex<float> T;
00091       cgemv_(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
00092       }
00093     else
00094     if(is_supported_complex_double<eT>::value == true)
00095       {
00096       typedef std::complex<double> T;
00097       zgemv_(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
00098       }
00099     
00100     }
00101   
00102   
00103   
00104   template<typename eT>
00105   inline
00106   void
00107   gemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const eT* alpha, const eT* A, const int* ldA, const eT* B, const int* ldB, const eT* beta, eT* C, const int* ldC)
00108     {
00109     arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
00110     
00111     if(is_float<eT>::value == true)
00112       {
00113       typedef float T;
00114       sgemm_(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_double<eT>::value == true)
00118       {
00119       typedef double T;
00120       dgemm_(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_float<eT>::value == true)
00124       {
00125       typedef std::complex<float> T;
00126       cgemm_(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
00127       }
00128     else
00129     if(is_supported_complex_double<eT>::value == true)
00130       {
00131       typedef std::complex<double> T;
00132       zgemm_(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
00133       }
00134     
00135     }
00136   
00137   }
00138 
00139 #endif