| Col_bones.hpp | | Col_bones.hpp | |
| | | | |
| skipping to change at line 118 | | skipping to change at line 118 | |
| | | | |
| static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc
); | | static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc
); | |
| | | | |
| arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; | | arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; | |
| | | | |
| arma_inline void mem_setup(); | | arma_inline void mem_setup(); | |
| arma_inline void change_to_row(); | | arma_inline void change_to_row(); | |
| | | | |
| public: | | public: | |
| | | | |
|
| | | typedef fixed<fixed_n_elem> Col_fixed_type; | |
| | | | |
| | | typedef eT elem_type; | |
| | | typedef typename get_pod_type<eT>::result pod_type; | |
| | | | |
| | | static const bool is_col = true; | |
| | | static const bool is_row = false; | |
| | | | |
| static const uword n_rows = fixed_n_elem; | | static const uword n_rows = fixed_n_elem; | |
| static const uword n_cols = 1; | | static const uword n_cols = 1; | |
| static const uword n_elem = fixed_n_elem; | | static const uword n_elem = fixed_n_elem; | |
| | | | |
| arma_inline fixed(); | | arma_inline fixed(); | |
| arma_inline fixed(const fixed<fixed_n_elem>& X); | | arma_inline fixed(const fixed<fixed_n_elem>& X); | |
| inline fixed(const subview_cube<eT>& X); | | inline fixed(const subview_cube<eT>& X); | |
| | | | |
| template<typename T1> inline fixed(const Base<eT,T1>& A); | | template<typename T1> inline fixed(const Base<eT,T1>& A); | |
| template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>
& A, const Base<pod_type,T2>& B); | | template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>
& A, const Base<pod_type,T2>& B); | |
| | | | |
| skipping to change at line 162 | | skipping to change at line 170 | |
| arma_inline arma_warn_unused eT& at (const uword i); | | arma_inline arma_warn_unused eT& at (const uword i); | |
| arma_inline arma_warn_unused eT at (const uword i) const; | | arma_inline arma_warn_unused eT at (const uword i) const; | |
| arma_inline arma_warn_unused eT& operator() (const uword i); | | arma_inline arma_warn_unused eT& operator() (const uword i); | |
| arma_inline arma_warn_unused eT operator() (const uword i) const; | | arma_inline arma_warn_unused eT operator() (const uword i) const; | |
| | | | |
| arma_inline arma_warn_unused eT& at (const uword in_row, const
uword in_col); | | arma_inline arma_warn_unused eT& at (const uword in_row, const
uword in_col); | |
| arma_inline arma_warn_unused eT at (const uword in_row, const
uword in_col) const; | | arma_inline arma_warn_unused eT at (const uword in_row, const
uword in_col) const; | |
| arma_inline arma_warn_unused eT& operator() (const uword in_row, const
uword in_col); | | arma_inline arma_warn_unused eT& operator() (const uword in_row, const
uword in_col); | |
| arma_inline arma_warn_unused eT operator() (const uword in_row, const
uword in_col) const; | | arma_inline arma_warn_unused eT operator() (const uword in_row, const
uword in_col) const; | |
| | | | |
|
| | | arma_inline arma_warn_unused eT* memptr(); | |
| | | arma_inline arma_warn_unused const eT* memptr() const; | |
| | | | |
| arma_hot inline const Col<eT>& fill(const eT val); | | arma_hot inline const Col<eT>& fill(const eT val); | |
| arma_hot inline const Col<eT>& zeros(); | | arma_hot inline const Col<eT>& zeros(); | |
| arma_hot inline const Col<eT>& ones(); | | arma_hot inline const Col<eT>& ones(); | |
| }; | | }; | |
| | | | |
| #ifdef ARMA_EXTRA_COL_PROTO | | #ifdef ARMA_EXTRA_COL_PROTO | |
| #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO) | | #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO) | |
| #endif | | #endif | |
| | | | |
| }; | | }; | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 11 lines changed or added | |
|
| Proxy.hpp | | Proxy.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 Proxy | | //! \addtogroup Proxy | |
| //! @{ | | //! @{ | |
| | | | |
|
| | | // ea_type is the "element accessor" type, | |
| | | // which can provide access to elements via operator[] | |
| | | | |
| template<typename T1> | | template<typename T1> | |
|
| class Proxy | | struct Proxy_Mat_fixed | |
| { | | { | |
|
| public: | | typedef typename T1::elem_type elem_type; | |
| inline Proxy(const T1&) | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | typedef T1 stored_type; | |
| | | typedef const elem_type* ea_type; | |
| | | | |
| | | static const bool prefer_at_accessor = false; | |
| | | static const bool has_subview = false; | |
| | | | |
| | | static const bool is_row = T1::is_row; | |
| | | static const bool is_col = T1::is_col; | |
| | | | |
| | | arma_aligned const T1& Q; | |
| | | | |
| | | inline explicit Proxy_Mat_fixed(const T1& A) | |
| | | : Q(A) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_inline static uword get_n_rows() { return T1::n_rows; } | |
| | | arma_inline static uword get_n_cols() { return T1::n_cols; } | |
| | | arma_inline static uword get_n_elem() { return T1::n_elem; } | |
| | | | |
| | | arma_inline elem_type operator[] (const uword i) const | |
| | | { return Q[i]; } | |
| | | arma_inline elem_type at (const uword row, const uword col) const | |
| | | { return Q.at(row, col); } | |
| | | | |
| | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| | | | |
| | | template<typename eT2> | |
| | | arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) | |
| | | == void_ptr(&X)); } | |
| | | }; | |
| | | | |
| | | template<typename T1> | |
| | | struct Proxy_extra_empty | |
| | | { | |
| | | inline Proxy_extra_empty(const T1&) | |
| { | | { | |
| arma_type_check(( is_arma_type<T1>::value == false )); | | arma_type_check(( is_arma_type<T1>::value == false )); | |
| } | | } | |
| }; | | }; | |
| | | | |
|
| // ea_type is the "element accessor" type, | | template<typename T1, bool condition> | |
| // which can provide access to elements via operator[] | | struct Proxy_extra {}; | |
| | | | |
| | | template<typename T1> | |
| | | struct Proxy_extra<T1, true> { typedef Proxy_Mat_fixed<T1> result; }; | |
| | | | |
| | | template<typename T1> | |
| | | struct Proxy_extra<T1, false> { typedef Proxy_extra_empty<T1> result; }; | |
| | | | |
| | | template<typename T1> | |
| | | class Proxy : public Proxy_extra<T1, is_Mat_fixed<T1>::value >::result | |
| | | { | |
| | | public: | |
| | | inline Proxy(const T1& A) | |
| | | : Proxy_extra<T1, is_Mat_fixed<T1>::value >::result(A) | |
| | | { | |
| | | } | |
| | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class Proxy< Mat<eT> > | | class Proxy< Mat<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef eT elem_type; | | typedef eT elem_type; | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| typedef Mat<eT> stored_type; | | typedef Mat<eT> stored_type; | |
| typedef const eT* ea_type; | | typedef const eT* ea_type; | |
| | | | |
| skipping to change at line 140 | | skipping to change at line 193 | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const uword i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const uword, const uword col) const { r
eturn Q[col]; } | | arma_inline elem_type at (const uword, const uword col) const { r
eturn Q[col]; } | |
| | | | |
| arma_inline ea_type get_ea() const { return Q.memptr(); } | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q)
== void_ptr(&X)); } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q)
== void_ptr(&X)); } | |
| }; | | }; | |
| | | | |
|
| // // TODO: how to allow general Mat<eT> instead of specific Mat<double> ? | | | |
| // template<uword fixed_n_rows, uword fixed_n_cols> | | | |
| // class Proxy< Mat<double>::fixed<fixed_n_rows,fixed_n_cols> > | | | |
| // { | | | |
| // public: | | | |
| // | | | |
| // typedef double eT; | | | |
| // | | | |
| // typedef eT elem_type; | | | |
| // typedef typename get_pod_type<elem_type>::result pod_type; | | | |
| // typedef Mat<eT>::fixed<fixed_n_rows,fixed_n_cols> stored_type; | | | |
| // typedef const eT* ea_type; | | | |
| // | | | |
| // static const bool prefer_at_accessor = false; | | | |
| // static const bool has_subview = false; | | | |
| // | | | |
| // static const bool is_row = false; | | | |
| // static const bool is_col = false; | | | |
| // | | | |
| // arma_aligned const Mat<eT>::fixed<fixed_n_rows,fixed_n_cols>& Q; | | | |
| // | | | |
| // inline explicit Proxy(const Mat<eT>::fixed<fixed_n_rows,fixed_n_cols>& | | | |
| A) | | | |
| // : Q(A) | | | |
| // { | | | |
| // arma_extra_debug_sigprint(); | | | |
| // } | | | |
| // | | | |
| // arma_inline uword get_n_rows() const { return fixed_n_rows; | | | |
| } | | | |
| // arma_inline uword get_n_cols() const { return fixed_n_cols; | | | |
| } | | | |
| // arma_inline uword get_n_elem() const { return fixed_n_rows*fixed_n_col | | | |
| s; } | | | |
| // | | | |
| // arma_inline elem_type operator[] (const uword i) co | | | |
| nst { return Q[i]; } | | | |
| // arma_inline elem_type at (const uword row, const uword col) co | | | |
| nst { return Q.at(row, col); } | | | |
| // | | | |
| // arma_inline ea_type get_ea() const { return Q.memptr | | | |
| (); } | | | |
| // arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == & | | | |
| X); } | | | |
| // }; | | | |
| | | | |
| template<typename T1, typename gen_type> | | template<typename T1, typename gen_type> | |
| class Proxy< Gen<T1, gen_type > > | | class Proxy< Gen<T1, gen_type > > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef typename T1::elem_type elem_type; | | typedef typename T1::elem_type elem_type; | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| typedef Gen<T1, gen_type> stored_type; | | typedef Gen<T1, gen_type> stored_type; | |
| typedef const Gen<T1, gen_type>& ea_type; | | typedef const Gen<T1, gen_type>& ea_type; | |
| | | | |
| | | | |
End of changes. 5 change blocks. |
| 51 lines changed or deleted | | 61 lines changed or added | |
|
| auxlib_meat.hpp | | auxlib_meat.hpp | |
| | | | |
| skipping to change at line 1140 | | skipping to change at line 1140 | |
| | | | |
| char jobz = 'N'; | | char jobz = 'N'; | |
| char uplo = 'U'; | | char uplo = 'U'; | |
| | | | |
| blas_int n_rows = A.n_rows; | | blas_int n_rows = A.n_rows; | |
| blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1) + 2; // +2 for p
aranoia: some versions of Lapack might be trashing memory | | blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1) + 2; // +2 for p
aranoia: some versions of Lapack might be trashing memory | |
| | | | |
| eigval.set_size( static_cast<uword>(n_rows) ); | | eigval.set_size( static_cast<uword>(n_rows) ); | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| | | | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| 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); | |
| | | | |
| skipping to change at line 1191 | | skipping to change at line 1191 | |
| blas_int n_rows = A.n_rows; | | blas_int n_rows = A.n_rows; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1) + 2; // +2 for
paranoia: some versions of Lapack might be trashing memory | | blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1) + 2; // +2 for
paranoia: some versions of Lapack might be trashing memory | |
| // TODO: automatically find best size of lwork | | // TODO: automatically find best size of lwork | |
| | | | |
| eigval.set_size( static_cast<uword>(n_rows) ); | | eigval.set_size( static_cast<uword>(n_rows) ); | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
- 2)) ); | | podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
- 2)) ); | |
| | | | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| 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); | |
| | | | |
| skipping to change at line 1241 | | skipping to change at line 1241 | |
| | | | |
| char jobz = 'V'; | | char jobz = 'V'; | |
| char uplo = 'U'; | | char uplo = 'U'; | |
| | | | |
| blas_int n_rows = eigvec.n_rows; | | blas_int n_rows = eigvec.n_rows; | |
| blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1) + 2; // +2 for p
aranoia: some versions of Lapack might be trashing memory | | blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1) + 2; // +2 for p
aranoia: some versions of Lapack might be trashing memory | |
| | | | |
| eigval.set_size( static_cast<uword>(n_rows) ); | | eigval.set_size( static_cast<uword>(n_rows) ); | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| | | | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| 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); | |
| | | | |
| skipping to change at line 1297 | | skipping to change at line 1297 | |
| blas_int n_rows = eigvec.n_rows; | | blas_int n_rows = eigvec.n_rows; | |
| blas_int lda = eigvec.n_rows; | | blas_int lda = eigvec.n_rows; | |
| blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1) + 2; // +2 for
paranoia: some versions of Lapack might be trashing memory | | blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1) + 2; // +2 for
paranoia: some versions of Lapack might be trashing memory | |
| // TODO: automatically find best size of lwork | | // TODO: automatically find best size of lwork | |
| | | | |
| eigval.set_size( static_cast<uword>(n_rows) ); | | eigval.set_size( static_cast<uword>(n_rows) ); | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
- 2)) ); | | podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
- 2)) ); | |
| | | | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| 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); | |
| | | | |
| skipping to change at line 1393 | | skipping to change at line 1393 | |
| l_eigvec.set_size(A_n_rows, A_n_rows); | | l_eigvec.set_size(A_n_rows, A_n_rows); | |
| r_eigvec.set_size(A_n_rows, A_n_rows); | | r_eigvec.set_size(A_n_rows, A_n_rows); | |
| | | | |
| podarray<T> work( static_cast<uword>(lwork) ); | | podarray<T> work( static_cast<uword>(lwork) ); | |
| podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows)
) ); | | podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows)
) ); | |
| | | | |
| podarray<T> wr(A_n_rows); | | podarray<T> wr(A_n_rows); | |
| podarray<T> wi(A_n_rows); | | podarray<T> wi(A_n_rows); | |
| | | | |
| Mat<T> A_copy = A; | | Mat<T> A_copy = A; | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| arma_extra_debug_print("lapack::geev()"); | | arma_extra_debug_print("lapack::geev()"); | |
| lapack::geev(&jobvl, &jobvr, &n_rows, A_copy.memptr(), &lda, wr.memptr(
), wi.memptr(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, wor
k.memptr(), &lwork, &info); | | lapack::geev(&jobvl, &jobvr, &n_rows, A_copy.memptr(), &lda, wr.memptr(
), wi.memptr(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, wor
k.memptr(), &lwork, &info); | |
| | | | |
| eigval.set_size(A_n_rows); | | eigval.set_size(A_n_rows); | |
| for(uword i=0; i<A_n_rows; ++i) | | for(uword i=0; i<A_n_rows; ++i) | |
| { | | { | |
| eigval[i] = std::complex<T>(wr[i], wi[i]); | | eigval[i] = std::complex<T>(wr[i], wi[i]); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 1495 | | skipping to change at line 1495 | |
| blas_int lwork = (std::max)(blas_int(1), 4*n_rows) + 2; // +2 for par
anoia: some versions of Lapack might be trashing memory | | blas_int lwork = (std::max)(blas_int(1), 4*n_rows) + 2; // +2 for par
anoia: some versions of Lapack might be trashing memory | |
| // TODO: automatically find best size of lwork | | // TODO: automatically find best size of lwork | |
| | | | |
| eigval.set_size(A_n_rows); | | eigval.set_size(A_n_rows); | |
| l_eigvec.set_size(A_n_rows, A_n_rows); | | l_eigvec.set_size(A_n_rows, A_n_rows); | |
| r_eigvec.set_size(A_n_rows, A_n_rows); | | r_eigvec.set_size(A_n_rows, A_n_rows); | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
)) ); // was 2,3 | | podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
)) ); // was 2,3 | |
| | | | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| arma_extra_debug_print("lapack::cx_geev()"); | | arma_extra_debug_print("lapack::cx_geev()"); | |
| lapack::cx_geev(&jobvl, &jobvr, &n_rows, A.memptr(), &lda, eigval.mempt
r(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, work.memptr(),
&lwork, rwork.memptr(), &info); | | lapack::cx_geev(&jobvl, &jobvr, &n_rows, A.memptr(), &lda, eigval.mempt
r(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, work.memptr(),
&lwork, rwork.memptr(), &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(eigval); | | arma_ignore(eigval); | |
| arma_ignore(l_eigvec); | | arma_ignore(l_eigvec); | |
| | | | |
| skipping to change at line 1589 | | skipping to change at line 1589 | |
| { | | { | |
| Q.eye(R_n_rows, R_n_rows); | | Q.eye(R_n_rows, R_n_rows); | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| blas_int m = static_cast<blas_int>(R_n_rows); | | blas_int m = static_cast<blas_int>(R_n_rows); | |
| blas_int n = static_cast<blas_int>(R_n_cols); | | blas_int n = static_cast<blas_int>(R_n_cols); | |
| blas_int work_len = (std::max)(blas_int(1),n); | | blas_int work_len = (std::max)(blas_int(1),n); | |
| blas_int work_len_tmp; | | blas_int work_len_tmp; | |
| blas_int k = (std::min)(m,n); | | blas_int k = (std::min)(m,n); | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| podarray<eT> tau( static_cast<uword>(k) ); | | podarray<eT> tau( static_cast<uword>(k) ); | |
| podarray<eT> work( static_cast<uword>(work_len) ); | | podarray<eT> work( static_cast<uword>(work_len) ); | |
| | | | |
| // query for the optimum value of work_len | | // query for the optimum value of work_len | |
| work_len_tmp = -1; | | work_len_tmp = -1; | |
| lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor
k_len_tmp, &info); | | lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor
k_len_tmp, &info); | |
| | | | |
| if(info == 0) | | if(info == 0) | |
| { | | { | |
| | | | |
| skipping to change at line 1696 | | skipping to change at line 1696 | |
| | | | |
| char jobu = 'N'; | | char jobu = 'N'; | |
| char jobvt = 'N'; | | char jobvt = 'N'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldu = U.n_rows; | | blas_int ldu = U.n_rows; | |
| blas_int ldvt = V.n_rows; | | blas_int ldvt = V.n_rows; | |
| blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)
(m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); | | blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)
(m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| S.set_size( static_cast<uword>((std::min)(m, n)) ); | | S.set_size( static_cast<uword>((std::min)(m, n)) ); | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| blas_int lwork_tmp = -1; | | blas_int lwork_tmp = -1; | |
| | | | |
| lapack::gesvd<eT> | | lapack::gesvd<eT> | |
| ( | | ( | |
| | | | |
| skipping to change at line 1788 | | skipping to change at line 1788 | |
| | | | |
| char jobu = 'N'; | | char jobu = 'N'; | |
| char jobvt = 'N'; | | char jobvt = 'N'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldu = U.n_rows; | | blas_int ldu = U.n_rows; | |
| blas_int ldvt = V.n_rows; | | blas_int ldvt = V.n_rows; | |
| blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m
ax)(m,n) ); | | blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m
ax)(m,n) ); | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| S.set_size( static_cast<uword>((std::min)(m,n)) ); | | S.set_size( static_cast<uword>((std::min)(m,n)) ); | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); | | podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| blas_int lwork_tmp = -1; | | blas_int lwork_tmp = -1; | |
| | | | |
| lapack::cx_gesvd<T> | | lapack::cx_gesvd<T> | |
| | | | |
| skipping to change at line 1902 | | skipping to change at line 1902 | |
| | | | |
| char jobu = 'A'; | | char jobu = 'A'; | |
| char jobvt = 'A'; | | char jobvt = 'A'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldu = U.n_rows; | | blas_int ldu = U.n_rows; | |
| blas_int ldvt = V.n_rows; | | blas_int ldvt = V.n_rows; | |
| blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)
(m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); | | blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)
(m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| S.set_size( static_cast<uword>((std::min)(m,n)) ); | | S.set_size( static_cast<uword>((std::min)(m,n)) ); | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| blas_int lwork_tmp = -1; | | blas_int lwork_tmp = -1; | |
| | | | |
| lapack::gesvd<eT> | | lapack::gesvd<eT> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| | | | |
| skipping to change at line 1993 | | skipping to change at line 1993 | |
| | | | |
| char jobu = 'A'; | | char jobu = 'A'; | |
| char jobvt = 'A'; | | char jobvt = 'A'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldu = U.n_rows; | | blas_int ldu = U.n_rows; | |
| blas_int ldvt = V.n_rows; | | blas_int ldvt = V.n_rows; | |
| blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m
ax)(m,n) ); | | blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m
ax)(m,n) ); | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| S.set_size( static_cast<uword>((std::min)(m,n)) ); | | S.set_size( static_cast<uword>((std::min)(m,n)) ); | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); | | podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| blas_int lwork_tmp = -1; | | blas_int lwork_tmp = -1; | |
| lapack::cx_gesvd<T> | | lapack::cx_gesvd<T> | |
| ( | | ( | |
| | | | |
| skipping to change at line 2384 | | skipping to change at line 2384 | |
| int info = atlas::clapack_gesv<eT>(atlas::CblasColMajor, A_n_rows,
B.n_cols, A.memptr(), A_n_rows, ipiv.memptr(), out.memptr(), A_n_rows); | | int info = atlas::clapack_gesv<eT>(atlas::CblasColMajor, A_n_rows,
B.n_cols, A.memptr(), A_n_rows, ipiv.memptr(), out.memptr(), A_n_rows); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #elif defined(ARMA_USE_LAPACK) | | #elif defined(ARMA_USE_LAPACK) | |
| { | | { | |
| blas_int n = A_n_rows; // assuming A is square | | blas_int n = A_n_rows; // assuming A is square | |
| blas_int lda = A_n_rows; | | blas_int lda = A_n_rows; | |
| blas_int ldb = A_n_rows; | | blas_int ldb = A_n_rows; | |
| blas_int nrhs = B.n_cols; | | blas_int nrhs = B.n_cols; | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| out = B; | | out = B; | |
| | | | |
| podarray<blas_int> ipiv(A_n_rows + 2); // +2 for paranoia: some ve
rsions of Lapack might be trashing memory | | podarray<blas_int> ipiv(A_n_rows + 2); // +2 for paranoia: some ve
rsions of Lapack might be trashing memory | |
| | | | |
| 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 | |
| | | | |
| skipping to change at line 2431 | | skipping to change at line 2431 | |
| } | | } | |
| | | | |
| char trans = 'N'; | | char trans = 'N'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldb = A.n_rows; | | blas_int ldb = A.n_rows; | |
| blas_int nrhs = B.n_cols; | | blas_int nrhs = B.n_cols; | |
| blas_int lwork = n + (std::max)(n, nrhs) + 2; // +2 for paranoia: som
e versions of Lapack might be trashing memory | | blas_int lwork = n + (std::max)(n, nrhs) + 2; // +2 for paranoia: som
e versions of Lapack might be trashing memory | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| Mat<eT> tmp = B; | | Mat<eT> tmp = B; | |
| | | | |
| podarray<eT> work( static_cast<uword>(lwork) ); | | podarray<eT> work( static_cast<uword>(lwork) ); | |
| | | | |
| arma_extra_debug_print("lapack::gels()"); | | arma_extra_debug_print("lapack::gels()"); | |
| | | | |
| // NOTE: the dgels() function in the lapack library supplied by ATLAS 3
.6 seems to have problems | | // NOTE: the dgels() function in the lapack library supplied by ATLAS 3
.6 seems to have problems | |
| | | | |
| lapack::gels<eT> | | lapack::gels<eT> | |
| | | | |
| skipping to change at line 2497 | | skipping to change at line 2497 | |
| } | | } | |
| | | | |
| char trans = 'N'; | | char trans = 'N'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldb = A.n_cols; | | blas_int ldb = A.n_cols; | |
| blas_int nrhs = B.n_cols; | | blas_int nrhs = B.n_cols; | |
| blas_int lwork = m + (std::max)(m,nrhs) + 2; // +2 for paranoia: some
versions of Lapack might be trashing memory | | blas_int lwork = m + (std::max)(m,nrhs) + 2; // +2 for paranoia: some
versions of Lapack might be trashing memory | |
|
| blas_int info; | | blas_int info = 0; | |
| | | | |
| Mat<eT> tmp; | | Mat<eT> tmp; | |
| tmp.zeros(A.n_cols, B.n_cols); | | tmp.zeros(A.n_cols, B.n_cols); | |
| | | | |
| for(uword col=0; col<B.n_cols; ++col) | | for(uword col=0; col<B.n_cols; ++col) | |
| { | | { | |
| eT* tmp_colmem = tmp.colptr(col); | | eT* tmp_colmem = tmp.colptr(col); | |
| | | | |
| arrayops::copy( tmp_colmem, B.colptr(col), B.n_rows ); | | arrayops::copy( tmp_colmem, B.colptr(col), B.n_rows ); | |
| | | | |
| | | | |
End of changes. 14 change blocks. |
| 14 lines changed or deleted | | 14 lines changed or added | |
|
| traits.hpp | | traits.hpp | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct get_pod_type | | struct get_pod_type | |
| { typedef T1 result; }; | | { typedef T1 result; }; | |
| | | | |
| template<typename T2> | | template<typename T2> | |
| struct get_pod_type< std::complex<T2> > | | struct get_pod_type< std::complex<T2> > | |
| { typedef T2 result; }; | | { typedef T2 result; }; | |
| | | | |
| template<typename T> | | template<typename T> | |
|
| | | struct is_Mat_fixed_only | |
| | | { | |
| | | typedef char yes[1]; | |
| | | typedef char no[2]; | |
| | | | |
| | | template<typename X> static yes& check(typename X::Mat_fixed_type*); | |
| | | template<typename> static no& check(...); | |
| | | | |
| | | static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) ); | |
| | | }; | |
| | | | |
| | | template<typename T> | |
| | | struct is_Row_fixed_only | |
| | | { | |
| | | typedef char yes[1]; | |
| | | typedef char no[2]; | |
| | | | |
| | | template<typename X> static yes& check(typename X::Row_fixed_type*); | |
| | | template<typename> static no& check(...); | |
| | | | |
| | | static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) ); | |
| | | }; | |
| | | | |
| | | template<typename T> | |
| | | struct is_Col_fixed_only | |
| | | { | |
| | | typedef char yes[1]; | |
| | | typedef char no[2]; | |
| | | | |
| | | template<typename X> static yes& check(typename X::Col_fixed_type*); | |
| | | template<typename> static no& check(...); | |
| | | | |
| | | static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) ); | |
| | | }; | |
| | | | |
| | | template<typename T> | |
| | | struct is_Mat_fixed | |
| | | { static const bool value = ( is_Mat_fixed_only<T>::value || is_Row_fixed | |
| | | _only<T>::value || is_Col_fixed_only<T>::value ); }; | |
| | | | |
| | | template<typename T> | |
| struct is_Mat_only | | struct is_Mat_only | |
|
| { static const bool value = false; }; | | { static const bool value = is_Mat_fixed_only<T>::value; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Mat_only< Mat<eT> > | | struct is_Mat_only< Mat<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Mat_only< const Mat<eT> > | | struct is_Mat_only< const Mat<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename T> | | template<typename T> | |
| struct is_Mat | | struct is_Mat | |
|
| { static const bool value = false; }; | | { static const bool value = ( is_Mat_fixed_only<T>::value || is_Row_fixed
_only<T>::value || is_Col_fixed_only<T>::value ); }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Mat< Mat<eT> > | | struct is_Mat< Mat<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Mat< const Mat<eT> > | | struct is_Mat< const Mat<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| | | | |
| skipping to change at line 66 | | skipping to change at line 106 | |
| template<typename eT> | | template<typename eT> | |
| struct is_Mat< Col<eT> > | | struct is_Mat< Col<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Mat< const Col<eT> > | | struct is_Mat< const Col<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename T> | | template<typename T> | |
| struct is_Row | | struct is_Row | |
|
| { static const bool value = false; }; | | { static const bool value = is_Row_fixed_only<T>::value; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Row< Row<eT> > | | struct is_Row< Row<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Row< const Row<eT> > | | struct is_Row< const Row<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename T> | | template<typename T> | |
| struct is_Col | | struct is_Col | |
|
| { static const bool value = false; }; | | { static const bool value = is_Col_fixed_only<T>::value; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Col< Col<eT> > | | struct is_Col< Col<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_Col< const Col<eT> > | | struct is_Col< const Col<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename T> | | template<typename T> | |
| | | | |
| skipping to change at line 420 | | skipping to change at line 460 | |
| template<typename out_eT, typename T1> | | template<typename out_eT, typename T1> | |
| struct is_op_rel< mtOp<out_eT, T1, op_rel_noteq> > | | struct is_op_rel< mtOp<out_eT, T1, op_rel_noteq> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| // | | // | |
| // | | // | |
| // | | // | |
| | | | |
| template<typename T> | | template<typename T> | |
| struct is_basevec | | struct is_basevec | |
|
| { static const bool value = false; }; | | { static const bool value = ( is_Row_fixed_only<T>::value || is_Col_fixed
_only<T>::value ); }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_basevec< Row<eT> > | | struct is_basevec< Row<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct is_basevec< const Row<eT> > | | struct is_basevec< const Row<eT> > | |
| { static const bool value = true; }; | | { static const bool value = true; }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| | | | |
End of changes. 6 change blocks. |
| 5 lines changed or deleted | | 46 lines changed or added | |
|