| Base_bones.hpp | | Base_bones.hpp | |
|
| // Copyright (C) 2008-2013 Conrad Sanderson | | // Copyright (C) 2008-2014 Conrad Sanderson | |
| // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-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 Base | | //! \addtogroup Base | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename derived> | | template<typename derived> | |
|
| struct Base_blas_elem_type | | struct Base_inv_yes | |
| { | | { | |
| arma_inline const Op<derived,op_inv> i(const bool slow = false) const;
//!< matrix inverse | | arma_inline const Op<derived,op_inv> i(const bool slow = false) const;
//!< matrix inverse | |
| arma_inline const Op<derived,op_inv> i(const char* method ) const;
//!< matrix inverse | | arma_inline const Op<derived,op_inv> i(const char* method ) const;
//!< matrix inverse | |
| }; | | }; | |
| | | | |
| template<typename derived> | | template<typename derived> | |
|
| struct Base_other_elem_type | | struct Base_inv_no | |
| { | | { | |
| }; | | }; | |
| | | | |
| template<typename derived, bool condition> | | template<typename derived, bool condition> | |
|
| struct Base_extra {}; | | struct Base_inv {}; | |
| | | | |
| template<typename derived> | | template<typename derived> | |
|
| struct Base_extra<derived, true> { typedef Base_blas_elem_type<derived> r
esult; }; | | struct Base_inv<derived, true> { typedef Base_inv_yes<derived> result; }; | |
| | | | |
| template<typename derived> | | template<typename derived> | |
|
| struct Base_extra<derived, false> { typedef Base_other_elem_type<derived> r
esult; }; | | struct Base_inv<derived, false> { typedef Base_inv_no<derived> result; }; | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| struct Base_eval_Mat | | struct Base_eval_Mat | |
| { | | { | |
| arma_inline const derived& eval() const; | | arma_inline const derived& eval() const; | |
| }; | | }; | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| struct Base_eval_expr | | struct Base_eval_expr | |
| { | | { | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 53 | |
| | | | |
| template<typename elem_type, typename derived, bool condition> | | template<typename elem_type, typename derived, bool condition> | |
| struct Base_eval {}; | | struct Base_eval {}; | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| struct Base_eval<elem_type, derived, true> { typedef Base_eval_Mat<elem_ty
pe, derived> result; }; | | struct Base_eval<elem_type, derived, true> { typedef Base_eval_Mat<elem_ty
pe, derived> result; }; | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| struct Base_eval<elem_type, derived, false> { typedef Base_eval_expr<elem_t
ype, derived> result; }; | | struct Base_eval<elem_type, derived, false> { typedef Base_eval_expr<elem_t
ype, derived> result; }; | |
| | | | |
|
| | | template<typename derived> | |
| | | struct Base_trans_cx | |
| | | { | |
| | | arma_inline const Op<derived,op_htrans> t() const; | |
| | | arma_inline const Op<derived,op_htrans> ht() const; | |
| | | arma_inline const Op<derived,op_strans> st() const; // simple transpose: | |
| | | no complex conjugates | |
| | | }; | |
| | | | |
| | | template<typename derived> | |
| | | struct Base_trans_default | |
| | | { | |
| | | arma_inline const Op<derived,op_htrans> t() const; | |
| | | arma_inline const Op<derived,op_htrans> ht() const; | |
| | | arma_inline const Op<derived,op_htrans> st() const; // return op_htrans | |
| | | instead of op_strans, as it's handled better by matrix multiplication code | |
| | | }; | |
| | | | |
| | | template<typename derived, bool condition> | |
| | | struct Base_trans {}; | |
| | | | |
| | | template<typename derived> | |
| | | struct Base_trans<derived, true> { typedef Base_trans_cx<derived> res | |
| | | ult; }; | |
| | | | |
| | | template<typename derived> | |
| | | struct Base_trans<derived, false> { typedef Base_trans_default<derived> res | |
| | | ult; }; | |
| | | | |
| //! Class for static polymorphism, modelled after the "Curiously Recurring
Template Pattern" (CRTP). | | //! Class for static polymorphism, modelled after the "Curiously Recurring
Template Pattern" (CRTP). | |
| //! Used for type-safe downcasting in functions that restrict their input(s
) to be classes that are | | //! Used for type-safe downcasting in functions that restrict their input(s
) to be classes that are | |
| //! derived from Base (e.g. Mat, Op, Glue, diagview, subview). | | //! derived from Base (e.g. Mat, Op, Glue, diagview, subview). | |
| //! A Base object can be converted to a Mat object by the unwrap class. | | //! A Base object can be converted to a Mat object by the unwrap class. | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| struct Base | | struct Base | |
|
| : public Base_extra<derived, is_supported_blas_type<elem_type>::value>::r
esult | | : public Base_inv<derived, is_supported_blas_type<elem_type>::value>::res
ult | |
| , public Base_eval<elem_type, derived, is_Mat<derived>::value>::result | | , public Base_eval<elem_type, derived, is_Mat<derived>::value>::result | |
|
| | | , public Base_trans<derived, is_cx<elem_type>::value>::result | |
| { | | { | |
| arma_inline const derived& get_ref() const; | | arma_inline const derived& get_ref() const; | |
| | | | |
|
| arma_inline const Op<derived,op_htrans> t() const; //!< Hermitian trans | | | |
| pose | | | |
| arma_inline const Op<derived,op_htrans> ht() const; //!< Hermitian trans | | | |
| pose | | | |
| arma_inline const Op<derived,op_strans> st() const; //!< simple transpos | | | |
| e | | | |
| | | | |
| inline void print(const std::string extra_text = "") const; | | inline void print(const std::string extra_text = "") const; | |
| inline void print(std::ostream& user_stream, const std::string extra_text
= "") const; | | inline void print(std::ostream& user_stream, const std::string extra_text
= "") const; | |
| | | | |
| inline void raw_print(const std::string extra_text = "") const; | | inline void raw_print(const std::string extra_text = "") const; | |
| inline void raw_print(std::ostream& user_stream, const std::string extra_
text = "") const; | | inline void raw_print(std::ostream& user_stream, const std::string extra_
text = "") const; | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 10 change blocks. |
| 15 lines changed or deleted | | 38 lines changed or added | |
|
| Base_meat.hpp | | Base_meat.hpp | |
|
| // Copyright (C) 2008-2013 Conrad Sanderson | | // Copyright (C) 2008-2014 Conrad Sanderson | |
| // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-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 Base | | //! \addtogroup Base | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| arma_inline | | arma_inline | |
| const derived& | | const derived& | |
| Base<elem_type,derived>::get_ref() const | | Base<elem_type,derived>::get_ref() const | |
| { | | { | |
| return static_cast<const derived&>(*this); | | return static_cast<const derived&>(*this); | |
| } | | } | |
| | | | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
|
| arma_inline | | | |
| const Op<derived,op_htrans> | | | |
| Base<elem_type,derived>::t() const | | | |
| { | | | |
| return Op<derived,op_htrans>( (*this).get_ref() ); | | | |
| } | | | |
| | | | |
| template<typename elem_type, typename derived> | | | |
| arma_inline | | | |
| const Op<derived,op_htrans> | | | |
| Base<elem_type,derived>::ht() const | | | |
| { | | | |
| return Op<derived,op_htrans>( (*this).get_ref() ); | | | |
| } | | | |
| | | | |
| template<typename elem_type, typename derived> | | | |
| arma_inline | | | |
| const Op<derived,op_strans> | | | |
| Base<elem_type,derived>::st() const | | | |
| { | | | |
| return Op<derived,op_strans>( (*this).get_ref() ); | | | |
| } | | | |
| | | | |
| template<typename elem_type, typename derived> | | | |
| inline | | inline | |
| void | | void | |
| Base<elem_type,derived>::print(const std::string extra_text) const | | Base<elem_type,derived>::print(const std::string extra_text) const | |
| { | | { | |
| const Proxy<derived> P( (*this).get_ref() ); | | const Proxy<derived> P( (*this).get_ref() ); | |
| | | | |
| const quasi_unwrap< typename Proxy<derived>::stored_type > tmp(P.Q); | | const quasi_unwrap< typename Proxy<derived>::stored_type > tmp(P.Q); | |
| | | | |
| tmp.M.impl_print(extra_text); | | tmp.M.impl_print(extra_text); | |
| } | | } | |
| | | | |
| skipping to change at line 92 | | skipping to change at line 68 | |
| Base<elem_type,derived>::raw_print(std::ostream& user_stream, const std::st
ring extra_text) const | | Base<elem_type,derived>::raw_print(std::ostream& user_stream, const std::st
ring extra_text) const | |
| { | | { | |
| const Proxy<derived> P( (*this).get_ref() ); | | const Proxy<derived> P( (*this).get_ref() ); | |
| | | | |
| const quasi_unwrap< typename Proxy<derived>::stored_type > tmp(P.Q); | | const quasi_unwrap< typename Proxy<derived>::stored_type > tmp(P.Q); | |
| | | | |
| tmp.M.impl_raw_print(user_stream, extra_text); | | tmp.M.impl_raw_print(user_stream, extra_text); | |
| } | | } | |
| | | | |
| // | | // | |
|
| // extra functions defined in Base_blas_elem_type | | // extra functions defined in Base_inv_yes | |
| | | | |
| template<typename derived> | | template<typename derived> | |
| arma_inline | | arma_inline | |
| const Op<derived,op_inv> | | const Op<derived,op_inv> | |
|
| Base_blas_elem_type<derived>::i(const bool slow) const | | Base_inv_yes<derived>::i(const bool slow) const | |
| { | | { | |
| return Op<derived,op_inv>( static_cast<const derived&>(*this), ((slow ==
false) ? 0 : 1), 0 ); | | return Op<derived,op_inv>( static_cast<const derived&>(*this), ((slow ==
false) ? 0 : 1), 0 ); | |
| } | | } | |
| | | | |
| template<typename derived> | | template<typename derived> | |
| arma_inline | | arma_inline | |
| const Op<derived,op_inv> | | const Op<derived,op_inv> | |
|
| Base_blas_elem_type<derived>::i(const char* method) const | | Base_inv_yes<derived>::i(const char* method) const | |
| { | | { | |
| const char sig = (method != NULL) ? method[0] : char(0); | | const char sig = (method != NULL) ? method[0] : char(0); | |
| | | | |
| arma_debug_check( ((sig != 's') && (sig != 'f')), "Base::i(): unknown met
hod specified" ); | | arma_debug_check( ((sig != 's') && (sig != 'f')), "Base::i(): unknown met
hod specified" ); | |
| | | | |
| return Op<derived,op_inv>( static_cast<const derived&>(*this), ((sig == '
f') ? 0 : 1), 0 ); | | return Op<derived,op_inv>( static_cast<const derived&>(*this), ((sig == '
f') ? 0 : 1), 0 ); | |
| } | | } | |
| | | | |
| // | | // | |
| // extra functions defined in Base_eval_Mat | | // extra functions defined in Base_eval_Mat | |
| | | | |
| skipping to change at line 140 | | skipping to change at line 116 | |
| template<typename elem_type, typename derived> | | template<typename elem_type, typename derived> | |
| arma_inline | | arma_inline | |
| Mat<elem_type> | | Mat<elem_type> | |
| Base_eval_expr<elem_type, derived>::eval() const | | Base_eval_expr<elem_type, derived>::eval() const | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Mat<elem_type>( static_cast<const derived&>(*this) ); | | return Mat<elem_type>( static_cast<const derived&>(*this) ); | |
| } | | } | |
| | | | |
|
| | | // | |
| | | // extra functions defined in Base_trans_cx | |
| | | | |
| | | template<typename derived> | |
| | | arma_inline | |
| | | const Op<derived,op_htrans> | |
| | | Base_trans_cx<derived>::t() const | |
| | | { | |
| | | return Op<derived,op_htrans>( static_cast<const derived&>(*this) ); | |
| | | } | |
| | | | |
| | | template<typename derived> | |
| | | arma_inline | |
| | | const Op<derived,op_htrans> | |
| | | Base_trans_cx<derived>::ht() const | |
| | | { | |
| | | return Op<derived,op_htrans>( static_cast<const derived&>(*this) ); | |
| | | } | |
| | | | |
| | | template<typename derived> | |
| | | arma_inline | |
| | | const Op<derived,op_strans> | |
| | | Base_trans_cx<derived>::st() const | |
| | | { | |
| | | return Op<derived,op_strans>( static_cast<const derived&>(*this) ); | |
| | | } | |
| | | | |
| | | // | |
| | | // extra functions defined in Base_trans_default | |
| | | | |
| | | template<typename derived> | |
| | | arma_inline | |
| | | const Op<derived,op_htrans> | |
| | | Base_trans_default<derived>::t() const | |
| | | { | |
| | | return Op<derived,op_htrans>( static_cast<const derived&>(*this) ); | |
| | | } | |
| | | | |
| | | template<typename derived> | |
| | | arma_inline | |
| | | const Op<derived,op_htrans> | |
| | | Base_trans_default<derived>::ht() const | |
| | | { | |
| | | return Op<derived,op_htrans>( static_cast<const derived&>(*this) ); | |
| | | } | |
| | | | |
| | | template<typename derived> | |
| | | arma_inline | |
| | | const Op<derived,op_htrans> | |
| | | Base_trans_default<derived>::st() const | |
| | | { | |
| | | return Op<derived,op_htrans>( static_cast<const derived&>(*this) ); | |
| | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 6 change blocks. |
| 29 lines changed or deleted | | 59 lines changed or added | |
|
| diagmat_proxy.hpp | | diagmat_proxy.hpp | |
|
| // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2008-2012 Conrad Sanderson | | // Copyright (C) 2008-2014 Conrad Sanderson | |
| // | | // | |
| // 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 diagmat_proxy | | //! \addtogroup diagmat_proxy | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| class diagmat_proxy_default | | class diagmat_proxy_default | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| return P.at(row,row); | | return P.at(row,row); | |
| } | | } | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| return elem_type(0); | | return elem_type(0); | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<elem_type>&) const { return false; } | |
| | | | |
| const Proxy<T1> P; | | const Proxy<T1> P; | |
| const bool P_is_vec; | | const bool P_is_vec; | |
| const bool P_is_col; | | const bool P_is_col; | |
| const uword n_elem; | | const uword n_elem; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| class diagmat_proxy_fixed | | class diagmat_proxy_fixed | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 132 | | skipping to change at line 134 | |
| if(row == col) | | if(row == col) | |
| { | | { | |
| return (P_is_vec) ? P[row] : P.at(row,row); | | return (P_is_vec) ? P[row] : P.at(row,row); | |
| } | | } | |
| else | | else | |
| { | | { | |
| return elem_type(0); | | return elem_type(0); | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<elem_type>& X) const { return (void_p | |
| | | tr(&X) == void_ptr(&P)); } | |
| | | | |
| const T1& P; | | const T1& P; | |
| | | | |
| static const bool P_is_vec = (T1::n_rows == 1) || (T1::n_cols == 1); | | static const bool P_is_vec = (T1::n_rows == 1) || (T1::n_cols == 1); | |
| static const uword n_elem = P_is_vec ? T1::n_elem : ( (T1::n_elem < T1:
:n_rows) ? T1::n_elem : T1::n_rows ); | | static const uword n_elem = P_is_vec ? T1::n_elem : ( (T1::n_elem < T1:
:n_rows) ? T1::n_elem : T1::n_rows ); | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct diagmat_proxy_redirect {}; | | struct diagmat_proxy_redirect {}; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
| skipping to change at line 183 | | skipping to change at line 187 | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| (P_is_vec == false) && (P.n_rows != P.n_cols), | | (P_is_vec == false) && (P.n_rows != P.n_cols), | |
| "diagmat(): only vectors and square matrices are accepted" | | "diagmat(): only vectors and square matrices are accepted" | |
| ); | | ); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return P_is_vec ? P[i] : P.at(i,i);
} | | arma_inline elem_type operator[] (const uword i) const
{ return P_is_vec ? P[i] : P.at(i,i);
} | |
| arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(
0); } | | arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(
0); } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<eT>& X) const { return (void_ptr(&X) | |
| | | == void_ptr(&P)); } | |
| | | | |
| const Mat<eT>& P; | | const Mat<eT>& P; | |
| const bool P_is_vec; | | const bool P_is_vec; | |
| const uword n_elem; | | const uword n_elem; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class diagmat_proxy< Row<eT> > | | class diagmat_proxy< Row<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| | | | |
| skipping to change at line 204 | | skipping to change at line 210 | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | | |
| inline | | inline | |
| diagmat_proxy(const Row<eT>& X) | | diagmat_proxy(const Row<eT>& X) | |
| : P(X) | | : P(X) | |
| , n_elem(X.n_elem) | | , n_elem(X.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| arma_inline elem_type operator[] (const uword i) const
{ return P[i];
} | | arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | |
| arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | | arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<eT>& X) const { return (void_ptr(&X) | |
| | | == void_ptr(&P)); } | |
| | | | |
| static const bool P_is_vec = true; | | static const bool P_is_vec = true; | |
| | | | |
| const Row<eT>& P; | | const Row<eT>& P; | |
| const uword n_elem; | | const uword n_elem; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class diagmat_proxy< Col<eT> > | | class diagmat_proxy< Col<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 232 | | skipping to change at line 240 | |
| diagmat_proxy(const Col<eT>& X) | | diagmat_proxy(const Col<eT>& X) | |
| : P(X) | | : P(X) | |
| , n_elem(X.n_elem) | | , n_elem(X.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | | arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | |
| arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | | arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<eT>& X) const { return (void_ptr(&X) | |
| | | == void_ptr(&P)); } | |
| | | | |
| static const bool P_is_vec = true; | | static const bool P_is_vec = true; | |
| | | | |
| const Col<eT>& P; | | const Col<eT>& P; | |
| const uword n_elem; | | const uword n_elem; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class diagmat_proxy< subview_row<eT> > | | class diagmat_proxy< subview_row<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 257 | | skipping to change at line 267 | |
| diagmat_proxy(const subview_row<eT>& X) | | diagmat_proxy(const subview_row<eT>& X) | |
| : P(X) | | : P(X) | |
| , n_elem(X.n_elem) | | , n_elem(X.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | | arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | |
| arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | | arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<eT>& X) const { return (void_ptr(&X) | |
| | | == void_ptr(&(P.m))); } | |
| | | | |
| static const bool P_is_vec = true; | | static const bool P_is_vec = true; | |
| | | | |
| const subview_row<eT>& P; | | const subview_row<eT>& P; | |
| const uword n_elem; | | const uword n_elem; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class diagmat_proxy< subview_col<eT> > | | class diagmat_proxy< subview_col<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 282 | | skipping to change at line 294 | |
| diagmat_proxy(const subview_col<eT>& X) | | diagmat_proxy(const subview_col<eT>& X) | |
| : P(X) | | : P(X) | |
| , n_elem(X.n_elem) | | , n_elem(X.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | | arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | |
| arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | | arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | |
| | | | |
|
| | | arma_inline bool is_alias(const Mat<eT>& X) const { return (void_ptr(&X) | |
| | | == void_ptr(&(P.m))); } | |
| | | | |
| static const bool P_is_vec = true; | | static const bool P_is_vec = true; | |
| | | | |
| const subview_col<eT>& P; | | const subview_col<eT>& P; | |
| const uword n_elem; | | const uword n_elem; | |
| }; | | }; | |
| | | | |
| // | | // | |
| // | | // | |
| // | | // | |
| | | | |
| | | | |
| skipping to change at line 512 | | skipping to change at line 526 | |
| { | | { | |
| 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; | |
| | | | |
| inline | | inline | |
| diagmat_proxy_check(const subview_col<eT>& X, const Mat<eT>& out) | | diagmat_proxy_check(const subview_col<eT>& X, const Mat<eT>& out) | |
| : P ( const_cast<eT*>(X.colptr(0)), X.n_rows, (&(X.m) == &out), fal
se ) | | : P ( const_cast<eT*>(X.colptr(0)), X.n_rows, (&(X.m) == &out), fal
se ) | |
| , n_elem( X.n_elem ) | | , n_elem( X.n_elem ) | |
|
| //, X_ref ( X ) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | | arma_inline elem_type operator[] (const uword i) const
{ return P[i]; } | |
| arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | | arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); } | |
| | | | |
| static const bool P_is_vec = true; | | static const bool P_is_vec = true; | |
| | | | |
| const Col<eT> P; | | const Col<eT> P; | |
| const uword n_elem; | | const uword n_elem; | |
|
| | | | |
| //const subview_col<eT>& X_ref; // prevents the compiler from potential | | | |
| ly deleting X before we're done with it | | | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 11 change blocks. |
| 7 lines changed or deleted | | 23 lines changed or added | |
|
| glue_times_meat.hpp | | glue_times_meat.hpp | |
|
| // Copyright (C) 2008-2013 Conrad Sanderson | | // Copyright (C) 2008-2014 Conrad Sanderson | |
| // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-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 glue_times | | //! \addtogroup glue_times | |
| //! @{ | | //! @{ | |
| | | | |
| template<bool is_eT_blas_type> | | template<bool is_eT_blas_type> | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect2_helper<is_eT_blas_type>::apply(Mat<typename T1::elem_t
ype>& out, const Glue<T1,T2,glue_times>& X) | | glue_times_redirect2_helper<is_eT_blas_type>::apply(Mat<typename T1::elem_t
ype>& out, const Glue<T1,T2,glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const partial_unwrap_check<T1> tmp1(X.A, out); | | const partial_unwrap<T1> tmp1(X.A); | |
| const partial_unwrap_check<T2> tmp2(X.B, out); | | const partial_unwrap<T2> tmp2(X.B); | |
| | | | |
|
| const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | | const typename partial_unwrap<T1>::stored_type& A = tmp1.M; | |
| const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | | const typename partial_unwrap<T2>::stored_type& B = tmp2.M; | |
| | | | |
|
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times; | | const bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>
::do_times; | |
| const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) : eT
(0); | | const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) : eT
(0); | |
| | | | |
|
| glue_times::apply | | const bool alias = tmp1.is_alias(out) || tmp2.is_alias(out); | |
| < | | | |
| eT, | | if(alias == false) | |
| partial_unwrap_check<T1>::do_trans, | | { | |
| partial_unwrap_check<T2>::do_trans, | | glue_times::apply | |
| (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim | | < | |
| es) | | eT, | |
| > | | partial_unwrap<T1>::do_trans, | |
| (out, A, B, alpha); | | partial_unwrap<T2>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times) | |
| | | > | |
| | | (out, A, B, alpha); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_times::apply | |
| | | < | |
| | | eT, | |
| | | partial_unwrap<T1>::do_trans, | |
| | | partial_unwrap<T2>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times) | |
| | | > | |
| | | (tmp, A, B, alpha); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect2_helper<true>::apply(Mat<typename T1::elem_type>& out,
const Glue<T1,T2,glue_times>& X) | | glue_times_redirect2_helper<true>::apply(Mat<typename T1::elem_type>& out,
const Glue<T1,T2,glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| if(strip_inv<T1>::do_inv == false) | | if(strip_inv<T1>::do_inv == false) | |
| { | | { | |
|
| const partial_unwrap_check<T1> tmp1(X.A, out); | | const partial_unwrap<T1> tmp1(X.A); | |
| const partial_unwrap_check<T2> tmp2(X.B, out); | | const partial_unwrap<T2> tmp2(X.B); | |
| | | | |
|
| const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | | const typename partial_unwrap<T1>::stored_type& A = tmp1.M; | |
| const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | | const typename partial_unwrap<T2>::stored_type& B = tmp2.M; | |
| | | | |
|
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_un
wrap_check<T2>::do_times; | | const bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T
2>::do_times; | |
| const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) :
eT(0); | | const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) :
eT(0); | |
| | | | |
|
| glue_times::apply | | const bool alias = tmp1.is_alias(out) || tmp2.is_alias(out); | |
| < | | | |
| eT, | | if(alias == false) | |
| partial_unwrap_check<T1>::do_trans, | | { | |
| partial_unwrap_check<T2>::do_trans, | | glue_times::apply | |
| (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_t | | < | |
| imes) | | eT, | |
| > | | partial_unwrap<T1>::do_trans, | |
| (out, A, B, alpha); | | partial_unwrap<T2>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times) | |
| | | > | |
| | | (out, A, B, alpha); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_times::apply | |
| | | < | |
| | | eT, | |
| | | partial_unwrap<T1>::do_trans, | |
| | | partial_unwrap<T2>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times) | |
| | | > | |
| | | (tmp, A, B, alpha); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| arma_extra_debug_print("glue_times_redirect<2>::apply(): detected inv(A
)*B"); | | arma_extra_debug_print("glue_times_redirect<2>::apply(): detected inv(A
)*B"); | |
| | | | |
| const strip_inv<T1> A_strip(X.A); | | const strip_inv<T1> A_strip(X.A); | |
| | | | |
| Mat<eT> A = A_strip.M; | | Mat<eT> A = A_strip.M; | |
| | | | |
| arma_debug_check( (A.is_square() == false), "inv(): given matrix is not
square" ); | | arma_debug_check( (A.is_square() == false), "inv(): given matrix is not
square" ); | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 142 | |
| void | | void | |
| glue_times_redirect3_helper<is_eT_blas_type>::apply(Mat<typename T1::elem_t
ype>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) | | glue_times_redirect3_helper<is_eT_blas_type>::apply(Mat<typename T1::elem_t
ype>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| // we have exactly 3 objects | | // we have exactly 3 objects | |
| // hence we can safely expand X as X.A.A, X.A.B and X.B | | // hence we can safely expand X as X.A.A, X.A.B and X.B | |
| | | | |
|
| const partial_unwrap_check<T1> tmp1(X.A.A, out); | | const partial_unwrap<T1> tmp1(X.A.A); | |
| const partial_unwrap_check<T2> tmp2(X.A.B, out); | | const partial_unwrap<T2> tmp2(X.A.B); | |
| const partial_unwrap_check<T3> tmp3(X.B, out); | | const partial_unwrap<T3> tmp3(X.B ); | |
| | | | |
| const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | | const typename partial_unwrap<T1>::stored_type& A = tmp1.M; | |
| const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | | const typename partial_unwrap<T2>::stored_type& B = tmp2.M; | |
| const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M; | | const typename partial_unwrap<T3>::stored_type& C = tmp3.M; | |
| | | | |
|
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || partial_unwrap_check<T3>::do_times; | | const bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>
::do_times || partial_unwrap<T3>::do_times; | |
| const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp
3.get_val()) : eT(0); | | const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp
3.get_val()) : eT(0); | |
| | | | |
|
| glue_times::apply | | const bool alias = tmp1.is_alias(out) || tmp2.is_alias(out) || tmp3.is_al | |
| < | | ias(out); | |
| eT, | | | |
| partial_unwrap_check<T1>::do_trans, | | if(alias == false) | |
| partial_unwrap_check<T2>::do_trans, | | { | |
| partial_unwrap_check<T3>::do_trans, | | glue_times::apply | |
| (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim | | < | |
| es || partial_unwrap_check<T3>::do_times) | | eT, | |
| > | | partial_unwrap<T1>::do_trans, | |
| (out, A, B, C, alpha); | | partial_unwrap<T2>::do_trans, | |
| | | partial_unwrap<T3>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || part | |
| | | ial_unwrap<T3>::do_times) | |
| | | > | |
| | | (out, A, B, C, alpha); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_times::apply | |
| | | < | |
| | | eT, | |
| | | partial_unwrap<T1>::do_trans, | |
| | | partial_unwrap<T2>::do_trans, | |
| | | partial_unwrap<T3>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || part | |
| | | ial_unwrap<T3>::do_times) | |
| | | > | |
| | | (tmp, A, B, C, alpha); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename T3> | | template<typename T1, typename T2, typename T3> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect3_helper<true>::apply(Mat<typename T1::elem_type>& out,
const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) | | glue_times_redirect3_helper<true>::apply(Mat<typename T1::elem_type>& out,
const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // TODO: investigate detecting inv(A)*B*C and replacing with solve(A,B)*C | | // TODO: investigate detecting inv(A)*B*C and replacing with solve(A,B)*C | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| if(strip_inv<T2>::do_inv == false) | | if(strip_inv<T2>::do_inv == false) | |
| { | | { | |
| // we have exactly 3 objects | | // we have exactly 3 objects | |
| // hence we can safely expand X as X.A.A, X.A.B and X.B | | // hence we can safely expand X as X.A.A, X.A.B and X.B | |
| | | | |
|
| const partial_unwrap_check<T1> tmp1(X.A.A, out); | | const partial_unwrap<T1> tmp1(X.A.A); | |
| const partial_unwrap_check<T2> tmp2(X.A.B, out); | | const partial_unwrap<T2> tmp2(X.A.B); | |
| const partial_unwrap_check<T3> tmp3(X.B, out); | | const partial_unwrap<T3> tmp3(X.B ); | |
| | | | |
| | | const typename partial_unwrap<T1>::stored_type& A = tmp1.M; | |
| | | const typename partial_unwrap<T2>::stored_type& B = tmp2.M; | |
| | | const typename partial_unwrap<T3>::stored_type& C = tmp3.M; | |
| | | | |
|
| const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | | const bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T | |
| const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | | 2>::do_times || partial_unwrap<T3>::do_times; | |
| const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M; | | | |
| | | | |
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_un | | | |
| wrap_check<T2>::do_times || partial_unwrap_check<T3>::do_times; | | | |
| const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * t
mp3.get_val()) : eT(0); | | const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * t
mp3.get_val()) : eT(0); | |
| | | | |
|
| glue_times::apply | | const bool alias = tmp1.is_alias(out) || tmp2.is_alias(out) || tmp3.is_ | |
| < | | alias(out); | |
| eT, | | | |
| partial_unwrap_check<T1>::do_trans, | | if(alias == false) | |
| partial_unwrap_check<T2>::do_trans, | | { | |
| partial_unwrap_check<T3>::do_trans, | | glue_times::apply | |
| (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_t | | < | |
| imes || partial_unwrap_check<T3>::do_times) | | eT, | |
| > | | partial_unwrap<T1>::do_trans, | |
| (out, A, B, C, alpha); | | partial_unwrap<T2>::do_trans, | |
| | | partial_unwrap<T3>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || pa | |
| | | rtial_unwrap<T3>::do_times) | |
| | | > | |
| | | (out, A, B, C, alpha); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_times::apply | |
| | | < | |
| | | eT, | |
| | | partial_unwrap<T1>::do_trans, | |
| | | partial_unwrap<T2>::do_trans, | |
| | | partial_unwrap<T3>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || pa | |
| | | rtial_unwrap<T3>::do_times) | |
| | | > | |
| | | (tmp, A, B, C, alpha); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| // replace A*inv(B)*C with A*solve(B,C) | | // replace A*inv(B)*C with A*solve(B,C) | |
| | | | |
| arma_extra_debug_print("glue_times_redirect<3>::apply(): detected A*inv
(B)*C"); | | arma_extra_debug_print("glue_times_redirect<3>::apply(): detected A*inv
(B)*C"); | |
| | | | |
| const strip_inv<T2> B_strip(X.A.B); | | const strip_inv<T2> B_strip(X.A.B); | |
| | | | |
| Mat<eT> B = B_strip.M; | | Mat<eT> B = B_strip.M; | |
| | | | |
| skipping to change at line 210 | | skipping to change at line 292 | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue<
T1,T2,glue_times>& X) | | glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue<
T1,T2,glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const partial_unwrap_check<T1> tmp1(X.A, out); | | const partial_unwrap<T1> tmp1(X.A); | |
| const partial_unwrap_check<T2> tmp2(X.B, out); | | const partial_unwrap<T2> tmp2(X.B); | |
| | | | |
|
| const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | | const typename partial_unwrap<T1>::stored_type& A = tmp1.M; | |
| const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | | const typename partial_unwrap<T2>::stored_type& B = tmp2.M; | |
| | | | |
|
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times; | | const bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>
::do_times; | |
| const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) : eT
(0); | | const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) : eT
(0); | |
| | | | |
|
| glue_times::apply | | const bool alias = tmp1.is_alias(out) || tmp2.is_alias(out); | |
| < | | | |
| eT, | | if(alias == false) | |
| partial_unwrap_check<T1>::do_trans, | | { | |
| partial_unwrap_check<T2>::do_trans, | | glue_times::apply | |
| (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim | | < | |
| es) | | eT, | |
| > | | partial_unwrap<T1>::do_trans, | |
| (out, A, B, alpha); | | partial_unwrap<T2>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times) | |
| | | > | |
| | | (out, A, B, alpha); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_times::apply | |
| | | < | |
| | | eT, | |
| | | partial_unwrap<T1>::do_trans, | |
| | | partial_unwrap<T2>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times) | |
| | | > | |
| | | (tmp, A, B, alpha); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect<2>::apply(Mat<typename T1::elem_type>& out, const Glue<
T1,T2,glue_times>& X) | | glue_times_redirect<2>::apply(Mat<typename T1::elem_type>& out, const Glue<
T1,T2,glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
| skipping to change at line 268 | | skipping to change at line 370 | |
| void | | void | |
| glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue<
Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X) | | glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue<
Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| // there is exactly 4 objects | | // there is exactly 4 objects | |
| // hence we can safely expand X as X.A.A.A, X.A.A.B, X.A.B and X.B | | // hence we can safely expand X as X.A.A.A, X.A.A.B, X.A.B and X.B | |
| | | | |
|
| const partial_unwrap_check<T1> tmp1(X.A.A.A, out); | | const partial_unwrap<T1> tmp1(X.A.A.A); | |
| const partial_unwrap_check<T2> tmp2(X.A.A.B, out); | | const partial_unwrap<T2> tmp2(X.A.A.B); | |
| const partial_unwrap_check<T3> tmp3(X.A.B, out); | | const partial_unwrap<T3> tmp3(X.A.B ); | |
| const partial_unwrap_check<T4> tmp4(X.B, out); | | const partial_unwrap<T4> tmp4(X.B ); | |
| | | | |
| const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | | const typename partial_unwrap<T1>::stored_type& A = tmp1.M; | |
| const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | | const typename partial_unwrap<T2>::stored_type& B = tmp2.M; | |
| const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M; | | const typename partial_unwrap<T3>::stored_type& C = tmp3.M; | |
| const typename partial_unwrap_check<T4>::stored_type& D = tmp4.M; | | const typename partial_unwrap<T4>::stored_type& D = tmp4.M; | |
| | | | |
|
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || partial_unwrap_check<T3>::do_times || partial_unw
rap_check<T4>::do_times; | | const bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>
::do_times || partial_unwrap<T3>::do_times || partial_unwrap<T4>::do_times; | |
| const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp
3.get_val() * tmp4.get_val()) : eT(0); | | const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp
3.get_val() * tmp4.get_val()) : eT(0); | |
| | | | |
|
| glue_times::apply | | const bool alias = tmp1.is_alias(out) || tmp2.is_alias(out) || tmp3.is_al | |
| < | | ias(out) || tmp4.is_alias(out); | |
| eT, | | | |
| partial_unwrap_check<T1>::do_trans, | | if(alias == false) | |
| partial_unwrap_check<T2>::do_trans, | | { | |
| partial_unwrap_check<T3>::do_trans, | | glue_times::apply | |
| partial_unwrap_check<T4>::do_trans, | | < | |
| (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim | | eT, | |
| es || partial_unwrap_check<T3>::do_times || partial_unwrap_check<T4>::do_ti | | partial_unwrap<T1>::do_trans, | |
| mes) | | partial_unwrap<T2>::do_trans, | |
| > | | partial_unwrap<T3>::do_trans, | |
| (out, A, B, C, D, alpha); | | partial_unwrap<T4>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || part | |
| | | ial_unwrap<T3>::do_times || partial_unwrap<T4>::do_times) | |
| | | > | |
| | | (out, A, B, C, D, alpha); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_times::apply | |
| | | < | |
| | | eT, | |
| | | partial_unwrap<T1>::do_trans, | |
| | | partial_unwrap<T2>::do_trans, | |
| | | partial_unwrap<T3>::do_trans, | |
| | | partial_unwrap<T4>::do_trans, | |
| | | (partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || part | |
| | | ial_unwrap<T3>::do_times || partial_unwrap<T4>::do_times) | |
| | | > | |
| | | (tmp, A, B, C, D, alpha); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t
imes>& X) | | glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t
imes>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
| skipping to change at line 386 | | skipping to change at line 510 | |
| | | | |
| const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || (sign < sword(0)); | | const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || (sign < sword(0)); | |
| | | | |
| const eT alpha = use_alpha ? ( tmp1.get_val() * tmp2.get_val() * (
(sign > sword(0)) ? eT(1) : eT(-1) ) ) : eT(0); | | const eT alpha = use_alpha ? ( tmp1.get_val() * tmp2.get_val() * (
(sign > sword(0)) ? eT(1) : eT(-1) ) ) : eT(0); | |
| | | | |
| arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli
cation"); | | arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli
cation"); | |
| | | | |
| const uword result_n_rows = (do_trans_A == false) ? (TA::is_row ? 1 : A.n
_rows) : (TA::is_col ? 1 : A.n_cols); | | const uword result_n_rows = (do_trans_A == false) ? (TA::is_row ? 1 : A.n
_rows) : (TA::is_col ? 1 : A.n_cols); | |
| const uword result_n_cols = (do_trans_B == false) ? (TB::is_col ? 1 : B.n
_cols) : (TB::is_row ? 1 : B.n_rows); | | const uword result_n_cols = (do_trans_B == false) ? (TB::is_col ? 1 : B.n
_cols) : (TB::is_row ? 1 : B.n_rows); | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result
_n_cols, "addition"); | | arma_debug_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result
_n_cols, ( (sign > sword(0)) ? "addition" : "subtraction" ) ); | |
| | | | |
| if(out.n_elem == 0) | | if(out.n_elem == 0) | |
| { | | { | |
| return; | | return; | |
| } | | } | |
| | | | |
| if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == false
) ) | | if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == false
) ) | |
| { | | { | |
| if( ((A.n_rows == 1) || (TA::is_row)) && (is_cx<eT>::no) ) { gemv
<true, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1
)); } | | if( ((A.n_rows == 1) || (TA::is_row)) && (is_cx<eT>::no) ) { gemv
<true, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1
)); } | |
| else if( (B.n_cols == 1) || (TB::is_col) ) { gemv
<false, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1
)); } | | else if( (B.n_cols == 1) || (TB::is_col) ) { gemv
<false, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1
)); } | |
| | | | |
End of changes. 23 change blocks. |
| 104 lines changed or deleted | | 230 lines changed or added | |
|
| unwrap.hpp | | unwrap.hpp | |
|
| // Copyright (C) 2008-2013 Conrad Sanderson | | // Copyright (C) 2008-2014 Conrad Sanderson | |
| // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-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 unwrap | | //! \addtogroup unwrap | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct unwrap_default | | struct unwrap_default | |
| | | | |
| skipping to change at line 650 | | skipping to change at line 650 | |
| | | | |
| inline | | inline | |
| partial_unwrap_default(const T1& A) | | partial_unwrap_default(const T1& A) | |
| : M(A) | | : M(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return eT(1); } | | arma_hot arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Mat<eT> M; | | const Mat<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_fixed | | struct partial_unwrap_fixed | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| skipping to change at line 671 | | skipping to change at line 673 | |
| | | | |
| inline explicit | | inline explicit | |
| partial_unwrap_fixed(const T1& A) | | partial_unwrap_fixed(const T1& A) | |
| : M(A) | | : M(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return eT(1); } | | arma_hot arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const T1& M; | | const T1& M; | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct partial_unwrap_redirect {}; | | struct partial_unwrap_redirect {}; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
| skipping to change at line 710 | | skipping to change at line 714 | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Mat<eT>& A) | | partial_unwrap(const Mat<eT>& A) | |
| : M(A) | | : M(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(1); } | | inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return ((&X) | |
| | | == (&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Mat<eT>& M; | | const Mat<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Row<eT> > | | struct partial_unwrap< Row<eT> > | |
| { | | { | |
| typedef Row<eT> stored_type; | | typedef Row<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Row<eT>& A) | | partial_unwrap(const Row<eT>& A) | |
| : M(A) | | : M(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(1); } | | inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Row<eT>& M; | | const Row<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Col<eT> > | | struct partial_unwrap< Col<eT> > | |
| { | | { | |
| typedef Col<eT> stored_type; | | typedef Col<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Col<eT>& A) | | partial_unwrap(const Col<eT>& A) | |
| : M(A) | | : M(A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(1); } | | inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Col<eT>& M; | | const Col<eT>& M; | |
| }; | | }; | |
| | | | |
|
| // NOTE: we can get away with this shortcut as the partial_unwrap class is | | | |
| only used by as_scalar(), | | | |
| // NOTE: which doesn't need to check for aliasing (ie. it doesn't need to c | | | |
| ompare the address of M with another matrix) | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< subview_col<eT> > | | struct partial_unwrap< subview_col<eT> > | |
| { | | { | |
| typedef Col<eT> stored_type; | | typedef Col<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const subview_col<eT>& A) | | partial_unwrap(const subview_col<eT>& A) | |
|
| : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, false, false ) | | : orig( A.m ) | |
| | | , M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, false, false ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(1); } | | inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&orig)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
|
| const Col<eT> M; | | const Mat<eT>& orig; | |
| | | const Col<eT> M; | |
| | | }; | |
| | | | |
| | | template<typename eT> | |
| | | struct partial_unwrap< subview_row<eT> > | |
| | | { | |
| | | typedef Row<eT> stored_type; | |
| | | | |
| | | inline | |
| | | partial_unwrap(const subview_row<eT>& A) | |
| | | : M(A) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | inline eT get_val() const { return eT(1); } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| | | static const bool do_trans = false; | |
| | | static const bool do_times = false; | |
| | | | |
| | | const Row<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_htrans_default | | struct partial_unwrap_htrans_default | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef Mat<eT> stored_type; | | typedef Mat<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap_htrans_default(const Op<T1, op_htrans>& A) | | partial_unwrap_htrans_default(const Op<T1, op_htrans>& A) | |
| : M(A.m) | | : M(A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return eT(1); } | | arma_hot arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Mat<eT> M; | | const Mat<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_htrans_fixed | | struct partial_unwrap_htrans_fixed | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| skipping to change at line 814 | | skipping to change at line 850 | |
| | | | |
| inline explicit | | inline explicit | |
| partial_unwrap_htrans_fixed(const Op<T1, op_htrans>& A) | | partial_unwrap_htrans_fixed(const Op<T1, op_htrans>& A) | |
| : M(A.m) | | : M(A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return eT(1); } | | arma_hot arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const T1& M; | | const T1& M; | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct partial_unwrap_htrans_redirect {}; | | struct partial_unwrap_htrans_redirect {}; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
| skipping to change at line 852 | | skipping to change at line 890 | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Op< Mat<eT>, op_htrans>& A) | | partial_unwrap(const Op< Mat<eT>, op_htrans>& A) | |
| : M(A.m) | | : M(A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline eT get_val() const { return eT(1); } | | arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Mat<eT>& M; | | const Mat<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Op< Row<eT>, op_htrans> > | | struct partial_unwrap< Op< Row<eT>, op_htrans> > | |
| { | | { | |
| typedef Row<eT> stored_type; | | typedef Row<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Op< Row<eT>, op_htrans>& A) | | partial_unwrap(const Op< Row<eT>, op_htrans>& A) | |
| : M(A.m) | | : M(A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline eT get_val() const { return eT(1); } | | arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Row<eT>& M; | | const Row<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Op< Col<eT>, op_htrans> > | | struct partial_unwrap< Op< Col<eT>, op_htrans> > | |
| { | | { | |
| typedef Col<eT> stored_type; | | typedef Col<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Op< Col<eT>, op_htrans>& A) | | partial_unwrap(const Op< Col<eT>, op_htrans>& A) | |
| : M(A.m) | | : M(A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline eT get_val() const { return eT(1); } | | arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
| const Col<eT>& M; | | const Col<eT>& M; | |
| }; | | }; | |
| | | | |
|
| // NOTE: we can get away with this shortcut as the partial_unwrap class is | | | |
| only used by as_scalar(), | | | |
| // NOTE: which doesn't need to check for aliasing (ie. it doesn't need to c | | | |
| ompare the address of M with another matrix) | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Op< subview_col<eT>, op_htrans> > | | struct partial_unwrap< Op< subview_col<eT>, op_htrans> > | |
| { | | { | |
| typedef Col<eT> stored_type; | | typedef Col<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Op< subview_col<eT>, op_htrans>& A) | | partial_unwrap(const Op< subview_col<eT>, op_htrans>& A) | |
|
| : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false ) | | : orig( A.m.m ) | |
| | | , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline eT get_val() const { return eT(1); } | | arma_inline eT get_val() const { return eT(1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&orig)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = false; | | static const bool do_times = false; | |
| | | | |
|
| const Col<eT> M; | | const Mat<eT>& orig; | |
| | | const Col<eT> M; | |
| | | }; | |
| | | | |
| | | template<typename eT> | |
| | | struct partial_unwrap< Op< subview_row<eT>, op_htrans> > | |
| | | { | |
| | | typedef Row<eT> stored_type; | |
| | | | |
| | | inline | |
| | | partial_unwrap(const Op< subview_row<eT>, op_htrans>& A) | |
| | | : M(A.m) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_inline eT get_val() const { return eT(1); } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| | | static const bool do_trans = true; | |
| | | static const bool do_times = false; | |
| | | | |
| | | const Row<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_htrans2_default | | struct partial_unwrap_htrans2_default | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef Mat<eT> stored_type; | | typedef Mat<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap_htrans2_default(const Op<T1, op_htrans2>& A) | | partial_unwrap_htrans2_default(const Op<T1, op_htrans2>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.m) | | , M (A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline eT get_val() const { return val; } | | arma_inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Mat<eT> M; | | const Mat<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_htrans2_fixed | | struct partial_unwrap_htrans2_fixed | |
| { | | { | |
| | | | |
| skipping to change at line 959 | | skipping to change at line 1029 | |
| inline explicit | | inline explicit | |
| partial_unwrap_htrans2_fixed(const Op<T1, op_htrans2>& A) | | partial_unwrap_htrans2_fixed(const Op<T1, op_htrans2>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.m) | | , M (A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline eT get_val() const { return val; } | | arma_inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const T1& M; | | const T1& M; | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct partial_unwrap_htrans2_redirect {}; | | struct partial_unwrap_htrans2_redirect {}; | |
| | | | |
| | | | |
| skipping to change at line 999 | | skipping to change at line 1071 | |
| inline | | inline | |
| partial_unwrap(const Op< Mat<eT>, op_htrans2>& A) | | partial_unwrap(const Op< Mat<eT>, op_htrans2>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.m) | | , M (A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Mat<eT>& M; | | const Mat<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Op< Row<eT>, op_htrans2> > | | struct partial_unwrap< Op< Row<eT>, op_htrans2> > | |
| { | | { | |
| | | | |
| skipping to change at line 1021 | | skipping to change at line 1095 | |
| inline | | inline | |
| partial_unwrap(const Op< Row<eT>, op_htrans2>& A) | | partial_unwrap(const Op< Row<eT>, op_htrans2>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.m) | | , M (A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Row<eT>& M; | | const Row<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Op< Col<eT>, op_htrans2> > | | struct partial_unwrap< Op< Col<eT>, op_htrans2> > | |
| { | | { | |
| | | | |
| skipping to change at line 1043 | | skipping to change at line 1119 | |
| inline | | inline | |
| partial_unwrap(const Op< Col<eT>, op_htrans2>& A) | | partial_unwrap(const Op< Col<eT>, op_htrans2>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.m) | | , M (A.m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Col<eT>& M; | | const Col<eT>& M; | |
| }; | | }; | |
| | | | |
|
| // NOTE: we can get away with this shortcut as the partial_unwrap class is | | | |
| only used by as_scalar(), | | | |
| // NOTE: which doesn't need to check for aliasing (ie. it doesn't need to c | | | |
| ompare the address of M with another matrix) | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< Op< subview_col<eT>, op_htrans2> > | | struct partial_unwrap< Op< subview_col<eT>, op_htrans2> > | |
| { | | { | |
| typedef Col<eT> stored_type; | | typedef Col<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const Op< subview_col<eT>, op_htrans2>& A) | | partial_unwrap(const Op< subview_col<eT>, op_htrans2>& A) | |
|
| : val( A.aux ) | | : orig( A.m.m ) | |
| , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false ) | | , val ( A.aux ) | |
| | | , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&orig)); } | |
| | | | |
| static const bool do_trans = true; | | static const bool do_trans = true; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
|
| | | const Mat<eT>& orig; | |
| | | | |
| const eT val; | | const eT val; | |
| const Col<eT> M; | | const Col<eT> M; | |
| }; | | }; | |
| | | | |
|
| | | template<typename eT> | |
| | | struct partial_unwrap< Op< subview_row<eT>, op_htrans2> > | |
| | | { | |
| | | typedef Row<eT> stored_type; | |
| | | | |
| | | inline | |
| | | partial_unwrap(const Op< subview_row<eT>, op_htrans2>& A) | |
| | | : val(A.aux) | |
| | | , M (A.m ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | inline eT get_val() const { return val; } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| | | static const bool do_trans = true; | |
| | | static const bool do_times = true; | |
| | | | |
| | | const eT val; | |
| | | const Row<eT> M; | |
| | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_scalar_times_default | | struct partial_unwrap_scalar_times_default | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef Mat<eT> stored_type; | | typedef Mat<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap_scalar_times_default(const eOp<T1, eop_scalar_times>& A) | | partial_unwrap_scalar_times_default(const eOp<T1, eop_scalar_times>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.P.Q) | | , M (A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return val; } | | arma_hot arma_inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Mat<eT> M; | | const Mat<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_scalar_times_fixed | | struct partial_unwrap_scalar_times_fixed | |
| { | | { | |
| | | | |
| skipping to change at line 1113 | | skipping to change at line 1220 | |
| inline explicit | | inline explicit | |
| partial_unwrap_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A) | | partial_unwrap_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.P.Q) | | , M (A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return val; } | | arma_hot arma_inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const T1& M; | | const T1& M; | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct partial_unwrap_scalar_times_redirect {}; | | struct partial_unwrap_scalar_times_redirect {}; | |
| | | | |
| | | | |
| skipping to change at line 1156 | | skipping to change at line 1265 | |
| inline | | inline | |
| partial_unwrap(const eOp<Mat<eT>,eop_scalar_times>& A) | | partial_unwrap(const eOp<Mat<eT>,eop_scalar_times>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.P.Q) | | , M (A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Mat<eT>& M; | | const Mat<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< eOp<Row<eT>, eop_scalar_times> > | | struct partial_unwrap< eOp<Row<eT>, eop_scalar_times> > | |
| { | | { | |
| | | | |
| skipping to change at line 1178 | | skipping to change at line 1289 | |
| inline | | inline | |
| partial_unwrap(const eOp<Row<eT>,eop_scalar_times>& A) | | partial_unwrap(const eOp<Row<eT>,eop_scalar_times>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.P.Q) | | , M (A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Row<eT>& M; | | const Row<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< eOp<Col<eT>, eop_scalar_times> > | | struct partial_unwrap< eOp<Col<eT>, eop_scalar_times> > | |
| { | | { | |
| | | | |
| skipping to change at line 1200 | | skipping to change at line 1313 | |
| inline | | inline | |
| partial_unwrap(const eOp<Col<eT>,eop_scalar_times>& A) | | partial_unwrap(const eOp<Col<eT>,eop_scalar_times>& A) | |
| : val(A.aux) | | : val(A.aux) | |
| , M (A.P.Q) | | , M (A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return val; } | | inline eT get_val() const { return val; } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const eT val; | | const eT val; | |
| const Col<eT>& M; | | const Col<eT>& M; | |
| }; | | }; | |
| | | | |
|
| // TODO: struct partial_unwrap< eOp<subview_col<eT>, eop_scalar_times> > | | template<typename eT> | |
| | | struct partial_unwrap< eOp<subview_col<eT>, eop_scalar_times> > | |
| | | { | |
| | | typedef Col<eT> stored_type; | |
| | | | |
| | | arma_hot inline | |
| | | partial_unwrap(const eOp<subview_col<eT>,eop_scalar_times>& A) | |
| | | : orig( A.P.Q.m ) | |
| | | , val ( A.aux ) | |
| | | , M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, false, false | |
| | | ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_hot arma_inline eT get_val() const { return val; } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&orig)); } | |
| | | | |
| | | static const bool do_trans = false; | |
| | | static const bool do_times = true; | |
| | | | |
| | | const Mat<eT>& orig; | |
| | | | |
| | | const eT val; | |
| | | const Col<eT> M; | |
| | | }; | |
| | | | |
| | | template<typename eT> | |
| | | struct partial_unwrap< eOp<subview_row<eT>, eop_scalar_times> > | |
| | | { | |
| | | typedef Row<eT> stored_type; | |
| | | | |
| | | arma_hot inline | |
| | | partial_unwrap(const eOp<subview_row<eT>,eop_scalar_times>& A) | |
| | | : val(A.aux) | |
| | | , M (A.P.Q) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_hot arma_inline eT get_val() const { return val; } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| | | static const bool do_trans = false; | |
| | | static const bool do_times = true; | |
| | | | |
| | | const eT val; | |
| | | const Row<eT> M; | |
| | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_neg_default | | struct partial_unwrap_neg_default | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef Mat<eT> stored_type; | | typedef Mat<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap_neg_default(const eOp<T1, eop_neg>& A) | | partial_unwrap_neg_default(const eOp<T1, eop_neg>& A) | |
| : M(A.P.Q) | | : M(A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return eT(-1); } | | arma_hot arma_inline eT get_val() const { return eT(-1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const Mat<eT> M; | | const Mat<eT> M; | |
| }; | | }; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_neg_fixed | | struct partial_unwrap_neg_fixed | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| skipping to change at line 1245 | | skipping to change at line 1411 | |
| | | | |
| inline explicit | | inline explicit | |
| partial_unwrap_neg_fixed(const eOp<T1, eop_neg>& A) | | partial_unwrap_neg_fixed(const eOp<T1, eop_neg>& A) | |
| : M(A.P.Q) | | : M(A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_hot arma_inline eT get_val() const { return eT(-1); } | | arma_hot arma_inline eT get_val() const { return eT(-1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const T1& M; | | const T1& M; | |
| }; | | }; | |
| | | | |
| template<typename T1, bool condition> | | template<typename T1, bool condition> | |
| struct partial_unwrap_neg_redirect {}; | | struct partial_unwrap_neg_redirect {}; | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
| skipping to change at line 1286 | | skipping to change at line 1454 | |
| | | | |
| inline | | inline | |
| partial_unwrap(const eOp<Mat<eT>,eop_neg>& A) | | partial_unwrap(const eOp<Mat<eT>,eop_neg>& A) | |
| : M(A.P.Q) | | : M(A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(-1); } | | inline eT get_val() const { return eT(-1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const Mat<eT>& M; | | const Mat<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< eOp<Row<eT>, eop_neg> > | | struct partial_unwrap< eOp<Row<eT>, eop_neg> > | |
| { | | { | |
| typedef Row<eT> stored_type; | | typedef Row<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const eOp<Row<eT>,eop_neg>& A) | | partial_unwrap(const eOp<Row<eT>,eop_neg>& A) | |
| : M(A.P.Q) | | : M(A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(-1); } | | inline eT get_val() const { return eT(-1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const Row<eT>& M; | | const Row<eT>& M; | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| struct partial_unwrap< eOp<Col<eT>, eop_neg> > | | struct partial_unwrap< eOp<Col<eT>, eop_neg> > | |
| { | | { | |
| typedef Col<eT> stored_type; | | typedef Col<eT> stored_type; | |
| | | | |
| inline | | inline | |
| partial_unwrap(const eOp<Col<eT>,eop_neg>& A) | | partial_unwrap(const eOp<Col<eT>,eop_neg>& A) | |
| : M(A.P.Q) | | : M(A.P.Q) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| inline eT get_val() const { return eT(-1); } | | inline eT get_val() const { return eT(-1); } | |
| | | | |
|
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&M)); } | |
| | | | |
| static const bool do_trans = false; | | static const bool do_trans = false; | |
| static const bool do_times = true; | | static const bool do_times = true; | |
| | | | |
| const Col<eT>& M; | | const Col<eT>& M; | |
| }; | | }; | |
| | | | |
|
| // TODO: struct partial_unwrap< eOp<subview_col<eT>, eop_neg> > | | template<typename eT> | |
| | | struct partial_unwrap< eOp<subview_col<eT>, eop_neg> > | |
| | | { | |
| | | typedef Col<eT> stored_type; | |
| | | | |
| | | inline | |
| | | partial_unwrap(const eOp<subview_col<eT>,eop_neg>& A) | |
| | | : orig( A.P.Q.m ) | |
| | | , M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, false, false | |
| | | ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_hot arma_inline eT get_val() const { return eT(-1); } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>& X) const { return (void | |
| | | _ptr(&X) == void_ptr(&orig)); } | |
| | | | |
| | | static const bool do_trans = false; | |
| | | static const bool do_times = true; | |
| | | | |
| | | const Mat<eT>& orig; | |
| | | const Col<eT> M; | |
| | | }; | |
| | | | |
| | | template<typename eT> | |
| | | struct partial_unwrap< eOp<subview_row<eT>, eop_neg> > | |
| | | { | |
| | | typedef Row<eT> stored_type; | |
| | | | |
| | | inline | |
| | | partial_unwrap(const eOp<subview_row<eT>,eop_neg>& A) | |
| | | : M(A.P.Q) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | arma_hot arma_inline eT get_val() const { return eT(-1); } | |
| | | | |
| | | arma_hot arma_inline bool is_alias(const Mat<eT>&) const { return false; | |
| | | } | |
| | | | |
| | | static const bool do_trans = false; | |
| | | static const bool do_times = true; | |
| | | | |
| | | const Row<eT> M; | |
| | | }; | |
| | | | |
| // | | // | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| struct partial_unwrap_check_default | | struct partial_unwrap_check_default | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef Mat<eT> stored_type; | | typedef Mat<eT> stored_type; | |
| | | | |
| inline | | inline | |
| | | | |
End of changes. 41 change blocks. |
| 22 lines changed or deleted | | 271 lines changed or added | |
|