annotate armadillo-2.4.4/include/armadillo_bits/blas_wrapper.hpp @ 18:8d046a9d36aa slimline

Back out rev 13:ac07c60aa798. Like an idiot, I committed a whole pile of unrelated changes in the guise of a single typo fix. Will re-commit in stages
author Chris Cannam
date Thu, 10 May 2012 10:45:44 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2008-2011 Conrad Sanderson
max@0 3 //
max@0 4 // This file is part of the Armadillo C++ library.
max@0 5 // It is provided without any warranty of fitness
max@0 6 // for any purpose. You can redistribute this file
max@0 7 // and/or modify it under the terms of the GNU
max@0 8 // Lesser General Public License (LGPL) as published
max@0 9 // by the Free Software Foundation, either version 3
max@0 10 // of the License or (at your option) any later version.
max@0 11 // (see http://www.opensource.org/licenses for more info)
max@0 12
max@0 13
max@0 14
max@0 15 #ifdef ARMA_USE_BLAS
max@0 16
max@0 17
max@0 18 //! \namespace blas namespace for BLAS functions
max@0 19 namespace blas
max@0 20 {
max@0 21
max@0 22
max@0 23 template<typename eT>
max@0 24 inline
max@0 25 eT
max@0 26 dot(const uword n_elem, const eT* x, const eT* y)
max@0 27 {
max@0 28 arma_ignore(n_elem);
max@0 29 arma_ignore(x);
max@0 30 arma_ignore(y);
max@0 31
max@0 32 return eT(0);
max@0 33 }
max@0 34
max@0 35
max@0 36
max@0 37 template<>
max@0 38 inline
max@0 39 float
max@0 40 dot(const uword n_elem, const float* x, const float* y)
max@0 41 {
max@0 42 blas_int n = blas_int(n_elem);
max@0 43 blas_int inc = blas_int(1);
max@0 44
max@0 45 return arma_fortran(arma_sdot)(&n, x, &inc, y, &inc);
max@0 46 }
max@0 47
max@0 48
max@0 49
max@0 50 template<>
max@0 51 inline
max@0 52 double
max@0 53 dot(const uword n_elem, const double* x, const double* y)
max@0 54 {
max@0 55 blas_int n = blas_int(n_elem);
max@0 56 blas_int inc = blas_int(1);
max@0 57
max@0 58 return arma_fortran(arma_ddot)(&n, x, &inc, y, &inc);
max@0 59 }
max@0 60
max@0 61
max@0 62
max@0 63 template<typename eT>
max@0 64 inline
max@0 65 void
max@0 66 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)
max@0 67 {
max@0 68 arma_type_check((is_supported_blas_type<eT>::value == false));
max@0 69
max@0 70 if(is_float<eT>::value == true)
max@0 71 {
max@0 72 typedef float T;
max@0 73 arma_fortran(arma_sgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
max@0 74 }
max@0 75 else
max@0 76 if(is_double<eT>::value == true)
max@0 77 {
max@0 78 typedef double T;
max@0 79 arma_fortran(arma_dgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
max@0 80 }
max@0 81 else
max@0 82 if(is_supported_complex_float<eT>::value == true)
max@0 83 {
max@0 84 typedef std::complex<float> T;
max@0 85 arma_fortran(arma_cgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
max@0 86 }
max@0 87 else
max@0 88 if(is_supported_complex_double<eT>::value == true)
max@0 89 {
max@0 90 typedef std::complex<double> T;
max@0 91 arma_fortran(arma_zgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
max@0 92 }
max@0 93
max@0 94 }
max@0 95
max@0 96
max@0 97
max@0 98 template<typename eT>
max@0 99 inline
max@0 100 void
max@0 101 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)
max@0 102 {
max@0 103 arma_type_check((is_supported_blas_type<eT>::value == false));
max@0 104
max@0 105 if(is_float<eT>::value == true)
max@0 106 {
max@0 107 typedef float T;
max@0 108 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);
max@0 109 }
max@0 110 else
max@0 111 if(is_double<eT>::value == true)
max@0 112 {
max@0 113 typedef double T;
max@0 114 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);
max@0 115 }
max@0 116 else
max@0 117 if(is_supported_complex_float<eT>::value == true)
max@0 118 {
max@0 119 typedef std::complex<float> T;
max@0 120 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);
max@0 121 }
max@0 122 else
max@0 123 if(is_supported_complex_double<eT>::value == true)
max@0 124 {
max@0 125 typedef std::complex<double> T;
max@0 126 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);
max@0 127 }
max@0 128
max@0 129 }
max@0 130
max@0 131 }
max@0 132
max@0 133
max@0 134 #endif