| Proxy.hpp | | Proxy.hpp | |
| | | | |
| skipping to change at line 81 | | skipping to change at line 81 | |
| | | | |
| arma_aligned const Col<eT>& Q; | | arma_aligned const Col<eT>& Q; | |
| | | | |
| inline explicit Proxy(const Col<eT>& A) | | inline explicit Proxy(const Col<eT>& A) | |
| : Q(A) | | : Q(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline u32 get_n_rows() const { return Q.n_rows; } | | arma_inline u32 get_n_rows() const { return Q.n_rows; } | |
|
| arma_inline u32 get_n_cols() const { return Q.n_cols; } | | arma_inline u32 get_n_cols() const { return 1; } | |
| arma_inline u32 get_n_elem() const { return Q.n_elem; } | | arma_inline u32 get_n_elem() const { return Q.n_elem; } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| | | | |
| arma_inline ea_type get_ea() const { return Q.memptr();
} | | arma_inline ea_type get_ea() const { return Q.memptr();
} | |
| arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X);
} | | arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X);
} | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 111 | |
| static const bool prefer_at_accessor = false; | | static const bool prefer_at_accessor = false; | |
| | | | |
| arma_aligned const Row<eT>& Q; | | arma_aligned const Row<eT>& Q; | |
| | | | |
| inline explicit Proxy(const Row<eT>& A) | | inline explicit Proxy(const Row<eT>& A) | |
| : Q(A) | | : Q(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| arma_inline u32 get_n_rows() const { return Q.n_rows; } | | arma_inline u32 get_n_rows() const { return 1; } | |
| arma_inline u32 get_n_cols() const { return Q.n_cols; } | | arma_inline u32 get_n_cols() const { return Q.n_cols; } | |
| arma_inline u32 get_n_elem() const { return Q.n_elem; } | | arma_inline u32 get_n_elem() const { return Q.n_elem; } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| | | | |
| arma_inline ea_type get_ea() const { return Q.memptr();
} | | arma_inline ea_type get_ea() const { return Q.memptr();
} | |
| arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X);
} | | arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X);
} | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 236 | | skipping to change at line 236 | |
| | | | |
| arma_aligned const Mat<eT> Q; | | arma_aligned const Mat<eT> Q; | |
| | | | |
| inline explicit Proxy(const subview_elem1<eT,T1>& A) | | inline explicit Proxy(const subview_elem1<eT,T1>& A) | |
| : Q(A) | | : Q(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline u32 get_n_rows() const { return Q.n_rows; } | | arma_inline u32 get_n_rows() const { return Q.n_rows; } | |
|
| arma_inline u32 get_n_cols() const { return Q.n_cols; } | | arma_inline u32 get_n_cols() const { return 1; } | |
| arma_inline u32 get_n_elem() const { return Q.n_elem; } | | arma_inline u32 get_n_elem() const { return Q.n_elem; } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| | | | |
| arma_inline ea_type get_ea() const { return Q.memptr(); } | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| arma_inline bool is_alias(const Mat<eT>&) const { return false; } | | arma_inline bool is_alias(const Mat<eT>&) const { return false; } | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| | | | |
| skipping to change at line 267 | | skipping to change at line 267 | |
| | | | |
| arma_aligned const diagview<eT>& Q; | | arma_aligned const diagview<eT>& Q; | |
| | | | |
| inline explicit Proxy(const diagview<eT>& A) | | inline explicit Proxy(const diagview<eT>& A) | |
| : Q(A) | | : Q(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline u32 get_n_rows() const { return Q.n_rows; } | | arma_inline u32 get_n_rows() const { return Q.n_rows; } | |
|
| arma_inline u32 get_n_cols() const { return Q.n_cols; } | | arma_inline u32 get_n_cols() const { return 1; } | |
| arma_inline u32 get_n_elem() const { return Q.n_elem; } | | arma_inline u32 get_n_elem() const { return Q.n_elem; } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| | | | |
| arma_inline ea_type get_ea() const { return Q;
} | | arma_inline ea_type get_ea() const { return Q;
} | |
| arma_inline bool is_alias(const Mat<eT>& X) const { return (&(Q.m) ==
&X); } | | arma_inline bool is_alias(const Mat<eT>& X) const { return (&(Q.m) ==
&X); } | |
| }; | | }; | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| | | | |
End of changes. 4 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|
| auxlib_meat.hpp | | auxlib_meat.hpp | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| // 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 auxlib | | //! \addtogroup auxlib | |
| //! @{ | | //! @{ | |
| | | | |
| //! immediate matrix inverse | | //! immediate matrix inverse | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::inv(Mat<eT>& out, const Base<eT,T1>& X) | | auxlib::inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slow) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| bool status = false; | | | |
| | | | |
| out = X.get_ref(); | | out = X.get_ref(); | |
| | | | |
| arma_debug_check( (out.is_square() == false), "inv(): given matrix is not
square" ); | | arma_debug_check( (out.is_square() == false), "inv(): given matrix is not
square" ); | |
| | | | |
|
| | | bool status = false; | |
| | | | |
| const u32 N = out.n_rows; | | const u32 N = out.n_rows; | |
| | | | |
|
| if(N <= 4) | | if( (N <= 4) && (slow == false) ) | |
| { | | { | |
| status = auxlib::inv_inplace_tinymat(out, N); | | status = auxlib::inv_inplace_tinymat(out, N); | |
| } | | } | |
| | | | |
| if( (N > 4) || (status == false) ) | | if( (N > 4) || (status == false) ) | |
| { | | { | |
| status = auxlib::inv_inplace_lapack(out); | | status = auxlib::inv_inplace_lapack(out); | |
| } | | } | |
| | | | |
| if(status == false) | | if(status == false) | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| arma_print("inv(): matrix appears to be singular" ); | | arma_print("inv(): matrix appears to be singular" ); | |
| out.reset(); | | out.reset(); | |
| } | | } | |
| | | | |
| return status; | | return status; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::inv(Mat<eT>& out, const Mat<eT>& X) | | auxlib::inv(Mat<eT>& out, const Mat<eT>& X, const bool slow) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s
quare" ); | | arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s
quare" ); | |
| | | | |
| bool status = false; | | bool status = false; | |
| | | | |
| const u32 N = X.n_rows; | | const u32 N = X.n_rows; | |
| | | | |
|
| if(N <= 4) | | if( (N <= 4) && (slow == false) ) | |
| { | | { | |
| status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib
::inv_inplace_tinymat(out, N); | | status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib
::inv_inplace_tinymat(out, N); | |
| } | | } | |
| | | | |
| if( (N > 4) || (status == false) ) | | if( (N > 4) || (status == false) ) | |
| { | | { | |
| out = X; | | out = X; | |
| status = auxlib::inv_inplace_lapack(out); | | status = auxlib::inv_inplace_lapack(out); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 416 | | skipping to change at line 416 | |
| } | | } | |
| | | | |
| lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem
ptr(), &work_len, &info); | | lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem
ptr(), &work_len, &info); | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
|
| arma_stop("inv(): use of ATLAS or LAPACK needs to enabled"); | | arma_stop("inv(): use of ATLAS or LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout) | | auxlib::inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout) | |
| { | | { | |
| | | | |
| skipping to change at line 454 | | skipping to change at line 454 | |
| blas_int n = blas_int(out.n_rows); | | blas_int n = blas_int(out.n_rows); | |
| blas_int info = 0; | | blas_int info = 0; | |
| | | | |
| lapack::trtri(&uplo, &diag, &n, out.memptr(), &n, &info); | | lapack::trtri(&uplo, &diag, &n, out.memptr(), &n, &info); | |
| | | | |
| status = (info == 0); | | status = (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(layout); | | arma_ignore(layout); | |
|
| arma_stop("inv(): use of LAPACK needs to enabled"); | | arma_stop("inv(): use of LAPACK needs to be enabled"); | |
| status = false; | | status = false; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| if(status == false) | | if(status == false) | |
| { | | { | |
| arma_print("inv(): matrix appears to be singular" ); | | arma_print("inv(): matrix appears to be singular" ); | |
| out.reset(); | | out.reset(); | |
| } | | } | |
| else | | else | |
| | | | |
| skipping to change at line 515 | | skipping to change at line 515 | |
| lapack::potrf(&uplo, &n, out.memptr(), &n, &info); | | lapack::potrf(&uplo, &n, out.memptr(), &n, &info); | |
| lapack::potri(&uplo, &n, out.memptr(), &n, &info); | | lapack::potri(&uplo, &n, out.memptr(), &n, &info); | |
| | | | |
| out = (layout == 0) ? symmatu(out) : symmatl(out); | | out = (layout == 0) ? symmatu(out) : symmatl(out); | |
| | | | |
| status = (info == 0); | | status = (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(layout); | | arma_ignore(layout); | |
|
| arma_stop("inv(): use of LAPACK needs to enabled"); | | arma_stop("inv(): use of LAPACK needs to be enabled"); | |
| status = false; | | status = false; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| if(status == false) | | if(status == false) | |
| { | | { | |
| arma_print("inv(): matrix appears to be singular" ); | | arma_print("inv(): matrix appears to be singular" ); | |
| out.reset(); | | out.reset(); | |
| } | | } | |
| | | | |
| return status; | | return status; | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| eT | | eT | |
|
| auxlib::det(const Base<eT,T1>& X) | | auxlib::det(const Base<eT,T1>& X, const bool slow) | |
| { | | { | |
| const unwrap<T1> tmp(X.get_ref()); | | const unwrap<T1> tmp(X.get_ref()); | |
| const Mat<eT>& A = tmp.M; | | const Mat<eT>& A = tmp.M; | |
| | | | |
|
| arma_debug_check( !A.is_square(), "det(): matrix is not square" ); | | arma_debug_check( (A.is_square() == false), "det(): matrix is not square"
); | |
| | | | |
| const bool make_copy = (is_Mat<T1>::value == true) ? true : false; | | const bool make_copy = (is_Mat<T1>::value == true) ? true : false; | |
| | | | |
|
| const u32 N = A.n_rows; | | if(slow == false) | |
| | | | |
| switch(N) | | | |
| { | | { | |
|
| case 0: | | const u32 N = A.n_rows; | |
| case 1: | | | |
| case 2: | | | |
| return auxlib::det_tinymat(A, N); | | | |
| break; | | | |
| | | | |
|
| case 3: | | switch(N) | |
| case 4: | | | |
| { | | { | |
|
| const eT tmp_det = auxlib::det_tinymat(A, N); | | case 0: | |
| return (tmp_det != eT(0)) ? tmp_det : auxlib::det_lapack(A, make_copy | | case 1: | |
| ); | | case 2: | |
| } | | return auxlib::det_tinymat(A, N); | |
| break; | | break; | |
| | | | |
|
| default: | | case 3: | |
| return auxlib::det_lapack(A, make_copy); | | case 4: | |
| } | | { | |
| | | const eT tmp_det = auxlib::det_tinymat(A, N); | |
| | | return (tmp_det != eT(0)) ? tmp_det : auxlib::det_lapack(A, make_co | |
| | | py); | |
| | | } | |
| | | break; | |
| | | | |
|
| return eT(0); // prevent compiler warnings | | default: | |
| | | return auxlib::det_lapack(A, make_copy); | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | return auxlib::det_lapack(A, make_copy); | |
| | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
| auxlib::det_tinymat(const Mat<eT>& X, const u32 N) | | auxlib::det_tinymat(const Mat<eT>& X, const u32 N) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| switch(N) | | switch(N) | |
| | | | |
| skipping to change at line 678 | | skipping to change at line 683 | |
| | | | |
| Mat<eT> X_copy; | | Mat<eT> X_copy; | |
| | | | |
| if(make_copy == true) | | if(make_copy == true) | |
| { | | { | |
| X_copy = X; | | X_copy = X; | |
| } | | } | |
| | | | |
| Mat<eT>& tmp = (make_copy == true) ? X_copy : const_cast< Mat<eT>& >(X); | | Mat<eT>& tmp = (make_copy == true) ? X_copy : const_cast< Mat<eT>& >(X); | |
| | | | |
|
| | | if(tmp.is_empty()) | |
| | | { | |
| | | return eT(1); | |
| | | } | |
| | | | |
| #if defined(ARMA_USE_ATLAS) | | #if defined(ARMA_USE_ATLAS) | |
| { | | { | |
| podarray<int> ipiv(tmp.n_rows); | | podarray<int> ipiv(tmp.n_rows); | |
| | | | |
| atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp.
memptr(), tmp.n_rows, ipiv.memptr()); | | atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp.
memptr(), tmp.n_rows, ipiv.memptr()); | |
| | | | |
| // on output tmp appears to be L+U_alt, where U_alt is U with the main
diagonal set to zero | | // on output tmp appears to be L+U_alt, where U_alt is U with the main
diagonal set to zero | |
| eT val = tmp.at(0,0); | | eT val = tmp.at(0,0); | |
| for(u32 i=1; i < tmp.n_rows; ++i) | | for(u32 i=1; i < tmp.n_rows; ++i) | |
| { | | { | |
| | | | |
| skipping to change at line 735 | | skipping to change at line 745 | |
| } | | } | |
| } | | } | |
| | | | |
| return ( (sign < 0) ? -val : val ); | | return ( (sign < 0) ? -val : val ); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(X); | | arma_ignore(X); | |
| arma_ignore(make_copy); | | arma_ignore(make_copy); | |
| arma_ignore(tmp); | | arma_ignore(tmp); | |
|
| arma_stop("det(): use of ATLAS or LAPACK needs to enabled"); | | arma_stop("det(): use of ATLAS or LAPACK needs to be enabled"); | |
| return eT(0); | | return eT(0); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! immediate log determinant of a matrix using ATLAS or LAPACK | | //! immediate log determinant of a matrix using ATLAS or LAPACK | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| void | | void | |
| auxlib::log_det(eT& out_val, typename get_pod_type<eT>::result& out_sign, c
onst Base<eT,T1>& X) | | auxlib::log_det(eT& out_val, typename get_pod_type<eT>::result& out_sign, c
onst Base<eT,T1>& X) | |
| | | | |
| skipping to change at line 837 | | skipping to change at line 847 | |
| { | | { | |
| sign *= -1; | | sign *= -1; | |
| } | | } | |
| } | | } | |
| | | | |
| out_val = val; | | out_val = val; | |
| out_sign = T(sign); | | out_sign = T(sign); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
|
| arma_stop("log_det(): use of ATLAS or LAPACK needs to enabled"); | | arma_stop("log_det(): use of ATLAS or LAPACK needs to be enabled"); | |
| | | | |
| out_val = eT(0); | | out_val = eT(0); | |
| out_sign = T(0); | | out_sign = T(0); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! immediate LU decomposition of a matrix using ATLAS or LAPACK | | //! immediate LU decomposition of a matrix using ATLAS or LAPACK | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| | | | |
| skipping to change at line 916 | | skipping to change at line 926 | |
| { | | { | |
| L.at(row,col) = U.at(row,col); | | L.at(row,col) = U.at(row,col); | |
| U.at(row,col) = eT(0); | | U.at(row,col) = eT(0); | |
| } | | } | |
| } | | } | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(U_n_rows); | | arma_ignore(U_n_rows); | |
| arma_ignore(U_n_cols); | | arma_ignore(U_n_cols); | |
|
| arma_stop("lu(): use of ATLAS or LAPACK needs to enabled"); | | arma_stop("lu(): use of ATLAS or LAPACK needs to be enabled"); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| void | | void | |
| auxlib::lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X) | | auxlib::lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| skipping to change at line 1075 | | skipping to change at line 1085 | |
| | | | |
| arma_extra_debug_print("lapack::syev()"); | | arma_extra_debug_print("lapack::syev()"); | |
| lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr(
), work.memptr(), &lwork, &info); | | lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr(
), work.memptr(), &lwork, &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(X); | | arma_ignore(X); | |
|
| arma_stop("eig_sym(): use of LAPACK needs to enabled"); | | arma_stop("eig_sym(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! immediate eigenvalues of a hermitian complex matrix using LAPACK | | //! immediate eigenvalues of a hermitian complex matrix using LAPACK | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X) | | auxlib::eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X) | |
| | | | |
| skipping to change at line 1125 | | skipping to change at line 1135 | |
| | | | |
| arma_extra_debug_print("lapack::heev()"); | | arma_extra_debug_print("lapack::heev()"); | |
| lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(),
work.memptr(), &lwork, rwork.memptr(), &info); | | lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(),
work.memptr(), &lwork, rwork.memptr(), &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(X); | | arma_ignore(X); | |
|
| arma_stop("eig_sym(): use of LAPACK needs to enabled"); | | arma_stop("eig_sym(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! immediate eigenvalues and eigenvectors of a symmetric real matrix using
LAPACK | | //! immediate eigenvalues and eigenvectors of a symmetric real matrix using
LAPACK | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X) | | auxlib::eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X) | |
| | | | |
| skipping to change at line 1175 | | skipping to change at line 1185 | |
| | | | |
| arma_extra_debug_print("lapack::syev()"); | | arma_extra_debug_print("lapack::syev()"); | |
| lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me
mptr(), work.memptr(), &lwork, &info); | | lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me
mptr(), work.memptr(), &lwork, &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(eigvec); | | arma_ignore(eigvec); | |
|
| arma_stop("eig_sym(): use of LAPACK needs to enabled"); | | arma_stop("eig_sym(): use of LAPACK needs to be enabled"); | |
| | | | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! immediate eigenvalues and eigenvectors of a hermitian complex matrix us
ing LAPACK | | //! immediate eigenvalues and eigenvectors of a hermitian complex matrix us
ing LAPACK | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| | | | |
| skipping to change at line 1229 | | skipping to change at line 1239 | |
| arma_extra_debug_print("lapack::heev()"); | | arma_extra_debug_print("lapack::heev()"); | |
| lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt
r(), work.memptr(), &lwork, rwork.memptr(), &info); | | lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt
r(), work.memptr(), &lwork, rwork.memptr(), &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(eigvec); | | arma_ignore(eigvec); | |
| arma_ignore(X); | | arma_ignore(X); | |
|
| arma_stop("eig_sym(): use of LAPACK needs to enabled"); | | arma_stop("eig_sym(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! Eigenvalues and eigenvectors of a general square real matrix using LAPA
CK. | | //! Eigenvalues and eigenvectors of a general square real matrix using LAPA
CK. | |
| //! The argument 'side' specifies which eigenvectors should be calculated | | //! The argument 'side' specifies which eigenvectors should be calculated | |
| //! (see code for mode details). | | //! (see code for mode details). | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| | | | |
| skipping to change at line 1332 | | skipping to change at line 1342 | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(l_eigvec); | | arma_ignore(l_eigvec); | |
| arma_ignore(r_eigvec); | | arma_ignore(r_eigvec); | |
| arma_ignore(X); | | arma_ignore(X); | |
| arma_ignore(side); | | arma_ignore(side); | |
|
| arma_stop("eig_gen(): use of LAPACK needs to enabled"); | | arma_stop("eig_gen(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! Eigenvalues and eigenvectors of a general square complex matrix using L
APACK | | //! Eigenvalues and eigenvectors of a general square complex matrix using L
APACK | |
| //! The argument 'side' specifies which eigenvectors should be calculated | | //! The argument 'side' specifies which eigenvectors should be calculated | |
| //! (see code for mode details). | | //! (see code for mode details). | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| | | | |
| skipping to change at line 1427 | | skipping to change at line 1437 | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(l_eigvec); | | arma_ignore(l_eigvec); | |
| arma_ignore(r_eigvec); | | arma_ignore(r_eigvec); | |
| arma_ignore(X); | | arma_ignore(X); | |
| arma_ignore(side); | | arma_ignore(side); | |
|
| arma_stop("eig_gen(): use of LAPACK needs to enabled"); | | arma_stop("eig_gen(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::chol(Mat<eT>& out, const Base<eT,T1>& X) | | auxlib::chol(Mat<eT>& out, const Base<eT,T1>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 1474 | | skipping to change at line 1484 | |
| { | | { | |
| colptr[row] = eT(0); | | colptr[row] = eT(0); | |
| } | | } | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
|
| arma_stop("chol(): use of LAPACK needs to enabled"); | | arma_stop("chol(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X) | | auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 1575 | | skipping to change at line 1585 | |
| lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr()
, &work_len, &info); | | lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr()
, &work_len, &info); | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(Q); | | arma_ignore(Q); | |
| arma_ignore(R); | | arma_ignore(R); | |
| arma_ignore(X); | | arma_ignore(X); | |
|
| arma_stop("qr(): use of LAPACK needs to enabled"); | | arma_stop("qr(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, u32& X_n_rows, u32& X_n_cols) | | auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, u32& X_n_rows, u32& X_n_cols) | |
| { | | { | |
| | | | |
| skipping to change at line 1667 | | skipping to change at line 1677 | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(S); | | arma_ignore(S); | |
| arma_ignore(X); | | arma_ignore(X); | |
| arma_ignore(X_n_rows); | | arma_ignore(X_n_rows); | |
| arma_ignore(X_n_cols); | | arma_ignore(X_n_cols); | |
|
| arma_stop("svd(): use of LAPACK needs to enabled"); | | arma_stop("svd(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X, u32& X_n_rows, u
32& X_n_cols) | | auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X, u32& X_n_rows, u
32& X_n_cols) | |
| { | | { | |
| | | | |
| skipping to change at line 1764 | | skipping to change at line 1774 | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(S); | | arma_ignore(S); | |
| arma_ignore(X); | | arma_ignore(X); | |
| arma_ignore(X_n_rows); | | arma_ignore(X_n_rows); | |
| arma_ignore(X_n_cols); | | arma_ignore(X_n_cols); | |
| | | | |
|
| arma_stop("svd(): use of LAPACK needs to enabled"); | | arma_stop("svd(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT, typename T1> | | template<typename eT, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::svd(Col<eT>& S, const Base<eT,T1>& X) | | auxlib::svd(Col<eT>& S, const Base<eT,T1>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 1875 | | skipping to change at line 1885 | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(U); | | arma_ignore(U); | |
| arma_ignore(S); | | arma_ignore(S); | |
| arma_ignore(V); | | arma_ignore(V); | |
| arma_ignore(X); | | arma_ignore(X); | |
|
| arma_stop("svd(): use of LAPACK needs to enabled"); | | arma_stop("svd(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V
, const Base< std::complex<T>, T1>& X) | | auxlib::svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V
, const Base< std::complex<T>, T1>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 1969 | | skipping to change at line 1979 | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(U); | | arma_ignore(U); | |
| arma_ignore(S); | | arma_ignore(S); | |
| arma_ignore(V); | | arma_ignore(V); | |
| arma_ignore(X); | | arma_ignore(X); | |
|
| arma_stop("svd(): use of LAPACK needs to enabled"); | | arma_stop("svd(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| } | | } | |
| | | | |
| //! Solve a system of linear equations. | | //! Solve a system of linear equations. | |
| //! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows | | //! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) | | auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, const bool slow) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if(A.is_empty() || B.is_empty()) | | if(A.is_empty() || B.is_empty()) | |
| { | | { | |
| out.reset(); | | out.reset(); | |
| A.reset(); | | A.reset(); | |
| return true; | | return true; | |
| } | | } | |
| else | | else | |
| { | | { | |
| const u32 A_n_rows = A.n_rows; | | const u32 A_n_rows = A.n_rows; | |
| | | | |
| bool status = false; | | bool status = false; | |
| | | | |
|
| if(A_n_rows <= 4) | | if( (A_n_rows <= 4) && (slow == false) ) | |
| { | | { | |
| Mat<eT> A_inv; | | Mat<eT> A_inv; | |
| | | | |
| status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows); | | status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows); | |
| | | | |
| if(status == true) | | if(status == true) | |
| { | | { | |
| out.set_size(A_n_rows, B.n_cols); | | out.set_size(A_n_rows, B.n_cols); | |
| | | | |
| gemm_emul<false,false,false,false>::apply(out, A_inv, B); | | gemm_emul<false,false,false,false>::apply(out, A_inv, B); | |
| | | | |
| skipping to change at line 2033 | | skipping to change at line 2043 | |
| podarray<blas_int> ipiv(A_n_rows); | | podarray<blas_int> ipiv(A_n_rows); | |
| | | | |
| out = B; | | out = B; | |
| | | | |
| lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.me
mptr(), &ldb, &info); | | lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.me
mptr(), &ldb, &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
|
| arma_stop("solve(): use of LAPACK needs to enabled"); | | arma_stop("solve(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| } | | } | |
| | | | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| //! Solve an over-determined system. | | //! Solve an over-determined system. | |
| | | | |
| skipping to change at line 2104 | | skipping to change at line 2114 | |
| arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); | | arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
| arma_ignore(A); | | arma_ignore(A); | |
| arma_ignore(B); | | arma_ignore(B); | |
|
| arma_stop("solve(): use of LAPACK needs to enabled"); | | arma_stop("solve(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! Solve an under-determined system. | | //! Solve an under-determined system. | |
| //! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows | | //! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
| | | | |
| skipping to change at line 2184 | | skipping to change at line 2194 | |
| arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); | | arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
| arma_ignore(A); | | arma_ignore(A); | |
| arma_ignore(B); | | arma_ignore(B); | |
|
| arma_stop("solve(): use of LAPACK needs to enabled"); | | arma_stop("solve(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| // | | // | |
| // solve_tr | | // solve_tr | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
| skipping to change at line 2227 | | skipping to change at line 2237 | |
| lapack::trtrs<eT>(&uplo, &trans, &diag, &n, &nrhs, A.memptr(), &n, out.
memptr(), &n, &info); | | lapack::trtrs<eT>(&uplo, &trans, &diag, &n, &nrhs, A.memptr(), &n, out.
memptr(), &n, &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
| arma_ignore(A); | | arma_ignore(A); | |
| arma_ignore(B); | | arma_ignore(B); | |
| arma_ignore(layout); | | arma_ignore(layout); | |
|
| arma_stop("solve(): use of LAPACK needs to enabled"); | | arma_stop("solve(): use of LAPACK needs to be enabled"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| // | | // | |
| // Schur decomposition | | // Schur decomposition | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
End of changes. 39 change blocks. |
| 51 lines changed or deleted | | 61 lines changed or added | |
|
| fn_solve.hpp | | fn_solve.hpp | |
|
| // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2009-2010 Conrad Sanderson | | // Copyright (C) 2009-2011 Conrad Sanderson | |
| // | | // | |
| // This file is part of the Armadillo C++ library. | | // This file is part of the Armadillo C++ library. | |
| // It is provided without any warranty of fitness | | // It is provided without any warranty of fitness | |
| // for any purpose. You can redistribute this file | | // for any purpose. You can redistribute this file | |
| // and/or modify it under the terms of the GNU | | // and/or modify it under the terms of the GNU | |
| // 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) | |
| | | | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| //! This function will also try to provide approximate solutions | | //! This function will also try to provide approximate solutions | |
| //! to under-determined as well as over-determined systems (non-square A ma
trices). | | //! to under-determined as well as over-determined systems (non-square A ma
trices). | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| const Glue<T1, T2, glue_solve> | | const Glue<T1, T2, glue_solve> | |
| solve | | solve | |
| ( | | ( | |
| const Base<typename T1::elem_type,T1>& A, | | const Base<typename T1::elem_type,T1>& A, | |
| const Base<typename T1::elem_type,T2>& B, | | const Base<typename T1::elem_type,T2>& B, | |
|
| | | const bool slow = false, | |
| const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0 | | const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0 | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
|
| return Glue<T1, T2, glue_solve>(A.get_ref(), B.get_ref()); | | return Glue<T1, T2, glue_solve>(A.get_ref(), B.get_ref(), ((slow == false
) ? 0 : 1) ); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| const Glue<T1, T2, glue_solve_tr> | | const Glue<T1, T2, glue_solve_tr> | |
| solve | | solve | |
| ( | | ( | |
| const Op<T1, op_trimat>& A, | | const Op<T1, op_trimat>& A, | |
| const Base<typename T1::elem_type,T2>& B, | | const Base<typename T1::elem_type,T2>& B, | |
|
| | | const bool slow = false, | |
| const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0 | | const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0 | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| | | arma_ignore(slow); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_u32_a); | | return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_u32_a); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| bool | | bool | |
| solve | | solve | |
| ( | | ( | |
| Mat<typename T1::elem_type>& out, | | Mat<typename T1::elem_type>& out, | |
| const Base<typename T1::elem_type,T1>& A, | | const Base<typename T1::elem_type,T1>& A, | |
| const Base<typename T1::elem_type,T2>& B, | | const Base<typename T1::elem_type,T2>& B, | |
|
| | | const bool slow = false, | |
| const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0 | | const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0 | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
|
| out = solve( A.get_ref(), B.get_ref() ); | | out = solve( A.get_ref(), B.get_ref(), slow ); | |
| | | | |
| return (out.n_elem == 0) ? false : true; | | return (out.n_elem == 0) ? false : true; | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 7 change blocks. |
| 4 lines changed or deleted | | 8 lines changed or added | |
|
| gemv.hpp | | gemv.hpp | |
| | | | |
| skipping to change at line 16 | | skipping to change at line 16 | |
| // for any purpose. You can redistribute this file | | // for any purpose. You can redistribute this file | |
| // and/or modify it under the terms of the GNU | | // and/or modify it under the terms of the GNU | |
| // 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 gemv | | //! \addtogroup gemv | |
| //! @{ | | //! @{ | |
| | | | |
|
| //! for tiny square matrices with n_rows <= 4 | | //! for tiny square matrices, size <= 4x4 | |
| template<const bool do_trans_A=false, const bool use_alpha=false, const boo
l use_beta=false> | | template<const bool do_trans_A=false, const bool use_alpha=false, const boo
l use_beta=false> | |
|
| class gemv_emul_tiny | | class gemv_emul_tinysq | |
| { | | { | |
| public: | | public: | |
| | | | |
| template<const u32 row, const u32 col> | | template<const u32 row, const u32 col> | |
| struct pos | | struct pos | |
| { | | { | |
| static const u32 n2 = (do_trans_A == false) ? (row + col*2) : (col + ro
w*2); | | static const u32 n2 = (do_trans_A == false) ? (row + col*2) : (col + ro
w*2); | |
| static const u32 n3 = (do_trans_A == false) ? (row + col*3) : (col + ro
w*3); | | static const u32 n3 = (do_trans_A == false) ? (row + col*3) : (col + ro
w*3); | |
| static const u32 n4 = (do_trans_A == false) ? (row + col*4) : (col + ro
w*4); | | static const u32 n4 = (do_trans_A == false) ? (row + col*4) : (col + ro
w*4); | |
| }; | | }; | |
| | | | |
| skipping to change at line 148 | | skipping to change at line 148 | |
| void | | void | |
| apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0) ) | | apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0) ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 A_n_rows = A.n_rows; | | const u32 A_n_rows = A.n_rows; | |
| const u32 A_n_cols = A.n_cols; | | const u32 A_n_cols = A.n_cols; | |
| | | | |
| if(do_trans_A == false) | | if(do_trans_A == false) | |
| { | | { | |
|
| | | if(A_n_rows == 1) | |
| | | { | |
| | | const eT acc = op_dot::direct_dot_arma(A_n_cols, A.mem, x); | |
| | | | |
| | | if( (use_alpha == false) && (use_beta == false) ) | |
| | | { | |
| | | y[0] = acc; | |
| | | } | |
| | | else | |
| | | if( (use_alpha == true) && (use_beta == false) ) | |
| | | { | |
| | | y[0] = alpha * acc; | |
| | | } | |
| | | else | |
| | | if( (use_alpha == false) && (use_beta == true) ) | |
| | | { | |
| | | y[0] = acc + beta*y[0]; | |
| | | } | |
| | | else | |
| | | if( (use_alpha == true) && (use_beta == true) ) | |
| | | { | |
| | | y[0] = alpha*acc + beta*y[0]; | |
| | | } | |
| | | } | |
| | | else | |
| for(u32 row=0; row < A_n_rows; ++row) | | for(u32 row=0; row < A_n_rows; ++row) | |
| { | | { | |
| eT acc = eT(0); | | eT acc = eT(0); | |
| | | | |
| for(u32 i=0; i < A_n_cols; ++i) | | for(u32 i=0; i < A_n_cols; ++i) | |
| { | | { | |
| acc += A.at(row,i) * x[i]; | | acc += A.at(row,i) * x[i]; | |
| } | | } | |
| | | | |
| if( (use_alpha == false) && (use_beta == false) ) | | if( (use_alpha == false) && (use_beta == false) ) | |
| | | | |
| skipping to change at line 236 | | skipping to change at line 261 | |
| template<typename eT> | | template<typename eT> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| static | | static | |
| void | | void | |
| apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 ) | | apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
|
| if( A.n_rows > 4 ) | | const u32 A_n_rows = A.n_rows; | |
| | | const u32 A_n_cols = A.n_cols; | |
| | | | |
| | | if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | |
| { | | { | |
|
| gemv_emul_large<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alph
a, beta); | | gemv_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alp
ha, beta); | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| gemv_emul_tiny<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alpha
, beta); | | gemv_emul_large<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alph
a, beta); | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| static | | static | |
| void | | void | |
| apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0), const typename arma_cx_only<eT>::result* junk = 0 ) | | apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0), const typename arma_cx_only<eT>::result* junk = 0 ) | |
| { | | { | |
| | | | |
| skipping to change at line 264 | | skipping to change at line 292 | |
| | | | |
| Mat<eT> tmp_A; | | Mat<eT> tmp_A; | |
| | | | |
| if(do_trans_A) | | if(do_trans_A) | |
| { | | { | |
| op_htrans::apply_noalias(tmp_A, A); | | op_htrans::apply_noalias(tmp_A, A); | |
| } | | } | |
| | | | |
| const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A; | | const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A; | |
| | | | |
|
| if( AA.n_rows > 4 ) | | const u32 AA_n_rows = AA.n_rows; | |
| | | const u32 AA_n_cols = AA.n_cols; | |
| | | | |
| | | if( (AA_n_rows <= 4) && (AA_n_rows == AA_n_cols) ) | |
| { | | { | |
|
| gemv_emul_large<false, use_alpha, use_beta>::apply(y, AA, x, alpha, b
eta); | | gemv_emul_tinysq<false, use_alpha, use_beta>::apply(y, AA, x, alpha,
beta); | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| gemv_emul_tiny<false, use_alpha, use_beta>::apply(y, AA, x, alpha, be
ta); | | gemv_emul_large<false, use_alpha, use_beta>::apply(y, AA, x, alpha, b
eta); | |
| } | | } | |
| } | | } | |
| }; | | }; | |
| | | | |
| //! \brief | | //! \brief | |
| //! Wrapper for ATLAS/BLAS gemv function, using template arguments to contr
ol the arguments passed to gemv. | | //! Wrapper for ATLAS/BLAS gemv function, using template arguments to contr
ol the arguments passed to gemv. | |
| //! 'y' is assumed to have been set to the correct size (i.e. taking into a
ccount the transpose) | | //! 'y' is assumed to have been set to the correct size (i.e. taking into a
ccount the transpose) | |
| | | | |
| template<const bool do_trans_A=false, const bool use_alpha=false, const boo
l use_beta=false> | | template<const bool do_trans_A=false, const bool use_alpha=false, const boo
l use_beta=false> | |
| class gemv | | class gemv | |
| | | | |
End of changes. 9 change blocks. |
| 8 lines changed or deleted | | 39 lines changed or added | |
|