Col_bones.hpp | Col_bones.hpp | |||
---|---|---|---|---|
skipping to change at line 164 | skipping to change at line 164 | |||
inline fixed(const char* text); | inline fixed(const char* text); | |||
inline fixed(const std::string& text); | inline fixed(const std::string& text); | |||
template<typename T1> inline const Col& operator=(const Base<eT,T1>& A); | template<typename T1> inline const Col& operator=(const Base<eT,T1>& A); | |||
inline const Col& operator=(const eT val); | inline const Col& operator=(const eT val); | |||
inline const Col& operator=(const char* text); | inline const Col& operator=(const char* text); | |||
inline const Col& operator=(const std::string& text); | inline const Col& operator=(const std::string& text); | |||
inline const Col& operator=(const subview_cube<eT>& X); | inline const Col& operator=(const subview_cube<eT>& X); | |||
#if !defined(ARMA_GCC47_BUG) | using Col<eT>::operator(); | |||
using Col<eT>::operator(); | ||||
#endif | ||||
#if defined(ARMA_USE_CXX11) | #if defined(ARMA_USE_CXX11) | |||
inline fixed(const std::initializer_list<eT>& list); | inline fixed(const std::initializer_list<eT>& list); | |||
inline const Col& operator=(const std::initializer_list<eT>& list); | inline const Col& operator=(const std::initializer_list<eT>& list); | |||
#endif | #endif | |||
arma_inline arma_warn_unused eT& operator[] (const uword i); | arma_inline arma_warn_unused eT& operator[] (const uword i); | |||
arma_inline arma_warn_unused eT operator[] (const uword i) const; | arma_inline arma_warn_unused eT operator[] (const uword i) const; | |||
arma_inline arma_warn_unused eT& at (const uword i); | arma_inline arma_warn_unused eT& at (const uword i); | |||
arma_inline arma_warn_unused eT at (const uword i) const; | arma_inline arma_warn_unused eT at (const uword i) const; | |||
End of changes. 1 change blocks. | ||||
3 lines changed or deleted | 1 lines changed or added | |||
Cube_bones.hpp | Cube_bones.hpp | |||
---|---|---|---|---|
skipping to change at line 257 | skipping to change at line 257 | |||
inline bool quiet_load( std::istream& is, const file_type type = a uto_detect); | inline bool quiet_load( std::istream& is, const file_type type = a uto_detect); | |||
// iterators | // iterators | |||
typedef eT* iterator; | typedef eT* iterator; | |||
typedef const eT* const_iterator; | typedef const eT* const_iterator; | |||
typedef eT* slice_iterator; | typedef eT* slice_iterator; | |||
typedef const eT* const_slice_iterator; | typedef const eT* const_slice_iterator; | |||
inline iterator begin(); | inline iterator begin(); | |||
inline const_iterator begin() const; | inline const_iterator begin() const; | |||
inline const_iterator cbegin() const; | ||||
inline iterator end(); | ||||
inline const_iterator end() const; | inline iterator end(); | |||
inline const_iterator end() const; | ||||
inline const_iterator cend() const; | ||||
inline slice_iterator begin_slice(const uword slice_num); | inline slice_iterator begin_slice(const uword slice_num); | |||
inline const_slice_iterator begin_slice(const uword slice_num) const; | inline const_slice_iterator begin_slice(const uword slice_num) const; | |||
inline slice_iterator end_slice(const uword slice_num); | inline slice_iterator end_slice(const uword slice_num); | |||
inline const_slice_iterator end_slice(const uword slice_num) const; | inline const_slice_iterator end_slice(const uword slice_num) const; | |||
inline void clear(); | inline void clear(); | |||
inline bool empty() const; | inline bool empty() const; | |||
inline uword size() const; | inline uword size() const; | |||
skipping to change at line 307 | skipping to change at line 309 | |||
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_PROTO) | #include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_PROTO) | |||
#endif | #endif | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | |||
class Cube<eT>::fixed : public Cube<eT> | class Cube<eT>::fixed : public Cube<eT> | |||
{ | { | |||
private: | private: | |||
static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n_s | static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols * fix | |||
lices; | ed_n_slices; | |||
static const uword fixed_n_elem_slice = fixed_n_rows * fixed_n_cols; | ||||
static const bool use_extra = (fixed_n_elem > Cube_prealloc::mem_n_elem); | ||||
arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_preall oc::mat_ptrs_size) ? fixed_n_slices : 1 ]; | arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_preall oc::mat_ptrs_size) ? fixed_n_slices : 1 ]; | |||
arma_aligned eT mem_local_extra [ (fixed_n_elem > Cube_preall oc::mem_n_elem) ? fixed_n_elem : 1 ]; | arma_aligned eT mem_local_extra [ use_extra ? fixed_n_elem : 1 ]; | |||
arma_inline void mem_setup(); | arma_inline void mem_setup(); | |||
public: | public: | |||
inline fixed() { mem_setup(); } | inline fixed() { mem_setup(); } | |||
inline const Cube& operator=(const eT val) { mem_setup(); Cube<eT>::opera tor=(val); return *this; } | inline const Cube& operator=(const eT val) { mem_setup(); Cube<eT>::opera tor=(val); return *this; } | |||
template<typename T1> | template<typename T1> | |||
inline fixed(const BaseCube<eT,T1>& A) { mem_setup(); Cube<eT>::operator= (A.get_ref()); } | inline fixed(const BaseCube<eT,T1>& A) { mem_setup(); Cube<eT>::operator= (A.get_ref()); } | |||
template<typename T1> | template<typename T1> | |||
inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::operat or=(A.get_ref()); return *this; } | inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::operat or=(A.get_ref()); return *this; } | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<pod_ type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); } | inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<pod_ type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); } | |||
// using Cube<eT>::operator(); | using Cube<eT>::operator(); | |||
// TODO: overload operator(), operator[] and .at() to allow faster elemen | ||||
t access | arma_inline arma_warn_unused eT& operator[] (const uword i); | |||
arma_inline arma_warn_unused eT operator[] (const uword i) const; | ||||
arma_inline arma_warn_unused eT& at (const uword i); | ||||
arma_inline arma_warn_unused eT at (const uword i) const; | ||||
arma_inline arma_warn_unused eT& operator() (const uword i); | ||||
arma_inline arma_warn_unused eT operator() (const uword i) const; | ||||
arma_inline arma_warn_unused eT& at (const uword in_row, const uw | ||||
ord in_col, const uword in_slice); | ||||
arma_inline arma_warn_unused eT at (const uword in_row, const uw | ||||
ord in_col, const uword in_slice) const; | ||||
arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw | ||||
ord in_col, const uword in_slice); | ||||
arma_inline arma_warn_unused eT operator() (const uword in_row, const uw | ||||
ord in_col, const uword in_slice) const; | ||||
}; | }; | |||
class Cube_aux | class Cube_aux | |||
{ | { | |||
public: | public: | |||
template<typename eT> arma_inline static void prefix_pp(Cube<eT>& x); | template<typename eT> arma_inline static void prefix_pp(Cube<eT>& x); | |||
template<typename T> arma_inline static void prefix_pp(Cube< std::comple x<T> >& x); | template<typename T> arma_inline static void prefix_pp(Cube< std::comple x<T> >& x); | |||
template<typename eT> arma_inline static void postfix_pp(Cube<eT>& x); | template<typename eT> arma_inline static void postfix_pp(Cube<eT>& x); | |||
End of changes. 4 change blocks. | ||||
11 lines changed or deleted | 33 lines changed or added | |||
Cube_meat.hpp | Cube_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 237 | skipping to change at line 237 | |||
inline | inline | |||
void | void | |||
Cube<eT>::init | Cube<eT>::init | |||
( | ( | |||
const BaseCube<typename Cube<eT>::pod_type,T1>& X, | const BaseCube<typename Cube<eT>::pod_type,T1>& X, | |||
const BaseCube<typename Cube<eT>::pod_type,T2>& Y | const BaseCube<typename Cube<eT>::pod_type,T2>& Y | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type T; | typedef typename T1::elem_type T; | |||
arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex | arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex | |||
arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex | arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex | |||
arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible | arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible | |||
const ProxyCube<T1> PX(X.get_ref()); | const ProxyCube<T1> PX(X.get_ref()); | |||
const ProxyCube<T2> PY(Y.get_ref()); | const ProxyCube<T2> PY(Y.get_ref()); | |||
arma_assert_same_size(PX, PY, "Cube()"); | arma_debug_assert_same_size(PX, PY, "Cube()"); | |||
const uword local_n_rows = PX.get_n_rows(); | const uword local_n_rows = PX.get_n_rows(); | |||
const uword local_n_cols = PX.get_n_cols(); | const uword local_n_cols = PX.get_n_cols(); | |||
const uword local_n_slices = PX.get_n_slices(); | const uword local_n_slices = PX.get_n_slices(); | |||
init_warm(local_n_rows, local_n_cols, local_n_slices); | init_warm(local_n_rows, local_n_cols, local_n_slices); | |||
eT* out_mem = (*this).memptr(); | eT* out_mem = (*this).memptr(); | |||
const bool prefer_at_accessor = ( ProxyCube<T1>::prefer_at_accessor || Pr oxyCube<T2>::prefer_at_accessor ); | const bool prefer_at_accessor = ( ProxyCube<T1>::prefer_at_accessor || Pr oxyCube<T2>::prefer_at_accessor ); | |||
skipping to change at line 500 | skipping to change at line 500 | |||
} | } | |||
//! in-place cube addition | //! in-place cube addition | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
const Cube<eT>& | const Cube<eT>& | |||
Cube<eT>::operator+=(const Cube<eT>& m) | Cube<eT>::operator+=(const Cube<eT>& m) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_assert_same_size(*this, m, "cube addition"); | arma_debug_assert_same_size(*this, m, "addition"); | |||
arrayops::inplace_plus( memptr(), m.memptr(), n_elem ); | arrayops::inplace_plus( memptr(), m.memptr(), n_elem ); | |||
return *this; | return *this; | |||
} | } | |||
//! in-place cube subtraction | //! in-place cube subtraction | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
const Cube<eT>& | const Cube<eT>& | |||
Cube<eT>::operator-=(const Cube<eT>& m) | Cube<eT>::operator-=(const Cube<eT>& m) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_assert_same_size(*this, m, "cube subtraction"); | arma_debug_assert_same_size(*this, m, "subtraction"); | |||
arrayops::inplace_minus( memptr(), m.memptr(), n_elem ); | arrayops::inplace_minus( memptr(), m.memptr(), n_elem ); | |||
return *this; | return *this; | |||
} | } | |||
//! in-place element-wise cube multiplication | //! in-place element-wise cube multiplication | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
const Cube<eT>& | const Cube<eT>& | |||
Cube<eT>::operator%=(const Cube<eT>& m) | Cube<eT>::operator%=(const Cube<eT>& m) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_assert_same_size(*this, m, "element-wise cube multiplication") ; | arma_debug_assert_same_size(*this, m, "element-wise multiplication"); | |||
arrayops::inplace_mul( memptr(), m.memptr(), n_elem ); | arrayops::inplace_mul( memptr(), m.memptr(), n_elem ); | |||
return *this; | return *this; | |||
} | } | |||
//! in-place element-wise cube division | //! in-place element-wise cube division | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
const Cube<eT>& | const Cube<eT>& | |||
Cube<eT>::operator/=(const Cube<eT>& m) | Cube<eT>::operator/=(const Cube<eT>& m) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_assert_same_size(*this, m, "element-wise cube division"); | arma_debug_assert_same_size(*this, m, "element-wise division"); | |||
arrayops::inplace_div( memptr(), m.memptr(), n_elem ); | arrayops::inplace_div( memptr(), m.memptr(), n_elem ); | |||
return *this; | return *this; | |||
} | } | |||
//! for constructing a complex cube out of two non-complex cubes | //! for constructing a complex cube out of two non-complex cubes | |||
template<typename eT> | template<typename eT> | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
inline | inline | |||
skipping to change at line 2741 | skipping to change at line 2741 | |||
typename Cube<eT>::const_iterator | typename Cube<eT>::const_iterator | |||
Cube<eT>::begin() const | Cube<eT>::begin() const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return memptr(); | return memptr(); | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
typename Cube<eT>::const_iterator | ||||
Cube<eT>::cbegin() const | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
return memptr(); | ||||
} | ||||
template<typename eT> | ||||
inline | ||||
typename Cube<eT>::iterator | typename Cube<eT>::iterator | |||
Cube<eT>::end() | Cube<eT>::end() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return memptr() + n_elem; | return memptr() + n_elem; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
typename Cube<eT>::const_iterator | typename Cube<eT>::const_iterator | |||
Cube<eT>::end() const | Cube<eT>::end() const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return memptr() + n_elem; | return memptr() + n_elem; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
typename Cube<eT>::const_iterator | ||||
Cube<eT>::cend() const | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
return memptr() + n_elem; | ||||
} | ||||
template<typename eT> | ||||
inline | ||||
typename Cube<eT>::slice_iterator | typename Cube<eT>::slice_iterator | |||
Cube<eT>::begin_slice(const uword slice_num) | Cube<eT>::begin_slice(const uword slice_num) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_check( (slice_num >= n_slices), "begin_slice(): index out of b ounds"); | arma_debug_check( (slice_num >= n_slices), "begin_slice(): index out of b ounds"); | |||
return slice_memptr(slice_num); | return slice_memptr(slice_num); | |||
} | } | |||
skipping to change at line 2807 | skipping to change at line 2827 | |||
typename Cube<eT>::const_slice_iterator | typename Cube<eT>::const_slice_iterator | |||
Cube<eT>::end_slice(const uword slice_num) const | Cube<eT>::end_slice(const uword slice_num) const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_check( (slice_num >= n_slices), "end_slice(): index out of bou nds"); | arma_debug_check( (slice_num >= n_slices), "end_slice(): index out of bou nds"); | |||
return slice_memptr(slice_num) + n_elem_slice; | return slice_memptr(slice_num) + n_elem_slice; | |||
} | } | |||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
void | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::mem_setup() | ||||
{ | ||||
arma_extra_debug_sigprint_this(this); | ||||
if(fixed_n_elem > 0) | ||||
{ | ||||
access::rw(Cube<eT>::n_rows) = fixed_n_rows; | ||||
access::rw(Cube<eT>::n_cols) = fixed_n_cols; | ||||
access::rw(Cube<eT>::n_elem_slice) = fixed_n_rows * fixed_n_cols; | ||||
access::rw(Cube<eT>::n_slices) = fixed_n_slices; | ||||
access::rw(Cube<eT>::n_elem) = fixed_n_elem; | ||||
access::rw(Cube<eT>::mem_state) = 3; | ||||
access::rw(Cube<eT>::mat_ptrs) = const_cast< const Mat<eT>** >( \ | ||||
(fixed_n_slices > Cube_prealloc::m | ||||
at_ptrs_size) ? mat_ptrs_local_extra : mat_ptrs_local ); | ||||
access::rw(Cube<eT>::mem) = (fixed_n_elem > Cube_prealloc::m | ||||
em_n_elem) ? mem_local_extra : mem_local; | ||||
create_mat(); | ||||
} | ||||
else | ||||
{ | ||||
access::rw(Cube<eT>::n_rows) = 0; | ||||
access::rw(Cube<eT>::n_cols) = 0; | ||||
access::rw(Cube<eT>::n_elem_slice) = 0; | ||||
access::rw(Cube<eT>::n_slices) = 0; | ||||
access::rw(Cube<eT>::n_elem) = 0; | ||||
access::rw(Cube<eT>::mem_state) = 3; | ||||
access::rw(Cube<eT>::mat_ptrs) = 0; | ||||
access::rw(Cube<eT>::mem) = 0; | ||||
} | ||||
} | ||||
//! resets this cube to an empty matrix | //! resets this cube to an empty matrix | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
void | void | |||
Cube<eT>::clear() | Cube<eT>::clear() | |||
{ | { | |||
reset(); | reset(); | |||
} | } | |||
//! returns true if the cube has no elements | //! returns true if the cube has no elements | |||
skipping to change at line 2931 | skipping to change at line 2916 | |||
access::rw(x.n_elem) = 0; | access::rw(x.n_elem) = 0; | |||
access::rw(x.mem) = 0; | access::rw(x.mem) = 0; | |||
} | } | |||
else | else | |||
{ | { | |||
(*this).operator=(x); | (*this).operator=(x); | |||
} | } | |||
} | } | |||
} | } | |||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
void | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::mem_setup() | ||||
{ | ||||
arma_extra_debug_sigprint_this(this); | ||||
if(fixed_n_elem > 0) | ||||
{ | ||||
access::rw(Cube<eT>::n_rows) = fixed_n_rows; | ||||
access::rw(Cube<eT>::n_cols) = fixed_n_cols; | ||||
access::rw(Cube<eT>::n_elem_slice) = fixed_n_rows * fixed_n_cols; | ||||
access::rw(Cube<eT>::n_slices) = fixed_n_slices; | ||||
access::rw(Cube<eT>::n_elem) = fixed_n_elem; | ||||
access::rw(Cube<eT>::mem_state) = 3; | ||||
access::rw(Cube<eT>::mat_ptrs) = const_cast< const Mat<eT>** >( \ | ||||
(fixed_n_slices > Cube_prealloc::m | ||||
at_ptrs_size) ? mat_ptrs_local_extra : mat_ptrs_local ); | ||||
access::rw(Cube<eT>::mem) = (fixed_n_elem > Cube_prealloc::m | ||||
em_n_elem) ? mem_local_extra : mem_local; | ||||
create_mat(); | ||||
} | ||||
else | ||||
{ | ||||
access::rw(Cube<eT>::n_rows) = 0; | ||||
access::rw(Cube<eT>::n_cols) = 0; | ||||
access::rw(Cube<eT>::n_elem_slice) = 0; | ||||
access::rw(Cube<eT>::n_slices) = 0; | ||||
access::rw(Cube<eT>::n_elem) = 0; | ||||
access::rw(Cube<eT>::mem_state) = 3; | ||||
access::rw(Cube<eT>::mat_ptrs) = 0; | ||||
access::rw(Cube<eT>::mem) = 0; | ||||
} | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT& | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::operator[] (co | ||||
nst uword i) | ||||
{ | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::operator[] (co | ||||
nst uword i) const | ||||
{ | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT& | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::at(const uword | ||||
i) | ||||
{ | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::at(const uword | ||||
i) const | ||||
{ | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT& | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::operator() (co | ||||
nst uword i) | ||||
{ | ||||
arma_debug_check( (i >= fixed_n_elem), "Cube::operator(): out of bounds") | ||||
; | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::operator() (co | ||||
nst uword i) const | ||||
{ | ||||
arma_debug_check( (i >= fixed_n_elem), "Cube::operator(): out of bounds") | ||||
; | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT& | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::at(const uword | ||||
in_row, const uword in_col, const uword in_slice) | ||||
{ | ||||
const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_ro | ||||
w; | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::at(const uword | ||||
in_row, const uword in_col, const uword in_slice) const | ||||
{ | ||||
const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_ro | ||||
w; | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT& | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::operator() (co | ||||
nst uword in_row, const uword in_col, const uword in_slice) | ||||
{ | ||||
arma_debug_check | ||||
( | ||||
(in_row >= fixed_n_rows ) || | ||||
(in_col >= fixed_n_cols ) || | ||||
(in_slice >= fixed_n_slices) | ||||
, | ||||
"Cube::operator(): index out of bounds" | ||||
); | ||||
const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_ro | ||||
w; | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT | ||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::operator() (co | ||||
nst uword in_row, const uword in_col, const uword in_slice) const | ||||
{ | ||||
arma_debug_check | ||||
( | ||||
(in_row >= fixed_n_rows ) || | ||||
(in_col >= fixed_n_cols ) || | ||||
(in_slice >= fixed_n_slices) | ||||
, | ||||
"Cube::operator(): index out of bounds" | ||||
); | ||||
const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_ro | ||||
w; | ||||
return (use_extra) ? mem_local_extra[i] : mem_local[i]; | ||||
} | ||||
//! prefix ++ | //! prefix ++ | |||
template<typename eT> | template<typename eT> | |||
arma_inline | arma_inline | |||
void | void | |||
Cube_aux::prefix_pp(Cube<eT>& x) | Cube_aux::prefix_pp(Cube<eT>& x) | |||
{ | { | |||
eT* memptr = x.memptr(); | eT* memptr = x.memptr(); | |||
const uword n_elem = x.n_elem; | const uword n_elem = x.n_elem; | |||
uword i,j; | uword i,j; | |||
End of changes. 10 change blocks. | ||||
43 lines changed or deleted | 209 lines changed or added | |||
Mat_bones.hpp | Mat_bones.hpp | |||
---|---|---|---|---|
skipping to change at line 442 | skipping to change at line 442 | |||
inline void operator--(int); | inline void operator--(int); | |||
inline bool operator!=(const const_row_iterator& X) const; | inline bool operator!=(const const_row_iterator& X) const; | |||
inline bool operator==(const const_row_iterator& X) const; | inline bool operator==(const const_row_iterator& X) const; | |||
arma_aligned const Mat<eT>& M; | arma_aligned const Mat<eT>& M; | |||
arma_aligned uword row; | arma_aligned uword row; | |||
arma_aligned uword col; | arma_aligned uword col; | |||
}; | }; | |||
inline iterator begin(); | inline iterator begin(); | |||
inline const_iterator begin() const; | inline const_iterator begin() const; | |||
inline const_iterator cbegin() const; | ||||
inline iterator end(); | ||||
inline const_iterator end() const; | inline iterator end(); | |||
inline const_iterator end() const; | ||||
inline const_iterator cend() const; | ||||
inline col_iterator begin_col(const uword col_num); | inline col_iterator begin_col(const uword col_num); | |||
inline const_col_iterator begin_col(const uword col_num) const; | inline const_col_iterator begin_col(const uword col_num) const; | |||
inline col_iterator end_col (const uword col_num); | inline col_iterator end_col (const uword col_num); | |||
inline const_col_iterator end_col (const uword col_num) const; | inline const_col_iterator end_col (const uword col_num) const; | |||
inline row_iterator begin_row(const uword row_num); | inline row_iterator begin_row(const uword row_num); | |||
inline const_row_iterator begin_row(const uword row_num) const; | inline const_row_iterator begin_row(const uword row_num) const; | |||
skipping to change at line 540 | skipping to change at line 542 | |||
arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X); | arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X); | |||
template<typename T1> inline fixed(const Base<eT,T1>& A); | template<typename T1> inline fixed(const Base<eT,T1>& A); | |||
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |||
inline fixed(const eT* aux_mem); | inline fixed(const eT* aux_mem); | |||
inline fixed(const char* text); | inline fixed(const char* text); | |||
inline fixed(const std::string& text); | inline fixed(const std::string& text); | |||
#if !defined(ARMA_GCC47_BUG) | using Mat<eT>::operator=; | |||
using Mat<eT>::operator=; | using Mat<eT>::operator(); | |||
using Mat<eT>::operator(); | ||||
#else | ||||
template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A) | ||||
; | ||||
inline const Mat& operator=(const eT val); | ||||
inline const Mat& operator=(const char* text); | ||||
inline const Mat& operator=(const std::string& text); | ||||
#endif | ||||
#if defined(ARMA_USE_CXX11) | #if defined(ARMA_USE_CXX11) | |||
inline fixed(const std::initializer_list<eT>& list); | inline fixed(const std::initializer_list<eT>& list); | |||
inline const Mat& operator=(const std::initializer_list<eT>& list); | inline const Mat& operator=(const std::initializer_list<eT>& list); | |||
#endif | #endif | |||
arma_inline arma_warn_unused eT& operator[] (const uword i); | arma_inline arma_warn_unused eT& operator[] (const uword i); | |||
arma_inline arma_warn_unused eT operator[] (const uword i) const; | arma_inline arma_warn_unused eT operator[] (const uword i) const; | |||
arma_inline arma_warn_unused eT& at (const uword i); | arma_inline arma_warn_unused eT& at (const uword i); | |||
arma_inline arma_warn_unused eT at (const uword i) const; | arma_inline arma_warn_unused eT at (const uword i) const; | |||
arma_inline arma_warn_unused eT& operator() (const uword i); | arma_inline arma_warn_unused eT& operator() (const uword i); | |||
arma_inline arma_warn_unused eT operator() (const uword i) const; | arma_inline arma_warn_unused eT operator() (const uword i) const; | |||
arma_inline arma_warn_unused eT& at (const uword in_row, const uw ord in_col); | arma_inline arma_warn_unused eT& at (const uword in_row, const uw ord in_col); | |||
arma_inline arma_warn_unused eT at (const uword in_row, const uw ord in_col) const; | arma_inline arma_warn_unused eT at (const uword in_row, const uw ord in_col) const; | |||
arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw ord in_col); | arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw ord in_col); | |||
arma_inline arma_warn_unused eT operator() (const uword in_row, const uw ord in_col) const; | arma_inline arma_warn_unused eT operator() (const uword in_row, const uw ord in_col) const; | |||
arma_inline arma_warn_unused eT* colptr(const uword in_col); | ||||
arma_inline arma_warn_unused const eT* colptr(const uword in_col) const; | ||||
arma_inline arma_warn_unused eT* memptr(); | arma_inline arma_warn_unused eT* memptr(); | |||
arma_inline arma_warn_unused const eT* memptr() const; | arma_inline arma_warn_unused const eT* memptr() const; | |||
arma_inline arma_warn_unused bool is_vec() const; | ||||
arma_hot inline const Mat<eT>& fill(const eT val); | arma_hot inline const Mat<eT>& fill(const eT val); | |||
arma_hot inline const Mat<eT>& zeros(); | arma_hot inline const Mat<eT>& zeros(); | |||
arma_hot inline const Mat<eT>& ones(); | arma_hot inline const Mat<eT>& ones(); | |||
}; | }; | |||
class Mat_aux | class Mat_aux | |||
{ | { | |||
public: | public: | |||
template<typename eT> arma_inline static void prefix_pp(Mat<eT>& x); | template<typename eT> arma_inline static void prefix_pp(Mat<eT>& x); | |||
End of changes. 4 change blocks. | ||||
17 lines changed or deleted | 14 lines changed or added | |||
Mat_meat.hpp | Mat_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 620 | skipping to change at line 620 | |||
typedef typename T1::elem_type T; | typedef typename T1::elem_type T; | |||
arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex | arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex | |||
arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex | arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex | |||
arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible | arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible | |||
const Proxy<T1> PX(X.get_ref()); | const Proxy<T1> PX(X.get_ref()); | |||
const Proxy<T2> PY(Y.get_ref()); | const Proxy<T2> PY(Y.get_ref()); | |||
arma_assert_same_size(PX, PY, "Mat()"); | arma_debug_assert_same_size(PX, PY, "Mat()"); | |||
const uword local_n_rows = PX.get_n_rows(); | const uword local_n_rows = PX.get_n_rows(); | |||
const uword local_n_cols = PX.get_n_cols(); | const uword local_n_cols = PX.get_n_cols(); | |||
init_warm(local_n_rows, local_n_cols); | init_warm(local_n_rows, local_n_cols); | |||
eT* out_mem = (*this).memptr(); | eT* out_mem = (*this).memptr(); | |||
const bool prefer_at_accessor = ( Proxy<T1>::prefer_at_accessor || Proxy< T2>::prefer_at_accessor ); | const bool prefer_at_accessor = ( Proxy<T1>::prefer_at_accessor || Proxy< T2>::prefer_at_accessor ); | |||
skipping to change at line 5358 | skipping to change at line 5358 | |||
typename Mat<eT>::const_iterator | typename Mat<eT>::const_iterator | |||
Mat<eT>::begin() const | Mat<eT>::begin() const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return memptr(); | return memptr(); | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
typename Mat<eT>::const_iterator | ||||
Mat<eT>::cbegin() const | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
return memptr(); | ||||
} | ||||
template<typename eT> | ||||
inline | ||||
typename Mat<eT>::iterator | typename Mat<eT>::iterator | |||
Mat<eT>::end() | Mat<eT>::end() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return memptr() + n_elem; | return memptr() + n_elem; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
typename Mat<eT>::const_iterator | typename Mat<eT>::const_iterator | |||
Mat<eT>::end() const | Mat<eT>::end() const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return memptr() + n_elem; | return memptr() + n_elem; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
inline | inline | |||
typename Mat<eT>::const_iterator | ||||
Mat<eT>::cend() const | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
return memptr() + n_elem; | ||||
} | ||||
template<typename eT> | ||||
inline | ||||
typename Mat<eT>::col_iterator | typename Mat<eT>::col_iterator | |||
Mat<eT>::begin_col(const uword col_num) | Mat<eT>::begin_col(const uword col_num) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_check( (col_num >= n_cols), "begin_col(): index out of bounds" ); | arma_debug_check( (col_num >= n_cols), "begin_col(): index out of bounds" ); | |||
return colptr(col_num); | return colptr(col_num); | |||
} | } | |||
skipping to change at line 5580 | skipping to change at line 5600 | |||
template<uword fixed_n_rows, uword fixed_n_cols> | template<uword fixed_n_rows, uword fixed_n_cols> | |||
inline | inline | |||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::string& text) | Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::string& text) | |||
: Mat<eT>( arma_fixed_indicator(), fixed_n_rows, fixed_n_cols, 0, ((use_e xtra) ? mem_local_extra : mem_local) ) | : Mat<eT>( arma_fixed_indicator(), fixed_n_rows, fixed_n_cols, 0, ((use_e xtra) ? mem_local_extra : mem_local) ) | |||
{ | { | |||
arma_extra_debug_sigprint_this(this); | arma_extra_debug_sigprint_this(this); | |||
Mat<eT>::operator=(text); | Mat<eT>::operator=(text); | |||
} | } | |||
#if defined(ARMA_GCC47_BUG) | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
template<typename T1> | ||||
inline | ||||
const Mat<eT>& | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const Base<eT,T1>& | ||||
A) | ||||
{ | ||||
Mat<eT>::operator=(A.get_ref()); | ||||
return *this; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
inline | ||||
const Mat<eT>& | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const eT val) | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
Mat<eT>::operator=(val); | ||||
return *this; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
inline | ||||
const Mat<eT>& | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const char* text) | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
Mat<eT>::operator=(text); | ||||
return *this; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
inline | ||||
const Mat<eT>& | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::string& | ||||
text) | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
Mat<eT>::operator=(text); | ||||
return *this; | ||||
} | ||||
#endif | ||||
#if defined(ARMA_USE_CXX11) | #if defined(ARMA_USE_CXX11) | |||
template<typename eT> | template<typename eT> | |||
template<uword fixed_n_rows, uword fixed_n_cols> | template<uword fixed_n_rows, uword fixed_n_cols> | |||
inline | inline | |||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::initializer_ list<eT>& list) | Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::initializer_ list<eT>& list) | |||
: Mat<eT>( arma_fixed_indicator(), fixed_n_rows, fixed_n_cols, 0, ((use _extra) ? mem_local_extra : mem_local) ) | : Mat<eT>( arma_fixed_indicator(), fixed_n_rows, fixed_n_cols, 0, ((use _extra) ? mem_local_extra : mem_local) ) | |||
{ | { | |||
arma_extra_debug_sigprint_this(this); | arma_extra_debug_sigprint_this(this); | |||
skipping to change at line 5792 | skipping to change at line 5757 | |||
const uword iq = in_row + in_col*fixed_n_rows; | const uword iq = in_row + in_col*fixed_n_rows; | |||
return (use_extra) ? mem_local_extra[iq] : mem_local[iq]; | return (use_extra) ? mem_local_extra[iq] : mem_local[iq]; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
template<uword fixed_n_rows, uword fixed_n_cols> | template<uword fixed_n_rows, uword fixed_n_cols> | |||
arma_inline | arma_inline | |||
arma_warn_unused | arma_warn_unused | |||
eT* | eT* | |||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::colptr(const uword in_col) | ||||
{ | ||||
eT* mem_actual = (use_extra) ? mem_local_extra : mem_local; | ||||
return & access::rw(mem_actual[in_col*fixed_n_rows]); | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
arma_inline | ||||
arma_warn_unused | ||||
const eT* | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::colptr(const uword in_col) cons | ||||
t | ||||
{ | ||||
const eT* mem_actual = (use_extra) ? mem_local_extra : mem_local; | ||||
return & mem_actual[in_col*fixed_n_rows]; | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
arma_inline | ||||
arma_warn_unused | ||||
eT* | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::memptr() | Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::memptr() | |||
{ | { | |||
return (use_extra) ? mem_local_extra : mem_local; | return (use_extra) ? mem_local_extra : mem_local; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
template<uword fixed_n_rows, uword fixed_n_cols> | template<uword fixed_n_rows, uword fixed_n_cols> | |||
arma_inline | arma_inline | |||
arma_warn_unused | arma_warn_unused | |||
const eT* | const eT* | |||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::memptr() const | Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::memptr() const | |||
{ | { | |||
return (use_extra) ? mem_local_extra : mem_local; | return (use_extra) ? mem_local_extra : mem_local; | |||
} | } | |||
template<typename eT> | template<typename eT> | |||
template<uword fixed_n_rows, uword fixed_n_cols> | template<uword fixed_n_rows, uword fixed_n_cols> | |||
arma_inline | ||||
arma_warn_unused | ||||
bool | ||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::is_vec() const | ||||
{ | ||||
return ( (fixed_n_rows == 1) || (fixed_n_cols == 1) ); | ||||
} | ||||
template<typename eT> | ||||
template<uword fixed_n_rows, uword fixed_n_cols> | ||||
arma_hot | arma_hot | |||
inline | inline | |||
const Mat<eT>& | const Mat<eT>& | |||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fill(const eT val) | Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fill(const eT val) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(mem_local[0]); | eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(mem_local[0]); | |||
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val ); | arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val ); | |||
End of changes. 6 change blocks. | ||||
58 lines changed or deleted | 56 lines changed or added | |||
Row_bones.hpp | Row_bones.hpp | |||
---|---|---|---|---|
skipping to change at line 162 | skipping to change at line 162 | |||
inline fixed(const char* text); | inline fixed(const char* text); | |||
inline fixed(const std::string& text); | inline fixed(const std::string& text); | |||
template<typename T1> inline const Row& operator=(const Base<eT,T1>& A); | template<typename T1> inline const Row& operator=(const Base<eT,T1>& A); | |||
inline const Row& operator=(const eT val); | inline const Row& operator=(const eT val); | |||
inline const Row& operator=(const char* text); | inline const Row& operator=(const char* text); | |||
inline const Row& operator=(const std::string& text); | inline const Row& operator=(const std::string& text); | |||
inline const Row& operator=(const subview_cube<eT>& X); | inline const Row& operator=(const subview_cube<eT>& X); | |||
#if !defined(ARMA_GCC47_BUG) | using Row<eT>::operator(); | |||
using Row<eT>::operator(); | ||||
#endif | ||||
#if defined(ARMA_USE_CXX11) | #if defined(ARMA_USE_CXX11) | |||
inline fixed(const std::initializer_list<eT>& list); | inline fixed(const std::initializer_list<eT>& list); | |||
inline const Row& operator=(const std::initializer_list<eT>& list); | inline const Row& operator=(const std::initializer_list<eT>& list); | |||
#endif | #endif | |||
arma_inline arma_warn_unused eT& operator[] (const uword i); | arma_inline arma_warn_unused eT& operator[] (const uword i); | |||
arma_inline arma_warn_unused eT operator[] (const uword i) const; | arma_inline arma_warn_unused eT operator[] (const uword i) const; | |||
arma_inline arma_warn_unused eT& at (const uword i); | arma_inline arma_warn_unused eT& at (const uword i); | |||
arma_inline arma_warn_unused eT at (const uword i) const; | arma_inline arma_warn_unused eT at (const uword i) const; | |||
End of changes. 1 change blocks. | ||||
3 lines changed or deleted | 1 lines changed or added | |||
SpMat_meat.hpp | SpMat_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 609 | skipping to change at line 609 | |||
// Compile-time abort if types are not compatible. | // Compile-time abort if types are not compatible. | |||
arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); | arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); | |||
const unwrap_spmat<T1> tmp1(A.get_ref()); | const unwrap_spmat<T1> tmp1(A.get_ref()); | |||
const unwrap_spmat<T2> tmp2(B.get_ref()); | const unwrap_spmat<T2> tmp2(B.get_ref()); | |||
const SpMat<T>& X = tmp1.M; | const SpMat<T>& X = tmp1.M; | |||
const SpMat<T>& Y = tmp2.M; | const SpMat<T>& Y = tmp2.M; | |||
arma_assert_same_size(X.n_rows, X.n_cols, Y.n_rows, Y.n_cols, "SpMat()"); | arma_debug_assert_same_size(X.n_rows, X.n_cols, Y.n_rows, Y.n_cols, "SpMa t()"); | |||
const uword l_n_rows = X.n_rows; | const uword l_n_rows = X.n_rows; | |||
const uword l_n_cols = X.n_cols; | const uword l_n_cols = X.n_cols; | |||
// Set size of matrix correctly. | // Set size of matrix correctly. | |||
init(l_n_rows, l_n_cols); | init(l_n_rows, l_n_cols); | |||
mem_resize(n_unique(X, Y, op_n_unique_count())); | mem_resize(n_unique(X, Y, op_n_unique_count())); | |||
// Now on a second iteration, fill it. | // Now on a second iteration, fill it. | |||
typename SpMat<T>::const_iterator x_it = X.begin(); | typename SpMat<T>::const_iterator x_it = X.begin(); | |||
typename SpMat<T>::const_iterator y_it = Y.begin(); | typename SpMat<T>::const_iterator x_end = X.end(); | |||
typename SpMat<T>::const_iterator y_it = Y.begin(); | ||||
typename SpMat<T>::const_iterator y_end = Y.end(); | ||||
uword cur_pos = 0; | uword cur_pos = 0; | |||
while ((x_it != X.end()) || (y_it != Y.end())) | while ((x_it != x_end) || (y_it != y_end)) | |||
{ | { | |||
if(x_it == y_it) // if we are at the same place | if(x_it == y_it) // if we are at the same place | |||
{ | { | |||
access::rw(values[cur_pos]) = std::complex<T>((T) *x_it, (T) *y_it); | access::rw(values[cur_pos]) = std::complex<T>((T) *x_it, (T) *y_it); | |||
access::rw(row_indices[cur_pos]) = x_it.row(); | access::rw(row_indices[cur_pos]) = x_it.row(); | |||
++access::rw(col_ptrs[x_it.col() + 1]); | ++access::rw(col_ptrs[x_it.col() + 1]); | |||
++x_it; | ++x_it; | |||
++y_it; | ++y_it; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 8 lines changed or added | |||
arma_version.hpp | arma_version.hpp | |||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
// Copyright (C) 2009-2013 Conrad Sanderson | // Copyright (C) 2009-2013 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 arma_version | //! \addtogroup arma_version | |||
//! @{ | //! @{ | |||
#define ARMA_VERSION_MAJOR 3 | #define ARMA_VERSION_MAJOR 3 | |||
#define ARMA_VERSION_MINOR 810 | #define ARMA_VERSION_MINOR 819 | |||
#define ARMA_VERSION_PATCH 3 | #define ARMA_VERSION_PATCH 0 | |||
#define ARMA_VERSION_NAME "Newell Highway" | #define ARMA_VERSION_NAME "unstable development version -- not for product | |||
ion use" | ||||
struct arma_version | struct arma_version | |||
{ | { | |||
static const unsigned int major = ARMA_VERSION_MAJOR; | static const unsigned int major = ARMA_VERSION_MAJOR; | |||
static const unsigned int minor = ARMA_VERSION_MINOR; | static const unsigned int minor = ARMA_VERSION_MINOR; | |||
static const unsigned int patch = ARMA_VERSION_PATCH; | static const unsigned int patch = ARMA_VERSION_PATCH; | |||
static | static | |||
inline | inline | |||
std::string | std::string | |||
End of changes. 1 change blocks. | ||||
3 lines changed or deleted | 4 lines changed or added | |||
compiler_setup.hpp | compiler_setup.hpp | |||
---|---|---|---|---|
skipping to change at line 129 | skipping to change at line 129 | |||
#define ARMA_USE_CXX11 | #define ARMA_USE_CXX11 | |||
#endif | #endif | |||
#endif | #endif | |||
#if defined(__clang__) | #if defined(__clang__) | |||
#undef ARMA_HAVE_STD_TR1 | #undef ARMA_HAVE_STD_TR1 | |||
//#undef ARMA_GOOD_COMPILER | //#undef ARMA_GOOD_COMPILER | |||
#endif | #endif | |||
#if ( (ARMA_GCC_VERSION >= 40700) && (ARMA_GCC_VERSION <= 40701) ) | #if ( (ARMA_GCC_VERSION >= 40700) && (ARMA_GCC_VERSION <= 40701) ) | |||
#define ARMA_GCC47_BUG | #error "gcc versions 4.7.0 and 4.7.1 are unsupported; use 4.7.2 or late | |||
r" | ||||
#warning "*** Detected GCC 4.7.0 / 4.7.1, which has a regression (bug)" | // due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53549 | |||
#warning "*** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53549 " | ||||
#warning "*** A partial workaround for the bug has been activated, " | ||||
#warning "*** which reduces some functionality in fixed-size matrices " | ||||
#endif | #endif | |||
#undef ARMA_GCC_VERSION | #undef ARMA_GCC_VERSION | |||
#endif | #endif | |||
#if defined(__APPLE__) | #if defined(__APPLE__) | |||
#define ARMA_BLAS_SDOT_BUG | #define ARMA_BLAS_SDOT_BUG | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
6 lines changed or deleted | 3 lines changed or added | |||
config.hpp | config.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2012 Conrad Sanderson | // Copyright (C) 2008-2012 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/. | |||
#if !defined(ARMA_USE_LAPACK) | #if !defined(ARMA_USE_LAPACK) | |||
#define ARMA_USE_LAPACK | #define ARMA_USE_LAPACK | |||
//// Uncomment the above line if you have LAPACK or a high-speed replacemen t for LAPACK, | //// Uncomment the above line if you have LAPACK or a high-speed replacemen t for LAPACK, | |||
//// such as Intel's MKL, AMD's ACML, or the Accelerate framework. | //// such as Intel MKL, AMD ACML, or the Accelerate framework. | |||
//// LAPACK is required for matrix decompositions (eg. SVD) and matrix inve rse. | //// LAPACK is required for matrix decompositions (eg. SVD) and matrix inve rse. | |||
#endif | #endif | |||
#if !defined(ARMA_USE_BLAS) | #if !defined(ARMA_USE_BLAS) | |||
#define ARMA_USE_BLAS | #define ARMA_USE_BLAS | |||
//// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS, | //// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS, | |||
//// such as OpenBLAS, GotoBLAS, Intel's MKL, AMD's ACML, or the Accelerate framework. | //// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate fra mework. | |||
//// BLAS is used for matrix multiplication. | //// BLAS is used for matrix multiplication. | |||
//// Without BLAS, matrix multiplication will still work, but might be slow er. | //// Without BLAS, matrix multiplication will still work, but might be slow er. | |||
#endif | #endif | |||
#define ARMA_USE_WRAPPER | #define ARMA_USE_WRAPPER | |||
//// Comment out the above line if you prefer to directly link with LAPACK | //// Comment out the above line if you're getting linking errors when compi | |||
and/or BLAS (eg. -llapack -lblas) | ling your programs, | |||
//// instead of linking indirectly with LAPACK and/or BLAS via Armadillo's | //// or if you prefer to directly link with LAPACK and/or BLAS. | |||
run-time wrapper library. | //// You will then need to link your programs directly with -llapack -lblas | |||
instead of -larmadillo | ||||
// #define ARMA_BLAS_CAPITALS | // #define ARMA_BLAS_CAPITALS | |||
//// Uncomment the above line if your BLAS and LAPACK libraries have capita lised function names (eg. ACML on 64-bit Windows) | //// Uncomment the above line if your BLAS and LAPACK libraries have capita lised function names (eg. ACML on 64-bit Windows) | |||
#define ARMA_BLAS_UNDERSCORE | #define ARMA_BLAS_UNDERSCORE | |||
//// Uncomment the above line if your BLAS and LAPACK libraries have functi on names with a trailing underscore. | //// Uncomment the above line if your BLAS and LAPACK libraries have functi on names with a trailing underscore. | |||
//// Conversely, comment it out if the function names don't have a trailing underscore. | //// Conversely, comment it out if the function names don't have a trailing underscore. | |||
// #define ARMA_BLAS_LONG | // #define ARMA_BLAS_LONG | |||
//// Uncomment the above line if your BLAS and LAPACK libraries use "long" instead of "int" | //// Uncomment the above line if your BLAS and LAPACK libraries use "long" instead of "int" | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 7 lines changed or added | |||
debug.hpp | debug.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2011 Conrad Sanderson | // Copyright (C) 2008-2013 Conrad Sanderson | |||
// Copyright (C) 2011 Stanislav Funiak | // Copyright (C) 2011 Stanislav Funiak | |||
// | // | |||
// 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 debug | //! \addtogroup debug | |||
//! @{ | //! @{ | |||
template<typename T> | template<typename T> | |||
skipping to change at line 903 | skipping to change at line 903 | |||
if(final_A_n_cols != final_B_n_rows) | if(final_A_n_cols != final_B_n_rows) | |||
{ | { | |||
const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_col s; | const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_col s; | |||
const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_row s; | const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_row s; | |||
arma_stop( arma_incompat_size_string(final_A_n_rows, final_A_n_cols, fi nal_B_n_rows, final_B_n_cols, x) ); | arma_stop( arma_incompat_size_string(final_A_n_rows, final_A_n_cols, fi nal_B_n_rows, final_B_n_cols, x) ); | |||
} | } | |||
} | } | |||
template<const bool do_trans_A, const bool do_trans_B> | ||||
arma_hot | ||||
inline | ||||
void | ||||
arma_assert_trans_mul_size(const uword A_n_rows, const uword A_n_cols, cons | ||||
t uword B_n_rows, const uword B_n_cols, const char* x) | ||||
{ | ||||
const uword final_A_n_cols = (do_trans_A == false) ? A_n_cols : A_n_rows; | ||||
const uword final_B_n_rows = (do_trans_B == false) ? B_n_rows : B_n_cols; | ||||
if(final_A_n_cols != final_B_n_rows) | ||||
{ | ||||
const uword final_A_n_rows = (do_trans_A == false) ? A_n_rows : A_n_col | ||||
s; | ||||
const uword final_B_n_cols = (do_trans_B == false) ? B_n_cols : B_n_row | ||||
s; | ||||
arma_stop( arma_incompat_size_string(final_A_n_rows, final_A_n_cols, fi | ||||
nal_B_n_rows, final_B_n_cols, x) ); | ||||
} | ||||
} | ||||
template<typename eT1, typename eT2> | template<typename eT1, typename eT2> | |||
arma_hot | arma_hot | |||
inline | inline | |||
void | void | |||
arma_assert_mul_size(const Mat<eT1>& A, const subview<eT2>& B, const char* x) | arma_assert_mul_size(const Mat<eT1>& A, const subview<eT2>& B, const char* x) | |||
{ | { | |||
if(A.n_cols != B.n_rows) | if(A.n_cols != B.n_rows) | |||
{ | { | |||
arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_ cols, x) ); | arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_ cols, x) ); | |||
} | } | |||
skipping to change at line 960 | skipping to change at line 978 | |||
#elif defined (ARMA_USE_BOOST) | #elif defined (ARMA_USE_BOOST) | |||
#define ARMA_FNSIG BOOST_CURRENT_FUNCTION | #define ARMA_FNSIG BOOST_CURRENT_FUNCTION | |||
#elif defined (ARMA_USE_CXX11) | #elif defined (ARMA_USE_CXX11) | |||
#define ARMA_FNSIG __func__ | #define ARMA_FNSIG __func__ | |||
#else | #else | |||
#define ARMA_FNSIG "(unknown)" | #define ARMA_FNSIG "(unknown)" | |||
#endif | #endif | |||
#if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) | #if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) | |||
#define arma_debug_print arma_print | #define arma_debug_print arma_print | |||
#define arma_debug_warn arma_warn | #define arma_debug_warn arma_warn | |||
#define arma_debug_check arma_check | #define arma_debug_check arma_check | |||
#define arma_debug_set_error arma_set_error | #define arma_debug_set_error arma_set_error | |||
#define arma_debug_assert_same_size arma_assert_same_size | #define arma_debug_assert_same_size arma_assert_same_size | |||
#define arma_debug_assert_mul_size arma_assert_mul_size | #define arma_debug_assert_mul_size arma_assert_mul_size | |||
#define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat | #define arma_debug_assert_trans_mul_size arma_assert_trans_mul_size | |||
#define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat | ||||
#else | #else | |||
#undef ARMA_EXTRA_DEBUG | #undef ARMA_EXTRA_DEBUG | |||
#define arma_debug_print true ? (void)0 : arma_print | #define arma_debug_print true ? (void)0 : arma_print | |||
#define arma_debug_warn true ? (void)0 : arma_warn | #define arma_debug_warn true ? (void)0 : arma_warn | |||
#define arma_debug_check true ? (void)0 : arma_check | #define arma_debug_check true ? (void)0 : arma_check | |||
#define arma_debug_set_error true ? (void)0 : arma_set_error | #define arma_debug_set_error true ? (void)0 : arma_set_error | |||
#define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s | #define arma_debug_assert_same_size true ? (void)0 : arma_assert_sam | |||
ize | e_size | |||
#define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si | #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul | |||
ze | _size | |||
#define arma_debug_assert_cube_as_mat true ? (void)0 : arma_assert_cube_a | #define arma_debug_assert_trans_mul_size true ? (void)0 : arma_assert_tra | |||
s_mat | ns_mul_size | |||
#define arma_debug_assert_cube_as_mat true ? (void)0 : arma_assert_cub | ||||
e_as_mat | ||||
#endif | #endif | |||
#if defined(ARMA_EXTRA_DEBUG) | #if defined(ARMA_EXTRA_DEBUG) | |||
#define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint | #define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint | |||
#define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint | #define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint | |||
#define arma_extra_debug_print arma_print | #define arma_extra_debug_print arma_print | |||
#define arma_extra_debug_warn arma_warn | #define arma_extra_debug_warn arma_warn | |||
#define arma_extra_debug_check arma_check | #define arma_extra_debug_check arma_check | |||
End of changes. 4 change blocks. | ||||
19 lines changed or deleted | 44 lines changed or added | |||
eGlueCube_meat.hpp | eGlueCube_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 26 | skipping to change at line 26 | |||
} | } | |||
template<typename T1, typename T2, typename eglue_type> | template<typename T1, typename T2, typename eglue_type> | |||
arma_inline | arma_inline | |||
eGlueCube<T1,T2,eglue_type>::eGlueCube(const T1& in_A, const T2& in_B) | eGlueCube<T1,T2,eglue_type>::eGlueCube(const T1& in_A, const T2& in_B) | |||
: P1(in_A) | : P1(in_A) | |||
, P2(in_B) | , P2(in_B) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_assert_same_size | arma_debug_assert_same_size | |||
( | ( | |||
P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(), | P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(), | |||
P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(), | P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(), | |||
eglue_type::text() | eglue_type::text() | |||
); | ); | |||
} | } | |||
template<typename T1, typename T2, typename eglue_type> | template<typename T1, typename T2, typename eglue_type> | |||
arma_inline | arma_inline | |||
uword | uword | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
eglue_core_meat.hpp | eglue_core_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 138 | skipping to change at line 138 | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | |||
// NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; | // NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; | |||
// size setting and alias checking is done by either the Mat contructor o r operator=() | // size setting and alias checking is done by either the Mat contructor o r operator=() | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
if(prefer_at_accessor == false) | if(prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? x.g | |||
tly causes a mis-optimisation (slowdown) of the loop under GCC 4.4 | et_n_elem() : out.n_elem; | |||
const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? ( ( | ||||
x.get_n_elem() <= 4) ? x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | |||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | |||
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(=, +); } | if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(=, +); } | |||
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(=, -); } | else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(=, -); } | |||
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(=, /); } | else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(=, /); } | |||
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(=, *); } | else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(=, *); } | |||
} | } | |||
else | else | |||
skipping to change at line 186 | skipping to change at line 185 | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | |||
if(prefer_at_accessor == false) | if(prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? x.g | |||
tly causes a mis-optimisation (slowdown) of the loop under GCC 4.4 | et_n_elem() : out.n_elem; | |||
const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? ( ( | ||||
x.get_n_elem() <= 4) ? x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | |||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | |||
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); } | if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); } | |||
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); } | else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); } | |||
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); } | else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); } | |||
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); } | else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); } | |||
} | } | |||
else | else | |||
skipping to change at line 231 | skipping to change at line 229 | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | |||
if(prefer_at_accessor == false) | if(prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? x.g | |||
tly causes a mis-optimisation (slowdown) of the loop under GCC 4.4 | et_n_elem() : out.n_elem; | |||
const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? ( ( | ||||
x.get_n_elem() <= 4) ? x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | |||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | |||
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); } | if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); } | |||
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); } | else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); } | |||
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); } | else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); } | |||
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); } | else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); } | |||
} | } | |||
else | else | |||
skipping to change at line 276 | skipping to change at line 273 | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | |||
if(prefer_at_accessor == false) | if(prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? x.g | |||
tly causes a mis-optimisation (slowdown) of the loop under GCC 4.4 | et_n_elem() : out.n_elem; | |||
const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? ( ( | ||||
x.get_n_elem() <= 4) ? x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | |||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | |||
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); } | if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); } | |||
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); } | else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); } | |||
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); } | else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); } | |||
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); } | else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); } | |||
} | } | |||
else | else | |||
skipping to change at line 321 | skipping to change at line 317 | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); | |||
if(prefer_at_accessor == false) | if(prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? x.g | |||
tly causes a mis-optimisation (slowdown) of the loop under GCC 4.4 | et_n_elem() : out.n_elem; | |||
const uword n_elem = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed) ? ( ( | ||||
x.get_n_elem() <= 4) ? x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); | |||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); | |||
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); } | if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); } | |||
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); } | else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); } | |||
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); } | else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); } | |||
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); } | else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); } | |||
} | } | |||
else | else | |||
End of changes. 5 change blocks. | ||||
20 lines changed or deleted | 10 lines changed or added | |||
eop_core_meat.hpp | eop_core_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 123 | skipping to change at line 123 | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
// NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; | // NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; | |||
// size setting and alias checking is done by either the Mat contructor o r operator=() | // size setting and alias checking is done by either the Mat contructor o r operator=() | |||
const eT k = x.aux; | const eT k = x.aux; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
if(Proxy<T1>::prefer_at_accessor == false) | if(Proxy<T1>::prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_ele | |||
tly can cause a mis-optimisation (slowdown) of the loop under GCC 4.4 | m; | |||
const uword n_elem = (Proxy<T1>::is_fixed) ? ( (x.get_n_elem() <= 4) ? | ||||
x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P = x.P.get_ea(); | typename Proxy<T1>::ea_type P = x.P.get_ea(); | |||
arma_applier_1(=); | arma_applier_1(=); | |||
} | } | |||
else | else | |||
{ | { | |||
const uword n_rows = x.get_n_rows(); | const uword n_rows = x.get_n_rows(); | |||
const uword n_cols = x.get_n_cols(); | const uword n_cols = x.get_n_cols(); | |||
skipping to change at line 162 | skipping to change at line 161 | |||
const uword n_rows = x.get_n_rows(); | const uword n_rows = x.get_n_rows(); | |||
const uword n_cols = x.get_n_cols(); | const uword n_cols = x.get_n_cols(); | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); | |||
const eT k = x.aux; | const eT k = x.aux; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
if(Proxy<T1>::prefer_at_accessor == false) | if(Proxy<T1>::prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_ele | |||
tly can cause a mis-optimisation (slowdown) of the loop under GCC 4.4 | m; | |||
const uword n_elem = (Proxy<T1>::is_fixed) ? ( (x.get_n_elem() <= 4) ? | ||||
x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P = x.P.get_ea(); | typename Proxy<T1>::ea_type P = x.P.get_ea(); | |||
arma_applier_1(+=); | arma_applier_1(+=); | |||
} | } | |||
else | else | |||
{ | { | |||
const Proxy<T1>& P = x.P; | const Proxy<T1>& P = x.P; | |||
arma_applier_2(+=); | arma_applier_2(+=); | |||
skipping to change at line 198 | skipping to change at line 196 | |||
const uword n_rows = x.get_n_rows(); | const uword n_rows = x.get_n_rows(); | |||
const uword n_cols = x.get_n_cols(); | const uword n_cols = x.get_n_cols(); | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); | |||
const eT k = x.aux; | const eT k = x.aux; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
if(Proxy<T1>::prefer_at_accessor == false) | if(Proxy<T1>::prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_ele | |||
tly can cause a mis-optimisation (slowdown) of the loop under GCC 4.4 | m; | |||
const uword n_elem = (Proxy<T1>::is_fixed) ? ( (x.get_n_elem() <= 4) ? | ||||
x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P = x.P.get_ea(); | typename Proxy<T1>::ea_type P = x.P.get_ea(); | |||
arma_applier_1(-=); | arma_applier_1(-=); | |||
} | } | |||
else | else | |||
{ | { | |||
const Proxy<T1>& P = x.P; | const Proxy<T1>& P = x.P; | |||
arma_applier_2(-=); | arma_applier_2(-=); | |||
skipping to change at line 234 | skipping to change at line 231 | |||
const uword n_rows = x.get_n_rows(); | const uword n_rows = x.get_n_rows(); | |||
const uword n_cols = x.get_n_cols(); | const uword n_cols = x.get_n_cols(); | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); | |||
const eT k = x.aux; | const eT k = x.aux; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
if(Proxy<T1>::prefer_at_accessor == false) | if(Proxy<T1>::prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_ele | |||
tly can cause a mis-optimisation (slowdown) of the loop under GCC 4.4 | m; | |||
const uword n_elem = (Proxy<T1>::is_fixed) ? ( (x.get_n_elem() <= 4) ? | ||||
x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P = x.P.get_ea(); | typename Proxy<T1>::ea_type P = x.P.get_ea(); | |||
arma_applier_1(*=); | arma_applier_1(*=); | |||
} | } | |||
else | else | |||
{ | { | |||
const Proxy<T1>& P = x.P; | const Proxy<T1>& P = x.P; | |||
arma_applier_2(*=); | arma_applier_2(*=); | |||
skipping to change at line 270 | skipping to change at line 266 | |||
const uword n_rows = x.get_n_rows(); | const uword n_rows = x.get_n_rows(); | |||
const uword n_cols = x.get_n_cols(); | const uword n_cols = x.get_n_cols(); | |||
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); | |||
const eT k = x.aux; | const eT k = x.aux; | |||
eT* out_mem = out.memptr(); | eT* out_mem = out.memptr(); | |||
if(Proxy<T1>::prefer_at_accessor == false) | if(Proxy<T1>::prefer_at_accessor == false) | |||
{ | { | |||
// for fixed-sized vectors with n_elem >= 6, using x.get_n_elem() direc | const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_ele | |||
tly can cause a mis-optimisation (slowdown) of the loop under GCC 4.4 | m; | |||
const uword n_elem = (Proxy<T1>::is_fixed) ? ( (x.get_n_elem() <= 4) ? | ||||
x.get_n_elem() : out.n_elem ) : out.n_elem; | ||||
typename Proxy<T1>::ea_type P = x.P.get_ea(); | typename Proxy<T1>::ea_type P = x.P.get_ea(); | |||
arma_applier_1(/=); | arma_applier_1(/=); | |||
} | } | |||
else | else | |||
{ | { | |||
const Proxy<T1>& P = x.P; | const Proxy<T1>& P = x.P; | |||
arma_applier_2(/=); | arma_applier_2(/=); | |||
End of changes. 5 change blocks. | ||||
20 lines changed or deleted | 10 lines changed or added | |||
field_bones.hpp | field_bones.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2011 Conrad Sanderson | // Copyright (C) 2008-2013 Conrad Sanderson | |||
// Copyright (C) 2009-2010 Ian Cullinan | // Copyright (C) 2009-2010 Ian Cullinan | |||
// | // | |||
// 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 field | //! \addtogroup field | |||
//! @{ | //! @{ | |||
struct field_prealloc_n_elem | struct field_prealloc_n_elem | |||
skipping to change at line 105 | skipping to change at line 105 | |||
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 fill(const oT& x); | inline void fill(const oT& x); | |||
inline void reset(); | inline void reset(); | |||
inline void reset_objects(); | inline void reset_objects(); | |||
arma_inline bool is_empty() const; | arma_inline bool is_empty() const; | |||
arma_inline arma_warn_unused bool in_range(const uword i) const; | arma_inline arma_warn_unused bool in_range(const uword i) const; | |||
arma_inline arma_warn_unused bool in_range(const span& x) const; | arma_inline arma_warn_unused bool in_range(const span& x) const; | |||
arma_inline arma_warn_unused bool in_range(const uword in_row, const | arma_inline arma_warn_unused bool in_range(const uword in_row, const uw | |||
uword in_col ) const; | ord in_col) const; | |||
arma_inline arma_warn_unused bool in_range(const span& row_span, const uw | arma_inline arma_warn_unused bool in_range(const span& row_span, const uw | |||
ord in_col ) const; | ord in_col) const; | |||
arma_inline arma_warn_unused bool in_range(const uword in_row, const | arma_inline arma_warn_unused bool in_range(const uword in_row, const sp | |||
span& col_span) const; | an& col_span) const; | |||
arma_inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span) const; | arma_inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span) const; | |||
inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const; | inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const; | |||
inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const; | inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const; | |||
inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true); | inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true); | |||
inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true); | inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true); | |||
inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const; | inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const; | |||
inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const; | inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const; | |||
inline bool quiet_load(const std::string name, const file_type type = a uto_detect); | inline bool quiet_load(const std::string name, const file_type type = a uto_detect); | |||
inline bool quiet_load( std::istream& is, const file_type type = a uto_detect); | inline bool quiet_load( std::istream& is, const file_type type = a uto_detect); | |||
// iterators | // for container-like functionality | |||
typedef oT value_type; | ||||
typedef uword size_type; | ||||
class iterator | class iterator | |||
{ | { | |||
public: | public: | |||
inline iterator(field<oT>& in_M, const bool at_end = false); | inline iterator(field<oT>& in_M, const bool at_end = false); | |||
inline oT& operator* (); | inline oT& operator* (); | |||
inline iterator& operator++(); | inline iterator& operator++(); | |||
inline void operator++(int); | inline void operator++(int); | |||
inline iterator& operator--(); | inline iterator& operator--(); | |||
inline void operator--(int); | inline void operator--(int); | |||
inline bool operator!=(const iterator& X) const; | inline bool operator!=(const iterator& X) const; | |||
inline bool operator==(const iterator& X) const; | inline bool operator==(const iterator& X) const; | |||
arma_aligned field<oT>& M; | arma_aligned field<oT>& M; | |||
arma_aligned uword i; | arma_aligned uword i; | |||
}; | }; | |||
class const_iterator | class const_iterator | |||
{ | { | |||
public: | public: | |||
const_iterator(const field<oT>& in_M, const bool at_end = false); | const_iterator(const field<oT>& in_M, const bool at_end = false); | |||
const_iterator(const iterator& X); | const_iterator(const iterator& X); | |||
inline const oT& operator*() const; | inline const oT& operator*() const; | |||
skipping to change at line 167 | skipping to change at line 170 | |||
inline const_iterator& operator++(); | inline const_iterator& operator++(); | |||
inline void operator++(int); | inline void operator++(int); | |||
inline const_iterator& operator--(); | inline const_iterator& operator--(); | |||
inline void operator--(int); | inline void operator--(int); | |||
inline bool operator!=(const const_iterator& X) const; | inline bool operator!=(const const_iterator& X) const; | |||
inline bool operator==(const const_iterator& X) const; | inline bool operator==(const const_iterator& X) const; | |||
arma_aligned const field<oT>& M; | arma_aligned const field<oT>& M; | |||
arma_aligned uword i; | arma_aligned uword i; | |||
}; | }; | |||
inline iterator begin(); | inline iterator begin(); | |||
inline const_iterator begin() const; | inline const_iterator begin() const; | |||
inline const_iterator cbegin() const; | ||||
inline iterator end(); | ||||
inline const_iterator end() const; | inline iterator end(); | |||
inline const_iterator end() const; | ||||
inline const_iterator cend() const; | ||||
inline void clear(); | ||||
inline bool empty() const; | ||||
inline uword size() const; | ||||
private: | private: | |||
inline void init(const field<oT>& x); | inline void init(const field<oT>& x); | |||
inline void init(const uword n_rows_in, const uword n_cols_in); | inline void init(const uword n_rows_in, const uword n_cols_in); | |||
inline void delete_objects(); | inline void delete_objects(); | |||
inline void create_objects(); | inline void create_objects(); | |||
friend class field_aux; | friend class field_aux; | |||
skipping to change at line 205 | skipping to change at line 214 | |||
{ | { | |||
public: | public: | |||
template<typename oT> inline static void reset_objects(field< oT >& x); | template<typename oT> inline static void reset_objects(field< oT >& x); | |||
template<typename eT> inline static void reset_objects(field< Mat<eT> >& x); | template<typename eT> inline static void reset_objects(field< Mat<eT> >& x); | |||
template<typename eT> inline static void reset_objects(field< Col<eT> >& x); | template<typename eT> inline static void reset_objects(field< Col<eT> >& x); | |||
template<typename eT> inline static void reset_objects(field< Row<eT> >& x); | template<typename eT> inline static void reset_objects(field< Row<eT> >& x); | |||
template<typename eT> inline static void reset_objects(field< Cube<eT> >& x); | template<typename eT> inline static void reset_objects(field< Cube<eT> >& x); | |||
inline static void reset_objects(field< std::string >& x); | inline static void reset_objects(field< std::string >& x); | |||
template<typename oT> inline static bool save(const field< oT >& x, | template<typename oT> inline static bool save(const field< oT >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename oT> inline static bool save(const field< oT >& x, | template<typename oT> inline static bool save(const field< oT >& x, | |||
std::ostream& os, const file_type type, std::string& err_msg); | std::ostream& os, const file_type type, std::string& err_msg); | |||
template<typename oT> inline static bool load( field< oT >& x, | template<typename oT> inline static bool load( field< oT >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename oT> inline static bool load( field< oT >& x, | template<typename oT> inline static bool load( field< oT >& x, | |||
std::istream& is, const file_type type, std::string& err_msg); | std::istream& is, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Mat<eT> >& x, | template<typename eT> inline static bool save(const field< Mat<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Mat<eT> >& x, | template<typename eT> inline static bool save(const field< Mat<eT> >& x, | |||
std::ostream& os, const file_type type, std::string& err_msg); | std::ostream& os, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Mat<eT> >& x, | template<typename eT> inline static bool load( field< Mat<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Mat<eT> >& x, | template<typename eT> inline static bool load( field< Mat<eT> >& x, | |||
std::istream& is, const file_type type, std::string& err_msg); | std::istream& is, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Col<eT> >& x, | template<typename eT> inline static bool save(const field< Col<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Col<eT> >& x, | template<typename eT> inline static bool save(const field< Col<eT> >& x, | |||
std::ostream& os, const file_type type, std::string& err_msg); | std::ostream& os, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Col<eT> >& x, | template<typename eT> inline static bool load( field< Col<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Col<eT> >& x, | template<typename eT> inline static bool load( field< Col<eT> >& x, | |||
std::istream& is, const file_type type, std::string& err_msg); | std::istream& is, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Row<eT> >& x, | template<typename eT> inline static bool save(const field< Row<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Row<eT> >& x, | template<typename eT> inline static bool save(const field< Row<eT> >& x, | |||
std::ostream& os, const file_type type, std::string& err_msg); | std::ostream& os, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Row<eT> >& x, | template<typename eT> inline static bool load( field< Row<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Row<eT> >& x, | template<typename eT> inline static bool load( field< Row<eT> >& x, | |||
std::istream& is, const file_type type, std::string& err_msg); | std::istream& is, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Cube<eT> >& x, | template<typename eT> inline static bool save(const field< Cube<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool save(const field< Cube<eT> >& x, | template<typename eT> inline static bool save(const field< Cube<eT> >& x, | |||
std::ostream& os, const file_type type, std::string& err_msg); | std::ostream& os, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Cube<eT> >& x, | template<typename eT> inline static bool load( field< Cube<eT> >& x, | |||
const std::string& name, const file_type type, std::string& err_msg); | const std::string& name, const file_type type, std::string& err_msg); | |||
template<typename eT> inline static bool load( field< Cube<eT> >& x, | template<typename eT> inline static bool load( field< Cube<eT> >& x, | |||
std::istream& is, const file_type type, std::string& err_msg); | std::istream& is, const file_type type, std::string& err_msg); | |||
inline static bool save(const field< std::string >& x, const std::string& | inline static bool save(const field< std::string >& x, const std::string& | |||
name, const file_type type, std::string& err_msg); | name, const file_type type, std::string& err_msg); | |||
inline static bool save(const field< std::string >& x, std::ostream& os, | inline static bool save(const field< std::string >& x, std::ostream | |||
const file_type type, std::string& err_msg); | & os, const file_type type, std::string& err_msg); | |||
inline static bool load( field< std::string >& x, const std::string& | inline static bool load( field< std::string >& x, const std::string& | |||
name, const file_type type, std::string& err_msg); | name, const file_type type, std::string& err_msg); | |||
inline static bool load( field< std::string >& x, std::istream& is, | inline static bool load( field< std::string >& x, std::istream | |||
const file_type type, std::string& err_msg); | & is, const file_type type, std::string& err_msg); | |||
}; | }; | |||
//! @} | //! @} | |||
End of changes. 8 change blocks. | ||||
69 lines changed or deleted | 78 lines changed or added | |||
field_meat.hpp | field_meat.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2011 Conrad Sanderson | // Copyright (C) 2008-2013 Conrad Sanderson | |||
// Copyright (C) 2009-2010 Ian Cullinan | // Copyright (C) 2009-2010 Ian Cullinan | |||
// | // | |||
// 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 field | //! \addtogroup field | |||
//! @{ | //! @{ | |||
template<typename oT> | template<typename oT> | |||
skipping to change at line 919 | skipping to change at line 919 | |||
} | } | |||
//! internal field construction; if the requested size is small enough, mem ory from the stack is used. otherwise memory is allocated via 'new' | //! internal field construction; if the requested size is small enough, mem ory from the stack is used. otherwise memory is allocated via 'new' | |||
template<typename oT> | template<typename oT> | |||
inline | inline | |||
void | void | |||
field<oT>::init(const uword n_rows_in, const uword n_cols_in) | field<oT>::init(const uword n_rows_in, const uword n_cols_in) | |||
{ | { | |||
arma_extra_debug_sigprint( arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in ); | arma_extra_debug_sigprint( arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in ); | |||
arma_debug_check | ||||
( | ||||
( | ||||
( (n_rows_in > ARMA_MAX_UHWORD) || (n_cols_in > ARMA_MAX_UHWORD) ) | ||||
? ( (float(n_rows_in) * float(n_cols_in)) > float(ARMA_MAX_UWORD) ) | ||||
: false | ||||
), | ||||
"field::init(): requested size is too large" | ||||
); | ||||
const uword n_elem_new = n_rows_in * n_cols_in; | const uword n_elem_new = n_rows_in * n_cols_in; | |||
if(n_elem == n_elem_new) | if(n_elem == n_elem_new) | |||
{ | { | |||
// delete_objects(); | // delete_objects(); | |||
// create_objects(); | // create_objects(); | |||
access::rw(n_rows) = n_rows_in; | access::rw(n_rows) = n_rows_in; | |||
access::rw(n_cols) = n_cols_in; | access::rw(n_cols) = n_cols_in; | |||
} | } | |||
else | else | |||
skipping to change at line 1173 | skipping to change at line 1183 | |||
typename field<oT>::const_iterator | typename field<oT>::const_iterator | |||
field<oT>::begin() const | field<oT>::begin() const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return field<oT>::const_iterator(*this); | return field<oT>::const_iterator(*this); | |||
} | } | |||
template<typename oT> | template<typename oT> | |||
inline | inline | |||
typename field<oT>::const_iterator | ||||
field<oT>::cbegin() const | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
return field<oT>::const_iterator(*this); | ||||
} | ||||
template<typename oT> | ||||
inline | ||||
typename field<oT>::iterator | typename field<oT>::iterator | |||
field<oT>::end() | field<oT>::end() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return field<oT>::iterator(*this, true); | return field<oT>::iterator(*this, true); | |||
} | } | |||
template<typename oT> | template<typename oT> | |||
inline | inline | |||
typename field<oT>::const_iterator | typename field<oT>::const_iterator | |||
field<oT>::end() const | field<oT>::end() const | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return field<oT>::const_iterator(*this, true); | return field<oT>::const_iterator(*this, true); | |||
} | } | |||
template<typename oT> | ||||
inline | ||||
typename field<oT>::const_iterator | ||||
field<oT>::cend() const | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
return field<oT>::const_iterator(*this, true); | ||||
} | ||||
template<typename oT> | ||||
inline | ||||
void | ||||
field<oT>::clear() | ||||
{ | ||||
reset(); | ||||
} | ||||
template<typename oT> | ||||
inline | ||||
bool | ||||
field<oT>::empty() const | ||||
{ | ||||
return (n_elem == 0); | ||||
} | ||||
template<typename oT> | ||||
inline | ||||
uword | ||||
field<oT>::size() const | ||||
{ | ||||
return n_elem; | ||||
} | ||||
// | // | |||
// | // | |||
// | // | |||
template<typename oT> | template<typename oT> | |||
inline | inline | |||
void | void | |||
field_aux::reset_objects(field<oT>& x) | field_aux::reset_objects(field<oT>& x) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 55 lines changed or added | |||
fn_as_scalar.hpp | fn_as_scalar.hpp | |||
---|---|---|---|---|
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2010-2011 Conrad Sanderson | // Copyright (C) 2010-2013 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 fn_as_scalar | //! \addtogroup fn_as_scalar | |||
//! @{ | //! @{ | |||
template<uword N> | template<uword N> | |||
struct as_scalar_redirect | struct as_scalar_redirect | |||
skipping to change at line 42 | skipping to change at line 42 | |||
template<uword N> | template<uword N> | |||
template<typename T1> | template<typename T1> | |||
inline | inline | |||
typename T1::elem_type | typename T1::elem_type | |||
as_scalar_redirect<N>::apply(const T1& X) | as_scalar_redirect<N>::apply(const T1& X) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
const unwrap<T1> tmp(X); | const Proxy<T1> P(X); | |||
const Mat<eT>& A = tmp.M; | ||||
arma_debug_check( (A.n_elem != 1), "as_scalar(): expression doesn't evalu ate to exactly one element" ); | arma_debug_check( (P.get_n_elem() != 1), "as_scalar(): expression doesn't evaluate to exactly one element" ); | |||
return A.mem[0]; | return (Proxy<T1>::prefer_at_accessor == true) ? P.at(0,0) : P[0]; | |||
} | } | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
inline | inline | |||
typename T1::elem_type | typename T1::elem_type | |||
as_scalar_redirect<2>::apply(const Glue<T1, T2, glue_times>& X) | as_scalar_redirect<2>::apply(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; | |||
// T1 must result in a matrix with one row | // T1 must result in a matrix with one row | |||
// T2 must result in a matrix with one column | // T2 must result in a matrix with one column | |||
const partial_unwrap<T1> tmp1(X.A); | const bool has_all_mat = is_Mat<T1>::value && is_Mat<T | |||
const partial_unwrap<T2> tmp2(X.B); | 2>::value; | |||
const bool has_op_htrans2 = is_op_htrans2<T1>::value || is_op_ht | ||||
rans2<T2>::value; | ||||
const bool prefer_at_accessor = Proxy<T1>::prefer_at_accessor || Proxy<T2 | ||||
>::prefer_at_accessor; | ||||
const Mat<eT>& A = tmp1.M; | const bool do_partial_unwrap = has_all_mat || has_op_htrans2 || prefer_at | |||
const Mat<eT>& B = tmp2.M; | _accessor; | |||
const uword A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols; | if(do_partial_unwrap == true) | |||
const uword A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows; | { | |||
const partial_unwrap<T1> tmp1(X.A); | ||||
const partial_unwrap<T2> tmp2(X.B); | ||||
typedef typename partial_unwrap<T1>::stored_type TA; | ||||
typedef typename partial_unwrap<T2>::stored_type TB; | ||||
const uword B_n_rows = (tmp2.do_trans == false) ? B.n_rows : B.n_cols; | const TA& A = tmp1.M; | |||
const uword B_n_cols = (tmp2.do_trans == false) ? B.n_cols : B.n_rows; | const TB& B = tmp2.M; | |||
const eT val = tmp1.get_val() * tmp2.get_val(); | const uword A_n_rows = (tmp1.do_trans == false) ? (TA::is_row ? 1 : A.n | |||
_rows) : (TA::is_col ? 1 : A.n_cols); | ||||
const uword A_n_cols = (tmp1.do_trans == false) ? (TA::is_col ? 1 : A.n | ||||
_cols) : (TA::is_row ? 1 : A.n_rows); | ||||
arma_debug_check( (A_n_rows != 1) || (B_n_cols != 1) || (A_n_cols != B_n_ | const uword B_n_rows = (tmp2.do_trans == false) ? (TB::is_row ? 1 : B.n | |||
rows), "as_scalar(): incompatible dimensions" ); | _rows) : (TB::is_col ? 1 : B.n_cols); | |||
const uword B_n_cols = (tmp2.do_trans == false) ? (TB::is_col ? 1 : B.n | ||||
_cols) : (TB::is_row ? 1 : B.n_rows); | ||||
return val * op_dot::direct_dot(A.n_elem, A.mem, B.mem); | arma_debug_check( (A_n_rows != 1) || (B_n_cols != 1) || (A_n_cols != B_ | |||
n_rows), "as_scalar(): incompatible dimensions" ); | ||||
const eT val = op_dot::direct_dot(A.n_elem, A.memptr(), B.memptr()); | ||||
return (tmp1.do_times || tmp2.do_times) ? (val * tmp1.get_val() * tmp2. | ||||
get_val()) : val; | ||||
} | ||||
else | ||||
{ | ||||
const Proxy<T1> PA(X.A); | ||||
const Proxy<T2> PB(X.B); | ||||
arma_debug_check | ||||
( | ||||
(PA.get_n_rows() != 1) || (PB.get_n_cols() != 1) || (PA.get_n_cols() | ||||
!= PB.get_n_rows()), | ||||
"as_scalar(): incompatible dimensions" | ||||
); | ||||
return op_dot::apply_proxy(PA,PB); | ||||
} | ||||
} | } | |||
template<typename T1, typename T2, typename T3> | template<typename T1, typename T2, typename T3> | |||
inline | inline | |||
typename T1::elem_type | typename T1::elem_type | |||
as_scalar_redirect<3>::apply(const Glue< Glue<T1, T2, glue_times>, T3, glue _times >& X) | as_scalar_redirect<3>::apply(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; | |||
skipping to change at line 275 | skipping to change at line 299 | |||
template<typename T1> | template<typename T1> | |||
inline | inline | |||
arma_warn_unused | arma_warn_unused | |||
typename T1::elem_type | typename T1::elem_type | |||
as_scalar(const Base<typename T1::elem_type,T1>& X) | as_scalar(const Base<typename T1::elem_type,T1>& X) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
const unwrap<T1> tmp(X.get_ref()); | const Proxy<T1> P(X.get_ref()); | |||
const Mat<eT>& A = tmp.M; | ||||
arma_debug_check( (A.n_elem != 1), "as_scalar(): expression doesn't evalu ate to exactly one element" ); | arma_debug_check( (P.get_n_elem() != 1), "as_scalar(): expression doesn't evaluate to exactly one element" ); | |||
return A.mem[0]; | return (Proxy<T1>::prefer_at_accessor == true) ? P.at(0,0) : P[0]; | |||
} | } | |||
template<typename T1> | // ensure the following two functions are aware of each other | |||
arma_inline | template<typename T1, typename eop_type> inline arma_warn_un | |||
used typename T1::elem_type as_scalar(const eOp<T1, eop_type>& X); | ||||
template<typename T1, typename T2, typename eglue_type> inline arma_warn_un | ||||
used typename T1::elem_type as_scalar(const eGlue<T1, T2, eglue_type>& X); | ||||
template<typename T1, typename eop_type> | ||||
inline | ||||
arma_warn_unused | arma_warn_unused | |||
typename T1::elem_type | typename T1::elem_type | |||
as_scalar(const eOp<T1, eop_neg>& X) | as_scalar(const eOp<T1, eop_type>& X) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
return -(as_scalar(X.P.Q)); | typedef typename T1::elem_type eT; | |||
const eT val = as_scalar(X.P.Q); | ||||
return eop_core<eop_type>::process(val, X.aux); | ||||
} | ||||
template<typename T1, typename T2, typename eglue_type> | ||||
inline | ||||
arma_warn_unused | ||||
typename T1::elem_type | ||||
as_scalar(const eGlue<T1, T2, eglue_type>& X) | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
typedef typename T1::elem_type eT; | ||||
const eT a = as_scalar(X.P1.Q); | ||||
const eT b = as_scalar(X.P2.Q); | ||||
// the optimiser will keep only one return statement | ||||
if(is_same_type<eglue_type, eglue_plus >::value == true) { return a | ||||
+ b; } | ||||
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return a | ||||
- b; } | ||||
else if(is_same_type<eglue_type, eglue_div >::value == true) { return a | ||||
/ b; } | ||||
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return a | ||||
* b; } | ||||
} | } | |||
template<typename T1> | template<typename T1> | |||
inline | inline | |||
arma_warn_unused | arma_warn_unused | |||
typename T1::elem_type | typename T1::elem_type | |||
as_scalar(const BaseCube<typename T1::elem_type,T1>& X) | as_scalar(const BaseCube<typename T1::elem_type,T1>& X) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
const unwrap_cube<T1> tmp(X.get_ref()); | const ProxyCube<T1> P(X.get_ref()); | |||
const Cube<eT>& A = tmp.M; | ||||
arma_debug_check( (A.n_elem != 1), "as_scalar(): expression doesn't evalu ate to exactly one element" ); | arma_debug_check( (P.get_n_elem() != 1), "as_scalar(): expression doesn't evaluate to exactly one element" ); | |||
return A.mem[0]; | return (ProxyCube<T1>::prefer_at_accessor == true) ? P.at(0,0,0) : P[0]; | |||
} | } | |||
template<typename T> | template<typename T> | |||
arma_inline | arma_inline | |||
arma_warn_unused | arma_warn_unused | |||
const typename arma_scalar_only<T>::result & | const typename arma_scalar_only<T>::result & | |||
as_scalar(const T& x) | as_scalar(const T& x) | |||
{ | { | |||
return x; | return x; | |||
} | } | |||
End of changes. 20 change blocks. | ||||
30 lines changed or deleted | 97 lines changed or added | |||
fn_trace.hpp | fn_trace.hpp | |||
---|---|---|---|---|
skipping to change at line 89 | skipping to change at line 89 | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
const Proxy<T1> PA(XA); | const Proxy<T1> PA(XA); | |||
const unwrap<T2> tmpB(XB); | const unwrap<T2> tmpB(XB); | |||
const Mat<eT>& B = tmpB.M; | const Mat<eT>& B = tmpB.M; | |||
arma_debug_assert_mul_size(PA.get_n_rows(), PA.get_n_cols(), B.n_rows, B. n_cols, "matrix multiply"); | arma_debug_assert_mul_size(PA.get_n_rows(), PA.get_n_cols(), B.n_rows, B. n_cols, "matrix multiplication"); | |||
arma_debug_check( (PA.get_n_rows() != B.n_cols), "trace(): matrix must be square sized" ); | arma_debug_check( (PA.get_n_rows() != B.n_cols), "trace(): matrix must be square sized" ); | |||
const uword N1 = PA.get_n_rows(); // equivalent to B.n_cols, due to squ are size requirements | const uword N1 = PA.get_n_rows(); // equivalent to B.n_cols, due to squ are size requirements | |||
const uword N2 = PA.get_n_cols(); // equivalent to B.n_rows, due to mat rix multiplication requirements | const uword N2 = PA.get_n_cols(); // equivalent to B.n_rows, due to mat rix multiplication requirements | |||
eT val = eT(0); | eT val = eT(0); | |||
for(uword i=0; i<N1; ++i) | for(uword i=0; i<N1; ++i) | |||
{ | { | |||
skipping to change at line 145 | skipping to change at line 145 | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
const Proxy<T1> PA(XA); | const Proxy<T1> PA(XA); | |||
const Proxy<T2> PB(XB); | const Proxy<T2> PB(XB); | |||
if(is_Mat<typename Proxy<T2>::stored_type>::value == true) | if(is_Mat<typename Proxy<T2>::stored_type>::value == true) | |||
{ | { | |||
return trace_mul_unwrap(PA.Q, PB.Q); | return trace_mul_unwrap(PA.Q, PB.Q); | |||
} | } | |||
arma_debug_assert_mul_size(PA.get_n_rows(), PA.get_n_cols(), PB.get_n_row s(), PB.get_n_cols(), "matrix multiply"); | arma_debug_assert_mul_size(PA.get_n_rows(), PA.get_n_cols(), PB.get_n_row s(), PB.get_n_cols(), "matrix multiplication"); | |||
arma_debug_check( (PA.get_n_rows() != PB.get_n_cols()), "trace(): matrix must be square sized" ); | arma_debug_check( (PA.get_n_rows() != PB.get_n_cols()), "trace(): matrix must be square sized" ); | |||
const uword N1 = PA.get_n_rows(); // equivalent to PB.get_n_cols(), due to square size requirements | const uword N1 = PA.get_n_rows(); // equivalent to PB.get_n_cols(), due to square size requirements | |||
const uword N2 = PA.get_n_cols(); // equivalent to PB.get_n_rows(), due to matrix multiplication requirements | const uword N2 = PA.get_n_cols(); // equivalent to PB.get_n_rows(), due to matrix multiplication requirements | |||
eT val = eT(0); | eT val = eT(0); | |||
for(uword i=0; i<N1; ++i) | for(uword i=0; i<N1; ++i) | |||
{ | { | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added | |||
gemm.hpp | gemm.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2012 Conrad Sanderson | // Copyright (C) 2008-2013 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 gemm | //! \addtogroup gemm | |||
//! @{ | //! @{ | |||
//! for tiny square matrices, size <= 4x4 | //! for tiny square matrices, size <= 4x4 | |||
template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | |||
class gemm_emul_tinysq | class gemm_emul_tinysq | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA, typename TB> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat<eT>& C, | Mat<eT>& C, | |||
const Mat<eT>& A, | const TA& A, | |||
const Mat<eT>& B, | const TB& B, | |||
const eT alpha = eT(1), | const eT alpha = eT(1), | |||
const eT beta = eT(0) | const eT beta = eT(0) | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
switch(A.n_rows) | switch(A.n_rows) | |||
{ | { | |||
case 4: | case 4: | |||
gemv_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply( C.colptr( 3), A, B.colptr(3), alpha, beta ); | gemv_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply( C.colptr( 3), A, B.colptr(3), alpha, beta ); | |||
skipping to change at line 59 | skipping to change at line 59 | |||
} | } | |||
} | } | |||
}; | }; | |||
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> | template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> | |||
class gemm_emul_large | class gemm_emul_large | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA, typename TB> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat<eT>& C, | Mat<eT>& C, | |||
const Mat<eT>& A, | const TA& A, | |||
const Mat<eT>& B, | const TB& B, | |||
const eT alpha = eT(1), | const eT alpha = eT(1), | |||
const eT beta = eT(0) | const eT beta = eT(0) | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
const uword A_n_rows = A.n_rows; | const uword A_n_rows = A.n_rows; | |||
const uword A_n_cols = A.n_cols; | const uword A_n_cols = A.n_cols; | |||
const uword B_n_rows = B.n_rows; | const uword B_n_rows = B.n_rows; | |||
skipping to change at line 237 | skipping to change at line 237 | |||
} | } | |||
} | } | |||
}; | }; | |||
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> | template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> | |||
class gemm_emul | class gemm_emul | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA, typename TB> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat<eT>& C, | Mat<eT>& C, | |||
const Mat<eT>& A, | const TA& A, | |||
const Mat<eT>& B, | const TB& B, | |||
const eT alpha = eT(1), | const eT alpha = eT(1), | |||
const eT beta = eT(0), | const eT beta = eT(0), | |||
const typename arma_not_cx<eT>::result* junk = 0 | const typename arma_not_cx<eT>::result* junk = 0 | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_ignore(junk); | arma_ignore(junk); | |||
const uword A_n_rows = A.n_rows; | const uword A_n_rows = A.n_rows; | |||
const uword A_n_cols = A.n_cols; | const uword A_n_cols = A.n_cols; | |||
skipping to change at line 344 | skipping to change at line 344 | |||
//! \brief | //! \brief | |||
//! Wrapper for ATLAS/BLAS dgemm function, using template arguments to cont rol the arguments passed to dgemm. | //! Wrapper for ATLAS/BLAS dgemm function, using template arguments to cont rol the arguments passed to dgemm. | |||
//! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes) | //! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes) | |||
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> | template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> | |||
class gemm | class gemm | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA, typename TB> | |||
inline | inline | |||
static | static | |||
void | void | |||
apply_blas_type( Mat<eT>& C, const Mat<eT>& A, const Mat<eT>& B, const eT alpha = eT(1), const eT beta = eT(0) ) | apply_blas_type( Mat<eT>& C, const TA& A, const TB& B, const eT alpha = e T(1), const eT beta = eT(0) ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
const uword threshold = (is_complex<eT>::value == true) ? 16u : 48u; | const uword threshold = (is_Mat_fixed<TA>::value && is_Mat_fixed<TB>::v | |||
alue) | ||||
? (is_complex<eT>::value ? 16u : 64u) | ||||
: (is_complex<eT>::value ? 16u : 48u); | ||||
if( (A.n_elem <= threshold) && (B.n_elem <= threshold) ) | if( (A.n_elem <= threshold) && (B.n_elem <= threshold) ) | |||
{ | { | |||
gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B,a lpha,beta); | gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B,a lpha,beta); | |||
} | } | |||
else | else | |||
{ | { | |||
#if defined(ARMA_USE_ATLAS) | #if defined(ARMA_USE_ATLAS) | |||
{ | { | |||
arma_extra_debug_print("atlas::cblas_gemm()"); | arma_extra_debug_print("atlas::cblas_gemm()"); | |||
skipping to change at line 429 | skipping to change at line 431 | |||
} | } | |||
#else | #else | |||
{ | { | |||
gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B ,alpha,beta); | gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B ,alpha,beta); | |||
} | } | |||
#endif | #endif | |||
} | } | |||
} | } | |||
//! immediate multiplication of matrices A and B, storing the result in C | //! immediate multiplication of matrices A and B, storing the result in C | |||
template<typename eT> | template<typename eT, typename TA, typename TB> | |||
inline | inline | |||
static | static | |||
void | void | |||
apply( Mat<eT>& C, const Mat<eT>& A, const Mat<eT>& B, const eT alpha = e T(1), const eT beta = eT(0) ) | apply( Mat<eT>& C, const TA& A, const TB& B, const eT alpha = eT(1), cons t eT beta = eT(0) ) | |||
{ | { | |||
gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B,alp ha,beta); | gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B,alp ha,beta); | |||
} | } | |||
template<typename TA, typename TB> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat<float>& C, | Mat<float>& C, | |||
const Mat<float>& A, | const TA& A, | |||
const Mat<float>& B, | const TB& B, | |||
const float alpha = float(1), | const float alpha = float(1), | |||
const float beta = float(0) | const float beta = float(0) | |||
) | ) | |||
{ | { | |||
gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | |||
} | } | |||
template<typename TA, typename TB> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat<double>& C, | Mat<double>& C, | |||
const Mat<double>& A, | const TA& A, | |||
const Mat<double>& B, | const TB& B, | |||
const double alpha = double(1), | const double alpha = double(1), | |||
const double beta = double(0) | const double beta = double(0) | |||
) | ) | |||
{ | { | |||
gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | |||
} | } | |||
template<typename TA, typename TB> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat< std::complex<float> >& C, | Mat< std::complex<float> >& C, | |||
const Mat< std::complex<float> >& A, | const TA& A, | |||
const Mat< std::complex<float> >& B, | const TB& B, | |||
const std::complex<float> alpha = std::complex<float>(1), | const std::complex<float> alpha = std::complex<float>(1), | |||
const std::complex<float> beta = std::complex<float>(0) | const std::complex<float> beta = std::complex<float>(0) | |||
) | ) | |||
{ | { | |||
gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | |||
} | } | |||
template<typename TA, typename TB> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
Mat< std::complex<double> >& C, | Mat< std::complex<double> >& C, | |||
const Mat< std::complex<double> >& A, | const TA& A, | |||
const Mat< std::complex<double> >& B, | const TB& B, | |||
const std::complex<double> alpha = std::complex<double>(1), | const std::complex<double> alpha = std::complex<double>(1), | |||
const std::complex<double> beta = std::complex<double>(0) | const std::complex<double> beta = std::complex<double>(0) | |||
) | ) | |||
{ | { | |||
gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | gemm<do_trans_A, do_trans_B, use_alpha, use_beta>::apply_blas_type(C,A, B,alpha,beta); | |||
} | } | |||
}; | }; | |||
//! @} | //! @} | |||
End of changes. 20 change blocks. | ||||
24 lines changed or deleted | 31 lines changed or added | |||
gemv.hpp | gemv.hpp | |||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
y[i] = (use_alpha == false) ? acc : alpha*acc; | y[i] = (use_alpha == false) ? acc : alpha*acc; | |||
} | } | |||
else | else | |||
{ | { | |||
const eT tmp = y[i]; | const eT tmp = y[i]; | |||
y[i] = beta*tmp + ( (use_alpha == false) ? acc : alpha*acc ); | y[i] = beta*tmp + ( (use_alpha == false) ? acc : alpha*acc ); | |||
} | } | |||
} | } | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
void | void | |||
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) ) | apply( eT* y, const TA& A, const eT* x, const eT alpha = eT(1), const eT beta = eT(0) ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
const eT* Am = A.memptr(); | const eT* Am = A.memptr(); | |||
switch(A.n_rows) | switch(A.n_rows) | |||
{ | { | |||
case 1: | case 1: | |||
{ | { | |||
const eT acc = Am[0] * x[0]; | const eT acc = Am[0] * x[0]; | |||
skipping to change at line 124 | skipping to change at line 124 | |||
; | ; | |||
} | } | |||
} | } | |||
}; | }; | |||
class gemv_emul_large_helper | class gemv_emul_large_helper | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
typename arma_not_cx<eT>::result | typename arma_not_cx<eT>::result | |||
dot_row_col( const Mat<eT>& A, const eT* x, const uword row, const uword N) | dot_row_col( const TA& A, const eT* x, const uword row, const uword N ) | |||
{ | { | |||
eT acc1 = eT(0); | eT acc1 = eT(0); | |||
eT acc2 = eT(0); | eT acc2 = eT(0); | |||
uword i,j; | uword i,j; | |||
for(i=0, j=1; j < N; i+=2, j+=2) | for(i=0, j=1; j < N; i+=2, j+=2) | |||
{ | { | |||
const eT xi = x[i]; | const eT xi = x[i]; | |||
const eT xj = x[j]; | const eT xj = x[j]; | |||
skipping to change at line 152 | skipping to change at line 152 | |||
} | } | |||
if(i < N) | if(i < N) | |||
{ | { | |||
acc1 += A.at(row,i) * x[i]; | acc1 += A.at(row,i) * x[i]; | |||
} | } | |||
return (acc1 + acc2); | return (acc1 + acc2); | |||
} | } | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
typename arma_cx_only<eT>::result | typename arma_cx_only<eT>::result | |||
dot_row_col( const Mat<eT>& A, const eT* x, const uword row, const uword N) | dot_row_col( const TA& A, const eT* x, const uword row, const uword N ) | |||
{ | { | |||
typedef typename get_pod_type<eT>::result T; | typedef typename get_pod_type<eT>::result T; | |||
T val_real = T(0); | T val_real = T(0); | |||
T val_imag = T(0); | T val_imag = T(0); | |||
for(uword i=0; i<N; ++i) | for(uword i=0; i<N; ++i) | |||
{ | { | |||
const std::complex<T>& Ai = A.at(row,i); | const std::complex<T>& Ai = A.at(row,i); | |||
const std::complex<T>& xi = x[i]; | const std::complex<T>& xi = x[i]; | |||
skipping to change at line 193 | skipping to change at line 193 | |||
//! \brief | //! \brief | |||
//! Partial emulation of ATLAS/BLAS gemv(). | //! Partial emulation of ATLAS/BLAS gemv(). | |||
//! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose) | //! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose) | |||
template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | |||
class gemv_emul_large | class gemv_emul_large | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
void | void | |||
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) ) | apply( eT* y, const TA& A, const eT* x, const eT alpha = eT(1), const eT beta = eT(0) ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
const uword A_n_rows = A.n_rows; | const uword A_n_rows = A.n_rows; | |||
const uword A_n_cols = A.n_cols; | const uword A_n_cols = A.n_cols; | |||
if(do_trans_A == false) | if(do_trans_A == false) | |||
{ | { | |||
if(A_n_rows == 1) | if(A_n_rows == 1) | |||
{ | { | |||
const eT acc = op_dot::direct_dot_arma(A_n_cols, A.mem, x); | const eT acc = op_dot::direct_dot_arma(A_n_cols, A.memptr(), x); | |||
if( (use_alpha == false) && (use_beta == false) ) | if( (use_alpha == false) && (use_beta == false) ) | |||
{ | { | |||
y[0] = acc; | y[0] = acc; | |||
} | } | |||
else | else | |||
if( (use_alpha == true) && (use_beta == false) ) | if( (use_alpha == true) && (use_beta == false) ) | |||
{ | { | |||
y[0] = alpha * acc; | y[0] = alpha * acc; | |||
} | } | |||
skipping to change at line 305 | skipping to change at line 305 | |||
} | } | |||
} | } | |||
}; | }; | |||
template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | |||
class gemv_emul | class gemv_emul | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_hot | arma_hot | |||
inline | inline | |||
static | static | |||
void | void | |||
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 ) | apply( eT* y, const TA& A, const eT* x, const eT alpha = eT(1), const eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_ignore(junk); | arma_ignore(junk); | |||
const uword A_n_rows = A.n_rows; | const uword A_n_rows = A.n_rows; | |||
const uword A_n_cols = A.n_cols; | const uword A_n_cols = A.n_cols; | |||
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | |||
{ | { | |||
gemv_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alp ha, beta); | gemv_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alp ha, beta); | |||
skipping to change at line 370 | skipping to change at line 370 | |||
//! \brief | //! \brief | |||
//! Wrapper for ATLAS/BLAS gemv function, using template arguments to contr ol the arguments passed to gemv. | //! Wrapper for ATLAS/BLAS gemv function, using template arguments to contr ol the arguments passed to gemv. | |||
//! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose) | //! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose) | |||
template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> | |||
class gemv | class gemv | |||
{ | { | |||
public: | public: | |||
template<typename eT> | template<typename eT, typename TA> | |||
inline | inline | |||
static | static | |||
void | void | |||
apply_blas_type( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = e T(1), const eT beta = eT(0) ) | apply_blas_type( eT* y, const TA& A, const eT* x, const eT alpha = eT(1), const eT beta = eT(0) ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
//const uword threshold = (is_complex<eT>::value == true) ? 16u : 64u; | //const uword threshold = (is_complex<eT>::value == true) ? 16u : 64u; | |||
const uword threshold = (is_complex<eT>::value == true) ? 64u : 100u; | const uword threshold = (is_complex<eT>::value == true) ? 64u : 100u; | |||
if(A.n_elem <= threshold) | if(A.n_elem <= threshold) | |||
{ | { | |||
gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta); | gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta); | |||
} | } | |||
skipping to change at line 472 | skipping to change at line 472 | |||
} | } | |||
#else | #else | |||
{ | { | |||
gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta) ; | gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta) ; | |||
} | } | |||
#endif | #endif | |||
} | } | |||
} | } | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) ) | apply( eT* y, const TA& A, const eT* x, const eT alpha = eT(1), const eT beta = eT(0) ) | |||
{ | { | |||
gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta); | gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta); | |||
} | } | |||
template<typename TA> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
float* y, | float* y, | |||
const Mat<float>& A, | const TA& A, | |||
const float* x, | const float* x, | |||
const float alpha = float(1), | const float alpha = float(1), | |||
const float beta = float(0) | const float beta = float(0) | |||
) | ) | |||
{ | { | |||
gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | |||
} | } | |||
template<typename TA> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
double* y, | double* y, | |||
const Mat<double>& A, | const TA& A, | |||
const double* x, | const double* x, | |||
const double alpha = double(1), | const double alpha = double(1), | |||
const double beta = double(0) | const double beta = double(0) | |||
) | ) | |||
{ | { | |||
gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | |||
} | } | |||
template<typename TA> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
std::complex<float>* y, | std::complex<float>* y, | |||
const Mat< std::complex<float > >& A, | const TA& A, | |||
const std::complex<float>* x, | const std::complex<float>* x, | |||
const std::complex<float> alpha = std::complex<float>(1), | const std::complex<float> alpha = std::complex<float>(1), | |||
const std::complex<float> beta = std::complex<float>(0) | const std::complex<float> beta = std::complex<float>(0) | |||
) | ) | |||
{ | { | |||
gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | |||
} | } | |||
template<typename TA> | ||||
arma_inline | arma_inline | |||
static | static | |||
void | void | |||
apply | apply | |||
( | ( | |||
std::complex<double>* y, | std::complex<double>* y, | |||
const Mat< std::complex<double> >& A, | const TA& A, | |||
const std::complex<double>* x, | const std::complex<double>* x, | |||
const std::complex<double> alpha = std::complex<double>(1), | const std::complex<double> alpha = std::complex<double>(1), | |||
const std::complex<double> beta = std::complex<double>(0) | const std::complex<double> beta = std::complex<double>(0) | |||
) | ) | |||
{ | { | |||
gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | gemv<do_trans_A, use_alpha, use_beta>::apply_blas_type(y,A,x,alpha,beta ); | |||
} | } | |||
}; | }; | |||
//! @} | //! @} | |||
End of changes. 23 change blocks. | ||||
35 lines changed or deleted | 39 lines changed or added | |||
glue_mixed_meat.hpp | glue_mixed_meat.hpp | |||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
typedef typename T1::elem_type eT1; | typedef typename T1::elem_type eT1; | |||
typedef typename T2::elem_type eT2; | typedef typename T2::elem_type eT2; | |||
const unwrap_check_mixed<T1> tmp1(X.A, out); | const unwrap_check_mixed<T1> tmp1(X.A, out); | |||
const unwrap_check_mixed<T2> tmp2(X.B, out); | const unwrap_check_mixed<T2> tmp2(X.B, out); | |||
const Mat<eT1>& A = tmp1.M; | const Mat<eT1>& A = tmp1.M; | |||
const Mat<eT2>& B = tmp2.M; | const Mat<eT2>& B = tmp2.M; | |||
arma_debug_assert_mul_size(A, B, "multiplication"); | arma_debug_assert_mul_size(A, B, "matrix multiplication"); | |||
out.set_size(A.n_rows, B.n_cols); | out.set_size(A.n_rows, B.n_cols); | |||
gemm_mixed<>::apply(out, A, B); | gemm_mixed<>::apply(out, A, B); | |||
} | } | |||
//! matrix addition with different element types | //! matrix addition with different element types | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
inline | inline | |||
void | void | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
glue_times_bones.hpp | glue_times_bones.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2012 Conrad Sanderson | // Copyright (C) 2008-2013 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 glue_times | //! \addtogroup glue_times | |||
//! @{ | //! @{ | |||
//! \brief | //! \brief | |||
//! Template metaprogram depth_lhs | //! Template metaprogram depth_lhs | |||
skipping to change at line 87 | skipping to change at line 87 | |||
template<typename T1> | template<typename T1> | |||
arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& ou t, const T1& X); | arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& ou t, const T1& X); | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type >& out, const Glue<T1, T2, glue_times>& X, const sword sign); | arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type >& out, const Glue<T1, T2, glue_times>& X, const sword sign); | |||
template<typename eT1, typename eT2> | template<typename eT1, typename eT2> | |||
inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result >& out, const Mat<eT1>& X, const Mat<eT2>& Y); | inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result >& out, const Mat<eT1>& X, const Mat<eT2>& Y); | |||
template<typename eT, const bool do_trans_A, const bool do_trans_B> | // | |||
arma_inline static uword mul_storage_cost(const Mat<eT>& A, const Mat<eT | ||||
>& B); | ||||
template<typename eT, const bool do_trans_A, const bool do_trans_B, const | template<typename eT, const bool do_trans_A, const bool do_trans_B, typen | |||
bool do_scalar_times> | ame TA, typename TB> | |||
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M | arma_inline static uword mul_storage_cost(const TA& A, const TB& B); | |||
at<eT>& B, const eT val); | ||||
template<typename eT, const bool do_trans_A, const bool do_trans_B, const | template<typename eT, const bool do_trans_A, const bool do_trans_B, const | |||
bool do_trans_C, const bool do_scalar_times> | bool do_scalar_times, typename TA, typename TB> | |||
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M | arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B, | |||
at<eT>& B, const Mat<eT>& C, const eT val); | const eT val); | |||
template<typename eT, const bool do_trans_A, const bool do_trans_B, const | template<typename eT, const bool do_trans_A, const bool do_trans_B, const | |||
bool do_trans_C, const bool do_trans_D, const bool do_scalar_times> | bool do_trans_C, const bool do_scalar_times, typename TA, typename TB, typ | |||
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M | ename TC> | |||
at<eT>& B, const Mat<eT>& C, const Mat<eT>& D, const eT val); | arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B, | |||
const TC& C, const eT val); | ||||
template<typename eT, const bool do_trans_A, const bool do_trans_B, const | ||||
bool do_trans_C, const bool do_trans_D, const bool do_scalar_times, typena | ||||
me TA, typename TB, typename TC, typename TD> | ||||
arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B, | ||||
const TC& C, const TD& D, const eT val); | ||||
}; | }; | |||
class glue_times_diag | class glue_times_diag | |||
{ | { | |||
public: | public: | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times_diag>& X); | arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times_diag>& X); | |||
}; | }; | |||
End of changes. 6 change blocks. | ||||
17 lines changed or deleted | 20 lines changed or added | |||
glue_times_meat.hpp | glue_times_meat.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2012 Conrad Sanderson | // Copyright (C) 2008-2013 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 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> | |||
skipping to change at line 25 | skipping to change at line 25 | |||
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_check<T1> tmp1(X.A, out); | |||
const partial_unwrap_check<T2> tmp2(X.B, out); | const partial_unwrap_check<T2> tmp2(X.B, out); | |||
const Mat<eT>& A = tmp1.M; | const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | |||
const Mat<eT>& B = tmp2.M; | const typename partial_unwrap_check<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_check<T1>::do_times || partial_unwr ap_check<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 | glue_times::apply | |||
< | < | |||
eT, | eT, | |||
partial_unwrap_check<T1>::do_trans, | partial_unwrap_check<T1>::do_trans, | |||
partial_unwrap_check<T2>::do_trans, | partial_unwrap_check<T2>::do_trans, | |||
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim es) | (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim es) | |||
skipping to change at line 56 | skipping to change at line 56 | |||
{ | { | |||
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_check<T1> tmp1(X.A, out); | |||
const partial_unwrap_check<T2> tmp2(X.B, out); | const partial_unwrap_check<T2> tmp2(X.B, out); | |||
const Mat<eT>& A = tmp1.M; | const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | |||
const Mat<eT>& B = tmp2.M; | const typename partial_unwrap_check<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_check<T1>::do_times || partial_un wrap_check<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 | glue_times::apply | |||
< | < | |||
eT, | eT, | |||
partial_unwrap_check<T1>::do_trans, | partial_unwrap_check<T1>::do_trans, | |||
partial_unwrap_check<T2>::do_trans, | partial_unwrap_check<T2>::do_trans, | |||
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_t imes) | (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_t imes) | |||
skipping to change at line 102 | skipping to change at line 102 | |||
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_check<T1> tmp1(X.A, out); | |||
const partial_unwrap_check<T2> tmp2(X.B, out); | const partial_unwrap_check<T2> tmp2(X.B, out); | |||
const Mat<eT>& A = tmp1.M; | const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | |||
const Mat<eT>& B = tmp2.M; | const typename partial_unwrap_check<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_check<T1>::do_times || partial_unwr ap_check<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 | glue_times::apply | |||
< | < | |||
eT, | eT, | |||
partial_unwrap_check<T1>::do_trans, | partial_unwrap_check<T1>::do_trans, | |||
partial_unwrap_check<T2>::do_trans, | partial_unwrap_check<T2>::do_trans, | |||
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim es) | (partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim es) | |||
skipping to change at line 151 | skipping to change at line 151 | |||
// 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 | |||
// TODO: investigate detecting A*inv(B)*C and replacing with A*solve(B,C) | // TODO: investigate detecting A*inv(B)*C and replacing with A*solve(B,C) | |||
// there is exactly 3 objects | // there is 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_check<T1> tmp1(X.A.A, out); | |||
const partial_unwrap_check<T2> tmp2(X.A.B, out); | const partial_unwrap_check<T2> tmp2(X.A.B, out); | |||
const partial_unwrap_check<T3> tmp3(X.B, out); | const partial_unwrap_check<T3> tmp3(X.B, out); | |||
const Mat<eT>& A = tmp1.M; | const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | |||
const Mat<eT>& B = tmp2.M; | const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | |||
const Mat<eT>& C = tmp3.M; | const typename partial_unwrap_check<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_check<T1>::do_times || partial_unwr ap_check<T2>::do_times || partial_unwrap_check<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 | glue_times::apply | |||
< | < | |||
eT, | eT, | |||
partial_unwrap_check<T1>::do_trans, | partial_unwrap_check<T1>::do_trans, | |||
partial_unwrap_check<T2>::do_trans, | partial_unwrap_check<T2>::do_trans, | |||
partial_unwrap_check<T3>::do_trans, | partial_unwrap_check<T3>::do_trans, | |||
skipping to change at line 187 | skipping to change at line 187 | |||
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_check<T1> tmp1(X.A.A.A, out); | |||
const partial_unwrap_check<T2> tmp2(X.A.A.B, out); | const partial_unwrap_check<T2> tmp2(X.A.A.B, out); | |||
const partial_unwrap_check<T3> tmp3(X.A.B, out); | const partial_unwrap_check<T3> tmp3(X.A.B, out); | |||
const partial_unwrap_check<T4> tmp4(X.B, out); | const partial_unwrap_check<T4> tmp4(X.B, out); | |||
const Mat<eT>& A = tmp1.M; | const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M; | |||
const Mat<eT>& B = tmp2.M; | const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M; | |||
const Mat<eT>& C = tmp3.M; | const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M; | |||
const Mat<eT>& D = tmp4.M; | const typename partial_unwrap_check<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_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 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 | glue_times::apply | |||
< | < | |||
eT, | eT, | |||
partial_unwrap_check<T1>::do_trans, | partial_unwrap_check<T1>::do_trans, | |||
partial_unwrap_check<T2>::do_trans, | partial_unwrap_check<T2>::do_trans, | |||
partial_unwrap_check<T3>::do_trans, | partial_unwrap_check<T3>::do_trans, | |||
skipping to change at line 281 | skipping to change at line 281 | |||
void | void | |||
glue_times::apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue <T1, T2, glue_times>& X, const sword sign) | glue_times::apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue <T1, T2, glue_times>& X, const sword sign) | |||
{ | { | |||
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_check<T1> tmp1(X.A, out); | |||
const partial_unwrap_check<T2> tmp2(X.B, out); | const partial_unwrap_check<T2> tmp2(X.B, out); | |||
const Mat<eT>& A = tmp1.M; | typedef typename partial_unwrap_check<T1>::stored_type TA; | |||
const Mat<eT>& B = tmp2.M; | typedef typename partial_unwrap_check<T2>::stored_type TB; | |||
const TA& A = tmp1.M; | ||||
const TB& B = tmp2.M; | ||||
const bool do_trans_A = partial_unwrap_check<T1>::do_trans; | const bool do_trans_A = partial_unwrap_check<T1>::do_trans; | |||
const bool do_trans_B = partial_unwrap_check<T2>::do_trans; | const bool do_trans_B = partial_unwrap_check<T2>::do_trans; | |||
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) ? A.n_rows : A.n_cols; | const uword result_n_rows = (do_trans_A == false) ? (TA::is_row ? 1 : A.n | |||
const uword result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; | _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); | ||||
arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "addition"); | arma_debug_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result _n_cols, "addition"); | |||
if(out.n_elem > 0) | if(out.n_elem > 0) | |||
{ | { | |||
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == fal se) ) | if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == fal se) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | gemv<true, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<false, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | gemv<false, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, false, false, true>::apply(out, A, B, alpha, eT(1)); | gemm<false, false, false, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == tru e) ) | if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == tru e) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, false, true, true>::apply(out, A, B, alpha, eT(1)); | gemm<false, false, true, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == fals e) ) | if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == fals e) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | gemv<true, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, false, false, true>::apply(out, A, B, alpha, eT(1)); | gemm<true, false, false, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true ) ) | if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true ) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), a lpha, eT(1)); | gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), a lpha, eT(1)); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), a lpha, eT(1)); | gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), a lpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, false, true, true>::apply(out, A, B, alpha, eT(1)); | gemm<true, false, true, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == fals e) ) | if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == fals e) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | gemv<false, false, true>::apply(out.memptr(), A, B.memptr(), alpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, true, false, true>::apply(out, A, B, alpha, eT(1)); | gemm<false, true, false, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true ) ) | if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true ) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), a lpha, eT(1)); | gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), a lpha, eT(1)); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), a lpha, eT(1)); | gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), a lpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, true, true, true>::apply(out, A, B, alpha, eT(1)); | gemm<false, true, true, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false ) ) | if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false ) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), a lpha, eT(1)); | gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), a lpha, eT(1)); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), a lpha, eT(1)); | gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), a lpha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, true, false, true>::apply(out, A, B, alpha, eT(1)); | gemm<true, true, false, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) ) | if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), al pha, eT(1)); | gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), al pha, eT(1)); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), al pha, eT(1)); | gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), al pha, eT(1)); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, true, true, true>::apply(out, A, B, alpha, eT(1)); | gemm<true, true, true, true>::apply(out, A, B, alpha, eT(1)); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
template<typename eT, const bool do_trans_A, const bool do_trans_B> | template<typename eT, const bool do_trans_A, const bool do_trans_B, typenam e TA, typename TB> | |||
arma_inline | arma_inline | |||
uword | uword | |||
glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B) | glue_times::mul_storage_cost(const TA& A, const TB& B) | |||
{ | { | |||
const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; | const uword final_A_n_rows = (do_trans_A == false) ? ( TA::is_row ? 1 : A | |||
const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; | .n_rows ) : ( TA::is_col ? 1 : A.n_cols ); | |||
const uword final_B_n_cols = (do_trans_B == false) ? ( TB::is_col ? 1 : B | ||||
.n_cols ) : ( TB::is_row ? 1 : B.n_rows ); | ||||
return final_A_n_rows * final_B_n_cols; | return final_A_n_rows * final_B_n_cols; | |||
} | } | |||
template | template | |||
< | < | |||
typename eT, | typename eT, | |||
const bool do_trans_A, | const bool do_trans_A, | |||
const bool do_trans_B, | const bool do_trans_B, | |||
const bool use_alpha | const bool use_alpha, | |||
typename TA, | ||||
typename TB | ||||
> | > | |||
arma_hot | arma_hot | |||
inline | inline | |||
void | void | |||
glue_times::apply | glue_times::apply | |||
( | ( | |||
Mat<eT>& out, | Mat<eT>& out, | |||
const Mat<eT>& A, | const TA& A, | |||
const Mat<eT>& B, | const TB& B, | |||
const eT alpha | const eT alpha | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli | //arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multip | |||
cation"); | lication"); | |||
arma_debug_assert_trans_mul_size<do_trans_A, do_trans_B>(A.n_rows, A.n_co | ||||
ls, B.n_rows, B.n_cols, "matrix multiplication"); | ||||
const uword final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; | const uword final_n_rows = (do_trans_A == false) ? (TA::is_row ? 1 : A.n_ | |||
const uword final_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; | rows) : (TA::is_col ? 1 : A.n_cols); | |||
const uword final_n_cols = (do_trans_B == false) ? (TB::is_col ? 1 : B.n_ | ||||
cols) : (TB::is_row ? 1 : B.n_rows); | ||||
out.set_size(final_n_rows, final_n_cols); | out.set_size(final_n_rows, final_n_cols); | |||
if( (A.n_elem > 0) && (B.n_elem > 0) ) | if( (A.n_elem > 0) && (B.n_elem > 0) ) | |||
{ | { | |||
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == fal se) ) | if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == fal se) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, false, false>::apply(out.memptr(), B, A.memptr() ); | gemv<true, false, false>::apply(out.memptr(), B, A.memptr() ); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<false, false, false>::apply(out.memptr(), A, B.memptr() ); | gemv<false, false, false>::apply(out.memptr(), A, B.memptr() ); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, false, false, false>::apply(out, A, B); | gemm<false, false, false, false>::apply(out, A, B); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == tru e) ) | if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == tru e) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, true, false>::apply(out.memptr(), B, A.memptr(), alpha); | gemv<true, true, false>::apply(out.memptr(), B, A.memptr(), alpha); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<false, true, false>::apply(out.memptr(), A, B.memptr(), alpha); | gemv<false, true, false>::apply(out.memptr(), A, B.memptr(), alpha); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, false, true, false>::apply(out, A, B, alpha); | gemm<false, false, true, false>::apply(out, A, B, alpha); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == fals e) ) | if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == fals e) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, false, false>::apply(out.memptr(), B, A.memptr()) ; | gemv<true, false, false>::apply(out.memptr(), B, A.memptr()) ; | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<true, false, false>::apply(out.memptr(), A, B.memptr()) ; | gemv<true, false, false>::apply(out.memptr(), A, B.memptr()) ; | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, false, false, false>::apply(out, A, B); | gemm<true, false, false, false>::apply(out, A, B); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true ) ) | if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true ) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, true, false>::apply(out.memptr(), B, A.memptr(), alpha); | gemv<true, true, false>::apply(out.memptr(), B, A.memptr(), alpha); | |||
} | } | |||
else | else | |||
if(B.n_cols == 1) | if( (B.n_cols == 1) || (TB::is_col) ) | |||
{ | { | |||
gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), alpha); | gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), alpha); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, false, true, false>::apply(out, A, B, alpha); | gemm<true, false, true, false>::apply(out, A, B, alpha); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == fals e) ) | if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == fals e) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, false, false>::apply(out.memptr(), B, A.memptr()) ; | gemv<false, false, false>::apply(out.memptr(), B, A.memptr()) ; | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, false, false>::apply(out.memptr(), A, B.memptr()) ; | gemv<false, false, false>::apply(out.memptr(), A, B.memptr()) ; | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, true, false, false>::apply(out, A, B); | gemm<false, true, false, false>::apply(out, A, B); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true ) ) | if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true ) ) | |||
{ | { | |||
if( (A.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_rows == 1) || (TA::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), alpha); | gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), alpha); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, true, false>::apply(out.memptr(), A, B.memptr(), alpha); | gemv<false, true, false>::apply(out.memptr(), A, B.memptr(), alpha); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<false, true, true, false>::apply(out, A, B, alpha); | gemm<false, true, true, false>::apply(out, A, B, alpha); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false ) ) | if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false ) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, false, false>::apply(out.memptr(), B, A.memptr()); | gemv<false, false, false>::apply(out.memptr(), B, A.memptr()); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, false, false>::apply(out.memptr(), A, B.memptr()); | gemv<true, false, false>::apply(out.memptr(), A, B.memptr()); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, true, false, false>::apply(out, A, B); | gemm<true, true, false, false>::apply(out, A, B); | |||
} | } | |||
} | } | |||
else | else | |||
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) ) | if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) ) | |||
{ | { | |||
if( (A.n_cols == 1) && (is_complex<eT>::value == false) ) | if( ((A.n_cols == 1) || (TA::is_col)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), a lpha); | gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), a lpha); | |||
} | } | |||
else | else | |||
if( (B.n_rows == 1) && (is_complex<eT>::value == false) ) | if( ((B.n_rows == 1) || (TB::is_row)) && (is_complex<eT>::value == fa lse) ) | |||
{ | { | |||
gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), a lpha); | gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), a lpha); | |||
} | } | |||
else | else | |||
{ | { | |||
gemm<true, true, true, false>::apply(out, A, B, alpha); | gemm<true, true, true, false>::apply(out, A, B, alpha); | |||
} | } | |||
} | } | |||
} | } | |||
else | else | |||
skipping to change at line 626 | skipping to change at line 632 | |||
out.zeros(); | out.zeros(); | |||
} | } | |||
} | } | |||
template | template | |||
< | < | |||
typename eT, | typename eT, | |||
const bool do_trans_A, | const bool do_trans_A, | |||
const bool do_trans_B, | const bool do_trans_B, | |||
const bool do_trans_C, | const bool do_trans_C, | |||
const bool use_alpha | const bool use_alpha, | |||
typename TA, | ||||
typename TB, | ||||
typename TC | ||||
> | > | |||
arma_hot | arma_hot | |||
inline | inline | |||
void | void | |||
glue_times::apply | glue_times::apply | |||
( | ( | |||
Mat<eT>& out, | Mat<eT>& out, | |||
const Mat<eT>& A, | const TA& A, | |||
const Mat<eT>& B, | const TB& B, | |||
const Mat<eT>& C, | const TC& C, | |||
const eT alpha | const eT alpha | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
Mat<eT> tmp; | Mat<eT> tmp; | |||
if( glue_times::mul_storage_cost<eT, do_trans_A, do_trans_B>(A, B) <= glu | const uword storage_cost_AB = glue_times::mul_storage_cost<eT, do_trans_A | |||
e_times::mul_storage_cost<eT, do_trans_B, do_trans_C>(B, C) ) | , do_trans_B>(A, B); | |||
const uword storage_cost_BC = glue_times::mul_storage_cost<eT, do_trans_B | ||||
, do_trans_C>(B, C); | ||||
if(storage_cost_AB <= storage_cost_BC) | ||||
{ | { | |||
// out = (A*B)*C | // out = (A*B)*C | |||
glue_times::apply<eT, do_trans_A, do_trans_B, use_alpha>(tmp, A, B, a lpha); | glue_times::apply<eT, do_trans_A, do_trans_B, use_alpha>(tmp, A, B, a lpha); | |||
glue_times::apply<eT, false, do_trans_C, false >(out, tmp, C, e T(0)); | glue_times::apply<eT, false, do_trans_C, false >(out, tmp, C, e T(0)); | |||
} | } | |||
else | else | |||
{ | { | |||
// out = A*(B*C) | // out = A*(B*C) | |||
skipping to change at line 667 | skipping to change at line 679 | |||
} | } | |||
} | } | |||
template | template | |||
< | < | |||
typename eT, | typename eT, | |||
const bool do_trans_A, | const bool do_trans_A, | |||
const bool do_trans_B, | const bool do_trans_B, | |||
const bool do_trans_C, | const bool do_trans_C, | |||
const bool do_trans_D, | const bool do_trans_D, | |||
const bool use_alpha | const bool use_alpha, | |||
typename TA, | ||||
typename TB, | ||||
typename TC, | ||||
typename TD | ||||
> | > | |||
arma_hot | arma_hot | |||
inline | inline | |||
void | void | |||
glue_times::apply | glue_times::apply | |||
( | ( | |||
Mat<eT>& out, | Mat<eT>& out, | |||
const Mat<eT>& A, | const TA& A, | |||
const Mat<eT>& B, | const TB& B, | |||
const Mat<eT>& C, | const TC& C, | |||
const Mat<eT>& D, | const TD& D, | |||
const eT alpha | const eT alpha | |||
) | ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
Mat<eT> tmp; | Mat<eT> tmp; | |||
if( glue_times::mul_storage_cost<eT, do_trans_A, do_trans_C>(A, C) <= glu | const uword storage_cost_AC = glue_times::mul_storage_cost<eT, do_trans_A | |||
e_times::mul_storage_cost<eT, do_trans_B, do_trans_D>(B, D) ) | , do_trans_C>(A, C); | |||
const uword storage_cost_BD = glue_times::mul_storage_cost<eT, do_trans_B | ||||
, do_trans_D>(B, D); | ||||
if(storage_cost_AC <= storage_cost_BD) | ||||
{ | { | |||
// out = (A*B*C)*D | // out = (A*B*C)*D | |||
glue_times::apply<eT, do_trans_A, do_trans_B, do_trans_C, use_alpha>(tm p, A, B, C, alpha); | glue_times::apply<eT, do_trans_A, do_trans_B, do_trans_C, use_alpha>(tm p, A, B, C, alpha); | |||
glue_times::apply<eT, false, do_trans_D, false>(out, tmp, D, eT(0)); | glue_times::apply<eT, false, do_trans_D, false>(out, tmp, D, eT(0)); | |||
} | } | |||
else | else | |||
{ | { | |||
// out = A*(B*C*D) | // out = A*(B*C*D) | |||
End of changes. 54 change blocks. | ||||
76 lines changed or deleted | 104 lines changed or added | |||
op_dot_bones.hpp | op_dot_bones.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2012 Conrad Sanderson | // Copyright (C) 2008-2013 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 op_dot | //! \addtogroup op_dot | |||
//! @{ | //! @{ | |||
//! \brief | //! \brief | |||
//! dot product operation | //! dot product operation | |||
skipping to change at line 47 | skipping to change at line 47 | |||
arma_hot arma_pure inline static typename arma_integral_only<eT>::result | arma_hot arma_pure inline static typename arma_integral_only<eT>::result | |||
direct_dot(const uword n_elem, const eT* const A, const eT* const B); | direct_dot(const uword n_elem, const eT* const A, const eT* const B); | |||
template<typename eT> | template<typename eT> | |||
arma_hot arma_pure inline static eT direct_dot(const uword n_elem, const eT* const A, const eT* const B, const eT* C); | arma_hot arma_pure inline static eT direct_dot(const uword n_elem, const eT* const A, const eT* const B, const eT* C); | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot inline static typename T1::elem_type apply(const T1& X, const T2 & Y); | arma_hot inline static typename T1::elem_type apply(const T1& X, const T2 & Y); | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot inline static typename T1::elem_type apply_unwrap(const T1& X, c onst T2& Y); | arma_hot inline static typename arma_not_cx<typename T1::elem_type>::res ult apply_proxy(const Proxy<T1>& PA, const Proxy<T2>& PB); | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot inline static typename arma_not_cx<typename T1::elem_type>::resu lt apply_proxy(const T1& X, const T2& Y); | arma_hot inline static typename arma_cx_only<typename T1::elem_type>::res ult apply_proxy(const Proxy<T1>& PA, const Proxy<T2>& PB); | |||
template<typename T1, typename T2> | template<typename eT, typename TA> | |||
arma_hot inline static typename arma_cx_only<typename T1::elem_type>::res | arma_hot inline static eT dot_and_copy_row(eT* out, const TA& A, const uw | |||
ult apply_proxy(const T1& X, const T2& Y); | ord row, const eT* B_mem, const uword N); | |||
template<typename eT> | ||||
arma_hot inline static eT dot_and_copy_row(eT* out, const Mat<eT>& A, con | ||||
st uword row, const eT* B_mem, const uword N); | ||||
}; | }; | |||
//! \brief | //! \brief | |||
//! normalised dot product operation | //! normalised dot product operation | |||
class op_norm_dot | class op_norm_dot | |||
{ | { | |||
public: | public: | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
End of changes. 4 change blocks. | ||||
11 lines changed or deleted | 7 lines changed or added | |||
op_dot_meat.hpp | op_dot_meat.hpp | |||
---|---|---|---|---|
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |||
// Copyright (C) 2008-2012 Conrad Sanderson | // Copyright (C) 2008-2013 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 op_dot | //! \addtogroup op_dot | |||
//! @{ | //! @{ | |||
//! for two arrays, generic version for non-complex values | //! for two arrays, generic version for non-complex values | |||
template<typename eT> | template<typename eT> | |||
skipping to change at line 182 | skipping to change at line 182 | |||
} | } | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot | arma_hot | |||
inline | inline | |||
typename T1::elem_type | typename T1::elem_type | |||
op_dot::apply(const T1& X, const T2& Y) | op_dot::apply(const T1& X, const T2& Y) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) ) | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) || (Proxy | |||
{ | <T2>::prefer_at_accessor); | |||
return op_dot::apply_unwrap(X,Y); | ||||
} | ||||
else | ||||
{ | ||||
return op_dot::apply_proxy(X,Y); | ||||
} | ||||
} | ||||
template<typename T1, typename T2> | const bool do_unwrap = ((is_Mat<T1>::value == true) && (is_Mat<T2>::value | |||
arma_hot | == true)) || prefer_at_accessor; | |||
inline | ||||
typename T1::elem_type | ||||
op_dot::apply_unwrap(const T1& X, const T2& Y) | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
typedef typename T1::elem_type eT; | if(do_unwrap == true) | |||
{ | ||||
const unwrap<T1> tmp1(X); | ||||
const unwrap<T2> tmp2(Y); | ||||
const unwrap<T1> tmp1(X); | const typename unwrap<T1>::stored_type& A = tmp1.M; | |||
const unwrap<T2> tmp2(Y); | const typename unwrap<T2>::stored_type& B = tmp2.M; | |||
const Mat<eT>& A = tmp1.M; | arma_debug_check | |||
const Mat<eT>& B = tmp2.M; | ( | |||
(A.n_elem != B.n_elem), | ||||
"dot(): objects must have the same number of elements" | ||||
); | ||||
arma_debug_check( (A.n_elem != B.n_elem), "dot(): objects must have the s | return op_dot::direct_dot(A.n_elem, A.memptr(), B.memptr()); | |||
ame number of elements" ); | } | |||
else | ||||
{ | ||||
const Proxy<T1> PA(X); | ||||
const Proxy<T2> PB(Y); | ||||
return op_dot::direct_dot(A.n_elem, A.mem, B.mem); | arma_debug_check( (PA.get_n_elem() != PB.get_n_elem()), "dot(): objects | |||
must have the same number of elements" ); | ||||
return op_dot::apply_proxy(PA,PB); | ||||
} | ||||
} | } | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot | arma_hot | |||
inline | inline | |||
typename arma_not_cx<typename T1::elem_type>::result | typename arma_not_cx<typename T1::elem_type>::result | |||
op_dot::apply_proxy(const T1& X, const T2& Y) | op_dot::apply_proxy(const Proxy<T1>& PA, const Proxy<T2>& PB) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef typename Proxy<T1>::ea_type ea_type1; | typedef typename Proxy<T1>::ea_type ea_type1; | |||
typedef typename Proxy<T2>::ea_type ea_type2; | typedef typename Proxy<T2>::ea_type ea_type2; | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) || (Proxy | const uword N = PA.get_n_elem(); | |||
<T2>::prefer_at_accessor); | ||||
if(prefer_at_accessor == false) | ||||
{ | ||||
const Proxy<T1> PA(X); | ||||
const Proxy<T2> PB(Y); | ||||
const uword N = PA.get_n_elem(); | ||||
arma_debug_check( (N != PB.get_n_elem()), "dot(): objects must have the | ||||
same number of elements" ); | ||||
ea_type1 A = PA.get_ea(); | ||||
ea_type2 B = PB.get_ea(); | ||||
eT val1 = eT(0); | ea_type1 A = PA.get_ea(); | |||
eT val2 = eT(0); | ea_type2 B = PB.get_ea(); | |||
uword i,j; | eT val1 = eT(0); | |||
eT val2 = eT(0); | ||||
for(i=0, j=1; j<N; i+=2, j+=2) | ||||
{ | ||||
val1 += A[i] * B[i]; | ||||
val2 += A[j] * B[j]; | ||||
} | ||||
if(i < N) | uword i,j; | |||
{ | ||||
val1 += A[i] * B[i]; | ||||
} | ||||
return val1 + val2; | for(i=0, j=1; j<N; i+=2, j+=2) | |||
{ | ||||
val1 += A[i] * B[i]; | ||||
val2 += A[j] * B[j]; | ||||
} | } | |||
else | ||||
if(i < N) | ||||
{ | { | |||
return op_dot::apply_unwrap(X,Y); | val1 += A[i] * B[i]; | |||
} | } | |||
return val1 + val2; | ||||
} | } | |||
template<typename T1, typename T2> | template<typename T1, typename T2> | |||
arma_hot | arma_hot | |||
inline | inline | |||
typename arma_cx_only<typename T1::elem_type>::result | typename arma_cx_only<typename T1::elem_type>::result | |||
op_dot::apply_proxy(const T1& X, const T2& Y) | op_dot::apply_proxy(const Proxy<T1>& PA, const Proxy<T2>& PB) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef typename get_pod_type<eT>::result T; | typedef typename get_pod_type<eT>::result T; | |||
typedef typename Proxy<T1>::ea_type ea_type1; | typedef typename Proxy<T1>::ea_type ea_type1; | |||
typedef typename Proxy<T2>::ea_type ea_type2; | typedef typename Proxy<T2>::ea_type ea_type2; | |||
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) || (Proxy | const uword N = PA.get_n_elem(); | |||
<T2>::prefer_at_accessor); | ||||
if(prefer_at_accessor == false) | ||||
{ | ||||
const Proxy<T1> PA(X); | ||||
const Proxy<T2> PB(Y); | ||||
const uword N = PA.get_n_elem(); | ea_type1 A = PA.get_ea(); | |||
ea_type2 B = PB.get_ea(); | ||||
arma_debug_check( (N != PB.get_n_elem()), "dot(): objects must have the | T val_real = T(0); | |||
same number of elements" ); | T val_imag = T(0); | |||
ea_type1 A = PA.get_ea(); | ||||
ea_type2 B = PB.get_ea(); | ||||
T val_real = T(0); | ||||
T val_imag = T(0); | ||||
for(uword i=0; i<N; ++i) | ||||
{ | ||||
const std::complex<T> xx = A[i]; | ||||
const std::complex<T> yy = B[i]; | ||||
const T a = xx.real(); | for(uword i=0; i<N; ++i) | |||
const T b = xx.imag(); | { | |||
const std::complex<T> xx = A[i]; | ||||
const std::complex<T> yy = B[i]; | ||||
const T c = yy.real(); | const T a = xx.real(); | |||
const T d = yy.imag(); | const T b = xx.imag(); | |||
val_real += (a*c) - (b*d); | const T c = yy.real(); | |||
val_imag += (a*d) + (b*c); | const T d = yy.imag(); | |||
} | ||||
return std::complex<T>(val_real, val_imag); | val_real += (a*c) - (b*d); | |||
} | val_imag += (a*d) + (b*c); | |||
else | ||||
{ | ||||
return op_dot::apply_unwrap(X,Y); | ||||
} | } | |||
return std::complex<T>(val_real, val_imag); | ||||
} | } | |||
template<typename eT> | template<typename eT, typename TA> | |||
arma_hot | arma_hot | |||
inline | inline | |||
eT | eT | |||
op_dot::dot_and_copy_row(eT* out, const Mat<eT>& A, const uword row, const eT* B_mem, const uword N) | op_dot::dot_and_copy_row(eT* out, const TA& A, const uword row, const eT* B _mem, const uword N) | |||
{ | { | |||
eT acc1 = eT(0); | eT acc1 = eT(0); | |||
eT acc2 = eT(0); | eT acc2 = eT(0); | |||
uword i,j; | uword i,j; | |||
for(i=0, j=1; j < N; i+=2, j+=2) | for(i=0, j=1; j < N; i+=2, j+=2) | |||
{ | { | |||
const eT val_i = A.at(row, i); | const eT val_i = A.at(row, i); | |||
const eT val_j = A.at(row, j); | const eT val_j = A.at(row, j); | |||
End of changes. 28 change blocks. | ||||
94 lines changed or deleted | 64 lines changed or added | |||
operator_times.hpp | operator_times.hpp | |||
---|---|---|---|---|
skipping to change at line 153 | skipping to change at line 153 | |||
typedef typename T1::elem_type eT1; | typedef typename T1::elem_type eT1; | |||
typedef typename T2::elem_type eT2; | typedef typename T2::elem_type eT2; | |||
typedef typename promote_type<eT1,eT2>::result out_eT; | typedef typename promote_type<eT1,eT2>::result out_eT; | |||
promote_type<eT1,eT2>::check(); | promote_type<eT1,eT2>::check(); | |||
const diagmat_proxy<T1> A(X.m); | const diagmat_proxy<T1> A(X.m); | |||
const diagmat_proxy<T2> B(Y.m); | const diagmat_proxy<T2> B(Y.m); | |||
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "matri x multiply"); | arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "matri x multiplication"); | |||
const uword N = A.n_elem; | const uword N = A.n_elem; | |||
Mat<out_eT> out(N,N); | Mat<out_eT> out(N,N); | |||
out.zeros(); | out.zeros(); | |||
for(uword i=0; i<N; ++i) | for(uword i=0; i<N; ++i) | |||
{ | { | |||
out.at(i,i) = upgrade_val<eT1,eT2>::apply( A[i] ) * upgrade_val<eT1,eT2 >::apply( B[i] ); | out.at(i,i) = upgrade_val<eT1,eT2>::apply( A[i] ) * upgrade_val<eT1,eT2 >::apply( B[i] ); | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
traits.hpp | traits.hpp | |||
---|---|---|---|---|
skipping to change at line 342 | skipping to change at line 342 | |||
{ static const bool value = false; }; | { static const bool value = false; }; | |||
template<typename T1> | template<typename T1> | |||
struct is_op_diagmat< Op<T1,op_diagmat> > | struct is_op_diagmat< Op<T1,op_diagmat> > | |||
{ static const bool value = true; }; | { static const bool value = true; }; | |||
template<typename T1> | template<typename T1> | |||
struct is_op_diagmat< const Op<T1,op_diagmat> > | struct is_op_diagmat< const Op<T1,op_diagmat> > | |||
{ static const bool value = true; }; | { static const bool value = true; }; | |||
template<typename T> | ||||
struct is_op_htrans2 | ||||
{ static const bool value = false; }; | ||||
template<typename T1> | ||||
struct is_op_htrans2< Op<T1,op_htrans2> > | ||||
{ static const bool value = true; }; | ||||
template<typename T1> | ||||
struct is_op_htrans2< const Op<T1,op_htrans2> > | ||||
{ static const bool value = true; }; | ||||
// | // | |||
// | // | |||
template<typename T> | template<typename T> | |||
struct is_GenCube | struct is_GenCube | |||
{ static const bool value = false; }; | { static const bool value = false; }; | |||
template<typename eT, typename gen_type> | template<typename eT, typename gen_type> | |||
struct is_GenCube< GenCube<eT,gen_type> > | struct is_GenCube< GenCube<eT,gen_type> > | |||
{ static const bool value = true; }; | { static const bool value = true; }; | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 12 lines changed or added | |||
unwrap.hpp | unwrap.hpp | |||
---|---|---|---|---|
skipping to change at line 15 | skipping to change at line 15 | |||
// 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 | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef Mat<eT> stored_type; | ||||
inline | inline | |||
unwrap_default(const T1& A) | unwrap_default(const T1& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Mat<eT> M; | const Mat<eT> M; | |||
}; | }; | |||
template<typename T1> | template<typename T1> | |||
struct unwrap_fixed | struct unwrap_fixed | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef T1 stored_type; | |||
inline explicit | inline explicit | |||
unwrap_fixed(const T1& A) | unwrap_fixed(const T1& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Mat<eT>& M; | const T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct unwrap_redirect {}; | struct unwrap_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct unwrap_redirect<T1, false> { typedef unwrap_default<T1> result; }; | struct unwrap_redirect<T1, false> { typedef unwrap_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct unwrap_redirect<T1, true> { typedef unwrap_fixed<T1> result; }; | struct unwrap_redirect<T1, true> { typedef unwrap_fixed<T1> result; }; | |||
skipping to change at line 63 | skipping to change at line 64 | |||
inline | inline | |||
unwrap(const T1& A) | unwrap(const T1& A) | |||
: unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A) | : unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct unwrap< Mat<eT> > | struct unwrap< Mat<eT> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
inline | inline | |||
unwrap(const Mat<eT>& A) | unwrap(const Mat<eT>& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Mat<eT>& M; | const Mat<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct unwrap< Row<eT> > | struct unwrap< Row<eT> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
inline | inline | |||
unwrap(const Row<eT>& A) | unwrap(const Row<eT>& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Row<eT>& M; | const Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct unwrap< Col<eT> > | struct unwrap< Col<eT> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
inline | inline | |||
unwrap(const Col<eT>& A) | unwrap(const Col<eT>& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Col<eT>& M; | const Col<eT>& M; | |||
}; | }; | |||
template<typename out_eT, typename T1, typename T2, typename glue_type> | template<typename out_eT, typename T1, typename T2, typename glue_type> | |||
struct unwrap< mtGlue<out_eT, T1, T2, glue_type> > | struct unwrap< mtGlue<out_eT, T1, T2, glue_type> > | |||
{ | { | |||
typedef Mat<out_eT> stored_type; | ||||
inline | inline | |||
unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A) | unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Mat<out_eT> M; | const Mat<out_eT> M; | |||
}; | }; | |||
template<typename out_eT, typename T1, typename op_type> | template<typename out_eT, typename T1, typename op_type> | |||
struct unwrap< mtOp<out_eT, T1, op_type> > | struct unwrap< mtOp<out_eT, T1, op_type> > | |||
{ | { | |||
typedef Mat<out_eT> stored_type; | ||||
inline | inline | |||
unwrap(const mtOp<out_eT, T1, op_type>& A) | unwrap(const mtOp<out_eT, T1, op_type>& A) | |||
: M(A) | : M(A) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
const Mat<out_eT> M; | const Mat<out_eT> M; | |||
}; | }; | |||
skipping to change at line 620 | skipping to change at line 631 | |||
}; | }; | |||
// | // | |||
// | // | |||
// | // | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_default | struct partial_unwrap_default | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef Mat<eT> stored_type; | ||||
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); } | |||
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; | |||
typedef T1 stored_type; | ||||
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); } | |||
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 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> | |||
struct partial_unwrap_redirect<T1, false> { typedef partial_unwrap_default< T1> result; }; | struct partial_unwrap_redirect<T1, false> { typedef partial_unwrap_default< T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_redirect<T1, true> { typedef partial_unwrap_fixed<T1 > result; }; | struct partial_unwrap_redirect<T1, true> { typedef partial_unwrap_fixed<T1 > result; }; | |||
skipping to change at line 678 | skipping to change at line 691 | |||
inline | inline | |||
partial_unwrap(const T1& A) | partial_unwrap(const T1& A) | |||
: partial_unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A) | : partial_unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap< Mat<eT> > | struct partial_unwrap< Mat<eT> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
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); } | |||
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; | ||||
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); } | |||
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 Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap< Col<eT> > | struct partial_unwrap< Col<eT> > | |||
{ | { | |||
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); } | |||
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 Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap class is only used by as_scalar(), | // 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) | // 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; | ||||
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, 1, false, false ) | : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, false, false ) | |||
//, ref( 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); } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const subview_col<eT>& ref; | ||||
}; | }; | |||
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; | ||||
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); } | |||
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; | |||
typedef T1 stored_type; | ||||
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); } | |||
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 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> | |||
struct partial_unwrap_htrans_redirect<T1, false> { typedef partial_unwrap_h trans_default<T1> result; }; | struct partial_unwrap_htrans_redirect<T1, false> { typedef partial_unwrap_h trans_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_htrans_redirect<T1, true> { typedef partial_unwrap_h trans_fixed<T1> result; }; | struct partial_unwrap_htrans_redirect<T1, true> { typedef partial_unwrap_h trans_fixed<T1> result; }; | |||
skipping to change at line 814 | skipping to change at line 833 | |||
{ | { | |||
inline partial_unwrap(const Op<T1, op_htrans>& A) | inline partial_unwrap(const Op<T1, op_htrans>& A) | |||
: partial_unwrap_htrans_redirect< T1, is_Mat_fixed<T1>::value >::result (A) | : partial_unwrap_htrans_redirect< T1, is_Mat_fixed<T1>::value >::result (A) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap< Op< Mat<eT>, op_htrans> > | struct partial_unwrap< Op< Mat<eT>, op_htrans> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
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); } | |||
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; | ||||
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); } | |||
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 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; | ||||
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); } | |||
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 Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap class is only used by as_scalar(), | // 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) | // 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; | ||||
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, 1, false, false ) | : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false ) | |||
//, ref( A ) | ||||
{ | { | |||
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); } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const Op< subview_col<eT>, op_htrans>& ref; | ||||
}; | }; | |||
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; | ||||
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; } | |||
skipping to change at line 915 | skipping to change at line 939 | |||
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 | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
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; } | |||
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 T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_htrans2_redirect {}; | struct partial_unwrap_htrans2_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_htrans2_redirect<T1, false> { typedef partial_unwrap_ htrans2_default<T1> result; }; | struct partial_unwrap_htrans2_redirect<T1, false> { typedef partial_unwrap_ htrans2_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_htrans2_redirect<T1, true> { typedef partial_unwrap_ htrans2_fixed<T1> result; }; | struct partial_unwrap_htrans2_redirect<T1, true> { typedef partial_unwrap_ htrans2_fixed<T1> result; }; | |||
skipping to change at line 954 | skipping to change at line 979 | |||
{ | { | |||
inline partial_unwrap(const Op<T1, op_htrans2>& A) | inline partial_unwrap(const Op<T1, op_htrans2>& A) | |||
: partial_unwrap_htrans2_redirect< T1, is_Mat_fixed<T1>::value >::resul t(A) | : partial_unwrap_htrans2_redirect< T1, is_Mat_fixed<T1>::value >::resul t(A) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap< Op< Mat<eT>, op_htrans2> > | struct partial_unwrap< Op< Mat<eT>, op_htrans2> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
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; } | |||
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> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
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; } | |||
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 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> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
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; } | |||
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 Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap class is only used by as_scalar(), | // 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) | // 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; | ||||
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 ) | : val( A.aux ) | |||
, M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, false, false ) | , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false ) | |||
//, ref( A ) | ||||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline eT get_val() const { return val; } | inline eT get_val() const { return val; } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const Op< subview_col<eT>, op_htrans2>& ref; | ||||
}; | }; | |||
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; | ||||
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; } | |||
skipping to change at line 1063 | skipping to change at line 1093 | |||
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 | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
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; } | |||
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 T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_scalar_times_redirect {}; | struct partial_unwrap_scalar_times_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_scalar_times_redirect<T1, false> { typedef partial_un wrap_scalar_times_default<T1> result; }; | struct partial_unwrap_scalar_times_redirect<T1, false> { typedef partial_un wrap_scalar_times_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_scalar_times_redirect<T1, true> { typedef partial_un wrap_scalar_times_fixed<T1> result; }; | struct partial_unwrap_scalar_times_redirect<T1, true> { typedef partial_un wrap_scalar_times_fixed<T1> result; }; | |||
skipping to change at line 1105 | skipping to change at line 1136 | |||
inline | inline | |||
partial_unwrap(const eOp<T1, eop_scalar_times>& A) | partial_unwrap(const eOp<T1, eop_scalar_times>& A) | |||
: partial_unwrap_scalar_times_redirect< T1, is_Mat_fixed<T1>::value >:: result(A) | : partial_unwrap_scalar_times_redirect< T1, is_Mat_fixed<T1>::value >:: result(A) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap< eOp<Mat<eT>, eop_scalar_times> > | struct partial_unwrap< eOp<Mat<eT>, eop_scalar_times> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
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; } | |||
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> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
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; } | |||
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 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> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
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; } | |||
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 Col<eT>& M; | |||
}; | }; | |||
// TODO: struct partial_unwrap< eOp<subview_col<eT>, eop_scalar_times> > | ||||
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; | ||||
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); } | |||
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; | |||
typedef T1 stored_type; | ||||
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); } | |||
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 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> | |||
struct partial_unwrap_neg_redirect<T1, false> { typedef partial_unwrap_neg_ default<T1> result; }; | struct partial_unwrap_neg_redirect<T1, false> { typedef partial_unwrap_neg_ default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_neg_redirect<T1, true> { typedef partial_unwrap_neg_ fixed<T1> result; }; | struct partial_unwrap_neg_redirect<T1, true> { typedef partial_unwrap_neg_ fixed<T1> result; }; | |||
skipping to change at line 1226 | skipping to change at line 1267 | |||
inline | inline | |||
partial_unwrap(const eOp<T1, eop_neg>& A) | partial_unwrap(const eOp<T1, eop_neg>& A) | |||
: partial_unwrap_neg_redirect< T1, is_Mat_fixed<T1>::value >::result(A) | : partial_unwrap_neg_redirect< T1, is_Mat_fixed<T1>::value >::result(A) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap< eOp<Mat<eT>, eop_neg> > | struct partial_unwrap< eOp<Mat<eT>, eop_neg> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
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); } | |||
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; | ||||
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); } | |||
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 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; | ||||
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); } | |||
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 Col<eT>& M; | |||
}; | }; | |||
// TODO: struct partial_unwrap< eOp<subview_col<eT>, eop_neg> > | ||||
// | // | |||
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; | ||||
inline | inline | |||
partial_unwrap_check_default(const T1& A, const Mat<eT>&) | partial_unwrap_check_default(const T1& A, const Mat<eT>&) | |||
: 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); } | |||
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_check_fixed | struct partial_unwrap_check_fixed | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
inline explicit | inline explicit | |||
partial_unwrap_check_fixed(const T1& A, const Mat<eT>& B) | partial_unwrap_check_fixed(const T1& A, const Mat<eT>& B) | |||
: M_local( (&A == &B) ? new Mat<eT>(A) : 0 ) | : M_local( (&A == &B) ? new T1(A) : 0 ) | |||
, M ( (&A == &B) ? (*M_local) : A ) | , M ( (&A == &B) ? (*M_local) : A ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check_fixed() | ~partial_unwrap_check_fixed() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(1); } | arma_hot arma_inline eT get_val() const { return eT(1); } | |||
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_local; | const T1* M_local; | |||
const Mat<eT>& M; | const T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_check_redirect {}; | struct partial_unwrap_check_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_redirect<T1, false> { typedef partial_unwrap_ch eck_default<T1> result; }; | struct partial_unwrap_check_redirect<T1, false> { typedef partial_unwrap_ch eck_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_redirect<T1, true> { typedef partial_unwrap_ch eck_fixed<T1> result; }; | struct partial_unwrap_check_redirect<T1, true> { typedef partial_unwrap_ch eck_fixed<T1> result; }; | |||
skipping to change at line 1352 | skipping to change at line 1403 | |||
inline partial_unwrap_check(const T1& A, const Mat<eT>& B) | inline partial_unwrap_check(const T1& A, const Mat<eT>& B) | |||
: partial_unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result( A, B) | : partial_unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result( A, B) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Mat<eT> > | struct partial_unwrap_check< Mat<eT> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Mat<eT>& A, const Mat<eT>& B) | partial_unwrap_check(const Mat<eT>& A, const Mat<eT>& B) | |||
: M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) | : M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) | |||
, M ( (&A == &B) ? (*M_local) : A ) | , M ( (&A == &B) ? (*M_local) : A ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
skipping to change at line 1381 | skipping to change at line 1434 | |||
static const bool do_times = false; | static const bool do_times = false; | |||
// the order below is important | // the order below is important | |||
const Mat<eT>* M_local; | const Mat<eT>* M_local; | |||
const Mat<eT>& M; | const Mat<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Row<eT> > | struct partial_unwrap_check< Row<eT> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Row<eT>& A, const Mat<eT>& B) | partial_unwrap_check(const Row<eT>& A, const Mat<eT>& B) | |||
: M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) | : M_local ( (&A == &B) ? new Row<eT>(A) : 0 ) | |||
, M ( (&A == &B) ? (*M_local) : A ) | , M ( (&A == &B) ? (*M_local) : A ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(1); } | arma_hot arma_inline eT get_val() const { return eT(1); } | |||
static const bool do_trans = false; | static const bool do_trans = false; | |||
static const bool do_times = false; | static const bool do_times = false; | |||
// the order below is important | // the order below is important | |||
const Mat<eT>* M_local; | const Row<eT>* M_local; | |||
const Mat<eT>& M; | const Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Col<eT> > | struct partial_unwrap_check< Col<eT> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Col<eT>& A, const Mat<eT>& B) | partial_unwrap_check(const Col<eT>& A, const Mat<eT>& B) | |||
: M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) | : M_local ( (&A == &B) ? new Col<eT>(A) : 0 ) | |||
, M ( (&A == &B) ? (*M_local) : A ) | , M ( (&A == &B) ? (*M_local) : A ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(1); } | arma_hot arma_inline eT get_val() const { return eT(1); } | |||
static const bool do_trans = false; | static const bool do_trans = false; | |||
static const bool do_times = false; | static const bool do_times = false; | |||
// the order below is important | // the order below is important | |||
const Mat<eT>* M_local; | const Col<eT>* M_local; | |||
const Mat<eT>& M; | const Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | // NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | |||
// NOTE: which relies on partial_unwrap_check to check for aliasing | // NOTE: which relies on partial_unwrap_check to check for aliasing | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< subview_col<eT> > | struct partial_unwrap_check< subview_col<eT> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const subview_col<eT>& A, const Mat<eT>& B) | partial_unwrap_check(const subview_col<eT>& A, const Mat<eT>& B) | |||
: M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, (&(A.m) == &B), fal | : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, (&(A.m) == &B), false | |||
se ) | ) | |||
//, ref( 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); } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const subview_col<eT>& ref; | ||||
}; | }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_htrans_default | struct partial_unwrap_check_htrans_default | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef Mat<eT> stored_type; | ||||
inline | inline | |||
partial_unwrap_check_htrans_default(const Op<T1, op_htrans>& A, const Mat <eT>&) | partial_unwrap_check_htrans_default(const Op<T1, op_htrans>& A, const Mat <eT>&) | |||
: 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); } | |||
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_check_htrans_fixed | struct partial_unwrap_check_htrans_fixed | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
inline explicit | inline explicit | |||
partial_unwrap_check_htrans_fixed(const Op<T1, op_htrans>& A, const Mat<e T>& B) | partial_unwrap_check_htrans_fixed(const Op<T1, op_htrans>& A, const Mat<e T>& B) | |||
: M_local( (&(A.m) == &B) ? new Mat<eT>(A.m) : 0 ) | : M_local( (&(A.m) == &B) ? new T1(A.m) : 0 ) | |||
, M ( (&(A.m) == &B) ? (*M_local) : A.m ) | , M ( (&(A.m) == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check_htrans_fixed() | ~partial_unwrap_check_htrans_fixed() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(1); } | arma_hot arma_inline eT get_val() const { return eT(1); } | |||
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_local; | const T1* M_local; | |||
const Mat<eT>& M; | const T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_check_htrans_redirect {}; | struct partial_unwrap_check_htrans_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_htrans_redirect<T1, false> { typedef partial_un wrap_check_htrans_default<T1> result; }; | struct partial_unwrap_check_htrans_redirect<T1, false> { typedef partial_un wrap_check_htrans_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_htrans_redirect<T1, true> { typedef partial_un wrap_check_htrans_fixed<T1> result; }; | struct partial_unwrap_check_htrans_redirect<T1, true> { typedef partial_un wrap_check_htrans_fixed<T1> result; }; | |||
skipping to change at line 1533 | skipping to change at line 1590 | |||
inline partial_unwrap_check(const Op<T1, op_htrans>& A, const Mat<eT>& B) | inline partial_unwrap_check(const Op<T1, op_htrans>& A, const Mat<eT>& B) | |||
: partial_unwrap_check_htrans_redirect< T1, is_Mat_fixed<T1>::value >:: result(A, B) | : partial_unwrap_check_htrans_redirect< T1, is_Mat_fixed<T1>::value >:: result(A, B) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< Mat<eT>, op_htrans> > | struct partial_unwrap_check< Op< Mat<eT>, op_htrans> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< Mat<eT>, op_htrans>& A, const Mat<eT>& B) | partial_unwrap_check(const Op< Mat<eT>, op_htrans>& A, const Mat<eT>& B) | |||
: M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | : M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | |||
, M ( (&A.m == &B) ? (*M_local) : A.m ) | , M ( (&A.m == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
skipping to change at line 1562 | skipping to change at line 1621 | |||
static const bool do_times = false; | static const bool do_times = false; | |||
// the order below is important | // the order below is important | |||
const Mat<eT>* M_local; | const Mat<eT>* M_local; | |||
const Mat<eT>& M; | const Mat<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< Row<eT>, op_htrans> > | struct partial_unwrap_check< Op< Row<eT>, op_htrans> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< Row<eT>, op_htrans>& A, const Mat<eT>& B) | partial_unwrap_check(const Op< Row<eT>, op_htrans>& A, const Mat<eT>& B) | |||
: M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | : M_local ( (&A.m == &B) ? new Row<eT>(A.m) : 0 ) | |||
, M ( (&A.m == &B) ? (*M_local) : A.m ) | , M ( (&A.m == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(1); } | arma_hot arma_inline eT get_val() const { return eT(1); } | |||
static const bool do_trans = true; | static const bool do_trans = true; | |||
static const bool do_times = false; | static const bool do_times = false; | |||
// the order below is important | // the order below is important | |||
const Mat<eT>* M_local; | const Row<eT>* M_local; | |||
const Mat<eT>& M; | const Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< Col<eT>, op_htrans> > | struct partial_unwrap_check< Op< Col<eT>, op_htrans> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< Col<eT>, op_htrans>& A, const Mat<eT>& B) | partial_unwrap_check(const Op< Col<eT>, op_htrans>& A, const Mat<eT>& B) | |||
: M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | : M_local ( (&A.m == &B) ? new Col<eT>(A.m) : 0 ) | |||
, M ( (&A.m == &B) ? (*M_local) : A.m ) | , M ( (&A.m == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(1); } | arma_hot arma_inline eT get_val() const { return eT(1); } | |||
static const bool do_trans = true; | static const bool do_trans = true; | |||
static const bool do_times = false; | static const bool do_times = false; | |||
// the order below is important | // the order below is important | |||
const Mat<eT>* M_local; | const Col<eT>* M_local; | |||
const Mat<eT>& M; | const Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | // NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | |||
// NOTE: which relies on partial_unwrap_check to check for aliasing | // NOTE: which relies on partial_unwrap_check to check for aliasing | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< subview_col<eT>, op_htrans> > | struct partial_unwrap_check< Op< subview_col<eT>, op_htrans> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< subview_col<eT>, op_htrans>& A, const Mat< eT>& B) | partial_unwrap_check(const Op< subview_col<eT>, op_htrans>& A, const Mat< eT>& B) | |||
: M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, (&(A.m.m) == &B | : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, (&(A.m.m) == &B), | |||
), false ) | false ) | |||
//, ref( 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); } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const Op< subview_col<eT>, op_htrans>& ref; | ||||
}; | }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_htrans2_default | struct partial_unwrap_check_htrans2_default | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef Mat<eT> stored_type; | ||||
inline | inline | |||
partial_unwrap_check_htrans2_default(const Op<T1, op_htrans2>& A, const M at<eT>&) | partial_unwrap_check_htrans2_default(const Op<T1, op_htrans2>& A, const M at<eT>&) | |||
: val(A.aux) | : val(A.aux) | |||
, M (A.m) | , M (A.m) | |||
{ | { | |||
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; } | |||
skipping to change at line 1667 | skipping to change at line 1729 | |||
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_check_htrans2_fixed | struct partial_unwrap_check_htrans2_fixed | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
inline explicit | inline explicit | |||
partial_unwrap_check_htrans2_fixed(const Op<T1, op_htrans2>& A, const Mat <eT>& B) | partial_unwrap_check_htrans2_fixed(const Op<T1, op_htrans2>& A, const Mat <eT>& B) | |||
: val (A.aux) | : val (A.aux) | |||
, M_local( (&(A.m) == &B) ? new Mat<eT>(A.m) : 0 ) | , M_local( (&(A.m) == &B) ? new T1(A.m) : 0 ) | |||
, M ( (&(A.m) == &B) ? (*M_local) : A.m ) | , M ( (&(A.m) == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check_htrans2_fixed() | ~partial_unwrap_check_htrans2_fixed() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return val; } | arma_hot arma_inline eT get_val() const { return val; } | |||
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_local; | const T1* M_local; | |||
const Mat<eT>& M; | const T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_check_htrans2_redirect {}; | struct partial_unwrap_check_htrans2_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_htrans2_redirect<T1, false> { typedef partial_u nwrap_check_htrans2_default<T1> result; }; | struct partial_unwrap_check_htrans2_redirect<T1, false> { typedef partial_u nwrap_check_htrans2_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_htrans2_redirect<T1, true> { typedef partial_u nwrap_check_htrans2_fixed<T1> result; }; | struct partial_unwrap_check_htrans2_redirect<T1, true> { typedef partial_u nwrap_check_htrans2_fixed<T1> result; }; | |||
skipping to change at line 1718 | skipping to change at line 1781 | |||
inline partial_unwrap_check(const Op<T1, op_htrans2>& A, const Mat<eT>& B ) | inline partial_unwrap_check(const Op<T1, op_htrans2>& A, const Mat<eT>& B ) | |||
: partial_unwrap_check_htrans2_redirect< T1, is_Mat_fixed<T1>::value >: :result(A, B) | : partial_unwrap_check_htrans2_redirect< T1, is_Mat_fixed<T1>::value >: :result(A, B) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< Mat<eT>, op_htrans2> > | struct partial_unwrap_check< Op< Mat<eT>, op_htrans2> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B) | partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B) | |||
: val (A.aux) | : val (A.aux) | |||
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | |||
, M ( (&A.m == &B) ? (*M_local) : A.m ) | , M ( (&A.m == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
skipping to change at line 1749 | skipping to change at line 1814 | |||
// the order below is important | // the order below is important | |||
const eT val; | const eT val; | |||
const Mat<eT>* M_local; | const Mat<eT>* M_local; | |||
const Mat<eT>& M; | const Mat<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< Row<eT>, op_htrans2> > | struct partial_unwrap_check< Op< Row<eT>, op_htrans2> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< Row<eT>, op_htrans2>& A, const Mat<eT>& B) | partial_unwrap_check(const Op< Row<eT>, op_htrans2>& A, const Mat<eT>& B) | |||
: val (A.aux) | : val (A.aux) | |||
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | , M_local ( (&A.m == &B) ? new Row<eT>(A.m) : 0 ) | |||
, M ( (&A.m == &B) ? (*M_local) : A.m ) | , M ( (&A.m == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return val; } | arma_hot arma_inline eT get_val() const { return val; } | |||
static const bool do_trans = true; | static const bool do_trans = true; | |||
static const bool do_times = true; | static const bool do_times = true; | |||
// the order below is important | // the order below is important | |||
const eT val; | const eT val; | |||
const Mat<eT>* M_local; | const Row<eT>* M_local; | |||
const Mat<eT>& M; | const Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< Col<eT>, op_htrans2> > | struct partial_unwrap_check< Op< Col<eT>, op_htrans2> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< Col<eT>, op_htrans2>& A, const Mat<eT>& B) | partial_unwrap_check(const Op< Col<eT>, op_htrans2>& A, const Mat<eT>& B) | |||
: val (A.aux) | : val (A.aux) | |||
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) | , M_local ( (&A.m == &B) ? new Col<eT>(A.m) : 0 ) | |||
, M ( (&A.m == &B) ? (*M_local) : A.m ) | , M ( (&A.m == &B) ? (*M_local) : A.m ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return val; } | arma_hot arma_inline eT get_val() const { return val; } | |||
static const bool do_trans = true; | static const bool do_trans = true; | |||
static const bool do_times = true; | static const bool do_times = true; | |||
// the order below is important | // the order below is important | |||
const eT val; | const eT val; | |||
const Mat<eT>* M_local; | const Col<eT>* M_local; | |||
const Mat<eT>& M; | const Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | // NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | |||
// NOTE: which relies on partial_unwrap_check to check for aliasing | // NOTE: which relies on partial_unwrap_check to check for aliasing | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< Op< subview_col<eT>, op_htrans2> > | struct partial_unwrap_check< Op< subview_col<eT>, op_htrans2> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const Op< subview_col<eT>, op_htrans2>& A, const Mat <eT>& B) | partial_unwrap_check(const Op< subview_col<eT>, op_htrans2>& A, const Mat <eT>& B) | |||
: val( A.aux ) | : val( A.aux ) | |||
, M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, (&(A.m.m) == &B | , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, (&(A.m.m) == &B), | |||
), false ) | false ) | |||
//, ref( A ) | ||||
{ | { | |||
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; } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const Op< subview_col<eT>, op_htrans2>& ref; | ||||
}; | }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_scalar_times_default | struct partial_unwrap_check_scalar_times_default | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef Mat<eT> stored_type; | ||||
inline | inline | |||
partial_unwrap_check_scalar_times_default(const eOp<T1, eop_scalar_times> & A, const Mat<eT>&) | partial_unwrap_check_scalar_times_default(const eOp<T1, eop_scalar_times> & A, const Mat<eT>&) | |||
: 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; } | |||
skipping to change at line 1860 | skipping to change at line 1928 | |||
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_check_scalar_times_fixed | struct partial_unwrap_check_scalar_times_fixed | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
inline explicit | inline explicit | |||
partial_unwrap_check_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A, const Mat<eT>& B) | partial_unwrap_check_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A, const Mat<eT>& B) | |||
: val ( A.aux ) | : val ( A.aux ) | |||
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | , M_local( (&(A.P.Q) == &B) ? new T1(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check_scalar_times_fixed() | ~partial_unwrap_check_scalar_times_fixed() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return val; } | arma_hot arma_inline eT get_val() const { return val; } | |||
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_local; | const T1* M_local; | |||
const Mat<eT>& M; | const T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_check_scalar_times_redirect {}; | struct partial_unwrap_check_scalar_times_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_scalar_times_redirect<T1, false> { typedef part ial_unwrap_check_scalar_times_default<T1> result; }; | struct partial_unwrap_check_scalar_times_redirect<T1, false> { typedef part ial_unwrap_check_scalar_times_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_scalar_times_redirect<T1, true> { typedef part ial_unwrap_check_scalar_times_fixed<T1> result; }; | struct partial_unwrap_check_scalar_times_redirect<T1, true> { typedef part ial_unwrap_check_scalar_times_fixed<T1> result; }; | |||
skipping to change at line 1911 | skipping to change at line 1980 | |||
inline partial_unwrap_check(const eOp<T1, eop_scalar_times>& A, const Mat <eT>& B) | inline partial_unwrap_check(const eOp<T1, eop_scalar_times>& A, const Mat <eT>& B) | |||
: partial_unwrap_check_scalar_times_redirect< T1, is_Mat_fixed<T1>::val ue >::result(A, B) | : partial_unwrap_check_scalar_times_redirect< T1, is_Mat_fixed<T1>::val ue >::result(A, B) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<Mat<eT>, eop_scalar_times> > | struct partial_unwrap_check< eOp<Mat<eT>, eop_scalar_times> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<Mat<eT>,eop_scalar_times>& A, const Mat<eT >& B) | partial_unwrap_check(const eOp<Mat<eT>,eop_scalar_times>& A, const Mat<eT >& B) | |||
: val (A.aux) | : val (A.aux) | |||
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | , M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
skipping to change at line 1941 | skipping to change at line 2012 | |||
static const bool do_times = true; | static const bool do_times = true; | |||
const eT val; | const eT val; | |||
const Mat<eT>* M_local; | const Mat<eT>* M_local; | |||
const Mat<eT>& M; | const Mat<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<Row<eT>, eop_scalar_times> > | struct partial_unwrap_check< eOp<Row<eT>, eop_scalar_times> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<Row<eT>,eop_scalar_times>& A, const Mat<eT >& B) | partial_unwrap_check(const eOp<Row<eT>,eop_scalar_times>& A, const Mat<eT >& B) | |||
: val(A.aux) | : val(A.aux) | |||
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | , M_local( (&(A.P.Q) == &B) ? new Row<eT>(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return val; } | arma_hot arma_inline eT get_val() const { return val; } | |||
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_local; | const Row<eT>* M_local; | |||
const Mat<eT>& M; | const Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<Col<eT>, eop_scalar_times> > | struct partial_unwrap_check< eOp<Col<eT>, eop_scalar_times> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<Col<eT>,eop_scalar_times>& A, const Mat<eT >& B) | partial_unwrap_check(const eOp<Col<eT>,eop_scalar_times>& A, const Mat<eT >& B) | |||
: val ( A.aux ) | : val ( A.aux ) | |||
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | , M_local( (&(A.P.Q) == &B) ? new Col<eT>(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return val; } | arma_hot arma_inline eT get_val() const { return val; } | |||
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_local; | const Col<eT>* M_local; | |||
const Mat<eT>& M; | const Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | // NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | |||
// NOTE: which relies on partial_unwrap_check to check for aliasing | // NOTE: which relies on partial_unwrap_check to check for aliasing | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<subview_col<eT>, eop_scalar_times> > | struct partial_unwrap_check< eOp<subview_col<eT>, eop_scalar_times> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<subview_col<eT>,eop_scalar_times>& A, cons t Mat<eT>& B) | partial_unwrap_check(const eOp<subview_col<eT>,eop_scalar_times>& A, cons t Mat<eT>& B) | |||
: val( A.aux ) | : val( A.aux ) | |||
, M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, 1, (&(A.P.Q.m) | , M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, (&(A.P.Q.m) == | |||
== &B), false ) | &B), false ) | |||
//, ref( A ) | ||||
{ | { | |||
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; } | |||
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 Col<eT> M; | |||
//// prevents the compiler from potentially deleting the subview object b | ||||
efore we're done with it | ||||
//const eOp<subview_col<eT>,eop_scalar_times>& ref; | ||||
}; | }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_neg_default | struct partial_unwrap_check_neg_default | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef Mat<eT> stored_type; | ||||
inline | inline | |||
partial_unwrap_check_neg_default(const eOp<T1, eop_neg>& A, const Mat<eT> &) | partial_unwrap_check_neg_default(const eOp<T1, eop_neg>& A, const Mat<eT> &) | |||
: 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); } | |||
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_check_neg_fixed | struct partial_unwrap_check_neg_fixed | |||
{ | { | |||
typedef typename T1::elem_type eT; | typedef typename T1::elem_type eT; | |||
typedef T1 stored_type; | ||||
inline explicit | inline explicit | |||
partial_unwrap_check_neg_fixed(const eOp<T1, eop_neg>& A, const Mat<eT>& B) | partial_unwrap_check_neg_fixed(const eOp<T1, eop_neg>& A, const Mat<eT>& B) | |||
: M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | : M_local( (&(A.P.Q) == &B) ? new T1(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check_neg_fixed() | ~partial_unwrap_check_neg_fixed() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(-1); } | arma_hot arma_inline eT get_val() const { return eT(-1); } | |||
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_local; | const T1* M_local; | |||
const Mat<eT>& M; | const T1& M; | |||
}; | }; | |||
template<typename T1, bool condition> | template<typename T1, bool condition> | |||
struct partial_unwrap_check_neg_redirect {}; | struct partial_unwrap_check_neg_redirect {}; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_neg_redirect<T1, false> { typedef partial_unwra p_check_neg_default<T1> result; }; | struct partial_unwrap_check_neg_redirect<T1, false> { typedef partial_unwra p_check_neg_default<T1> result; }; | |||
template<typename T1> | template<typename T1> | |||
struct partial_unwrap_check_neg_redirect<T1, true> { typedef partial_unwra p_check_neg_fixed<T1> result; }; | struct partial_unwrap_check_neg_redirect<T1, true> { typedef partial_unwra p_check_neg_fixed<T1> result; }; | |||
skipping to change at line 2097 | skipping to change at line 2172 | |||
inline partial_unwrap_check(const eOp<T1, eop_neg>& A, const Mat<eT>& B) | inline partial_unwrap_check(const eOp<T1, eop_neg>& A, const Mat<eT>& B) | |||
: partial_unwrap_check_neg_redirect< T1, is_Mat_fixed<T1>::value >::res ult(A, B) | : partial_unwrap_check_neg_redirect< T1, is_Mat_fixed<T1>::value >::res ult(A, B) | |||
{ | { | |||
} | } | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<Mat<eT>, eop_neg> > | struct partial_unwrap_check< eOp<Mat<eT>, eop_neg> > | |||
{ | { | |||
typedef Mat<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<Mat<eT>,eop_neg>& A, const Mat<eT>& B) | partial_unwrap_check(const eOp<Mat<eT>,eop_neg>& A, const Mat<eT>& B) | |||
: M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | : M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
skipping to change at line 2125 | skipping to change at line 2202 | |||
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_local; | const Mat<eT>* M_local; | |||
const Mat<eT>& M; | const Mat<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<Row<eT>, eop_neg> > | struct partial_unwrap_check< eOp<Row<eT>, eop_neg> > | |||
{ | { | |||
typedef Row<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<Row<eT>,eop_neg>& A, const Mat<eT>& B) | partial_unwrap_check(const eOp<Row<eT>,eop_neg>& A, const Mat<eT>& B) | |||
: M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | : M_local( (&(A.P.Q) == &B) ? new Row<eT>(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(-1); } | arma_hot arma_inline eT get_val() const { return eT(-1); } | |||
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_local; | const Row<eT>* M_local; | |||
const Mat<eT>& M; | const Row<eT>& M; | |||
}; | }; | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<Col<eT>, eop_neg> > | struct partial_unwrap_check< eOp<Col<eT>, eop_neg> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<Col<eT>,eop_neg>& A, const Mat<eT>& B) | partial_unwrap_check(const eOp<Col<eT>,eop_neg>& A, const Mat<eT>& B) | |||
: M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) | : M_local( (&(A.P.Q) == &B) ? new Col<eT>(A.P.Q) : 0 ) | |||
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
} | } | |||
inline | inline | |||
~partial_unwrap_check() | ~partial_unwrap_check() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(M_local) { delete M_local; } | if(M_local) { delete M_local; } | |||
} | } | |||
arma_hot arma_inline eT get_val() const { return eT(-1); } | arma_hot arma_inline eT get_val() const { return eT(-1); } | |||
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_local; | const Col<eT>* M_local; | |||
const Mat<eT>& M; | const Col<eT>& M; | |||
}; | }; | |||
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | // NOTE: we can get away with this shortcut as the partial_unwrap_check cla ss is only used by the glue_times class, | |||
// NOTE: which relies on partial_unwrap_check to check for aliasing | // NOTE: which relies on partial_unwrap_check to check for aliasing | |||
template<typename eT> | template<typename eT> | |||
struct partial_unwrap_check< eOp<subview_col<eT>, eop_neg> > | struct partial_unwrap_check< eOp<subview_col<eT>, eop_neg> > | |||
{ | { | |||
typedef Col<eT> stored_type; | ||||
arma_hot inline | arma_hot inline | |||
partial_unwrap_check(const eOp<subview_col<eT>,eop_neg>& A, const Mat<eT> & B) | partial_unwrap_check(const eOp<subview_col<eT>,eop_neg>& A, const Mat<eT> & B) | |||
: M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, 1, (&(A.P.Q.m) == &B), false ) | : M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, (&(A.P.Q.m) == &B), false ) | |||
{ | { | |||
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); } | |||
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 Col<eT> M; | |||
}; | }; | |||
//! @} | //! @} | |||
End of changes. 129 change blocks. | ||||
126 lines changed or deleted | 202 lines changed or added | |||