max@0: // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2008-2011 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: #ifdef ARMA_USE_ATLAS max@0: max@0: max@0: //! \namespace atlas namespace for ATLAS functions (imported from the global namespace) max@0: namespace atlas max@0: { max@0: max@0: template max@0: inline static const eT& tmp_real(const eT& X) { return X; } max@0: max@0: template max@0: inline static const T& tmp_real(const std::complex& X) { return X.real(); } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: eT max@0: cblas_dot(const int N, const eT* X, const eT* Y) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_float::value == true) max@0: { max@0: typedef float T; max@0: return eT( arma_atlas(cblas_sdot)(N, (const T*)X, 1, (const T*)Y, 1) ); max@0: } max@0: else max@0: if(is_double::value == true) max@0: { max@0: typedef double T; max@0: return eT( arma_atlas(cblas_ddot)(N, (const T*)X, 1, (const T*)Y, 1) ); max@0: } max@0: else max@0: { max@0: return eT(0); max@0: } max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: eT max@0: cx_cblas_dot(const int N, const eT* X, const eT* Y) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_supported_complex_float::value == true) max@0: { max@0: typedef typename std::complex T; max@0: max@0: T out; max@0: arma_atlas(cblas_cdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out); max@0: max@0: return eT(out); max@0: } max@0: else max@0: if(is_supported_complex_double::value == true) max@0: { max@0: typedef typename std::complex T; max@0: max@0: T out; max@0: arma_atlas(cblas_zdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out); max@0: max@0: return eT(out); max@0: } max@0: else max@0: { max@0: return eT(0); max@0: } max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: cblas_gemv max@0: ( max@0: const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, max@0: const int M, const int N, max@0: const eT alpha, max@0: const eT *A, const int lda, max@0: const eT *X, const int incX, max@0: const eT beta, max@0: eT *Y, const int incY max@0: ) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_float::value == true) max@0: { max@0: typedef float T; max@0: 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); max@0: } max@0: else max@0: if(is_double::value == true) max@0: { max@0: typedef double T; max@0: 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); max@0: } max@0: else max@0: if(is_supported_complex_float::value == true) max@0: { max@0: typedef std::complex T; max@0: 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); max@0: } max@0: else max@0: if(is_supported_complex_double::value == true) max@0: { max@0: typedef std::complex T; max@0: 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); max@0: } max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: cblas_gemm max@0: ( max@0: const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, max@0: const enum CBLAS_TRANSPOSE TransB, const int M, const int N, max@0: const int K, const eT alpha, const eT *A, max@0: const int lda, const eT *B, const int ldb, max@0: const eT beta, eT *C, const int ldc max@0: ) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_float::value == true) max@0: { max@0: typedef float T; max@0: 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); max@0: } max@0: else max@0: if(is_double::value == true) max@0: { max@0: typedef double T; max@0: 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); max@0: } max@0: else max@0: if(is_supported_complex_float::value == true) max@0: { max@0: typedef std::complex T; max@0: 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); max@0: } max@0: else max@0: if(is_supported_complex_double::value == true) max@0: { max@0: typedef std::complex T; max@0: 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); max@0: } max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: int max@0: clapack_getrf max@0: ( max@0: const enum CBLAS_ORDER Order, const int M, const int N, max@0: eT *A, const int lda, int *ipiv max@0: ) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_float::value == true) max@0: { max@0: typedef float T; max@0: return arma_atlas(clapack_sgetrf)(Order, M, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: if(is_double::value == true) max@0: { max@0: typedef double T; max@0: return arma_atlas(clapack_dgetrf)(Order, M, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: if(is_supported_complex_float::value == true) max@0: { max@0: typedef std::complex T; max@0: return arma_atlas(clapack_cgetrf)(Order, M, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: if(is_supported_complex_double::value == true) max@0: { max@0: typedef std::complex T; max@0: return arma_atlas(clapack_zgetrf)(Order, M, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: { max@0: return -1; max@0: } max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: int max@0: clapack_getri max@0: ( max@0: const enum CBLAS_ORDER Order, const int N, eT *A, max@0: const int lda, const int *ipiv max@0: ) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_float::value == true) max@0: { max@0: typedef float T; max@0: return arma_atlas(clapack_sgetri)(Order, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: if(is_double::value == true) max@0: { max@0: typedef double T; max@0: return arma_atlas(clapack_dgetri)(Order, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: if(is_supported_complex_float::value == true) max@0: { max@0: typedef std::complex T; max@0: return arma_atlas(clapack_cgetri)(Order, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: if(is_supported_complex_double::value == true) max@0: { max@0: typedef std::complex T; max@0: return arma_atlas(clapack_zgetri)(Order, N, (T*)A, lda, ipiv); max@0: } max@0: else max@0: { max@0: return -1; max@0: } max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: int max@0: clapack_gesv max@0: ( max@0: const enum CBLAS_ORDER Order, max@0: const int N, const int NRHS, max@0: eT* A, const int lda, int* ipiv, max@0: eT* B, const int ldb max@0: ) max@0: { max@0: arma_type_check((is_supported_blas_type::value == false)); max@0: max@0: if(is_float::value == true) max@0: { max@0: typedef float T; max@0: return arma_atlas(clapack_sgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); max@0: } max@0: else max@0: if(is_double::value == true) max@0: { max@0: typedef double T; max@0: return arma_atlas(clapack_dgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); max@0: } max@0: else max@0: if(is_supported_complex_float::value == true) max@0: { max@0: typedef std::complex T; max@0: return arma_atlas(clapack_cgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); max@0: } max@0: else max@0: if(is_supported_complex_double::value == true) max@0: { max@0: typedef std::complex T; max@0: return arma_atlas(clapack_zgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); max@0: } max@0: else max@0: { max@0: return -1; max@0: } max@0: } max@0: max@0: max@0: max@0: } max@0: max@0: #endif