00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifdef ARMA_USE_ATLAS
00015
00016
00018 namespace atlas
00019 {
00020
00021 template<typename eT>
00022 inline static const eT& tmp_real(const eT& X) { return X; }
00023
00024 template<typename T>
00025 inline static const T& tmp_real(const std::complex<T>& X) { return X.real(); }
00026
00027
00028
00029 template<typename eT>
00030 arma_inline
00031 eT
00032 cblas_dot(const int N, const eT* X, const eT* Y)
00033 {
00034 arma_type_check((is_supported_blas_type<eT>::value == false));
00035
00036 if(is_float<eT>::value == true)
00037 {
00038 typedef float T;
00039 return eT( arma_atlas(cblas_sdot)(N, (const T*)X, 1, (const T*)Y, 1) );
00040 }
00041 else
00042 if(is_double<eT>::value == true)
00043 {
00044 typedef double T;
00045 return eT( arma_atlas(cblas_ddot)(N, (const T*)X, 1, (const T*)Y, 1) );
00046 }
00047 else
00048 {
00049 return eT(0);
00050 }
00051 }
00052
00053
00054
00055 template<typename eT>
00056 arma_inline
00057 eT
00058 cx_cblas_dot(const int N, const eT* X, const eT* Y)
00059 {
00060 arma_type_check((is_supported_blas_type<eT>::value == false));
00061
00062 if(is_supported_complex_float<eT>::value == true)
00063 {
00064 typedef typename std::complex<float> T;
00065
00066 T out;
00067 arma_atlas(cblas_cdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out);
00068
00069 return eT(out);
00070 }
00071 else
00072 if(is_supported_complex_double<eT>::value == true)
00073 {
00074 typedef typename std::complex<double> T;
00075
00076 T out;
00077 arma_atlas(cblas_zdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out);
00078
00079 return eT(out);
00080 }
00081 else
00082 {
00083 return eT(0);
00084 }
00085 }
00086
00087
00088
00089 template<typename eT>
00090 inline
00091 void
00092 cblas_gemv
00093 (
00094 const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00095 const int M, const int N,
00096 const eT alpha,
00097 const eT *A, const int lda,
00098 const eT *X, const int incX,
00099 const eT beta,
00100 eT *Y, const int incY
00101 )
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_atlas(cblas_sgemv)(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY);
00109 }
00110 else
00111 if(is_double<eT>::value == true)
00112 {
00113 typedef double T;
00114 arma_atlas(cblas_dgemv)(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY);
00115 }
00116 else
00117 if(is_supported_complex_float<eT>::value == true)
00118 {
00119 typedef std::complex<float> T;
00120 arma_atlas(cblas_cgemv)(Order, TransA, M, N, (const T*)&alpha, (const T*)A, lda, (const T*)X, incX, (const T*)&beta, (T*)Y, incY);
00121 }
00122 else
00123 if(is_supported_complex_double<eT>::value == true)
00124 {
00125 typedef std::complex<double> T;
00126 arma_atlas(cblas_zgemv)(Order, TransA, M, N, (const T*)&alpha, (const T*)A, lda, (const T*)X, incX, (const T*)&beta, (T*)Y, incY);
00127 }
00128 }
00129
00130
00131
00132 template<typename eT>
00133 inline
00134 void
00135 cblas_gemm
00136 (
00137 const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00138 const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
00139 const int K, const eT alpha, const eT *A,
00140 const int lda, const eT *B, const int ldb,
00141 const eT beta, eT *C, const int ldc
00142 )
00143 {
00144 arma_type_check((is_supported_blas_type<eT>::value == false));
00145
00146 if(is_float<eT>::value == true)
00147 {
00148 typedef float T;
00149 arma_atlas(cblas_sgemm)(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc);
00150 }
00151 else
00152 if(is_double<eT>::value == true)
00153 {
00154 typedef double T;
00155 arma_atlas(cblas_dgemm)(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc);
00156 }
00157 else
00158 if(is_supported_complex_float<eT>::value == true)
00159 {
00160 typedef std::complex<float> T;
00161 arma_atlas(cblas_cgemm)(Order, TransA, TransB, M, N, K, (const T*)&alpha, (const T*)A, lda, (const T*)B, ldb, (const T*)&beta, (T*)C, ldc);
00162 }
00163 else
00164 if(is_supported_complex_double<eT>::value == true)
00165 {
00166 typedef std::complex<double> T;
00167 arma_atlas(cblas_zgemm)(Order, TransA, TransB, M, N, K, (const T*)&alpha, (const T*)A, lda, (const T*)B, ldb, (const T*)&beta, (T*)C, ldc);
00168 }
00169 }
00170
00171
00172
00173 template<typename eT>
00174 inline
00175 int
00176 clapack_getrf
00177 (
00178 const enum CBLAS_ORDER Order, const int M, const int N,
00179 eT *A, const int lda, int *ipiv
00180 )
00181 {
00182 arma_type_check((is_supported_blas_type<eT>::value == false));
00183
00184 if(is_float<eT>::value == true)
00185 {
00186 typedef float T;
00187 return arma_atlas(clapack_sgetrf)(Order, M, N, (T*)A, lda, ipiv);
00188 }
00189 else
00190 if(is_double<eT>::value == true)
00191 {
00192 typedef double T;
00193 return arma_atlas(clapack_dgetrf)(Order, M, N, (T*)A, lda, ipiv);
00194 }
00195 else
00196 if(is_supported_complex_float<eT>::value == true)
00197 {
00198 typedef std::complex<float> T;
00199 return arma_atlas(clapack_cgetrf)(Order, M, N, (T*)A, lda, ipiv);
00200 }
00201 else
00202 if(is_supported_complex_double<eT>::value == true)
00203 {
00204 typedef std::complex<double> T;
00205 return arma_atlas(clapack_zgetrf)(Order, M, N, (T*)A, lda, ipiv);
00206 }
00207 else
00208 {
00209 return -1;
00210 }
00211 }
00212
00213
00214
00215 template<typename eT>
00216 inline
00217 int
00218 clapack_getri
00219 (
00220 const enum CBLAS_ORDER Order, const int N, eT *A,
00221 const int lda, const int *ipiv
00222 )
00223 {
00224 arma_type_check((is_supported_blas_type<eT>::value == false));
00225
00226 if(is_float<eT>::value == true)
00227 {
00228 typedef float T;
00229 return arma_atlas(clapack_sgetri)(Order, N, (T*)A, lda, ipiv);
00230 }
00231 else
00232 if(is_double<eT>::value == true)
00233 {
00234 typedef double T;
00235 return arma_atlas(clapack_dgetri)(Order, N, (T*)A, lda, ipiv);
00236 }
00237 else
00238 if(is_supported_complex_float<eT>::value == true)
00239 {
00240 typedef std::complex<float> T;
00241 return arma_atlas(clapack_cgetri)(Order, N, (T*)A, lda, ipiv);
00242 }
00243 else
00244 if(is_supported_complex_double<eT>::value == true)
00245 {
00246 typedef std::complex<double> T;
00247 return arma_atlas(clapack_zgetri)(Order, N, (T*)A, lda, ipiv);
00248 }
00249 else
00250 {
00251 return -1;
00252 }
00253 }
00254
00255
00256
00257 template<typename eT>
00258 inline
00259 int
00260 clapack_gesv
00261 (
00262 const enum CBLAS_ORDER Order,
00263 const int N, const int NRHS,
00264 eT* A, const int lda, int* ipiv,
00265 eT* B, const int ldb
00266 )
00267 {
00268 arma_type_check((is_supported_blas_type<eT>::value == false));
00269
00270 if(is_float<eT>::value == true)
00271 {
00272 typedef float T;
00273 return arma_atlas(clapack_sgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb);
00274 }
00275 else
00276 if(is_double<eT>::value == true)
00277 {
00278 typedef double T;
00279 return arma_atlas(clapack_dgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb);
00280 }
00281 else
00282 if(is_supported_complex_float<eT>::value == true)
00283 {
00284 typedef std::complex<float> T;
00285 return arma_atlas(clapack_cgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb);
00286 }
00287 else
00288 if(is_supported_complex_double<eT>::value == true)
00289 {
00290 typedef std::complex<double> T;
00291 return arma_atlas(clapack_zgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb);
00292 }
00293 else
00294 {
00295 return -1;
00296 }
00297 }
00298
00299
00300
00301 }
00302
00303 #endif