| Mat_bones.hpp | | Mat_bones.hpp | |
| | | | |
| skipping to change at line 108 | | skipping to change at line 108 | |
| inline const Mat& operator+=(const subview<eT>& X); | | inline const Mat& operator+=(const subview<eT>& X); | |
| inline const Mat& operator-=(const subview<eT>& X); | | inline const Mat& operator-=(const subview<eT>& X); | |
| inline const Mat& operator*=(const subview<eT>& X); | | inline const Mat& operator*=(const subview<eT>& X); | |
| inline const Mat& operator%=(const subview<eT>& X); | | inline const Mat& operator%=(const subview<eT>& X); | |
| inline const Mat& operator/=(const subview<eT>& X); | | inline const Mat& operator/=(const subview<eT>& X); | |
| | | | |
| inline Mat(const subview_row_strans<eT>& X); // subview_row_strans can o
nly be generated by the Proxy class | | inline Mat(const subview_row_strans<eT>& X); // subview_row_strans can o
nly be generated by the Proxy class | |
| inline Mat(const subview_row_htrans<eT>& X); // subview_row_htrans can o
nly be generated by the Proxy class | | inline Mat(const subview_row_htrans<eT>& X); // subview_row_htrans can o
nly be generated by the Proxy class | |
| inline Mat(const xvec_htrans<eT>& X); // xvec_htrans can o
nly be generated by the Proxy class | | inline Mat(const xvec_htrans<eT>& X); // xvec_htrans can o
nly be generated by the Proxy class | |
| | | | |
|
| //inline explicit Mat(const subview_cube<eT>& X); | | template<bool do_conj> | |
| | | inline Mat(const xtrans_mat<eT,do_conj>& X); // xtrans_mat can on | |
| | | ly be generated by the Proxy class | |
| | | | |
| inline Mat(const subview_cube<eT>& X); | | inline Mat(const subview_cube<eT>& X); | |
| inline const Mat& operator=(const subview_cube<eT>& X); | | inline const Mat& operator=(const subview_cube<eT>& X); | |
| inline const Mat& operator+=(const subview_cube<eT>& X); | | inline const Mat& operator+=(const subview_cube<eT>& X); | |
| inline const Mat& operator-=(const subview_cube<eT>& X); | | inline const Mat& operator-=(const subview_cube<eT>& X); | |
| inline const Mat& operator*=(const subview_cube<eT>& X); | | inline const Mat& operator*=(const subview_cube<eT>& X); | |
| inline const Mat& operator%=(const subview_cube<eT>& X); | | inline const Mat& operator%=(const subview_cube<eT>& X); | |
| inline const Mat& operator/=(const subview_cube<eT>& X); | | inline const Mat& operator/=(const subview_cube<eT>& X); | |
| | | | |
|
| //inline explicit Mat(const diagview<eT>& X); | | | |
| inline Mat(const diagview<eT>& X); | | inline Mat(const diagview<eT>& X); | |
| inline const Mat& operator=(const diagview<eT>& X); | | inline const Mat& operator=(const diagview<eT>& X); | |
| inline const Mat& operator+=(const diagview<eT>& X); | | inline const Mat& operator+=(const diagview<eT>& X); | |
| inline const Mat& operator-=(const diagview<eT>& X); | | inline const Mat& operator-=(const diagview<eT>& X); | |
| inline const Mat& operator*=(const diagview<eT>& X); | | inline const Mat& operator*=(const diagview<eT>& X); | |
| inline const Mat& operator%=(const diagview<eT>& X); | | inline const Mat& operator%=(const diagview<eT>& X); | |
| inline const Mat& operator/=(const diagview<eT>& X); | | inline const Mat& operator/=(const diagview<eT>& X); | |
| | | | |
| template<typename T1> inline Mat(const subview_elem1<eT
,T1>& X); | | template<typename T1> inline Mat(const subview_elem1<eT
,T1>& X); | |
| template<typename T1> inline const Mat& operator= (const subview_elem1<eT
,T1>& X); | | template<typename T1> inline const Mat& operator= (const subview_elem1<eT
,T1>& X); | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 143 | |
| template<typename T1> inline const Mat& operator/=(const subview_elem1<eT
,T1>& X); | | template<typename T1> inline const Mat& operator/=(const subview_elem1<eT
,T1>& X); | |
| | | | |
| template<typename T1, typename T2> inline Mat(const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline Mat(const sub
view_elem2<eT,T1,T2>& X); | |
| template<typename T1, typename T2> inline const Mat& operator= (const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline const Mat& operator= (const sub
view_elem2<eT,T1,T2>& X); | |
| template<typename T1, typename T2> inline const Mat& operator+=(const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline const Mat& operator+=(const sub
view_elem2<eT,T1,T2>& X); | |
| template<typename T1, typename T2> inline const Mat& operator-=(const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline const Mat& operator-=(const sub
view_elem2<eT,T1,T2>& X); | |
| template<typename T1, typename T2> inline const Mat& operator*=(const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline const Mat& operator*=(const sub
view_elem2<eT,T1,T2>& X); | |
| template<typename T1, typename T2> inline const Mat& operator%=(const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline const Mat& operator%=(const sub
view_elem2<eT,T1,T2>& X); | |
| template<typename T1, typename T2> inline const Mat& operator/=(const sub
view_elem2<eT,T1,T2>& X); | | template<typename T1, typename T2> inline const Mat& operator/=(const sub
view_elem2<eT,T1,T2>& X); | |
| | | | |
|
| // Operators on sparse matrices (and subviews). | | // Operators on sparse matrices (and subviews) | |
| template<typename T1> inline explicit Mat(const SpBase<eT, T1>&
m); | | template<typename T1> inline explicit Mat(const SpBase<eT, T1>&
m); | |
| template<typename T1> inline const Mat& operator=(const SpBase<eT, T1>&
m); | | template<typename T1> inline const Mat& operator=(const SpBase<eT, T1>&
m); | |
| template<typename T1> inline const Mat& operator+=(const SpBase<eT, T1>&
m); | | template<typename T1> inline const Mat& operator+=(const SpBase<eT, T1>&
m); | |
| template<typename T1> inline const Mat& operator-=(const SpBase<eT, T1>&
m); | | template<typename T1> inline const Mat& operator-=(const SpBase<eT, T1>&
m); | |
| template<typename T1> inline const Mat& operator*=(const SpBase<eT, T1>&
m); | | template<typename T1> inline const Mat& operator*=(const SpBase<eT, T1>&
m); | |
| template<typename T1> inline const Mat& operator%=(const SpBase<eT, T1>&
m); | | template<typename T1> inline const Mat& operator%=(const SpBase<eT, T1>&
m); | |
| template<typename T1> inline const Mat& operator/=(const SpBase<eT, T1>&
m); | | template<typename T1> inline const Mat& operator/=(const SpBase<eT, T1>&
m); | |
| | | | |
| inline mat_injector<Mat> operator<<(const eT val); | | inline mat_injector<Mat> operator<<(const eT val); | |
| inline mat_injector<Mat> operator<<(const injector_end_of_row<>& x); | | inline mat_injector<Mat> operator<<(const injector_end_of_row<>& x); | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 5 lines changed or added | |
|
| Proxy.hpp | | Proxy.hpp | |
|
| // Copyright (C) 2010-2013 Conrad Sanderson | | // Copyright (C) 2010-2014 Conrad Sanderson | |
| // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2014 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup Proxy | | //! \addtogroup Proxy | |
| //! @{ | | //! @{ | |
| | | | |
| // ea_type is the "element accessor" type, | | // ea_type is the "element accessor" type, | |
| // which can provide access to elements via operator[] | | // which can provide access to elements via operator[] | |
| | | | |
| skipping to change at line 439 | | skipping to change at line 439 | |
| inline explicit Proxy(const Op<T1, op_diagvec>& A) | | inline explicit Proxy(const Op<T1, op_diagvec>& A) | |
| : Proxy_diagvec(A) | | : Proxy_diagvec(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct Proxy_xtrans_default | | struct Proxy_xtrans_default | |
| { | | { | |
|
| typedef typename T1::elem_type eT; | | inline Proxy_xtrans_default(const T1&) {} | |
| | | }; | |
| | | | |
|
| static const bool prefer_at_accessor = false; | | template<typename T1> | |
| static const bool has_subview = false; | | struct Proxy_xtrans_default< Op<T1, op_htrans> > | |
| | | { | |
| | | public: | |
| | | | |
| | | typedef typename T1::elem_type elem_type; | |
| | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | typedef xtrans_mat<elem_type,true> stored_type; | |
| | | typedef const xtrans_mat<elem_type,true>& ea_type; | |
| | | typedef const xtrans_mat<elem_type,true>& aligned_ea_type; | |
| | | | |
| | | static const bool prefer_at_accessor = true; | |
| | | static const bool has_subview = true; | |
| static const bool is_fixed = false; | | static const bool is_fixed = false; | |
| static const bool fake_mat = false; | | static const bool fake_mat = false; | |
| | | | |
|
| arma_aligned const Mat<eT> Q; | | static const bool is_row = false; | |
| | | static const bool is_col = false; | |
| | | | |
|
| arma_hot | | const unwrap<T1> U; | |
| inline Proxy_xtrans_default(const T1& A) | | const xtrans_mat<elem_type,true> Q; | |
| : Q(A) | | | |
| | | inline explicit Proxy_xtrans_default(const Op<T1, op_htrans>& A) | |
| | | : U(A.m) | |
| | | , Q(U.M) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| | | arma_inline ea_type get_ea() const { return Q; } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
|
| arma_inline bool is_alias(const Mat<eT2>&) const { return false; } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return void_ptr(&(U. | |
| | | M)) == void_ptr(&X); } | |
| | | | |
| | | arma_inline bool is_aligned() const { return false; } | |
| | | }; | |
| | | | |
| | | template<typename T1> | |
| | | struct Proxy_xtrans_default< Op<T1, op_strans> > | |
| | | { | |
| | | public: | |
| | | | |
| | | typedef typename T1::elem_type elem_type; | |
| | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | typedef xtrans_mat<elem_type,false> stored_type; | |
| | | typedef const xtrans_mat<elem_type,false>& ea_type; | |
| | | typedef const xtrans_mat<elem_type,false>& aligned_ea_type; | |
| | | | |
| | | static const bool prefer_at_accessor = true; | |
| | | static const bool has_subview = true; | |
| | | static const bool is_fixed = false; | |
| | | static const bool fake_mat = false; | |
| | | | |
| | | static const bool is_row = false; | |
| | | static const bool is_col = false; | |
| | | | |
| | | const unwrap<T1> U; | |
| | | const xtrans_mat<elem_type,false> Q; | |
| | | | |
| | | inline explicit Proxy_xtrans_default(const Op<T1, op_strans>& A) | |
| | | : U(A.m) | |
| | | , Q(U.M) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_inline ea_type get_ea() const { return Q; } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| | | template<typename eT2> | |
| | | arma_inline bool is_alias(const Mat<eT2>& X) const { return void_ptr(&(U. | |
| | | M)) == void_ptr(&X); } | |
| | | | |
| | | arma_inline bool is_aligned() const { return false; } | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct Proxy_xtrans_vector | | struct Proxy_xtrans_vector | |
| { | | { | |
| inline Proxy_xtrans_vector(const T1&) {} | | inline Proxy_xtrans_vector(const T1&) {} | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct Proxy_xtrans_vector< Op<T1, op_htrans> > | | struct Proxy_xtrans_vector< Op<T1, op_htrans> > | |
| { | | { | |
|
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type elem_type; | |
| | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | typedef Mat<elem_type> stored_type; | |
| | | typedef const elem_type* ea_type; | |
| | | typedef const Mat<elem_type>& aligned_ea_type; | |
| | | | |
| static const bool prefer_at_accessor = false; | | static const bool prefer_at_accessor = false; | |
| static const bool has_subview = quasi_unwrap<T1>::has_subview; | | static const bool has_subview = quasi_unwrap<T1>::has_subview; | |
| static const bool is_fixed = false; | | static const bool is_fixed = false; | |
| static const bool fake_mat = true; | | static const bool fake_mat = true; | |
| | | | |
|
| | | // NOTE: the Op class takes care of swapping row and col for op_htrans | |
| | | static const bool is_row = Op<T1, op_htrans>::is_row; | |
| | | static const bool is_col = Op<T1, op_htrans>::is_col; | |
| | | | |
| arma_aligned const quasi_unwrap<T1> U; // avoid copy if T1 is a Row, Col
or subview_col | | arma_aligned const quasi_unwrap<T1> U; // avoid copy if T1 is a Row, Col
or subview_col | |
|
| arma_aligned const Mat<eT> Q; | | arma_aligned const Mat<elem_type> Q; | |
| | | | |
| inline Proxy_xtrans_vector(const Op<T1, op_htrans>& A) | | inline Proxy_xtrans_vector(const Op<T1, op_htrans>& A) | |
| : U(A.m) | | : U(A.m) | |
|
| , Q(const_cast<eT*>(U.M.memptr()), U.M.n_cols, U.M.n_rows, false, false
) | | , Q(const_cast<elem_type*>(U.M.memptr()), U.M.n_cols, U.M.n_rows, false
, false) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X)
; } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X)
; } | |
|
| | | | |
| | | arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr( | |
| | | )); } | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct Proxy_xtrans_vector< Op<T1, op_strans> > | | struct Proxy_xtrans_vector< Op<T1, op_strans> > | |
| { | | { | |
|
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type elem_type; | |
| | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | typedef Mat<elem_type> stored_type; | |
| | | typedef const elem_type* ea_type; | |
| | | typedef const Mat<elem_type>& aligned_ea_type; | |
| | | | |
| static const bool prefer_at_accessor = false; | | static const bool prefer_at_accessor = false; | |
| static const bool has_subview = quasi_unwrap<T1>::has_subview; | | static const bool has_subview = quasi_unwrap<T1>::has_subview; | |
| static const bool is_fixed = false; | | static const bool is_fixed = false; | |
| static const bool fake_mat = true; | | static const bool fake_mat = true; | |
| | | | |
|
| | | // NOTE: the Op class takes care of swapping row and col for op_htrans | |
| | | static const bool is_row = Op<T1, op_htrans>::is_row; | |
| | | static const bool is_col = Op<T1, op_htrans>::is_col; | |
| | | | |
| arma_aligned const quasi_unwrap<T1> U; // avoid copy if T1 is a Row, Col
or subview_col | | arma_aligned const quasi_unwrap<T1> U; // avoid copy if T1 is a Row, Col
or subview_col | |
|
| arma_aligned const Mat<eT> Q; | | arma_aligned const Mat<elem_type> Q; | |
| | | | |
| inline Proxy_xtrans_vector(const Op<T1, op_strans>& A) | | inline Proxy_xtrans_vector(const Op<T1, op_strans>& A) | |
| : U(A.m) | | : U(A.m) | |
|
| , Q(const_cast<eT*>(U.M.memptr()), U.M.n_cols, U.M.n_rows, false, false
) | | , Q(const_cast<elem_type*>(U.M.memptr()), U.M.n_cols, U.M.n_rows, false
, false) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X)
; } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X)
; } | |
|
| | | | |
| | | arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr( | |
| | | )); } | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct Proxy_xtrans_redirect {}; | | struct Proxy_xtrans_redirect {}; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct Proxy_xtrans_redirect<T1, false> { typedef Proxy_xtrans_default<T1>
result; }; | | struct Proxy_xtrans_redirect<T1, false> { typedef Proxy_xtrans_default<T1>
result; }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct Proxy_xtrans_redirect<T1, true> { typedef Proxy_xtrans_vector<T1>
result; }; | | struct Proxy_xtrans_redirect<T1, true> { typedef Proxy_xtrans_vector<T1>
result; }; | |
| | | | |
| skipping to change at line 542 | | skipping to change at line 627 | |
| | | | |
| typedef | | typedef | |
| typename | | typename | |
| Proxy_xtrans_redirect | | Proxy_xtrans_redirect | |
| < | | < | |
| Op<T1, op_htrans>, | | Op<T1, op_htrans>, | |
| ((is_complex<typename T1::elem_type>::value == false) && ((Op<T1, op_ht
rans>::is_row) || (Op<T1, op_htrans>::is_col)) ) | | ((is_complex<typename T1::elem_type>::value == false) && ((Op<T1, op_ht
rans>::is_row) || (Op<T1, op_htrans>::is_col)) ) | |
| >::result | | >::result | |
| Proxy_xtrans; | | Proxy_xtrans; | |
| | | | |
|
| typedef typename T1::elem_type elem_type; | | typedef typename Proxy_xtrans::elem_type elem_type; | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename Proxy_xtrans::pod_type pod_type; | |
| typedef Mat<elem_type> stored_type; | | typedef typename Proxy_xtrans::stored_type stored_type; | |
| typedef const elem_type* ea_type; | | typedef typename Proxy_xtrans::ea_type ea_type; | |
| typedef const Mat<elem_type>& aligned_ea_type; | | typedef typename Proxy_xtrans::aligned_ea_type aligned_ea_type; | |
| | | | |
| static const bool prefer_at_accessor = Proxy_xtrans::prefer_at_accessor; | | static const bool prefer_at_accessor = Proxy_xtrans::prefer_at_accessor; | |
| static const bool has_subview = Proxy_xtrans::has_subview; | | static const bool has_subview = Proxy_xtrans::has_subview; | |
| static const bool is_fixed = Proxy_xtrans::is_fixed; | | static const bool is_fixed = Proxy_xtrans::is_fixed; | |
| static const bool fake_mat = Proxy_xtrans::fake_mat; | | static const bool fake_mat = Proxy_xtrans::fake_mat; | |
| | | | |
|
| // NOTE: the Op class takes care of swapping row and col for op_htrans | | static const bool is_row = Proxy_xtrans::is_row; | |
| static const bool is_row = Op<T1, op_htrans>::is_row; | | static const bool is_col = Proxy_xtrans::is_col; | |
| static const bool is_col = Op<T1, op_htrans>::is_col; | | | |
| | | | |
| using Proxy_xtrans::Q; | | using Proxy_xtrans::Q; | |
| | | | |
| inline explicit Proxy(const Op<T1, op_htrans>& A) | | inline explicit Proxy(const Op<T1, op_htrans>& A) | |
| : Proxy_xtrans(A) | | : Proxy_xtrans(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | | arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | |
| arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | | arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | |
| arma_inline uword get_n_elem() const { return Q.n_elem; } | | arma_inline uword get_n_elem() const { return Q.n_elem; } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return Q[i]; } | | 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 elem_type at (const uword row, const uword col) const
{ return Q.at(row, col); } | |
| arma_inline elem_type at_alt (const uword i) const
{ return Q.at_alt(i); } | | arma_inline elem_type at_alt (const uword i) const
{ return Q.at_alt(i); } | |
| | | | |
|
| arma_inline ea_type get_ea() const { return Q.memptr(); } | | arma_inline ea_type get_ea() const { return Proxy_xtrans: | |
| arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | | :get_ea(); } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Proxy_xtrans: | |
| | | :get_aligned_ea(); } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return Proxy_xtrans:
:is_alias(X); } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return Proxy_xtrans:
:is_alias(X); } | |
| | | | |
|
| arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr(
)); } | | arma_inline bool is_aligned() const { return Proxy_xtrans::is_aligned();
} | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| class Proxy< Op<T1, op_strans> > | | class Proxy< Op<T1, op_strans> > | |
| : public | | : public | |
| Proxy_xtrans_redirect | | Proxy_xtrans_redirect | |
| < | | < | |
| Op<T1, op_strans>, | | Op<T1, op_strans>, | |
| ( (Op<T1, op_strans>::is_row) || (Op<T1, op_strans>::is_col) ) | | ( (Op<T1, op_strans>::is_row) || (Op<T1, op_strans>::is_col) ) | |
| >::result | | >::result | |
| | | | |
| skipping to change at line 602 | | skipping to change at line 686 | |
| | | | |
| typedef | | typedef | |
| typename | | typename | |
| Proxy_xtrans_redirect | | Proxy_xtrans_redirect | |
| < | | < | |
| Op<T1, op_strans>, | | Op<T1, op_strans>, | |
| ( (Op<T1, op_strans>::is_row) || (Op<T1, op_strans>::is_col) ) | | ( (Op<T1, op_strans>::is_row) || (Op<T1, op_strans>::is_col) ) | |
| >::result | | >::result | |
| Proxy_xtrans; | | Proxy_xtrans; | |
| | | | |
|
| typedef typename T1::elem_type elem_type; | | typedef typename Proxy_xtrans::elem_type elem_type; | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename Proxy_xtrans::pod_type pod_type; | |
| typedef Mat<elem_type> stored_type; | | typedef typename Proxy_xtrans::stored_type stored_type; | |
| typedef const elem_type* ea_type; | | typedef typename Proxy_xtrans::ea_type ea_type; | |
| typedef const Mat<elem_type>& aligned_ea_type; | | typedef typename Proxy_xtrans::aligned_ea_type aligned_ea_type; | |
| | | | |
| static const bool prefer_at_accessor = Proxy_xtrans::prefer_at_accessor; | | static const bool prefer_at_accessor = Proxy_xtrans::prefer_at_accessor; | |
| static const bool has_subview = Proxy_xtrans::has_subview; | | static const bool has_subview = Proxy_xtrans::has_subview; | |
| static const bool is_fixed = Proxy_xtrans::is_fixed; | | static const bool is_fixed = Proxy_xtrans::is_fixed; | |
| static const bool fake_mat = Proxy_xtrans::fake_mat; | | static const bool fake_mat = Proxy_xtrans::fake_mat; | |
| | | | |
|
| // NOTE: the Op class takes care of swapping row and col for op_strans | | static const bool is_row = Proxy_xtrans::is_row; | |
| static const bool is_row = Op<T1, op_strans>::is_row; | | static const bool is_col = Proxy_xtrans::is_col; | |
| static const bool is_col = Op<T1, op_strans>::is_col; | | | |
| | | | |
| using Proxy_xtrans::Q; | | using Proxy_xtrans::Q; | |
| | | | |
| inline explicit Proxy(const Op<T1, op_strans>& A) | | inline explicit Proxy(const Op<T1, op_strans>& A) | |
| : Proxy_xtrans(A) | | : Proxy_xtrans(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | | arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | |
| arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | | arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | |
| arma_inline uword get_n_elem() const { return Q.n_elem; } | | arma_inline uword get_n_elem() const { return Q.n_elem; } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return Q[i]; } | | 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 elem_type at (const uword row, const uword col) const
{ return Q.at(row, col); } | |
| arma_inline elem_type at_alt (const uword i) const
{ return Q.at_alt(i); } | | arma_inline elem_type at_alt (const uword i) const
{ return Q.at_alt(i); } | |
| | | | |
|
| arma_inline ea_type get_ea() const { return Q.memptr(); } | | arma_inline ea_type get_ea() const { return Proxy_xtrans: | |
| arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | | :get_ea(); } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Proxy_xtrans: | |
| | | :get_aligned_ea(); } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return Proxy_xtrans:
:is_alias(X); } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return Proxy_xtrans:
:is_alias(X); } | |
| | | | |
|
| arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr(
)); } | | arma_inline bool is_aligned() const { return Proxy_xtrans::is_aligned();
} | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct Proxy_subview_row_htrans_cx | | struct Proxy_subview_row_htrans_cx | |
| { | | { | |
| typedef eT elem_type; | | typedef eT elem_type; | |
| typedef typename get_pod_type<eT>::result pod_type; | | typedef typename get_pod_type<eT>::result pod_type; | |
| typedef subview_row_htrans<eT> stored_type; | | typedef subview_row_htrans<eT> stored_type; | |
| typedef const subview_row_htrans<eT>& ea_type; | | typedef const subview_row_htrans<eT>& ea_type; | |
| typedef const subview_row_htrans<eT>& aligned_ea_type; | | typedef const subview_row_htrans<eT>& aligned_ea_type; | |
| | | | |
| skipping to change at line 1422 | | skipping to change at line 1505 | |
| | | | |
| arma_inline ea_type get_ea() const { return Q; } | | arma_inline ea_type get_ea() const { return Q; } | |
| arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q
.sv_row.m)) == void_ptr(&X)); } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q
.sv_row.m)) == void_ptr(&X)); } | |
| | | | |
| arma_inline bool is_aligned() const { return false; } | | arma_inline bool is_aligned() const { return false; } | |
| }; | | }; | |
| | | | |
|
| | | template<typename eT, bool do_conj> | |
| | | class Proxy< xtrans_mat<eT, do_conj> > | |
| | | { | |
| | | public: | |
| | | | |
| | | typedef eT elem_type; | |
| | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | typedef Mat<eT> stored_type; | |
| | | typedef const eT* ea_type; | |
| | | typedef const Mat<eT>& aligned_ea_type; | |
| | | | |
| | | static const bool prefer_at_accessor = false; | |
| | | static const bool has_subview = false; | |
| | | static const bool is_fixed = false; | |
| | | static const bool fake_mat = false; | |
| | | | |
| | | static const bool is_row = false; | |
| | | static const bool is_col = false; | |
| | | | |
| | | arma_aligned const Mat<eT> Q; | |
| | | | |
| | | inline explicit Proxy(const xtrans_mat<eT, do_conj>& A) | |
| | | : Q(A) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_inline uword get_n_rows() const { return Q.n_rows; } | |
| | | arma_inline uword get_n_cols() const { return Q.n_cols; } | |
| | | arma_inline uword get_n_elem() const { return Q.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 elem_type at_alt (const uword i) const | |
| | | { return Q.at_alt(i); } | |
| | | | |
| | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| | | template<typename eT2> | |
| | | arma_inline bool is_alias(const Mat<eT2>& X) const { return false; } | |
| | | | |
| | | arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr( | |
| | | )); } | |
| | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class Proxy< xvec_htrans<eT> > | | class Proxy< xvec_htrans<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; | |
| typedef const Mat<eT>& aligned_ea_type; | | typedef const Mat<eT>& aligned_ea_type; | |
| | | | |
End of changes. 28 change blocks. |
| 38 lines changed or deleted | | 177 lines changed or added | |
|
| fn_sort_index.hpp | | fn_sort_index.hpp | |
| | | | |
| skipping to change at line 47 | | skipping to change at line 47 | |
| bool | | bool | |
| operator() (const arma_sort_index_packet<T1,T2>& A, const arma_sort_index
_packet<T1,T2>& B) const | | operator() (const arma_sort_index_packet<T1,T2>& A, const arma_sort_index
_packet<T1,T2>& B) const | |
| { | | { | |
| return (A.val > B.val); | | return (A.val > B.val); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template<typename umat_elem_type, typename eT, const uword sort_type, const
uword sort_stable> | | template<typename umat_elem_type, typename eT, const uword sort_type, const
uword sort_stable> | |
| void | | void | |
| inline | | inline | |
|
| sort_index_helper(umat_elem_type* out_mem, const eT* in_mem, const uword n_
elem) | | sort_index_helper(umat_elem_type* out_mem, const eT* in_mem, const uword n_
elem, typename arma_not_cx<eT>::result* junk = 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| | | arma_ignore(junk); | |
| | | | |
| std::vector< arma_sort_index_packet<eT, umat_elem_type> > packet_vec(n_el
em); | | std::vector< arma_sort_index_packet<eT, umat_elem_type> > packet_vec(n_el
em); | |
| | | | |
| for(uword i=0; i<n_elem; ++i) | | for(uword i=0; i<n_elem; ++i) | |
| { | | { | |
| packet_vec[i].val = in_mem[i]; | | packet_vec[i].val = in_mem[i]; | |
| packet_vec[i].index = i; | | packet_vec[i].index = i; | |
| } | | } | |
| | | | |
| if(sort_type == 0) | | if(sort_type == 0) | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 97 | |
| std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); | | std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); | |
| } | | } | |
| } | | } | |
| | | | |
| for(uword i=0; i<n_elem; ++i) | | for(uword i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = packet_vec[i].index; | | out_mem[i] = packet_vec[i].index; | |
| } | | } | |
| } | | } | |
| | | | |
|
| //! kept for compatibility with old code | | template<typename umat_elem_type, typename eT, const uword sort_type, const | |
| template<typename T1> | | uword sort_stable> | |
| | | void | |
| inline | | inline | |
|
| umat | | sort_index_helper(umat_elem_type* out_mem, const eT* in_mem, const uword n_ | |
| sort_index | | elem, typename arma_cx_only<eT>::result* junk = 0) | |
| ( | | | |
| const Base<typename T1::elem_type,T1>& X, | | | |
| const uword sort_type = 0, | | | |
| const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 | | | |
| ) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
|
| typedef typename T1::elem_type eT; | | typedef typename get_pod_type<eT>::result T; | |
| | | | |
|
| const unwrap<T1> tmp(X.get_ref()); | | std::vector< arma_sort_index_packet<T, umat_elem_type> > packet_vec(n_ele | |
| const Mat<eT>& A = tmp.M; | | m); | |
| | | | |
|
| if(A.is_empty() == true) | | for(uword i=0; i<n_elem; ++i) | |
| { | | { | |
|
| return umat(); | | packet_vec[i].val = std::abs(in_mem[i]); | |
| | | packet_vec[i].index = i; | |
| } | | } | |
| | | | |
|
| arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha | | | |
| ndles vectors"); | | | |
| | | | |
| typedef typename umat::elem_type out_elem_type; | | | |
| | | | |
| umat out(A.n_rows, A.n_cols); | | | |
| | | | |
| if(sort_type == 0) | | if(sort_type == 0) | |
| { | | { | |
|
| sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele | | // ascend | |
| m); | | | |
| | | arma_sort_index_helper_ascend comparator; | |
| | | | |
| | | if(sort_stable == 0) | |
| | | { | |
| | | std::sort( packet_vec.begin(), packet_vec.end(), comparator ); | |
| | | } | |
| | | else | |
| | | { | |
| | | std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); | |
| | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele | | // descend | |
| m); | | | |
| | | arma_sort_index_helper_descend comparator; | |
| | | | |
| | | if(sort_stable == 0) | |
| | | { | |
| | | std::sort( packet_vec.begin(), packet_vec.end(), comparator ); | |
| | | } | |
| | | else | |
| | | { | |
| | | std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); | |
| | | } | |
| } | | } | |
| | | | |
|
| return out; | | for(uword i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] = packet_vec[i].index; | |
| | | } | |
| } | | } | |
| | | | |
| //! kept for compatibility with old code | | //! kept for compatibility with old code | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| umat | | umat | |
|
| stable_sort_index | | sort_index | |
| ( | | ( | |
| const Base<typename T1::elem_type,T1>& X, | | const Base<typename T1::elem_type,T1>& X, | |
|
| const uword sort_type = 0, | | const uword sort_type = 0 | |
| const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 | | | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| arma_ignore(junk); | | | |
| | | | |
|
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | typedef typename umat::elem_type out_elem_type; | |
| | | | |
| 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; | |
| | | | |
|
| if(A.is_empty() == true) | | umat out; | |
| | | | |
| | | if(A.is_empty() == false) | |
| { | | { | |
|
| return umat(); | | arma_debug_check( (A.is_vec() == false), "sort_index(): currently only | |
| | | handles vectors"); | |
| | | | |
| | | out.set_size(A.n_rows, A.n_cols); | |
| | | | |
| | | if(sort_type == 0) | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| | | else | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| } | | } | |
| | | | |
|
| arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currently | | return out; | |
| only handles vectors"); | | } | |
| | | | |
| | | //! kept for compatibility with old code | |
| | | template<typename T1> | |
| | | inline | |
| | | umat | |
| | | stable_sort_index | |
| | | ( | |
| | | const Base<typename T1::elem_type,T1>& X, | |
| | | const uword sort_type = 0 | |
| | | ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
|
| | | typedef typename T1::elem_type eT; | |
| typedef typename umat::elem_type out_elem_type; | | typedef typename umat::elem_type out_elem_type; | |
| | | | |
|
| umat out(A.n_rows, A.n_cols); | | const unwrap<T1> tmp(X.get_ref()); | |
| | | const Mat<eT>& A = tmp.M; | |
| | | | |
|
| if(sort_type == 0) | | umat out; | |
| { | | | |
| sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_ele | | if(A.is_empty() == false) | |
| m); | | | |
| } | | | |
| else | | | |
| { | | { | |
|
| sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_ele | | arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currentl | |
| m); | | y only handles vectors"); | |
| | | | |
| | | out.set_size(A.n_rows, A.n_cols); | |
| | | | |
| | | if(sort_type == 0) | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| | | else | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| typename | | typename | |
| enable_if2 | | enable_if2 | |
| < | | < | |
|
| ( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value ==
true) && (is_cx<typename T1::elem_type>::value == false) ), | | ( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value ==
true) ), | |
| umat | | umat | |
| >::result | | >::result | |
| sort_index | | sort_index | |
| ( | | ( | |
| const T1& X, | | const T1& X, | |
| const T2* sort_direction | | const T2* sort_direction | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | typedef typename umat::elem_type out_elem_type; | |
| const unwrap<T1> tmp(X); | | | |
| const Mat<eT>& A = tmp.M; | | | |
| | | | |
| if(A.is_empty() == true) | | | |
| { | | | |
| return umat(); | | | |
| } | | | |
| | | | |
| arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha | | | |
| ndles vectors"); | | | |
| | | | |
| const char sig = (sort_direction != NULL) ? sort_direction[0] : char(0); | | const char sig = (sort_direction != NULL) ? sort_direction[0] : char(0); | |
| | | | |
| arma_debug_check( ((sig != 'a') && (sig != 'd')), "sort_index(): unknown
sort direction" ); | | arma_debug_check( ((sig != 'a') && (sig != 'd')), "sort_index(): unknown
sort direction" ); | |
| | | | |
|
| typedef typename umat::elem_type out_elem_type; | | const unwrap<T1> tmp(X); | |
| | | const Mat<eT>& A = tmp.M; | |
| | | | |
|
| umat out(A.n_rows, A.n_cols); | | umat out; | |
| | | | |
|
| if(sig == 'a') | | if(A.is_empty() == false) | |
| { | | | |
| sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele | | | |
| m); | | | |
| } | | | |
| else | | | |
| { | | { | |
|
| sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele | | arma_debug_check( (A.is_vec() == false), "sort_index(): currently only | |
| m); | | handles vectors"); | |
| | | | |
| | | out.set_size(A.n_rows, A.n_cols); | |
| | | | |
| | | if(sig == 'a') | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| | | else | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| typename | | typename | |
| enable_if2 | | enable_if2 | |
| < | | < | |
|
| ( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value ==
true) && (is_cx<typename T1::elem_type>::value == false) ), | | ( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value ==
true) ), | |
| umat | | umat | |
| >::result | | >::result | |
| stable_sort_index | | stable_sort_index | |
| ( | | ( | |
| const T1& X, | | const T1& X, | |
| const T2* sort_direction | | const T2* sort_direction | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | typedef typename umat::elem_type out_elem_type; | |
| const unwrap<T1> tmp(X); | | | |
| const Mat<eT>& A = tmp.M; | | | |
| | | | |
| if(A.is_empty() == true) | | | |
| { | | | |
| return umat(); | | | |
| } | | | |
| | | | |
| arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currently | | | |
| only handles vectors"); | | | |
| | | | |
| const char sig = (sort_direction != NULL) ? sort_direction[0] : char(0); | | const char sig = (sort_direction != NULL) ? sort_direction[0] : char(0); | |
| | | | |
| arma_debug_check( ((sig != 'a') && (sig != 'd')), "stable_sort_index(): u
nknown sort direction" ); | | arma_debug_check( ((sig != 'a') && (sig != 'd')), "stable_sort_index(): u
nknown sort direction" ); | |
| | | | |
|
| typedef typename umat::elem_type out_elem_type; | | const unwrap<T1> tmp(X); | |
| | | const Mat<eT>& A = tmp.M; | |
| | | | |
|
| umat out(A.n_rows, A.n_cols); | | umat out; | |
| | | | |
|
| if(sig == 'a') | | if(A.is_empty() == false) | |
| { | | | |
| sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_ele | | | |
| m); | | | |
| } | | | |
| else | | | |
| { | | { | |
|
| sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_ele | | arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currentl | |
| m); | | y only handles vectors"); | |
| | | | |
| | | out.set_size(A.n_rows, A.n_cols); | |
| | | | |
| | | if(sig == 'a') | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| | | else | |
| | | { | |
| | | sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_e | |
| | | lem); | |
| | | } | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 35 change blocks. |
| 91 lines changed or deleted | | 142 lines changed or added | |
|
| op_symmat_meat.hpp | | op_symmat_meat.hpp | |
|
| // Copyright (C) 2011-2012 Conrad Sanderson | | // Copyright (C) 2011-2014 Conrad Sanderson | |
| // Copyright (C) 2011-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2011-2014 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_symmat | | //! \addtogroup op_symmat | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
|
| op_symmat::apply | | op_symmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_symmat>& | |
| ( | | in) | |
| Mat<typename T1::elem_type>& out, | | | |
| const Op<T1,op_symmat>& in, | | | |
| const typename arma_not_cx<typename T1::elem_type>::result* junk | | | |
| ) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| arma_ignore(junk); | | | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap<T1> tmp(in.m); | | const unwrap<T1> tmp(in.m); | |
| const Mat<eT>& A = tmp.M; | | const Mat<eT>& A = tmp.M; | |
| | | | |
| arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m
atrix must be square" ); | | arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m
atrix must be square" ); | |
| | | | |
| const uword N = A.n_rows; | | const uword N = A.n_rows; | |
| const bool upper = (in.aux_uword_a == 0); | | const bool upper = (in.aux_uword_a == 0); | |
| | | | |
| skipping to change at line 97 | | skipping to change at line 91 | |
| { | | { | |
| out.at(col,row) = coldata[row]; | | out.at(col,row) = coldata[row]; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
|
| op_symmat::apply | | op_symmat_cx::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_symmat | |
| ( | | _cx>& in) | |
| Mat<typename T1::elem_type>& out, | | | |
| const Op<T1,op_symmat>& in, | | | |
| const typename arma_cx_only<typename T1::elem_type>::result* junk | | | |
| ) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| arma_ignore(junk); | | | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap<T1> tmp(in.m); | | const unwrap<T1> tmp(in.m); | |
| const Mat<eT>& A = tmp.M; | | const Mat<eT>& A = tmp.M; | |
| | | | |
| arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m
atrix must be square" ); | | arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m
atrix must be square" ); | |
| | | | |
|
| const uword N = A.n_rows; | | const uword N = A.n_rows; | |
| const bool upper = (in.aux_uword_a == 0); | | | |
| | | const bool upper = (in.aux_uword_a == 0); | |
| | | const bool do_conj = (in.aux_uword_b == 1); | |
| | | | |
| if(&out != &A) | | if(&out != &A) | |
| { | | { | |
| out.copy_size(A); | | out.copy_size(A); | |
| | | | |
| if(upper) | | if(upper) | |
| { | | { | |
| // upper triangular: copy the diagonal and the elements above the dia
gonal | | // upper triangular: copy the diagonal and the elements above the dia
gonal | |
| | | | |
| for(uword i=0; i<N; ++i) | | for(uword i=0; i<N; ++i) | |
| | | | |
| skipping to change at line 147 | | skipping to change at line 137 | |
| for(uword i=0; i<N; ++i) | | for(uword i=0; i<N; ++i) | |
| { | | { | |
| const eT* A_data = A.colptr(i); | | const eT* A_data = A.colptr(i); | |
| eT* out_data = out.colptr(i); | | eT* out_data = out.colptr(i); | |
| | | | |
| arrayops::copy( &out_data[i], &A_data[i], N-i ); | | arrayops::copy( &out_data[i], &A_data[i], N-i ); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
|
| if(upper) | | if(do_conj) | |
| { | | { | |
|
| // reflect elements across the diagonal from upper triangle to lower tr | | if(upper) | |
| iangle | | { | |
| | | // reflect elements across the diagonal from upper triangle to lower | |
| | | triangle | |
| | | | |
|
| for(uword col=1; col < N; ++col) | | for(uword col=1; col < N; ++col) | |
| | | { | |
| | | const eT* coldata = out.colptr(col); | |
| | | | |
| | | for(uword row=0; row < col; ++row) | |
| | | { | |
| | | out.at(col,row) = std::conj(coldata[row]); | |
| | | } | |
| | | } | |
| | | } | |
| | | else | |
| { | | { | |
|
| const eT* coldata = out.colptr(col); | | // reflect elements across the diagonal from lower triangle to upper
triangle | |
| | | | |
|
| for(uword row=0; row < col; ++row) | | for(uword col=0; col < N; ++col) | |
| { | | { | |
|
| out.at(col,row) = std::conj(coldata[row]); | | const eT* coldata = out.colptr(col); | |
| | | | |
| | | for(uword row=(col+1); row < N; ++row) | |
| | | { | |
| | | out.at(col,row) = std::conj(coldata[row]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
|
| else | | else // don't do complex conjugation | |
| { | | { | |
|
| // reflect elements across the diagonal from lower triangle to upper tr | | if(upper) | |
| iangle | | { | |
| | | // reflect elements across the diagonal from upper triangle to lower | |
| | | triangle | |
| | | | |
|
| for(uword col=0; col < N; ++col) | | for(uword col=1; col < N; ++col) | |
| | | { | |
| | | const eT* coldata = out.colptr(col); | |
| | | | |
| | | for(uword row=0; row < col; ++row) | |
| | | { | |
| | | out.at(col,row) = coldata[row]; | |
| | | } | |
| | | } | |
| | | } | |
| | | else | |
| { | | { | |
|
| const eT* coldata = out.colptr(col); | | // reflect elements across the diagonal from lower triangle to upper
triangle | |
| | | | |
|
| for(uword row=(col+1); row < N; ++row) | | for(uword col=0; col < N; ++col) | |
| { | | { | |
|
| out.at(col,row) = std::conj(coldata[row]); | | const eT* coldata = out.colptr(col); | |
| | | | |
| | | for(uword row=(col+1); row < N; ++row) | |
| | | { | |
| | | out.at(col,row) = coldata[row]; | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 18 change blocks. |
| 32 lines changed or deleted | | 58 lines changed or added | |
|