| blas_proto.hpp | | blas_proto.hpp | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| #ifdef ARMA_USE_BLAS | | #ifdef ARMA_USE_BLAS | |
| | | | |
| //! \namespace blas namespace for BLAS functions | | //! \namespace blas namespace for BLAS functions | |
| namespace blas | | namespace blas | |
| { | | { | |
| extern "C" | | extern "C" | |
| { | | { | |
|
| float arma_fortran(sdot)(const blas_int* n, const float* x, const bla | | float arma_fortran(sdot)(blas_int* n, const float* x, blas_int* incx, | |
| s_int* incx, const float* y, const blas_int* incy); | | const float* y, blas_int* incy); | |
| double arma_fortran(ddot)(const blas_int* n, const double* x, const bla | | double arma_fortran(ddot)(blas_int* n, const double* x, blas_int* incx, | |
| s_int* incx, const double* y, const blas_int* incy); | | const double* y, blas_int* incy); | |
| | | | |
| void arma_fortran(sgemv)(const char* transA, const blas_int* m, const b
las_int* n, const float* alpha, const float* A, const blas_int* ldA, cons
t float* x, const blas_int* incx, const float* beta, float* y, const bla
s_int* incy); | | void arma_fortran(sgemv)(const char* transA, const blas_int* m, const b
las_int* n, const float* alpha, const float* A, const blas_int* ldA, cons
t float* x, const blas_int* incx, const float* beta, float* y, const bla
s_int* incy); | |
| void arma_fortran(dgemv)(const char* transA, const blas_int* m, const b
las_int* n, const double* alpha, const double* A, const blas_int* ldA, cons
t double* x, const blas_int* incx, const double* beta, double* y, const bla
s_int* incy); | | void arma_fortran(dgemv)(const char* transA, const blas_int* m, const b
las_int* n, const double* alpha, const double* A, const blas_int* ldA, cons
t double* x, const blas_int* incx, const double* beta, double* y, const bla
s_int* incy); | |
| void arma_fortran(cgemv)(const char* transA, const blas_int* m, const b
las_int* n, const void* alpha, const void* A, const blas_int* ldA, cons
t void* x, const blas_int* incx, const void* beta, void* y, const bla
s_int* incy); | | void arma_fortran(cgemv)(const char* transA, const blas_int* m, const b
las_int* n, const void* alpha, const void* A, const blas_int* ldA, cons
t void* x, const blas_int* incx, const void* beta, void* y, const bla
s_int* incy); | |
| void arma_fortran(zgemv)(const char* transA, const blas_int* m, const b
las_int* n, const void* alpha, const void* A, const blas_int* ldA, cons
t void* x, const blas_int* incx, const void* beta, void* y, const bla
s_int* incy); | | void arma_fortran(zgemv)(const char* transA, const blas_int* m, const b
las_int* n, const void* alpha, const void* A, const blas_int* ldA, cons
t void* x, const blas_int* incx, const void* beta, void* y, const bla
s_int* incy); | |
| | | | |
| void arma_fortran(sgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const float* alpha, con
st float* A, const blas_int* ldA, const float* B, const blas_int* ldB, co
nst float* beta, float* C, const blas_int* ldC); | | void arma_fortran(sgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const float* alpha, con
st float* A, const blas_int* ldA, const float* B, const blas_int* ldB, co
nst float* beta, float* C, const blas_int* ldC); | |
| void arma_fortran(dgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const double* alpha, con
st double* A, const blas_int* ldA, const double* B, const blas_int* ldB, co
nst double* beta, double* C, const blas_int* ldC); | | void arma_fortran(dgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const double* alpha, con
st double* A, const blas_int* ldA, const double* B, const blas_int* ldB, co
nst double* beta, double* C, const blas_int* ldC); | |
| void arma_fortran(cgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const void* alpha, con
st void* A, const blas_int* ldA, const void* B, const blas_int* ldB, co
nst void* beta, void* C, const blas_int* ldC); | | void arma_fortran(cgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const void* alpha, con
st void* A, const blas_int* ldA, const void* B, const blas_int* ldB, co
nst void* beta, void* C, const blas_int* ldC); | |
| void arma_fortran(zgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const void* alpha, con
st void* A, const blas_int* ldA, const void* B, const blas_int* ldB, co
nst void* beta, void* C, const blas_int* ldC); | | void arma_fortran(zgemm)(const char* transA, const char* transB, const
blas_int* m, const blas_int* n, const blas_int* k, const void* alpha, con
st void* A, const blas_int* ldA, const void* B, const blas_int* ldB, co
nst void* beta, void* C, const blas_int* ldC); | |
| | | | |
| // void arma_fortran(dswap)(const blas_int* n, double* x, const blas_
int* incx, double* y, const blas_int* incy); | | // void arma_fortran(dswap)(const blas_int* n, double* x, const blas_
int* incx, double* y, const blas_int* incy); | |
| // void arma_fortran(dscal)(const blas_int* n, const double* alpha, d
ouble* x, const blas_int* incx); | | // void arma_fortran(dscal)(const blas_int* n, const double* alpha, d
ouble* x, const blas_int* incx); | |
| // void arma_fortran(dcopy)(const blas_int* n, const double* x, const
blas_int* incx, double* y, const blas_int* incy); | | // void arma_fortran(dcopy)(const blas_int* n, const double* x, const
blas_int* incx, double* y, const blas_int* incy); | |
| // void arma_fortran(daxpy)(const blas_int* n, const double* alpha, c
onst double* x, const blas_int* incx, double* y, const blas_int* incy); | | // void arma_fortran(daxpy)(const blas_int* n, const double* alpha, c
onst double* x, const blas_int* incx, double* y, const blas_int* incy); | |
| // void arma_fortran(dger)(const blas_int* m, const blas_int* n, con
st double* alpha, const double* x, const blas_int* incx, const double* y, c
onst blas_int* incy, double* A, const blas_int* ldA); | | // void arma_fortran(dger)(const blas_int* m, const blas_int* n, con
st double* alpha, const double* x, const blas_int* incx, const double* y, c
onst blas_int* incy, double* A, const blas_int* ldA); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
|
| arma_inline | | inline | |
| eT | | eT | |
|
| dot(const blas_int* n, const eT* x, const eT* y) | | dot(const u32 n_elem, const eT* x, const eT* y) | |
| { | | { | |
|
| arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); | | arma_ignore(n_elem); | |
| | | arma_ignore(x); | |
| | | arma_ignore(y); | |
| | | | |
|
| const blas_int inc = 1; | | return eT(0); | |
| | | } | |
| | | | |
|
| if(is_float<eT>::value == true) | | template<> | |
| { | | inline | |
| typedef float T; | | float | |
| return eT( arma_fortran(sdot)(n, (const T*)x, &inc, (const T*)y, &inc | | dot(const u32 n_elem, const float* x, const float* y) | |
| ) ); | | { | |
| } | | blas_int n = blas_int(n_elem); | |
| else | | blas_int inc = blas_int(1); | |
| if(is_double<eT>::value == true) | | | |
| { | | return arma_fortran(sdot)(&n, x, &inc, y, &inc); | |
| typedef double T; | | } | |
| return eT( arma_fortran(ddot)(n, (const T*)x, &inc, (const T*)y, &inc | | | |
| ) ); | | template<> | |
| } | | inline | |
| else | | double | |
| { | | dot(const u32 n_elem, const double* x, const double* y) | |
| return eT(0); // prevent compiler warnings | | { | |
| } | | blas_int n = blas_int(n_elem); | |
| | | blas_int inc = blas_int(1); | |
| | | | |
| | | return arma_fortran(ddot)(&n, x, &inc, y, &inc); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| 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) | | 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) | |
| { | | { | |
| arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); | | arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); | |
| | | | |
| if(is_float<eT>::value == true) | | if(is_float<eT>::value == true) | |
| | | | |
End of changes. 6 change blocks. |
| 25 lines changed or deleted | | 31 lines changed or added | |
|
| fn_norm.hpp | | fn_norm.hpp | |
| | | | |
| skipping to change at line 18 | | skipping to change at line 18 | |
| // Lesser General Public License (LGPL) as published | | // Lesser General Public License (LGPL) as published | |
| // by the Free Software Foundation, either version 3 | | // by the Free Software Foundation, either version 3 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| //! \addtogroup fn_norm | | //! \addtogroup fn_norm | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::pod_type | | typename T1::pod_type | |
|
| norm_1(const Proxy<T1>& A) | | arma_vec_norm_1(const Proxy<T1>& A) | |
| { | | { | |
|
| | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| T acc = T(0); | | T acc = T(0); | |
| | | | |
| ea_type P = A.get_ea(); | | ea_type P = A.get_ea(); | |
| const u32 N = A.get_n_elem(); | | const u32 N = A.get_n_elem(); | |
| | | | |
| u32 i,j; | | u32 i,j; | |
| | | | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 50 | |
| if(i < N) | | if(i < N) | |
| { | | { | |
| acc += std::abs(P[i]); | | acc += std::abs(P[i]); | |
| } | | } | |
| | | | |
| return acc; | | return acc; | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::pod_type | | typename T1::pod_type | |
|
| norm_2(const Proxy<T1>& A, const typename arma_not_cx<typename T1::elem_typ
e>::result* junk = 0) | | arma_vec_norm_2(const Proxy<T1>& A, const typename arma_not_cx<typename T1:
:elem_type>::result* junk = 0) | |
| { | | { | |
|
| | | arma_extra_debug_sigprint(); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| T acc = T(0); | | T acc = T(0); | |
| | | | |
| ea_type P = A.get_ea(); | | ea_type P = A.get_ea(); | |
| const u32 N = A.get_n_elem(); | | const u32 N = A.get_n_elem(); | |
| | | | |
| | | | |
| skipping to change at line 85 | | skipping to change at line 88 | |
| const T tmp_i = P[i]; | | const T tmp_i = P[i]; | |
| | | | |
| acc += tmp_i * tmp_i; | | acc += tmp_i * tmp_i; | |
| } | | } | |
| | | | |
| return std::sqrt(acc); | | return std::sqrt(acc); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::pod_type | | typename T1::pod_type | |
|
| norm_2(const Proxy<T1>& A, const typename arma_cx_only<typename T1::elem_ty
pe>::result* junk = 0) | | arma_vec_norm_2(const Proxy<T1>& A, const typename arma_cx_only<typename T1
::elem_type>::result* junk = 0) | |
| { | | { | |
|
| | | arma_extra_debug_sigprint(); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| T acc = T(0); | | T acc = T(0); | |
| | | | |
| ea_type P = A.get_ea(); | | ea_type P = A.get_ea(); | |
| const u32 N = A.get_n_elem(); | | const u32 N = A.get_n_elem(); | |
| | | | |
| | | | |
| skipping to change at line 110 | | skipping to change at line 114 | |
| { | | { | |
| const T tmp = std::abs(P[i]); | | const T tmp = std::abs(P[i]); | |
| acc += tmp*tmp; | | acc += tmp*tmp; | |
| } | | } | |
| | | | |
| return std::sqrt(acc); | | return std::sqrt(acc); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::pod_type | | typename T1::pod_type | |
|
| norm_k(const Proxy<T1>& A, const int k) | | arma_vec_norm_k(const Proxy<T1>& A, const int k) | |
| { | | { | |
|
| | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| T acc = T(0); | | T acc = T(0); | |
| | | | |
| ea_type P = A.get_ea(); | | ea_type P = A.get_ea(); | |
| const u32 N = A.get_n_elem(); | | const u32 N = A.get_n_elem(); | |
| | | | |
| u32 i,j; | | u32 i,j; | |
| | | | |
| | | | |
| skipping to change at line 140 | | skipping to change at line 146 | |
| if(i < N) | | if(i < N) | |
| { | | { | |
| acc += std::pow(std::abs(P[i]), k); | | acc += std::pow(std::abs(P[i]), k); | |
| } | | } | |
| | | | |
| return std::pow(acc, T(1)/T(k)); | | return std::pow(acc, T(1)/T(k)); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::pod_type | | typename T1::pod_type | |
|
| norm_max(const Proxy<T1>& A) | | arma_vec_norm_max(const Proxy<T1>& A) | |
| { | | { | |
|
| | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| ea_type P = A.get_ea(); | | ea_type P = A.get_ea(); | |
| const u32 N = A.get_n_elem(); | | const u32 N = A.get_n_elem(); | |
| | | | |
| T max_val = std::abs(P[0]); | | T max_val = std::abs(P[0]); | |
| | | | |
| u32 i,j; | | u32 i,j; | |
| | | | |
| | | | |
| skipping to change at line 175 | | skipping to change at line 183 | |
| const T tmp_i = std::abs(P[i]); | | const T tmp_i = std::abs(P[i]); | |
| | | | |
| if(max_val < tmp_i) { max_val = tmp_i; } | | if(max_val < tmp_i) { max_val = tmp_i; } | |
| } | | } | |
| | | | |
| return max_val; | | return max_val; | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::pod_type | | typename T1::pod_type | |
|
| norm_min(const Proxy<T1>& A) | | arma_vec_norm_min(const Proxy<T1>& A) | |
| { | | { | |
|
| | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| ea_type P = A.get_ea(); | | ea_type P = A.get_ea(); | |
| const u32 N = A.get_n_elem(); | | const u32 N = A.get_n_elem(); | |
| | | | |
| T min_val = std::abs(P[0]); | | T min_val = std::abs(P[0]); | |
| | | | |
| u32 i,j; | | u32 i,j; | |
| | | | |
| | | | |
| skipping to change at line 209 | | skipping to change at line 219 | |
| { | | { | |
| const T tmp_i = std::abs(P[i]); | | const T tmp_i = std::abs(P[i]); | |
| | | | |
| if(min_val > tmp_i) { min_val = tmp_i; } | | if(min_val > tmp_i) { min_val = tmp_i; } | |
| } | | } | |
| | | | |
| return min_val; | | return min_val; | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
|
| arma_inline | | inline | |
| | | typename T1::pod_type | |
| | | arma_mat_norm_1(const Proxy<T1>& A) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | typedef typename T1::pod_type T; | |
| | | | |
| | | const unwrap<typename Proxy<T1>::stored_type> tmp(A.Q); | |
| | | const Mat<eT>& X = tmp.M; | |
| | | | |
| | | // TODO: this can be sped up with a dedicated implementation | |
| | | return as_scalar( max( sum(abs(X)), 1) ); | |
| | | } | |
| | | | |
| | | template<typename T1> | |
| | | inline | |
| | | typename T1::pod_type | |
| | | arma_mat_norm_2(const Proxy<T1>& A) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | typedef typename T1::pod_type T; | |
| | | | |
| | | const unwrap<typename Proxy<T1>::stored_type> tmp(A.Q); | |
| | | const Mat<eT>& X = tmp.M; | |
| | | | |
| | | Col<T> S; | |
| | | svd(S, X); | |
| | | | |
| | | return (S.n_elem > 0) ? max(S) : T(0); | |
| | | } | |
| | | | |
| | | template<typename T1> | |
| | | inline | |
| | | typename T1::pod_type | |
| | | arma_mat_norm_inf(const Proxy<T1>& A) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | typedef typename T1::pod_type T; | |
| | | | |
| | | const unwrap<typename Proxy<T1>::stored_type> tmp(A.Q); | |
| | | const Mat<eT>& X = tmp.M; | |
| | | | |
| | | // TODO: this can be sped up with a dedicated implementation | |
| | | return as_scalar( max( sum(abs(X),1) ) ); | |
| | | } | |
| | | | |
| | | template<typename T1> | |
| | | inline | |
| arma_warn_unused | | arma_warn_unused | |
| typename T1::pod_type | | typename T1::pod_type | |
| norm | | norm | |
| ( | | ( | |
| const Base<typename T1::elem_type,T1>& X, | | const Base<typename T1::elem_type,T1>& X, | |
| const u32 k, | | const u32 k, | |
| const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun
k = 0 | | const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun
k = 0 | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| | | | |
| const Proxy<T1> A(X.get_ref()); | | const Proxy<T1> A(X.get_ref()); | |
| | | | |
|
| arma_debug_check( (A.get_n_elem() == 0), "n | | if(A.get_n_elem() == 0) | |
| orm(): given object has no elements" ); | | | |
| arma_debug_check( !( (A.get_n_rows() == 1) || (A.get_n_cols() == 1) ), "n | | | |
| orm(): given object must be a vector" ); | | | |
| | | | |
| switch(k) | | | |
| { | | { | |
|
| case 1: | | return T(0); | |
| return norm_1(A); | | } | |
| break; | | | |
| | | | |
|
| case 2: | | const bool is_vec = (A.get_n_rows() == 1) || (A.get_n_cols() == 1); | |
| return norm_2(A); | | | |
| break; | | | |
| | | | |
|
| default: | | if(is_vec == true) | |
| | | { | |
| | | switch(k) | |
| { | | { | |
|
| arma_debug_check( (k == 0), "norm(): k must be greater than zero" ) | | case 1: | |
| ; | | return arma_vec_norm_1(A); | |
| | | break; | |
| return norm_k(A, k); | | | |
| | | case 2: | |
| | | return arma_vec_norm_2(A); | |
| | | break; | |
| | | | |
| | | default: | |
| | | { | |
| | | arma_debug_check( (k == 0), "norm(): k must be greater than zero" | |
| | | ); | |
| | | return arma_vec_norm_k(A, k); | |
| | | } | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | switch(k) | |
| | | { | |
| | | case 1: | |
| | | return arma_mat_norm_1(A); | |
| | | break; | |
| | | | |
| | | case 2: | |
| | | return arma_mat_norm_2(A); | |
| | | break; | |
| | | | |
| | | default: | |
| | | arma_stop("norm(): unsupported matrix norm type"); | |
| | | return T(0); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
|
| arma_inline | | inline | |
| arma_warn_unused | | arma_warn_unused | |
| typename T1::pod_type | | typename T1::pod_type | |
| norm | | norm | |
| ( | | ( | |
| const Base<typename T1::elem_type,T1>& X, | | const Base<typename T1::elem_type,T1>& X, | |
| const char* method, | | const char* method, | |
| const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun
k = 0 | | const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun
k = 0 | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef typename T1::pod_type T; | | typedef typename T1::pod_type T; | |
| | | | |
| const Proxy<T1> A(X.get_ref()); | | const Proxy<T1> A(X.get_ref()); | |
| | | | |
|
| arma_debug_check( (A.get_n_elem() == 0), "n | | if(A.get_n_elem() == 0) | |
| orm(): given object has no elements" ); | | | |
| arma_debug_check( !( (A.get_n_rows() == 1) || (A.get_n_cols() == 1) ), "n | | | |
| orm(): given object must be a vector" ); | | | |
| | | | |
| const char sig = method[0]; | | | |
| | | | |
| if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm | | | |
| { | | { | |
|
| return norm_max(A); | | return T(0); | |
| } | | } | |
|
| else | | | |
| if(sig == '-') // min norm | | const char sig = method[0]; | |
| | | const bool is_vec = (A.get_n_rows() == 1) || (A.get_n_cols() == 1); | |
| | | | |
| | | if(is_vec == true) | |
| { | | { | |
|
| return norm_min(A); | | if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm | |
| | | { | |
| | | return arma_vec_norm_max(A); | |
| | | } | |
| | | else | |
| | | if(sig == '-') // min norm | |
| | | { | |
| | | return arma_vec_norm_min(A); | |
| | | } | |
| | | else | |
| | | if( (sig == 'f') || (sig == 'F') ) | |
| | | { | |
| | | return arma_vec_norm_2(A); | |
| | | } | |
| | | else | |
| | | { | |
| | | arma_stop("norm(): unsupported vector norm type"); | |
| | | return T(0); | |
| | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| arma_stop("norm(): unknown norm type"); | | if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // inf norm | |
| | | { | |
| return T(0); | | return arma_mat_norm_inf(A); | |
| | | } | |
| | | else | |
| | | if( (sig == 'f') || (sig == 'F') ) | |
| | | { | |
| | | return arma_vec_norm_2(A); | |
| | | } | |
| | | else | |
| | | { | |
| | | arma_stop("norm(): unsupported matrix norm type"); | |
| | | return T(0); | |
| | | } | |
| } | | } | |
|
| | | | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 33 change blocks. |
| 49 lines changed or deleted | | 155 lines changed or added | |
|
| op_dot_meat.hpp | | op_dot_meat.hpp | |
| | | | |
| skipping to change at line 63 | | skipping to change at line 63 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if( n_elem <= (128/sizeof(eT)) ) | | if( n_elem <= (128/sizeof(eT)) ) | |
| { | | { | |
| return op_dot::direct_dot_arma(n_elem, A, B); | | return op_dot::direct_dot_arma(n_elem, A, B); | |
| } | | } | |
| else | | else | |
| { | | { | |
| #if defined(ARMA_USE_ATLAS) | | #if defined(ARMA_USE_ATLAS) | |
| { | | { | |
|
| | | arma_extra_debug_print("atlas::cblas_dot()"); | |
| | | | |
| return atlas::cblas_dot(n_elem, A, B); | | return atlas::cblas_dot(n_elem, A, B); | |
| } | | } | |
| #elif defined(ARMA_USE_BLAS) | | #elif defined(ARMA_USE_BLAS) | |
| { | | { | |
|
| const blas_int n = n_elem; | | arma_extra_debug_print("blas::dot()"); | |
| return blas::dot(&n, A, B); | | | |
| | | return blas::dot(n_elem, A, B); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| return op_dot::direct_dot_arma(n_elem, A, B); | | return op_dot::direct_dot_arma(n_elem, A, B); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| } | | } | |
| | | | |
| //! for two arrays, complex version | | //! for two arrays, complex version | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| arma_hot | | arma_hot | |
| arma_pure | | arma_pure | |
| typename arma_cx_only<eT>::result | | typename arma_cx_only<eT>::result | |
| op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B) | | op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B) | |
| { | | { | |
| #if defined(ARMA_USE_ATLAS) | | #if defined(ARMA_USE_ATLAS) | |
| { | | { | |
|
| | | arma_extra_debug_print("atlas::cx_cblas_dot()"); | |
| | | | |
| return atlas::cx_cblas_dot(n_elem, A, B); | | return atlas::cx_cblas_dot(n_elem, A, B); | |
| } | | } | |
| #elif defined(ARMA_USE_BLAS) | | #elif defined(ARMA_USE_BLAS) | |
| { | | { | |
| // TODO: work out the mess with zdotu() and zdotu_sub() in BLAS | | // TODO: work out the mess with zdotu() and zdotu_sub() in BLAS | |
| return op_dot::direct_dot_arma(n_elem, A, B); | | return op_dot::direct_dot_arma(n_elem, A, B); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| return op_dot::direct_dot_arma(n_elem, A, B); | | return op_dot::direct_dot_arma(n_elem, A, B); | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 7 lines changed or added | |
|