Col_bones.hpp   Col_bones.hpp 
skipping to change at line 27 skipping to change at line 27
template<typename eT> template<typename eT>
class Col : public Mat<eT> class Col : public Mat<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
inline Col(); inline Col();
inline explicit Col(const u32 n_elem); inline explicit Col(const uword n_elem);
inline Col(const u32 in_rows, const u32 in_cols); inline Col(const uword in_rows, const uword in_cols);
inline Col(const char* text); inline Col(const char* text);
inline const Col& operator=(const char* text); inline const Col& operator=(const char* text);
inline Col(const std::string& text); inline Col(const std::string& text);
inline const Col& operator=(const std::string& text); inline const Col& operator=(const std::string& text);
#if defined(ARMA_USE_CXX11)
inline Col(const std::initializer_list<eT>& list);
inline const Col& operator=(const std::initializer_list<eT>& list);
#endif
inline const Col& operator=(const eT val); inline const Col& operator=(const eT val);
template<typename T1> inline Col(const Base<eT,T1>& X); template<typename T1> inline Col(const Base<eT,T1>& X);
template<typename T1> inline const Col& operator=(const Base<eT,T1>& X); template<typename T1> inline const Col& operator=(const Base<eT,T1>& X);
inline Col( eT* aux_mem, const u32 aux_length, const bool copy_aux_m inline Col( eT* aux_mem, const uword aux_length, const bool copy_aux
em = true, const bool strict = true); _mem = true, const bool strict = true);
inline Col(const eT* aux_mem, const u32 aux_length); inline Col(const eT* aux_mem, const uword aux_length);
template<typename T1, typename T2> template<typename T1, typename T2>
inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
template<typename T1> inline Col(const BaseCube<eT,T1>& X); template<typename T1> inline Col(const BaseCube<eT,T1>& X);
template<typename T1> inline const Col& operator=(const BaseCube<eT,T1>& X); template<typename T1> inline const Col& operator=(const BaseCube<eT,T1>& X);
inline Col(const subview_cube<eT>& X); inline Col(const subview_cube<eT>& X);
inline const Col& operator=(const subview_cube<eT>& X); inline const Col& operator=(const subview_cube<eT>& X);
inline mat_injector<Col> operator<<(const eT val); inline mat_injector<Col> operator<<(const eT val);
arma_inline eT& row(const u32 row_num); arma_inline eT& row(const uword row_num);
arma_inline eT row(const u32 row_num) const; arma_inline eT row(const uword row_num) const;
arma_inline subview_col<eT> rows(const u32 in_row1, const u32 in_ro arma_inline subview_col<eT> rows(const uword in_row1, const uword i
w2); n_row2);
arma_inline const subview_col<eT> rows(const u32 in_row1, const u32 in_ro arma_inline const subview_col<eT> rows(const uword in_row1, const uword i
w2) const; n_row2) const;
arma_inline subview_col<eT> subvec(const u32 in_row1, const u32 in_ arma_inline subview_col<eT> subvec(const uword in_row1, const uword
row2); in_row2);
arma_inline const subview_col<eT> subvec(const u32 in_row1, const u32 in_ arma_inline const subview_col<eT> subvec(const uword in_row1, const uword
row2) const; in_row2) const;
arma_inline subview_col<eT> subvec(const span& row_span); arma_inline subview_col<eT> subvec(const span& row_span);
arma_inline const subview_col<eT> subvec(const span& row_span) const; arma_inline const subview_col<eT> subvec(const span& row_span) const;
//arma_inline subview_col<eT> operator()(const span& row_span); //arma_inline subview_col<eT> operator()(const span& row_span);
//arma_inline const subview_col<eT> operator()(const span& row_span) cons t; //arma_inline const subview_col<eT> operator()(const span& row_span) cons t;
inline void shed_row (const u32 row_num); inline void shed_row (const uword row_num);
inline void shed_rows(const u32 in_row1, const u32 in_row2); inline void shed_rows(const uword in_row1, const uword in_row2);
inline void insert_rows(const u32 row_num, const u3 inline void insert_rows(const uword row_num, const
2 N, const bool set_to_zero = true); uword N, const bool set_to_zero = true);
template<typename T1> inline void insert_rows(const u32 row_num, const Ba template<typename T1> inline void insert_rows(const uword row_num, const
se<eT,T1>& X); Base<eT,T1>& X);
typedef eT* row_iterator; typedef eT* row_iterator;
typedef const eT* const_row_iterator; typedef const eT* const_row_iterator;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const uword row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const uword row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const uword row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const uword row_num) const;
template<u32 fixed_n_elem> template<uword fixed_n_elem>
class fixed : public Col<eT> class fixed : public Col<eT>
{ {
private: private:
static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc ); static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc );
arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
arma_inline void mem_setup(); arma_inline void mem_setup();
arma_inline void change_to_row(); arma_inline void change_to_row();
public: public:
static const u32 n_rows = fixed_n_elem; static const uword n_rows = fixed_n_elem;
static const u32 n_cols = 1; static const uword n_cols = 1;
static const u32 n_elem = fixed_n_elem; static const uword n_elem = fixed_n_elem;
arma_inline fixed(); arma_inline fixed();
arma_inline fixed(const fixed<fixed_n_elem>& X); arma_inline fixed(const fixed<fixed_n_elem>& X);
inline fixed(const subview_cube<eT>& X); inline fixed(const subview_cube<eT>& X);
template<typename T1> inline fixed(const Base<eT,T1>& A); template<typename T1> inline fixed(const Base<eT,T1>& A);
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B); template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B);
inline fixed( eT* aux_mem, const bool copy_aux_mem = true); inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
inline fixed(const eT* aux_mem); inline fixed(const eT* aux_mem);
skipping to change at line 122 skipping to change at line 128
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);
inline subview_row<eT> operator()(const u32 row_num, const spa inline subview_row<eT> operator()(const uword row_num, const s
n& col_span); pan& col_span);
inline const subview_row<eT> operator()(const u32 row_num, const spa inline const subview_row<eT> operator()(const uword row_num, const s
n& col_span) const; pan& col_span) const;
inline subview_col<eT> operator()(const span& row_span, const u32 inline subview_col<eT> operator()(const span& row_span, const uwo
col_num ); rd col_num );
inline const subview_col<eT> operator()(const span& row_span, const u32 inline const subview_col<eT> operator()(const span& row_span, const uwo
col_num ) const; rd col_num ) const;
inline subview<eT> operator()(const span& row_span, const spa n& col_span); inline subview<eT> operator()(const span& row_span, const spa n& col_span);
inline const subview<eT> operator()(const span& row_span, const spa n& col_span) const; inline const subview<eT> operator()(const span& row_span, const spa n& col_span) const;
arma_inline arma_warn_unused eT& operator[] (const u32 i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const u32 i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const u32 i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const u32 i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const u32 i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 in_row, const u3 arma_inline arma_warn_unused eT& at (const uword in_row, const
2 in_col); uword in_col);
arma_inline arma_warn_unused eT at (const u32 in_row, const u3 arma_inline arma_warn_unused eT at (const uword in_row, const
2 in_col) const; uword in_col) const;
arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u3 arma_inline arma_warn_unused eT& operator() (const uword in_row, const
2 in_col); uword in_col);
arma_inline arma_warn_unused eT operator() (const u32 in_row, const u3 arma_inline arma_warn_unused eT operator() (const uword in_row, const
2 in_col) const; uword in_col) const;
arma_hot inline const Col<eT>& fill(const eT val); arma_hot inline const Col<eT>& fill(const eT val);
arma_hot inline const Col<eT>& zeros(); arma_hot inline const Col<eT>& zeros();
arma_hot inline const Col<eT>& ones(); arma_hot inline const Col<eT>& ones();
}; };
#ifdef ARMA_EXTRA_COL_PROTO #ifdef ARMA_EXTRA_COL_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO)
#endif #endif
 End of changes. 16 change blocks. 
52 lines changed or deleted 58 lines changed or added


 Col_meat.hpp   Col_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Col //! \addtogroup Col
//! @{ //! @{
//! construct an empty column vector //! construct an empty column vector
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col() Col<eT>::Col()
: Mat<eT>(0, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
} }
//! construct a column vector with the specified number of n_elem //! construct a column vector with the specified number of n_elem
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const u32 in_n_elem) Col<eT>::Col(const uword in_n_elem)
: Mat<eT>(in_n_elem, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
Mat<eT>::init(in_n_elem, 1);
} }
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::Col(const uword in_n_rows, const uword in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
Mat<eT>::init(in_n_rows, in_n_cols); Mat<eT>::init_warm(in_n_rows, in_n_cols);
} }
//! construct a column vector from specified text //! construct a column vector from specified text
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const char* text) Col<eT>::Col(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
skipping to change at line 120 skipping to change at line 119
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
return *this; return *this;
} }
#if defined(ARMA_USE_CXX11)
template<typename eT>
inline
Col<eT>::Col(const std::initializer_list<eT>& list)
{
arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(list);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
access::rw(Mat<eT>::vec_state) = 1;
}
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator=(const std::initializer_list<eT>& list)
{
arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(list);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
access::rw(Mat<eT>::vec_state) = 1;
return *this;
}
#endif
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const eT val) Col<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(val); Mat<eT>::operator=(val);
return *this; return *this;
skipping to change at line 160 skipping to change at line 196
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X.get_ref()); Mat<eT>::operator=(X.get_ref());
return *this; return *this;
} }
//! construct a column vector from a given auxiliary array of eTs //! construct a column vector from a given auxiliary array of eTs
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co nst bool strict) Col<eT>::Col(eT* aux_mem, const uword aux_length, const bool copy_aux_mem, const bool strict)
: Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem, strict) : Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem, strict)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
} }
//! construct a column vector from a given auxiliary array of eTs //! construct a column vector from a given auxiliary array of eTs
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const eT* aux_mem, const u32 aux_length) Col<eT>::Col(const eT* aux_mem, const uword aux_length)
: Mat<eT>(aux_mem, aux_length, 1) : Mat<eT>(aux_mem, aux_length, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 254 skipping to change at line 290
inline inline
mat_injector< Col<eT> > mat_injector< Col<eT> >
Col<eT>::operator<<(const eT val) Col<eT>::operator<<(const eT val)
{ {
return mat_injector< Col<eT> >(*this, val); return mat_injector< Col<eT> >(*this, val);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
Col<eT>::row(const u32 row_num) Col<eT>::row(const uword row_num)
{ {
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound s" ); arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound s" );
return access::rw(Mat<eT>::mem[row_num]); return access::rw(Mat<eT>::mem[row_num]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
Col<eT>::row(const u32 row_num) const Col<eT>::row(const uword row_num) const
{ {
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound s" ); arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound s" );
return Mat<eT>::mem[row_num]; return Mat<eT>::mem[row_num];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_col<eT> subview_col<eT>
Col<eT>::rows(const u32 in_row1, const u32 in_row2) Col<eT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
return subview_col<eT>(*this, 0, in_row1, subview_n_rows); return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_col<eT> const subview_col<eT>
Col<eT>::rows(const u32 in_row1, const u32 in_row2) const Col<eT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
return subview_col<eT>(*this, 0, in_row1, subview_n_rows); return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_col<eT> subview_col<eT>
Col<eT>::subvec(const u32 in_row1, const u32 in_row2) Col<eT>::subvec(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
return subview_col<eT>(*this, 0, in_row1, subview_n_rows); return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_col<eT> const subview_col<eT>
Col<eT>::subvec(const u32 in_row1, const u32 in_row2) const Col<eT>::subvec(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
return subview_col<eT>(*this, 0, in_row1, subview_n_rows); return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_col<eT> subview_col<eT>
Col<eT>::subvec(const span& row_span) Col<eT>::subvec(const span& row_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const u32 local_n_rows = Mat<eT>::n_rows; const uword local_n_rows = Mat<eT>::n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 subvec_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword subvec_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
arma_debug_check( ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ), "Col::subvec(): indices out of bounds or incorrectly use d"); arma_debug_check( ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ), "Col::subvec(): indices out of bounds or incorrectly use d");
return subview_col<eT>(*this, 0, in_row1, subvec_n_rows); return subview_col<eT>(*this, 0, in_row1, subvec_n_rows);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_col<eT> const subview_col<eT>
Col<eT>::subvec(const span& row_span) const Col<eT>::subvec(const span& row_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const u32 local_n_rows = Mat<eT>::n_rows; const uword local_n_rows = Mat<eT>::n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 subvec_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword subvec_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
arma_debug_check( ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ), "Col::subvec(): indices out of bounds or incorrectly use d"); arma_debug_check( ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ), "Col::subvec(): indices out of bounds or incorrectly use d");
return subview_col<eT>(*this, 0, in_row1, subvec_n_rows); return subview_col<eT>(*this, 0, in_row1, subvec_n_rows);
} }
// template<typename eT> // template<typename eT>
// arma_inline // arma_inline
// subview_col<eT> // subview_col<eT>
// Col<eT>::operator()(const span& row_span) // Col<eT>::operator()(const span& row_span)
skipping to change at line 393 skipping to change at line 429
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// return subvec(row_span); // return subvec(row_span);
// } // }
//! remove specified row //! remove specified row
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::shed_row(const u32 row_num) Col<eT>::shed_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= Mat<eT>::n_rows, "Col::shed_row(): out of bo unds"); arma_debug_check( row_num >= Mat<eT>::n_rows, "Col::shed_row(): out of bo unds");
shed_rows(row_num, row_num); shed_rows(row_num, row_num);
} }
//! remove specified rows //! remove specified rows
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::shed_rows(const u32 in_row1, const u32 in_row2) Col<eT>::shed_rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows), (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows),
"Col::shed_rows(): indices out of bounds or incorrectly used" "Col::shed_rows(): indices out of bounds or incorrectly used"
); );
const u32 n_keep_front = in_row1; const uword n_keep_front = in_row1;
const u32 n_keep_back = Mat<eT>::n_rows - (in_row2 + 1); const uword n_keep_back = Mat<eT>::n_rows - (in_row2 + 1);
Col<eT> X(n_keep_front + n_keep_back); Col<eT> X(n_keep_front + n_keep_back);
eT* X_mem = X.memptr(); eT* X_mem = X.memptr();
const eT* t_mem = (*this).memptr(); const eT* t_mem = (*this).memptr();
if(n_keep_front > 0) if(n_keep_front > 0)
{ {
arrayops::copy( X_mem, t_mem, n_keep_front ); arrayops::copy( X_mem, t_mem, n_keep_front );
} }
skipping to change at line 442 skipping to change at line 478
} }
Mat<eT>::steal_mem(X); Mat<eT>::steal_mem(X);
} }
//! insert N rows at the specified row position, //! insert N rows at the specified row position,
//! optionally setting the elements of the inserted rows to zero //! optionally setting the elements of the inserted rows to zero
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::insert_rows(const u32 row_num, const u32 N, const bool set_to_zero ) Col<eT>::insert_rows(const uword row_num, const uword N, const bool set_to_ zero)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 t_n_rows = Mat<eT>::n_rows; const uword t_n_rows = Mat<eT>::n_rows;
const u32 A_n_rows = row_num; const uword A_n_rows = row_num;
const u32 B_n_rows = t_n_rows - row_num; const uword B_n_rows = t_n_rows - row_num;
// insertion at row_num == n_rows is in effect an append operation // insertion at row_num == n_rows is in effect an append operation
arma_debug_check( (row_num > t_n_rows), "Col::insert_rows(): out of bound s"); arma_debug_check( (row_num > t_n_rows), "Col::insert_rows(): out of bound s");
if(N > 0) if(N > 0)
{ {
Col<eT> out(t_n_rows + N); Col<eT> out(t_n_rows + N);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* t_mem = (*this).memptr(); const eT* t_mem = (*this).memptr();
skipping to change at line 486 skipping to change at line 522
Mat<eT>::steal_mem(out); Mat<eT>::steal_mem(out);
} }
} }
//! insert the given object at the specified row position; //! insert the given object at the specified row position;
//! the given object must have one column //! the given object must have one column
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Col<eT>::insert_rows(const u32 row_num, const Base<eT,T1>& X) Col<eT>::insert_rows(const uword row_num, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::insert_rows(row_num, X); Mat<eT>::insert_rows(row_num, X);
} }
template<typename eT> template<typename eT>
inline inline
typename Col<eT>::row_iterator typename Col<eT>::row_iterator
Col<eT>::begin_row(const u32 row_num) Col<eT>::begin_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds");
return Mat<eT>::memptr() + row_num; return Mat<eT>::memptr() + row_num;
} }
template<typename eT> template<typename eT>
inline inline
typename Col<eT>::const_row_iterator typename Col<eT>::const_row_iterator
Col<eT>::begin_row(const u32 row_num) const Col<eT>::begin_row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds");
return Mat<eT>::memptr() + row_num; return Mat<eT>::memptr() + row_num;
} }
template<typename eT> template<typename eT>
inline inline
typename Col<eT>::row_iterator typename Col<eT>::row_iterator
Col<eT>::end_row(const u32 row_num) Col<eT>::end_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
return Mat<eT>::memptr() + row_num + 1; return Mat<eT>::memptr() + row_num + 1;
} }
template<typename eT> template<typename eT>
inline inline
typename Col<eT>::const_row_iterator typename Col<eT>::const_row_iterator
Col<eT>::end_row(const u32 row_num) const Col<eT>::end_row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
return Mat<eT>::memptr() + row_num + 1; return Mat<eT>::memptr() + row_num + 1;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
void void
Col<eT>::fixed<fixed_n_elem>::mem_setup() Col<eT>::fixed<fixed_n_elem>::mem_setup()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = fixed_n_elem; access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = 1; access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = fixed_n_elem; access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3; access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>: :mem_local; access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>: :mem_local;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
void void
Col<eT>::fixed<fixed_n_elem>::change_to_row() Col<eT>::fixed<fixed_n_elem>::change_to_row()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_cols) = fixed_n_elem; access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_rows) = 1; access::rw(Mat<eT>::n_rows) = 1;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
Col<eT>::fixed<fixed_n_elem>::fixed() Col<eT>::fixed<fixed_n_elem>::fixed()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
Col<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X) Col<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
arrayops::copy( dest, X.mem, fixed_n_elem ); arrayops::copy( dest, X.mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X) Col<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Col<eT>::operator=(X); Col<eT>::operator=(X);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
template<typename T1> template<typename T1>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A) Col<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Col<eT>::operator=(A.get_ref()); Col<eT>::operator=(A.get_ref());
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base< pod_type,T2>& B) Col<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base< pod_type,T2>& B)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Col<eT>::init(A,B); Col<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
access::rw(Mat<eT>::n_rows) = fixed_n_elem; access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = 1; access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = fixed_n_elem; access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3; access::rw(Mat<eT>::mem_state) = 3;
skipping to change at line 659 skipping to change at line 695
arrayops::copy( dest, aux_mem, fixed_n_elem ); arrayops::copy( dest, aux_mem, fixed_n_elem );
} }
else else
{ {
access::rw(Mat<eT>::mem) = aux_mem; access::rw(Mat<eT>::mem) = aux_mem;
} }
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
//! NOTE: this function relies on //! NOTE: this function relies on
//! Col::operator=(text), to change vec_state as well as swapping n_rows an d n_cols, //! Col::operator=(text), to change vec_state as well as swapping n_rows an d n_cols,
//! and Mat::init(), to check that the given vector will not have a differe nt size than fixed_n_elem. //! and Mat::init(), to check that the given vector will not have a differe nt size than fixed_n_elem.
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const char* text) Col<eT>::fixed<fixed_n_elem>::fixed(const char* text)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
change_to_row(); change_to_row();
Col<eT>::operator=(text); Col<eT>::operator=(text);
} }
//! NOTE: this function relies on //! NOTE: this function relies on
//! Col::operator=(text), to change vec_state as well as swapping n_rows an d n_cols, //! Col::operator=(text), to change vec_state as well as swapping n_rows an d n_cols,
//! and Mat::init(), to check that the given vector will not have a differe nt size than fixed_n_elem. //! and Mat::init(), to check that the given vector will not have a differe nt size than fixed_n_elem.
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const std::string& text) Col<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
change_to_row(); change_to_row();
Col<eT>::operator=(text); Col<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
template<typename T1> template<typename T1>
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A) Col<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<eT>::operator=(A.get_ref()); Col<eT>::operator=(A.get_ref());
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const eT val) Col<eT>::fixed<fixed_n_elem>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<eT>::operator=(val); Col<eT>::operator=(val);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const char* text) Col<eT>::fixed<fixed_n_elem>::operator=(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
change_to_row(); change_to_row();
Col<eT>::operator=(text); Col<eT>::operator=(text);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const std::string& text) Col<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
change_to_row(); change_to_row();
Col<eT>::operator=(text); Col<eT>::operator=(text);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X) Col<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<eT>::operator=(X); Col<eT>::operator=(X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview_row<eT> subview_row<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col _span) Col<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c ol_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); return Mat<eT>::operator()(row_num, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_row<eT> const subview_row<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col _span) const Col<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c ol_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); return Mat<eT>::operator()(row_num, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview_col<eT> subview_col<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co l_num) Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); return Mat<eT>::operator()(row_span, col_num);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_col<eT> const subview_col<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co l_num) const Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); return Mat<eT>::operator()(row_span, col_num);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview<eT> subview<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview<eT> const subview<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) const Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) Col<eT>::fixed<fixed_n_elem>::operator[] (const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) const Col<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::at(const u32 i) Col<eT>::fixed<fixed_n_elem>::at(const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::at(const u32 i) const Col<eT>::fixed<fixed_n_elem>::at(const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 i) Col<eT>::fixed<fixed_n_elem>::operator() (const uword i)
{ {
arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo unds");
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 i) const Col<eT>::fixed<fixed_n_elem>::operator() (const uword i) const
{ {
arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo unds");
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col)
{ {
return access::rw( Mat<eT>::mem[in_row] ); return access::rw( Mat<eT>::mem[in_row] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) const Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) co nst
{ {
return ( Mat<eT>::mem[in_row] ); return ( Mat<eT>::mem[in_row] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co l) Col<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col)
{ {
arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe d::operator(): out of bounds" );
return access::rw( Mat<eT>::mem[in_row] ); return access::rw( Mat<eT>::mem[in_row] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co l) const Col<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) const
{ {
arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe d::operator(): out of bounds" );
return ( Mat<eT>::mem[in_row] ); return ( Mat<eT>::mem[in_row] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::fill(const eT val) Col<eT>::fixed<fixed_n_elem>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) ; arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) ;
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::zeros() Col<eT>::fixed<fixed_n_elem>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem ); arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::ones() Col<eT>::fixed<fixed_n_elem>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem ); arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem );
return *this; return *this;
 End of changes. 83 change blocks. 
88 lines changed or deleted 126 lines changed or added


 Cube_bones.hpp   Cube_bones.hpp 
skipping to change at line 18 skipping to change at line 18
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Cube //! \addtogroup Cube
//! @{ //! @{
struct Cube_prealloc struct Cube_prealloc
{ {
static const u32 mat_ptrs_size = 4; static const uword mat_ptrs_size = 4;
static const u32 mem_n_elem = 64; static const uword mem_n_elem = 64;
}; };
//! Dense cube class //! Dense cube class
template<typename eT> template<typename eT>
class Cube : public BaseCube< eT, Cube<eT> > class Cube : public BaseCube< eT, Cube<eT> >
{ {
public: public:
typedef eT elem_type; //!< the type of ele ments stored in the cube typedef eT elem_type; //!< the type of ele ments stored in the cube
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-co mplex, pod_type is same as eT. otherwise, pod_type is the underlying type u sed by std::complex typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-co mplex, pod_type is same as eT. otherwise, pod_type is the underlying type u sed by std::complex
const u32 n_rows; //!< number of rows in each slice (read-only) const uword n_rows; //!< number of rows in each slice (read-only)
const u32 n_cols; //!< number of columns in each slice (read-only) const uword n_cols; //!< number of columns in each slice (read-onl
const u32 n_elem_slice; //!< number of elements in each slice (read-only y)
) const uword n_elem_slice; //!< DEPRECATED: do not use this member variab
const u32 n_slices; //!< number of slices in the cube (read-only) le -- it will be _removed_ in version 3.0
const u32 n_elem; //!< number of elements in the cube (read-only) const uword n_slices; //!< number of slices in the cube (read-only)
const u32 mem_state; const uword n_elem; //!< number of elements in the cube (read-only
)
const uword mem_state;
// mem_state = 0: normal cube that can be resized; // mem_state = 0: normal cube that can be resized;
// mem_state = 1: use auxiliary memory until change in the number of elem ents is requested; // mem_state = 1: use auxiliary memory until change in the number of elem ents is requested;
// mem_state = 2: use auxiliary memory and don't allow the number of elem ents to be changed; // mem_state = 2: use auxiliary memory and don't allow the number of elem ents to be changed;
// mem_state = 3: fixed size (e.g. via template based size specification) . // mem_state = 3: fixed size (e.g. via template based size specification) .
arma_aligned const Mat<eT>** const mat_ptrs; //!< pointer to an array con taining pointers to Mat instances (one for each slice) arma_aligned const Mat<eT>** const mat_ptrs; //!< pointer to an array con taining pointers to Mat instances (one for each slice)
arma_aligned const eT* const mem; //!< pointer to the memory u sed by the cube (memory is read-only) arma_aligned const eT* const mem; //!< pointer to the memory u sed by the cube (memory is read-only)
protected: protected:
arma_aligned Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ]; arma_aligned Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ];
arma_aligned eT mem_local[ Cube_prealloc::mem_n_elem ]; arma_aligned eT mem_local[ Cube_prealloc::mem_n_elem ];
public: public:
inline ~Cube(); inline ~Cube();
inline Cube(); inline Cube();
inline Cube(const u32 in_rows, const u32 in_cols, const u32 in_slices); inline Cube(const uword in_rows, const uword in_cols, const uword in_slic es);
inline Cube( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols inline Cube( eT* aux_mem, const uword aux_n_rows, const uword aux_n_
, const u32 aux_n_slices, const bool copy_aux_mem = true, const bool strict cols, const uword aux_n_slices, const bool copy_aux_mem = true, const bool
= true); strict = true);
inline Cube(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols inline Cube(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_
, const u32 aux_n_slices); cols, const uword aux_n_slices);
arma_inline const Cube& operator=(const eT val); arma_inline const Cube& operator=(const eT val);
arma_inline const Cube& operator+=(const eT val); arma_inline const Cube& operator+=(const eT val);
arma_inline const Cube& operator-=(const eT val); arma_inline const Cube& operator-=(const eT val);
arma_inline const Cube& operator*=(const eT val); arma_inline const Cube& operator*=(const eT val);
arma_inline const Cube& operator/=(const eT val); arma_inline const Cube& operator/=(const eT val);
inline Cube(const Cube& m); inline Cube(const Cube& m);
inline const Cube& operator=(const Cube& m); inline const Cube& operator=(const Cube& m);
inline const Cube& operator+=(const Cube& m); inline const Cube& operator+=(const Cube& m);
skipping to change at line 84 skipping to change at line 84
template<typename T1, typename T2> template<typename T1, typename T2>
inline explicit Cube(const BaseCube<pod_type,T1>& A, const BaseCube<pod_t ype,T2>& B); inline explicit Cube(const BaseCube<pod_type,T1>& A, const BaseCube<pod_t ype,T2>& B);
inline Cube(const subview_cube<eT>& X); inline Cube(const subview_cube<eT>& X);
inline const Cube& operator=(const subview_cube<eT>& X); inline const Cube& operator=(const subview_cube<eT>& X);
inline const Cube& operator+=(const subview_cube<eT>& X); inline const Cube& operator+=(const subview_cube<eT>& X);
inline const Cube& operator-=(const subview_cube<eT>& X); inline const Cube& operator-=(const subview_cube<eT>& X);
inline const Cube& operator%=(const subview_cube<eT>& X); inline const Cube& operator%=(const subview_cube<eT>& X);
inline const Cube& operator/=(const subview_cube<eT>& X); inline const Cube& operator/=(const subview_cube<eT>& X);
arma_inline Mat<eT>& slice(const u32 in_slice); arma_inline Mat<eT>& slice(const uword in_slice);
arma_inline const Mat<eT>& slice(const u32 in_slice) const; arma_inline const Mat<eT>& slice(const uword in_slice) const;
arma_inline subview_cube<eT> slices(const u32 in_slice1, const u32 arma_inline subview_cube<eT> slices(const uword in_slice1, const uw
in_slice2); ord in_slice2);
arma_inline const subview_cube<eT> slices(const u32 in_slice1, const u32 arma_inline const subview_cube<eT> slices(const uword in_slice1, const uw
in_slice2) const; ord in_slice2) const;
arma_inline subview_cube<eT> subcube(const u32 in_row1, const u32 i arma_inline subview_cube<eT> subcube(const uword in_row1, const uwo
n_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u3 rd in_col1, const uword in_slice1, const uword in_row2, const uword in_col2
2 in_slice2); , const uword in_slice2);
arma_inline const subview_cube<eT> subcube(const u32 in_row1, const u32 i arma_inline const subview_cube<eT> subcube(const uword in_row1, const uwo
n_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u3 rd in_col1, const uword in_slice1, const uword in_row2, const uword in_col2
2 in_slice2) const; , const uword in_slice2) const;
inline subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span); inline subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span);
inline const subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span) const; inline const subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span) const;
inline subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span); inline subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span);
inline const subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span) const; inline const subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span) const;
inline void shed_slice(const u32 slice_num); inline void shed_slice(const uword slice_num);
inline void shed_slices(const u32 in_slice1, const u32 in_slice2); inline void shed_slices(const uword in_slice1, const uword in_slice2);
inline void insert_slices(const u32 slice_num, const u32 N, const bool se t_to_zero = true); inline void insert_slices(const uword slice_num, const uword N, const boo l set_to_zero = true);
template<typename T1> template<typename T1>
inline void insert_slices(const u32 row_num, const BaseCube<eT,T1>& X); inline void insert_slices(const uword row_num, const BaseCube<eT,T1>& X);
template<typename gen_type> inline Cube(const GenCube<e
T, gen_type>& X);
template<typename gen_type> inline const Cube& operator=(const GenCube<e
T, gen_type>& X);
template<typename gen_type> inline const Cube& operator+=(const GenCube<e
T, gen_type>& X);
template<typename gen_type> inline const Cube& operator-=(const GenCube<e
T, gen_type>& X);
template<typename gen_type> inline const Cube& operator%=(const GenCube<e
T, gen_type>& X);
template<typename gen_type> inline const Cube& operator/=(const GenCube<e
T, gen_type>& X);
template<typename T1, typename op_type> inline Cube(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline Cube(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator+=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator+=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator-=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator-=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator%=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator%=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator/=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator/=(con st OpCube<T1, op_type>& X);
template<typename T1, typename eop_type> inline Cube(co nst eOpCube<T1, eop_type>& X); template<typename T1, typename eop_type> inline Cube(co nst eOpCube<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Cube& operator=(co nst eOpCube<T1, eop_type>& X); template<typename T1, typename eop_type> inline const Cube& operator=(co nst eOpCube<T1, eop_type>& X);
skipping to change at line 150 skipping to change at line 157
template<typename T1, typename T2, typename eglue_type> inline const Cube & operator%=(const eGlueCube<T1, T2, eglue_type>& X); template<typename T1, typename T2, typename eglue_type> inline const Cube & operator%=(const eGlueCube<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename eglue_type> inline const Cube & operator/=(const eGlueCube<T1, T2, eglue_type>& X); template<typename T1, typename T2, typename eglue_type> inline const Cube & operator/=(const eGlueCube<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename glue_type> inline Cube(const mtGlueCube<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline Cube(const mtGlueCube<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Cube& operator=(const mtGlueCube<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Cube& operator=(const mtGlueCube<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Cube& operator+=(const mtGlueCube<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Cube& operator+=(const mtGlueCube<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Cube& operator-=(const mtGlueCube<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Cube& operator-=(const mtGlueCube<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Cube& operator%=(const mtGlueCube<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Cube& operator%=(const mtGlueCube<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Cube& operator/=(const mtGlueCube<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Cube& operator/=(const mtGlueCube<eT, T1, T2, glue_type>& X);
arma_inline arma_warn_unused eT& operator[] (const u32 i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const u32 i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at(const u32 i); arma_inline arma_warn_unused eT& at(const uword i);
arma_inline arma_warn_unused eT at(const u32 i) const; arma_inline arma_warn_unused eT at(const uword i) const;
arma_inline arma_warn_unused eT& operator() (const u32 i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const u32 i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 in_row, const u32 arma_inline arma_warn_unused eT& at (const uword in_row, const uw
in_col, const u32 in_slice); ord in_col, const uword in_slice);
arma_inline arma_warn_unused eT at (const u32 in_row, const u32 arma_inline arma_warn_unused eT at (const uword in_row, const uw
in_col, const u32 in_slice) const; ord in_col, const uword in_slice) const;
arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u32 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw
in_col, const u32 in_slice); ord in_col, const uword in_slice);
arma_inline arma_warn_unused eT operator() (const u32 in_row, const u32 arma_inline arma_warn_unused eT operator() (const uword in_row, const uw
in_col, const u32 in_slice) const; ord in_col, const uword in_slice) const;
arma_inline const Cube& operator++(); arma_inline const Cube& operator++();
arma_inline void operator++(int); arma_inline void operator++(int);
arma_inline const Cube& operator--(); arma_inline const Cube& operator--();
arma_inline void operator--(int); arma_inline void operator--(int);
arma_inline arma_warn_unused bool is_finite() const; arma_inline arma_warn_unused bool is_finite() const;
arma_inline arma_warn_unused bool is_empty() const; arma_inline arma_warn_unused bool is_empty() const;
arma_inline arma_warn_unused bool in_range(const u32 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 u32 in_row, const u3 2 in_col, const u32 in_slice) const; arma_inline arma_warn_unused bool in_range(const uword in_row, const uw ord in_col, const uword in_slice) const;
inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span, const span& slice_span) const; inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span, const span& slice_span) 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 eT* slice_memptr(const u32 slice); arma_inline arma_warn_unused eT* slice_memptr(const uword slice);
arma_inline arma_warn_unused const eT* slice_memptr(const u32 slice) cons arma_inline arma_warn_unused const eT* slice_memptr(const uword slice) co
t; nst;
arma_inline arma_warn_unused eT* slice_colptr(const u32 in_slice, c arma_inline arma_warn_unused eT* slice_colptr(const uword in_slice,
onst u32 in_col); const uword in_col);
arma_inline arma_warn_unused const eT* slice_colptr(const u32 in_slice, c arma_inline arma_warn_unused const eT* slice_colptr(const uword in_slice,
onst u32 in_col) const; const uword in_col) const;
inline void print(const std::string extra_text = "") const; inline void impl_print(const std::string& extra_text) const;
inline void print(std::ostream& user_stream, const std::string extra_text inline void impl_print(std::ostream& user_stream, const std::string& extr
= "") const; a_text) const;
inline void raw_print(const std::string extra_text = "") const; inline void impl_raw_print(const std::string& extra_text) const;
inline void raw_print(std::ostream& user_stream, const std::string extra_ inline void impl_raw_print(std::ostream& user_stream, const std::string&
text = "") const; extra_text) const;
inline void set_size(const u32 in_rows, const u32 in_cols, const u32 in_ inline void set_size(const uword in_rows, const uword in_cols, const uwo
slices); rd in_slices);
inline void reshape(const u32 in_rows, const u32 in_cols, const u32 in_ inline void reshape(const uword in_rows, const uword in_cols, const uwo
slices, const u32 dim = 0); rd in_slices, const uword dim = 0);
template<typename eT2> inline void copy_size(const Cube<eT2>& m); template<typename eT2> inline void copy_size(const Cube<eT2>& m);
inline const Cube& fill(const eT val); inline const Cube& fill(const eT val);
inline const Cube& zeros(); inline const Cube& zeros();
inline const Cube& zeros(const u32 in_rows, const u32 in_cols, const u32 in_slices); inline const Cube& zeros(const uword in_rows, const uword in_cols, const uword in_slices);
inline const Cube& ones(); inline const Cube& ones();
inline const Cube& ones(const u32 in_rows, const u32 in_cols, const u32 i n_slices); inline const Cube& ones(const uword in_rows, const uword in_cols, const u word in_slices);
inline const Cube& randu(); inline const Cube& randu();
inline const Cube& randu(const u32 in_rows, const u32 in_cols, const u32 in_slices); inline const Cube& randu(const uword in_rows, const uword in_cols, const uword in_slices);
inline const Cube& randn(); inline const Cube& randn();
inline const Cube& randn(const u32 in_rows, const u32 in_cols, const u32 in_slices); inline const Cube& randn(const uword in_rows, const uword in_cols, const uword in_slices);
inline void reset(); inline void reset();
template<typename T1> inline void set_real(const BaseCube<pod_type,T1>& X ); template<typename T1> inline void set_real(const BaseCube<pod_type,T1>& X );
template<typename T1> inline void set_imag(const BaseCube<pod_type,T1>& X ); template<typename T1> inline void set_imag(const BaseCube<pod_type,T1>& X );
inline arma_warn_unused eT min() const; inline arma_warn_unused eT min() const;
inline arma_warn_unused eT max() const; inline arma_warn_unused eT max() const;
inline eT min(u32& index_of_min_val) const; inline eT min(uword& index_of_min_val) const;
inline eT max(u32& index_of_max_val) const; inline eT max(uword& index_of_max_val) const;
inline eT min(u32& row_of_min_val, u32& col_of_min_val, u32& slice_of_min inline eT min(uword& row_of_min_val, uword& col_of_min_val, uword& slice_
_val) const; of_min_val) const;
inline eT max(u32& row_of_max_val, u32& col_of_max_val, u32& slice_of_max inline eT max(uword& row_of_max_val, uword& col_of_max_val, uword& slice_
_val) const; of_max_val) 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;
skipping to change at line 254 skipping to change at line 261
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 iterator end(); inline iterator end();
inline const_iterator end() const; inline const_iterator end() const;
inline slice_iterator begin_slice(const u32 slice_num); inline slice_iterator begin_slice(const uword slice_num);
inline const_slice_iterator begin_slice(const u32 slice_num) const; inline const_slice_iterator begin_slice(const uword slice_num) const;
inline slice_iterator end_slice(const u32 slice_num); inline slice_iterator end_slice(const uword slice_num);
inline const_slice_iterator end_slice(const u32 slice_num) const; inline const_slice_iterator end_slice(const uword slice_num) const;
template<u32 fixed_n_rows, u32 fixed_n_cols, u32 fixed_n_slices> template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices>
class fixed : public Cube<eT> class fixed : public Cube<eT>
{ {
private: private:
static const u32 fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n_s lices; static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n _slices;
arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_prea lloc::mat_ptrs_size) ? fixed_n_slices : 1 ]; arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_prea lloc::mat_ptrs_size) ? fixed_n_slices : 1 ];
arma_aligned eT mem_local_extra [ (fixed_n_elem > Cube_prea lloc::mem_n_elem) ? fixed_n_elem : 1 ]; arma_aligned eT mem_local_extra [ (fixed_n_elem > Cube_prea lloc::mem_n_elem) ? fixed_n_elem : 1 ];
arma_inline void mem_setup(); arma_inline void mem_setup();
public: public:
inline fixed() { mem_setup(); } inline fixed() { mem_setup(); }
skipping to change at line 290 skipping to change at line 297
template<typename T1> template<typename T1>
inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::oper ator=(A.get_ref()); return *this; } inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::oper ator=(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<po d_type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); } inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<po d_type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); }
}; };
protected: protected:
inline void init(const u32 in_rows, const u32 in_cols, const u32 in_slice inline void init_cold();
s); inline void init_warm(const uword in_rows, const uword in_cols, const uwo
inline void init(const Cube& x); rd in_slices);
template<typename T1, typename T2> template<typename T1, typename T2>
inline void init(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type, T2>& B); inline void init(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type, T2>& B);
inline void steal_mem(Cube& X); inline void steal_mem(Cube& X);
inline void delete_mat(); inline void delete_mat();
inline void create_mat(); inline void create_mat();
friend class op_reshape; friend class op_reshape;
 End of changes. 34 change blocks. 
83 lines changed or deleted 98 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 28 skipping to change at line 28
Cube<eT>::~Cube() Cube<eT>::~Cube()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
delete_mat(); delete_mat();
if(mem_state == 0) if(mem_state == 0)
{ {
if(n_elem > Cube_prealloc::mem_n_elem) if(n_elem > Cube_prealloc::mem_n_elem)
{ {
delete [] mem; #if defined(ARMA_USE_TBB_ALLOC)
scalable_free((void *)(mem));
#else
delete [] mem;
#endif
} }
} }
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
// try to expose buggy user code that accesses deleted objects // try to expose buggy user code that accesses deleted objects
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
access::rw(n_elem_slice) = 0; access::rw(n_slices) = 0;
access::rw(n_slices) = 0; access::rw(n_elem) = 0;
access::rw(n_elem) = 0; access::rw(mat_ptrs) = 0;
access::rw(mat_ptrs) = 0; access::rw(mem) = 0;
access::rw(mem) = 0;
} }
arma_type_check< is_supported_elem_type<eT>::value == false >::apply(); arma_type_check(( is_supported_elem_type<eT>::value == false ));
} }
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube() Cube<eT>::Cube()
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
//! construct the cube to have user specified dimensions //! construct the cube to have user specified dimensions
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in
ces) _n_slices)
: n_rows(0) : n_rows(in_n_rows)
, n_cols(0) , n_cols(in_n_cols)
, n_elem_slice(0) , n_elem_slice(in_n_rows*in_n_cols)
, n_slices(0) , n_slices(in_n_slices)
, n_elem(0) , n_elem(in_n_rows*in_n_cols*in_n_slices)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(in_n_rows, in_n_cols, in_n_slices); init_cold();
}
template<typename eT>
inline
void
Cube<eT>::init_cold()
{
arma_extra_debug_sigprint( arma_boost::format("n_rows = %d, n_cols = %d,
n_slices = %d") % n_rows % n_cols % n_slices );
arma_debug_check
(
(
( (n_rows > 0x0FFF) || (n_cols > 0x0FFF) || (n_slices > 0xFF) )
? ( (float(n_rows) * float(n_cols) * float(n_slices)) > float(ARMA_
MAX_UWORD) )
: false
),
"Cube::init(): requested size is too large"
);
if(n_elem <= Cube_prealloc::mem_n_elem)
{
access::rw(mem) = mem_local;
}
else
{
arma_extra_debug_print("Cube::init(): allocating memory");
#if defined(ARMA_USE_TBB_ALLOC)
access::rw(mem) = (eT *)scalable_malloc(sizeof(eT)*n_elem);
#else
access::rw(mem) = new(std::nothrow) eT[n_elem];
#endif
arma_check_bad_alloc( (mem == 0), "Cube::init(): out of memory" );
}
if(n_elem == 0)
{
access::rw(n_rows) = 0;
access::rw(n_cols) = 0;
access::rw(n_elem_slice) = 0;
access::rw(n_slices) = 0;
}
else
{
create_mat();
}
} }
//! internal cube construction; if the requested size is small enough, memo ry from the stack is used. //! internal cube construction; if the requested size is small enough, memo ry from the stack is used.
//! otherwise memory is allocated via 'new' //! otherwise memory is allocated via 'new'
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::init(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces) Cube<eT>::init_warm(const uword in_n_rows, const uword in_n_cols, const uwo rd in_n_slices)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d, in_n_slices = %d") % in_n_rows % in_n_cols % in_n_slices ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d, in_n_slices = %d") % in_n_rows % in_n_cols % in_n_slices );
const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) & if( (n_rows == in_n_rows) && (n_cols == in_n_cols) && (n_slices == in_n_s
& (n_slices == in_n_slices) ); lices) )
if(same_size == false)
{ {
const u32 t_mem_state = mem_state; return;
}
bool err_state = false; const uword t_mem_state = mem_state;
char* err_msg = 0;
arma_debug_set_error bool err_state = false;
( char* err_msg = 0;
err_state,
err_msg,
(t_mem_state == 3),
"Cube::init(): size is fixed and hence cannot be changed"
);
arma_debug_set_error arma_debug_set_error
(
err_state,
err_msg,
(t_mem_state == 3),
"Cube::init(): size is fixed and hence cannot be changed"
);
arma_debug_set_error
(
err_state,
err_msg,
( (
err_state, ( (in_n_rows > 0x0FFF) || (in_n_cols > 0x0FFF) || (in_n_slices > 0xFF
err_msg, ) )
(double(in_n_rows) * double(in_n_cols) * double(in_n_slices)) > doubl ? ( (float(in_n_rows) * float(in_n_cols) * float(in_n_slices)) > fl
e(0xFFFFFFFF), oat(ARMA_MAX_UWORD) )
"Cube::init(): requested size is too large" : false
); ),
"Cube::init(): requested size is too large"
);
arma_debug_check(err_state, err_msg); arma_debug_check(err_state, err_msg);
const u32 old_n_elem = n_elem; const uword old_n_elem = n_elem;
const u32 new_n_elem = in_n_rows * in_n_cols * in_n_slices; const uword new_n_elem = in_n_rows * in_n_cols * in_n_slices;
if(old_n_elem == new_n_elem) if(old_n_elem == new_n_elem)
{ {
if(same_size == false) delete_mat();
{
delete_mat();
if(new_n_elem > 0) if(new_n_elem > 0)
{ {
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols; access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices; access::rw(n_slices) = in_n_slices;
create_mat(); create_mat();
}
}
} }
else }
{ else
arma_debug_check( (t_mem_state == 2), "Cube::init(): requested size i {
s not compatible with the size of auxiliary memory" ); arma_debug_check( (t_mem_state == 2), "Cube::init(): requested size is
not compatible with the size of auxiliary memory" );
delete_mat(); delete_mat();
if(t_mem_state == 0) if(t_mem_state == 0)
{
if(n_elem > Cube_prealloc::mem_n_elem )
{ {
if(n_elem > Cube_prealloc::mem_n_elem ) arma_extra_debug_print("Cube::init(): freeing memory");
{
arma_extra_debug_print("Cube::init(): freeing memory");
#if defined(ARMA_USE_TBB_ALLOC)
scalable_free((void *)(mem));
#else
delete [] mem; delete [] mem;
} #endif
} }
}
access::rw(mem_state) = 0; access::rw(mem_state) = 0;
if(new_n_elem <= Cube_prealloc::mem_n_elem) if(new_n_elem <= Cube_prealloc::mem_n_elem)
{ {
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
else else
{ {
arma_extra_debug_print("Cube::init(): allocating memory"); arma_extra_debug_print("Cube::init(): allocating memory");
#if defined(ARMA_USE_TBB_ALLOC)
access::rw(mem) = (eT *)scalable_malloc(sizeof(eT)*new_n_elem);
#else
access::rw(mem) = new(std::nothrow) eT[new_n_elem]; access::rw(mem) = new(std::nothrow) eT[new_n_elem];
#endif
arma_check_bad_alloc( (mem == 0), "Cube::init(): out of memory" ); arma_check_bad_alloc( (mem == 0), "Cube::init(): out of memory" );
}
if(new_n_elem > 0)
{
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices;
access::rw(n_elem) = new_n_elem;
create_mat();
}
} }
if(new_n_elem == 0) if(new_n_elem > 0)
{ {
access::rw(n_rows) = 0; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = 0; access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = 0; access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = 0; access::rw(n_slices) = in_n_slices;
access::rw(n_elem) = 0; access::rw(n_elem) = new_n_elem;
create_mat();
} }
} }
if(new_n_elem == 0)
{
access::rw(n_rows) = 0;
access::rw(n_cols) = 0;
access::rw(n_elem_slice) = 0;
access::rw(n_slices) = 0;
access::rw(n_elem) = 0;
}
} }
//! 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
void void
Cube<eT>::init Cube<eT>::init
( (
const BaseCube<typename Cube<eT>::pod_type,T1>& A, const BaseCube<typename Cube<eT>::pod_type,T1>& A,
const BaseCube<typename Cube<eT>::pod_type,T2>& B const BaseCube<typename Cube<eT>::pod_type,T2>& B
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type T; typedef typename T1::elem_type T;
typedef typename ProxyCube<T1>::ea_type ea_type1; typedef typename ProxyCube<T1>::ea_type ea_type1;
typedef typename ProxyCube<T2>::ea_type ea_type2; typedef typename ProxyCube<T2>::ea_type ea_type2;
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil arma_type_check(( is_complex<eT>::value == false )); //!< compile-time
e-time abort if eT isn't std::complex abort if eT isn't std::complex
arma_type_check< is_complex< T>::value == true >::apply(); //!< compil arma_type_check(( is_complex< T>::value == true )); //!< compile-time
e-time abort if T is std::complex abort if T is std::complex
arma_type_check< is_same_type< std::complex<T>, eT >::value == false >::a pply(); //!< 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> X(A.get_ref()); const ProxyCube<T1> X(A.get_ref());
const ProxyCube<T2> Y(B.get_ref()); const ProxyCube<T2> Y(B.get_ref());
arma_assert_same_size(X, Y, "Cube()"); arma_assert_same_size(X, Y, "Cube()");
init(X.get_n_rows(), X.get_n_cols(), X.get_n_slices()); init_warm(X.get_n_rows(), X.get_n_cols(), X.get_n_slices());
const u32 N = n_elem; const uword N = n_elem;
eT* out_mem = memptr(); eT* out_mem = memptr();
ea_type1 PX = X.get_ea(); ea_type1 PX = X.get_ea();
ea_type2 PY = Y.get_ea(); ea_type2 PY = Y.get_ea();
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out_mem[i] = std::complex<T>(PX[i], PY[i]); out_mem[i] = std::complex<T>(PX[i], PY[i]);
} }
} }
//! try to steal the memory from a given cube; //! try to steal the memory from a given cube;
//! if memory can't be stolen, copy the given cube //! if memory can't be stolen, copy the given cube
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::steal_mem(Cube<eT>& x) Cube<eT>::steal_mem(Cube<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
if( (x.mem_state == 0) && (x.n_elem > Cube_prealloc::mem_n_elem) ) if( (x.mem_state == 0) && (x.n_elem > Cube_prealloc::mem_n_elem) )
{ {
reset(); reset();
const u32 x_n_slices = x.n_slices; const uword x_n_slices = x.n_slices;
access::rw(n_rows) = x.n_rows; access::rw(n_rows) = x.n_rows;
access::rw(n_cols) = x.n_cols; access::rw(n_cols) = x.n_cols;
access::rw(n_elem_slice) = x.n_elem_slice; access::rw(n_elem_slice) = x.n_elem_slice;
access::rw(n_slices) = x_n_slices; access::rw(n_slices) = x_n_slices;
access::rw(n_elem) = x.n_elem; access::rw(n_elem) = x.n_elem;
access::rw(mem) = x.mem; access::rw(mem) = x.mem;
if(x_n_slices > Cube_prealloc::mat_ptrs_size) if(x_n_slices > Cube_prealloc::mat_ptrs_size)
{ {
access::rw( mat_ptrs) = x.mat_ptrs; access::rw( mat_ptrs) = x.mat_ptrs;
access::rw(x.mat_ptrs) = 0; access::rw(x.mat_ptrs) = 0;
} }
else else
{ {
access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local ); access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local );
for(u32 i=0; i < x_n_slices; ++i) for(uword i=0; i < x_n_slices; ++i)
{ {
mat_ptrs[i] = x.mat_ptrs[i]; mat_ptrs[i] = x.mat_ptrs[i];
x.mat_ptrs[i] = 0; x.mat_ptrs[i] = 0;
} }
} }
access::rw(x.n_rows) = 0; access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0; access::rw(x.n_cols) = 0;
access::rw(x.n_elem_slice) = 0; access::rw(x.n_elem_slice) = 0;
access::rw(x.n_slices) = 0; access::rw(x.n_slices) = 0;
access::rw(x.n_elem) = 0; access::rw(x.n_elem) = 0;
access::rw(x.mem) = 0; access::rw(x.mem) = 0;
} }
else else
{ {
init(x); (*this).operator=(x);
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::delete_mat() Cube<eT>::delete_mat()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) for(uword slice = 0; slice < n_slices; ++slice)
{ {
delete access::rw(mat_ptrs[slice]); delete access::rw(mat_ptrs[slice]);
} }
if(mem_state <= 2) if(mem_state <= 2)
{ {
if(n_slices > Cube_prealloc::mat_ptrs_size) if(n_slices > Cube_prealloc::mat_ptrs_size)
{ {
delete [] mat_ptrs; delete [] mat_ptrs;
} }
skipping to change at line 326 skipping to change at line 385
access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local); access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local);
} }
else else
{ {
access::rw(mat_ptrs) = new(std::nothrow) const Mat<eT>*[n_slices]; access::rw(mat_ptrs) = new(std::nothrow) const Mat<eT>*[n_slices];
arma_check_bad_alloc( (mat_ptrs == 0), "Cube::create_mat(): out of me mory" ); arma_check_bad_alloc( (mat_ptrs == 0), "Cube::create_mat(): out of me mory" );
} }
} }
for(u32 slice = 0; slice < n_slices; ++slice) for(uword slice = 0; slice < n_slices; ++slice)
{ {
mat_ptrs[slice] = new Mat<eT>('j', slice_memptr(slice), n_rows, n_cols) ; mat_ptrs[slice] = new Mat<eT>('j', slice_memptr(slice), n_rows, n_cols) ;
} }
} }
//! Set the cube to be equal to the specified scalar. //! Set the cube to be equal to the specified scalar.
//! NOTE: the size of the cube will be 1x1x1 //! NOTE: the size of the cube will be 1x1x1
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const eT val) Cube<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(1,1,1); init_warm(1,1,1);
access::rw(mem[0]) = val; access::rw(mem[0]) = val;
return *this; return *this;
} }
//! In-place addition of a scalar to all elements of the cube //! In-place addition of a scalar to all elements of the cube
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const eT val) Cube<eT>::operator+=(const eT val)
{ {
skipping to change at line 401 skipping to change at line 460
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_div( memptr(), val, n_elem ); arrayops::inplace_div( memptr(), val, n_elem );
return *this; return *this;
} }
//! construct a cube from a given cube //! construct a cube from a given cube
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const Cube<eT>& in_cube) Cube<eT>::Cube(const Cube<eT>& x)
: n_rows(0) : n_rows(x.n_rows)
, n_cols(0) , n_cols(x.n_cols)
, n_elem_slice(0) , n_elem_slice(x.n_elem_slice)
, n_slices(0) , n_slices(x.n_slices)
, n_elem(0) , n_elem(x.n_elem)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint(arma_boost::format("this = %x in_cube = %x") arma_extra_debug_sigprint_this(this);
% this % &in_cube); arma_extra_debug_sigprint(arma_boost::format("this = %x in_cube = %x")
% this % &x);
init_cold();
init(in_cube); arrayops::copy( memptr(), x.mem, n_elem );
} }
//! construct a cube from a given cube //! construct a cube from a given cube
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const Cube<eT>& x) Cube<eT>::operator=(const Cube<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint(arma_boost::format("this = %x in_cube = %x")
% this % &x);
init(x);
return *this;
}
//! construct a cube from a given cube
template<typename eT>
inline
void
Cube<eT>::init(const Cube<eT>& x)
{
arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
init(x.n_rows, x.n_cols, x.n_slices); init_warm(x.n_rows, x.n_cols, x.n_slices);
arrayops::copy( memptr(), x.mem, n_elem ); arrayops::copy( memptr(), x.mem, n_elem );
} }
return *this;
} }
//! construct a cube from a given auxiliary array of eTs. //! construct a cube from a given auxiliary array of eTs.
//! if copy_aux_mem is true, new memory is allocated and the array is copie d. //! if copy_aux_mem is true, new memory is allocated and the array is copie d.
//! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying). //! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying).
//! note that in the latter case //! note that in the latter case
//! the default is to copy the array. //! the default is to copy the array.
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, con Cube<eT>::Cube(eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols,
st u32 aux_n_slices, const bool copy_aux_mem, const bool strict) const uword aux_n_slices, const bool copy_aux_mem, const bool strict)
: n_rows (copy_aux_mem ? 0 : aux_n_rows ) : n_rows ( aux_n_rows )
, n_cols (copy_aux_mem ? 0 : aux_n_cols ) , n_cols ( aux_n_cols )
, n_elem_slice(copy_aux_mem ? 0 : aux_n_rows*aux_n_cols ) , n_elem_slice( aux_n_rows*aux_n_cols )
, n_slices (copy_aux_mem ? 0 : aux_n_slices ) , n_slices ( aux_n_slices )
, n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols*aux_n_slices) , n_elem ( aux_n_rows*aux_n_cols*aux_n_slices )
, mem_state (copy_aux_mem ? 0 : (strict ? 2 : 1) ) , mem_state ( copy_aux_mem ? 0 : (strict ? 2 : 1) )
, mat_ptrs (mat_ptrs ) , mat_ptrs ( 0 )
, mem (copy_aux_mem ? mem : aux_mem ) , mem ( copy_aux_mem ? 0 : aux_mem )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(copy_aux_mem == true) if(copy_aux_mem == true)
{ {
init(aux_n_rows, aux_n_cols, aux_n_slices); init_cold();
arrayops::copy( memptr(), aux_mem, n_elem ); arrayops::copy( memptr(), aux_mem, n_elem );
} }
else else
{ {
create_mat(); create_mat();
} }
} }
//! construct a cube from a given auxiliary read-only array of eTs. //! construct a cube from a given auxiliary read-only array of eTs.
//! the array is copied. //! the array is copied.
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_col Cube<eT>::Cube(const eT* aux_mem, const uword aux_n_rows, const uword aux_n
s, const u32 aux_n_slices) _cols, const uword aux_n_slices)
: n_rows(0) : n_rows(aux_n_rows)
, n_cols(0) , n_cols(aux_n_cols)
, n_elem_slice(0) , n_elem_slice(aux_n_rows*aux_n_cols)
, n_slices(0) , n_slices(aux_n_slices)
, n_elem(0) , n_elem(aux_n_rows*aux_n_cols*aux_n_slices)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(aux_n_rows, aux_n_cols, aux_n_slices); init_cold();
arrayops::copy( memptr(), aux_mem, n_elem ); arrayops::copy( memptr(), aux_mem, n_elem );
} }
//! 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();
skipping to change at line 570 skipping to change at line 624
( (
const BaseCube<typename Cube<eT>::pod_type,T1>& A, const BaseCube<typename Cube<eT>::pod_type,T1>& A,
const BaseCube<typename Cube<eT>::pod_type,T2>& B const BaseCube<typename Cube<eT>::pod_type,T2>& B
) )
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(A,B); init(A,B);
} }
//! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation) //! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation)
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const subview_cube<eT>& X) Cube<eT>::Cube(const subview_cube<eT>& X)
: n_rows(0) : n_rows(X.n_rows)
, n_cols(0) , n_cols(X.n_cols)
, n_elem_slice(0) , n_elem_slice(X.n_elem_slice)
, n_slices(0) , n_slices(X.n_slices)
, n_elem(0) , n_elem(X.n_elem)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); init_cold();
subview_cube<eT>::extract(*this, X);
} }
//! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation) //! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const subview_cube<eT>& X) Cube<eT>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::extract(*this, X); const bool alias = (this == &(X.m));
if(alias == false)
{
init_warm(X.n_rows, X.n_cols, X.n_slices);
subview_cube<eT>::extract(*this, X);
}
else
{
Cube<eT> tmp(X);
steal_mem(tmp);
}
return *this; return *this;
} }
//! in-place cube addition (using a subcube on the right-hand-side) //! in-place cube addition (using a subcube on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const subview_cube<eT>& X) Cube<eT>::operator+=(const subview_cube<eT>& X)
{ {
skipping to change at line 665 skipping to change at line 734
subview_cube<eT>::div_inplace(*this, X); subview_cube<eT>::div_inplace(*this, X);
return *this; return *this;
} }
//! provide the reference to the matrix representing a single slice //! provide the reference to the matrix representing a single slice
template<typename eT> template<typename eT>
arma_inline arma_inline
Mat<eT>& Mat<eT>&
Cube<eT>::slice(const u32 in_slice) Cube<eT>::slice(const uword in_slice)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_slice >= n_slices), (in_slice >= n_slices),
"Cube::slice(): index out of bounds" "Cube::slice(): index out of bounds"
); );
return const_cast< Mat<eT>& >( *(mat_ptrs[in_slice]) ); return const_cast< Mat<eT>& >( *(mat_ptrs[in_slice]) );
} }
//! provide the reference to the matrix representing a single slice //! provide the reference to the matrix representing a single slice
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Cube<eT>::slice(const u32 in_slice) const Cube<eT>::slice(const uword in_slice) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_slice >= n_slices), (in_slice >= n_slices),
"Cube::slice(): index out of bounds" "Cube::slice(): index out of bounds"
); );
return *(mat_ptrs[in_slice]); return *(mat_ptrs[in_slice]);
} }
//! creation of subview_cube (subcube comprised of specified slices) //! creation of subview_cube (subcube comprised of specified slices)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_cube<eT> subview_cube<eT>
Cube<eT>::slices(const u32 in_slice1, const u32 in_slice2) Cube<eT>::slices(const uword in_slice1, const uword in_slice2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_slice1 > in_slice2) || (in_slice2 >= n_slices), (in_slice1 > in_slice2) || (in_slice2 >= n_slices),
"Cube::slices(): indices out of bounds or incorrectly used" "Cube::slices(): indices out of bounds or incorrectly used"
); );
const u32 subcube_n_slices = in_slice2 - in_slice1 + 1; const uword subcube_n_slices = in_slice2 - in_slice1 + 1;
return subview_cube<eT>(*this, 0, 0, in_slice1, n_rows, n_cols, subcube_n _slices); return subview_cube<eT>(*this, 0, 0, in_slice1, n_rows, n_cols, subcube_n _slices);
} }
//! creation of subview_cube (subcube comprised of specified slices) //! creation of subview_cube (subcube comprised of specified slices)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_cube<eT> const subview_cube<eT>
Cube<eT>::slices(const u32 in_slice1, const u32 in_slice2) const Cube<eT>::slices(const uword in_slice1, const uword in_slice2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_slice1 > in_slice2) || (in_slice2 >= n_slices), (in_slice1 > in_slice2) || (in_slice2 >= n_slices),
"Cube::rows(): indices out of bounds or incorrectly used" "Cube::rows(): indices out of bounds or incorrectly used"
); );
const u32 subcube_n_slices = in_slice2 - in_slice1 + 1; const uword subcube_n_slices = in_slice2 - in_slice1 + 1;
return subview_cube<eT>(*this, 0, 0, in_slice1, n_rows, n_cols, subcube_n _slices); return subview_cube<eT>(*this, 0, 0, in_slice1, n_rows, n_cols, subcube_n _slices);
} }
//! creation of subview_cube (generic subcube) //! creation of subview_cube (generic subcube)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_cube<eT> subview_cube<eT>
Cube<eT>::subcube(const u32 in_row1, const u32 in_col1, const u32 in_slice1 , const u32 in_row2, const u32 in_col2, const u32 in_slice2) Cube<eT>::subcube(const uword in_row1, const uword in_col1, const uword in_ slice1, const uword in_row2, const uword in_col2, const uword in_slice2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_slice1 > in_slice2 ) || (in_row1 > in_row2) || (in_col1 > in_col2) || (in_slice1 > in_slice2 ) ||
(in_row2 >= n_rows) || (in_col2 >= n_cols) || (in_slice2 >= n_slices) , (in_row2 >= n_rows) || (in_col2 >= n_cols) || (in_slice2 >= n_slices) ,
"Cube::subcube(): indices out of bounds or incorrectly used" "Cube::subcube(): indices out of bounds or incorrectly used"
); );
const u32 subcube_n_rows = in_row2 - in_row1 + 1; const uword subcube_n_rows = in_row2 - in_row1 + 1;
const u32 subcube_n_cols = in_col2 - in_col1 + 1; const uword subcube_n_cols = in_col2 - in_col1 + 1;
const u32 subcube_n_slices = in_slice2 - in_slice1 + 1; const uword subcube_n_slices = in_slice2 - in_slice1 + 1;
return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_row s, subcube_n_cols, subcube_n_slices); return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_row s, subcube_n_cols, subcube_n_slices);
} }
//! creation of subview_cube (generic subcube) //! creation of subview_cube (generic subcube)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_cube<eT> const subview_cube<eT>
Cube<eT>::subcube(const u32 in_row1, const u32 in_col1, const u32 in_slice1 , const u32 in_row2, const u32 in_col2, const u32 in_slice2) const Cube<eT>::subcube(const uword in_row1, const uword in_col1, const uword in_ slice1, const uword in_row2, const uword in_col2, const uword in_slice2) co nst
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_slice1 > in_slice2 ) || (in_row1 > in_row2) || (in_col1 > in_col2) || (in_slice1 > in_slice2 ) ||
(in_row2 >= n_rows) || (in_col2 >= n_cols) || (in_slice2 >= n_slices) , (in_row2 >= n_rows) || (in_col2 >= n_cols) || (in_slice2 >= n_slices) ,
"Cube::subcube(): indices out of bounds or incorrectly used" "Cube::subcube(): indices out of bounds or incorrectly used"
); );
const u32 subcube_n_rows = in_row2 - in_row1 + 1; const uword subcube_n_rows = in_row2 - in_row1 + 1;
const u32 subcube_n_cols = in_col2 - in_col1 + 1; const uword subcube_n_cols = in_col2 - in_col1 + 1;
const u32 subcube_n_slices = in_slice2 - in_slice1 + 1; const uword subcube_n_slices = in_slice2 - in_slice1 + 1;
return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_row s, subcube_n_cols, subcube_n_slices); return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_row s, subcube_n_cols, subcube_n_slices);
} }
//! creation of subview_cube (generic subcube) //! creation of subview_cube (generic subcube)
template<typename eT> template<typename eT>
inline inline
subview_cube<eT> subview_cube<eT>
Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s lice_span) Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s lice_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const bool slice_all = slice_span.whole; const bool slice_all = slice_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 subcube_n_rows = row_all ? local_n_rows : in_row2 - in_ro const uword subcube_n_rows = row_all ? local_n_rows : in_row2 - in_
w1 + 1; row1 + 1;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 subcube_n_cols = col_all ? local_n_cols : in_col2 - in_co const uword subcube_n_cols = col_all ? local_n_cols : in_col2 - in_
l1 + 1; col1 + 1;
const u32 in_slice1 = slice_all ? 0 : slice_span.a; const uword in_slice1 = slice_all ? 0 : slice_span.a;
const u32 in_slice2 = slice_span.b; const uword in_slice2 = slice_span.b;
const u32 subcube_n_slices = slice_all ? local_n_slices : in_slice2 - in_ const uword subcube_n_slices = slice_all ? local_n_slices : in_slice2 - i
slice1 + 1; n_slice1 + 1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_ n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_ n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_ n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_ n_cols)) )
|| ||
( slice_all ? false : ((in_slice1 > in_slice2) || (in_slice2 >= local_ n_slices)) ) ( slice_all ? false : ((in_slice1 > in_slice2) || (in_slice2 >= local_ n_slices)) )
, ,
"Cube::subcube(): indices out of bounds or incorrectly used" "Cube::subcube(): indices out of bounds or incorrectly used"
skipping to change at line 831 skipping to change at line 900
inline inline
const subview_cube<eT> const subview_cube<eT>
Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s lice_span) const Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s lice_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const bool slice_all = slice_span.whole; const bool slice_all = slice_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 subcube_n_rows = row_all ? local_n_rows : in_row2 - in_ro const uword subcube_n_rows = row_all ? local_n_rows : in_row2 - in_
w1 + 1; row1 + 1;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 subcube_n_cols = col_all ? local_n_cols : in_col2 - in_co const uword subcube_n_cols = col_all ? local_n_cols : in_col2 - in_
l1 + 1; col1 + 1;
const u32 in_slice1 = slice_all ? 0 : slice_span.a; const uword in_slice1 = slice_all ? 0 : slice_span.a;
const u32 in_slice2 = slice_span.b; const uword in_slice2 = slice_span.b;
const u32 subcube_n_slices = slice_all ? local_n_slices : in_slice2 - in_ const uword subcube_n_slices = slice_all ? local_n_slices : in_slice2 - i
slice1 + 1; n_slice1 + 1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_ n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_ n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_ n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_ n_cols)) )
|| ||
( slice_all ? false : ((in_slice1 > in_slice2) || (in_slice2 >= local_ n_slices)) ) ( slice_all ? false : ((in_slice1 > in_slice2) || (in_slice2 >= local_ n_slices)) )
, ,
"Cube::subcube(): indices out of bounds or incorrectly used" "Cube::subcube(): indices out of bounds or incorrectly used"
skipping to change at line 885 skipping to change at line 954
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).subcube(row_span, col_span, slice_span); return (*this).subcube(row_span, col_span, slice_span);
} }
//! remove specified slice //! remove specified slice
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::shed_slice(const u32 slice_num) Cube<eT>::shed_slice(const uword slice_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( slice_num >= n_slices, "Cube::shed_slice(): out of boun ds"); arma_debug_check( slice_num >= n_slices, "Cube::shed_slice(): out of boun ds");
shed_slices(slice_num, slice_num); shed_slices(slice_num, slice_num);
} }
//! remove specified slices //! remove specified slices
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::shed_slices(const u32 in_slice1, const u32 in_slice2) Cube<eT>::shed_slices(const uword in_slice1, const uword in_slice2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_slice1 > in_slice2) || (in_slice2 >= n_slices), (in_slice1 > in_slice2) || (in_slice2 >= n_slices),
"Cube::shed_slices(): indices out of bounds or incorrectly used" "Cube::shed_slices(): indices out of bounds or incorrectly used"
); );
const u32 n_keep_front = in_slice1; const uword n_keep_front = in_slice1;
const u32 n_keep_back = n_slices - (in_slice2 + 1); const uword n_keep_back = n_slices - (in_slice2 + 1);
Cube<eT> X(n_rows, n_cols, n_keep_front + n_keep_back); Cube<eT> X(n_rows, n_cols, n_keep_front + n_keep_back);
if(n_keep_front > 0) if(n_keep_front > 0)
{ {
X.slices( 0, (n_keep_front-1) ) = slices( 0, (in_slice1-1) ); X.slices( 0, (n_keep_front-1) ) = slices( 0, (in_slice1-1) );
} }
if(n_keep_back > 0) if(n_keep_back > 0)
{ {
skipping to change at line 931 skipping to change at line 1000
} }
steal_mem(X); steal_mem(X);
} }
//! insert N slices at the specified slice position, //! insert N slices at the specified slice position,
//! optionally setting the elements of the inserted slices to zero //! optionally setting the elements of the inserted slices to zero
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::insert_slices(const u32 slice_num, const u32 N, const bool set_to _zero) Cube<eT>::insert_slices(const uword slice_num, const uword N, const bool se t_to_zero)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 t_n_slices = n_slices; const uword t_n_slices = n_slices;
const u32 A_n_slices = slice_num; const uword A_n_slices = slice_num;
const u32 B_n_slices = t_n_slices - slice_num; const uword B_n_slices = t_n_slices - slice_num;
// insertion at slice_num == n_slices is in effect an append operation // insertion at slice_num == n_slices is in effect an append operation
arma_debug_check( (slice_num > t_n_slices), "Cube::insert_slices(): out o f bounds"); arma_debug_check( (slice_num > t_n_slices), "Cube::insert_slices(): out o f bounds");
if(N > 0) if(N > 0)
{ {
Cube<eT> out(n_rows, n_cols, t_n_slices + N); Cube<eT> out(n_rows, n_cols, t_n_slices + N);
if(A_n_slices > 0) if(A_n_slices > 0)
{ {
skipping to change at line 961 skipping to change at line 1030
if(B_n_slices > 0) if(B_n_slices > 0)
{ {
out.slices(slice_num + N, t_n_slices + N - 1) = slices(slice_num, t_n _slices-1); out.slices(slice_num + N, t_n_slices + N - 1) = slices(slice_num, t_n _slices-1);
} }
if(set_to_zero == true) if(set_to_zero == true)
{ {
//out.slices(slice_num, slice_num + N - 1).zeros(); //out.slices(slice_num, slice_num + N - 1).zeros();
for(u32 i=slice_num; i < (slice_num + N); ++i) for(uword i=slice_num; i < (slice_num + N); ++i)
{ {
out.slice(i).zeros(); out.slice(i).zeros();
} }
} }
steal_mem(out); steal_mem(out);
} }
} }
//! insert the given object at the specified slice position; //! insert the given object at the specified slice position;
//! the given object must have the same number of rows and columns as the c ube //! the given object must have the same number of rows and columns as the c ube
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Cube<eT>::insert_slices(const u32 slice_num, const BaseCube<eT,T1>& X) Cube<eT>::insert_slices(const uword slice_num, const BaseCube<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& C = tmp.M; const Cube<eT>& C = tmp.M;
const u32 N = C.n_slices; const uword N = C.n_slices;
const u32 t_n_slices = n_slices; const uword t_n_slices = n_slices;
const u32 A_n_slices = slice_num; const uword A_n_slices = slice_num;
const u32 B_n_slices = t_n_slices - slice_num; const uword B_n_slices = t_n_slices - slice_num;
// insertion at row_num == n_rows is in effect an append operation // insertion at slice_num == n_slices is in effect an append operation
arma_debug_check( (slice_num > t_n_slices), "Cube::insert_rows(): out o arma_debug_check( (slice_num > t_n_slices), "Cube::insert_slices(): out
f bounds"); of bounds");
arma_debug_check arma_debug_check
( (
( (C.n_rows != n_rows) || (C.n_cols != n_cols) ), ( (C.n_rows != n_rows) || (C.n_cols != n_cols) ),
"Cube::insert_slices(): given object has an incompatible dimensions" "Cube::insert_slices(): given object has an incompatible dimensions"
); );
if(N > 0) if(N > 0)
{ {
Cube<eT> out(n_rows, n_cols, t_n_slices + N); Cube<eT> out(n_rows, n_cols, t_n_slices + N);
skipping to change at line 1022 skipping to change at line 1091
} }
out.slices(slice_num, slice_num + N - 1) = C; out.slices(slice_num, slice_num + N - 1) = C;
steal_mem(out); steal_mem(out);
} }
} }
//! create a cube from OpCube, i.e. run the previously delayed unary operat ions //! create a cube from OpCube, i.e. run the previously delayed unary operat ions
template<typename eT> template<typename eT>
template<typename gen_type>
inline
Cube<eT>::Cube(const GenCube<eT, gen_type>& X)
: n_rows(X.n_rows)
, n_cols(X.n_cols)
, n_elem_slice(X.n_rows*X.n_cols)
, n_slices(X.n_slices)
, n_elem(X.n_rows*X.n_cols*X.n_slices)
, mem_state(0)
, mat_ptrs()
, mem()
{
arma_extra_debug_sigprint_this(this);
init_cold();
X.apply(*this);
}
template<typename eT>
template<typename gen_type>
inline
const Cube<eT>&
Cube<eT>::operator=(const GenCube<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
init_warm(X.n_rows, X.n_cols, X.n_slices);
X.apply(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Cube<eT>&
Cube<eT>::operator+=(const GenCube<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_plus(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Cube<eT>&
Cube<eT>::operator-=(const GenCube<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_minus(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Cube<eT>&
Cube<eT>::operator%=(const GenCube<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_schur(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Cube<eT>&
Cube<eT>::operator/=(const GenCube<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_div(*this);
return *this;
}
//! create a cube from OpCube, i.e. run the previously delayed unary operat
ions
template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Cube<eT>::Cube(const OpCube<T1, op_type>& X) Cube<eT>::Cube(const OpCube<T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! create a cube from OpCube, i.e. run the previously delayed unary operat ions //! create a cube from OpCube, i.e. run the previously delayed unary operat ions
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const OpCube<T1, op_type>& X) Cube<eT>::operator=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
op_type::apply(*this, X); op_type::apply(*this, X);
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operand having delayed operations //! in-place cube addition, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const OpCube<T1, op_type>& X) Cube<eT>::operator+=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place cube subtraction, with the right-hand-side operand having dela yed operations //! in-place cube subtraction, with the right-hand-side operand having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const OpCube<T1, op_type>& X) Cube<eT>::operator-=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const OpCube<T1, op_type>& X) Cube<eT>::operator%=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations //! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const OpCube<T1, op_type>& X) Cube<eT>::operator/=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! create a cube from eOpCube, i.e. run the previously delayed unary opera tions //! create a cube from eOpCube, i.e. run the previously delayed unary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
Cube<eT>::Cube(const eOpCube<T1, eop_type>& X) Cube<eT>::Cube(const eOpCube<T1, eop_type>& X)
: n_rows(0) : n_rows(X.get_n_rows())
, n_cols(0) , n_cols(X.get_n_cols())
, n_elem_slice(0) , n_elem_slice(X.get_n_elem_slice())
, n_slices(0) , n_slices(X.get_n_slices())
, n_elem(0) , n_elem(X.get_n_elem())
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
init_cold();
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
//! create a cube from eOpCube, i.e. run the previously delayed unary opera tions //! create a cube from eOpCube, i.e. run the previously delayed unary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply(*this, X); const bool bad_alias = ( X.P.has_subview && X.P.is_alias(*this) );
if(bad_alias == false)
{
init_warm(X.get_n_rows(), X.get_n_cols(), X.get_n_slices());
eop_type::apply(*this, X);
}
else
{
Cube<eT> tmp(X);
steal_mem(tmp);
}
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operand having delayed operations //! in-place cube addition, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator+=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_plus(*this, X); eop_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
//! in-place cube subtraction, with the right-hand-side operand having dela yed operations //! in-place cube subtraction, with the right-hand-side operand having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator-=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_minus(*this, X); eop_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator%=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_schur(*this, X); eop_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations //! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator/=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_div(*this, X); eop_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Cube<eT>::Cube(const mtOpCube<eT, T1, op_type>& X) Cube<eT>::Cube(const mtOpCube<eT, T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
skipping to change at line 1322 skipping to change at line 1494
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Cube<eT>::Cube(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::Cube(const GlueCube<T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
glue_type::apply(*this, X); glue_type::apply(*this, X);
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operands having delaye d operations //! in-place cube addition, with the right-hand-side operands having delaye d operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator+=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place cube subtraction, with the right-hand-side operands having del ayed operations //! in-place cube subtraction, with the right-hand-side operands having del ayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator-=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator%=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place cube element-wise division, with the right-hand-side operands having delayed operations //! in-place cube element-wise division, with the right-hand-side operands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator/=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! create a cube from eGlue, i.e. run the previously delayed binary operat ions //! create a cube from eGlue, i.e. run the previously delayed binary operat ions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
Cube<eT>::Cube(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::Cube(const eGlueCube<T1, T2, eglue_type>& X)
: n_rows(0) : n_rows(X.get_n_rows())
, n_cols(0) , n_cols(X.get_n_cols())
, n_elem_slice(0) , n_elem_slice(X.get_n_elem_slice())
, n_slices(0) , n_slices(X.get_n_slices())
, n_elem(0) , n_elem(X.get_n_elem())
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X);
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
lse ));
init_cold();
eglue_type::apply(*this, X);
} }
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply(*this, X); const bool bad_alias = ( (X.P1.has_subview && X.P1.is_alias(*this)) ||
(X.P2.has_subview && X.P2.is_alias(*this)) );
if(bad_alias == false)
{
init_warm(X.get_n_rows(), X.get_n_cols(), X.get_n_slices());
eglue_type::apply(*this, X);
}
else
{
Cube<eT> tmp(X);
steal_mem(tmp);
}
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operands having delaye d operations //! in-place cube addition, with the right-hand-side operands having delaye d operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator+=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_plus(*this, X); eglue_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
//! in-place cube subtraction, with the right-hand-side operands having del ayed operations //! in-place cube subtraction, with the right-hand-side operands having del ayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator-=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_minus(*this, X); eglue_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator%=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_schur(*this, X); eglue_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise division, with the right-hand-side operands having delayed operations //! in-place cube element-wise division, with the right-hand-side operands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator/=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_div(*this, X); eglue_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Cube<eT>::Cube(const mtGlueCube<eT, T1, T2, glue_type>& X) Cube<eT>::Cube(const mtGlueCube<eT, T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs()
, mem(mem) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
glue_type::apply(*this, X); glue_type::apply(*this, X);
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
skipping to change at line 1611 skipping to change at line 1802
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! linear element accessor (treats the cube as a vector); bounds checking not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the cube as a vector); bounds checking not done when ARMA_NO_DEBUG is defined
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Cube<eT>::operator() (const u32 i) Cube<eT>::operator() (const uword i)
{ {
arma_debug_check( (i >= n_elem), "Cube::operator(): index out of bounds") ; arma_debug_check( (i >= n_elem), "Cube::operator(): index out of bounds") ;
return access::rw(mem[i]); return access::rw(mem[i]);
} }
//! linear element accessor (treats the cube as a vector); bounds checking not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the cube as a vector); bounds checking not done when ARMA_NO_DEBUG is defined
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Cube<eT>::operator() (const u32 i) const Cube<eT>::operator() (const uword i) const
{ {
arma_debug_check( (i >= n_elem), "Cube::operator(): index out of bounds") ; arma_debug_check( (i >= n_elem), "Cube::operator(): index out of bounds") ;
return mem[i]; return mem[i];
} }
//! linear element accessor (treats the cube as a vector); no bounds check. //! linear element accessor (treats the cube as a vector); no bounds check.
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Cube<eT>::operator[] (const u32 i) Cube<eT>::operator[] (const uword i)
{ {
return access::rw(mem[i]); return access::rw(mem[i]);
} }
//! linear element accessor (treats the cube as a vector); no bounds check //! linear element accessor (treats the cube as a vector); no bounds check
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Cube<eT>::operator[] (const u32 i) const Cube<eT>::operator[] (const uword i) const
{ {
return mem[i]; return mem[i];
} }
//! linear element accessor (treats the cube as a vector); no bounds check. //! linear element accessor (treats the cube as a vector); no bounds check.
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Cube<eT>::at(const u32 i) Cube<eT>::at(const uword i)
{ {
return access::rw(mem[i]); return access::rw(mem[i]);
} }
//! linear element accessor (treats the cube as a vector); no bounds check //! linear element accessor (treats the cube as a vector); no bounds check
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Cube<eT>::at(const u32 i) const Cube<eT>::at(const uword i) const
{ {
return mem[i]; return mem[i];
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Cube<eT>::operator() (const u32 in_row, const u32 in_col, const u32 in_slic e) Cube<eT>::operator() (const uword in_row, const uword in_col, const uword i n_slice)
{ {
arma_debug_check arma_debug_check
( (
(in_row >= n_rows) || (in_row >= n_rows) ||
(in_col >= n_cols) || (in_col >= n_cols) ||
(in_slice >= n_slices) (in_slice >= n_slices)
, ,
"Cube::operator(): index out of bounds" "Cube::operator(): index out of bounds"
); );
return access::rw(mem[in_slice*n_elem_slice + in_col*n_rows + in_row]); return access::rw(mem[in_slice*n_elem_slice + in_col*n_rows + in_row]);
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Cube<eT>::operator() (const u32 in_row, const u32 in_col, const u32 in_slic e) const Cube<eT>::operator() (const uword in_row, const uword in_col, const uword i n_slice) const
{ {
arma_debug_check arma_debug_check
( (
(in_row >= n_rows) || (in_row >= n_rows) ||
(in_col >= n_cols) || (in_col >= n_cols) ||
(in_slice >= n_slices) (in_slice >= n_slices)
, ,
"Cube::operator(): index out of bounds" "Cube::operator(): index out of bounds"
); );
return mem[in_slice*n_elem_slice + in_col*n_rows + in_row]; return mem[in_slice*n_elem_slice + in_col*n_rows + in_row];
} }
//! element accessor; no bounds check //! element accessor; no bounds check
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice) Cube<eT>::at(const uword in_row, const uword in_col, const uword in_slice)
{ {
return access::rw( mem[in_slice*n_elem_slice + in_col*n_rows + in_row] ); return access::rw( mem[in_slice*n_elem_slice + in_col*n_rows + in_row] );
} }
//! element accessor; no bounds check //! element accessor; no bounds check
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice) const Cube<eT>::at(const uword in_row, const uword in_col, const uword in_slice) const
{ {
return mem[in_slice*n_elem_slice + in_col*n_rows + in_row]; return mem[in_slice*n_elem_slice + in_col*n_rows + in_row];
} }
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator++() Cube<eT>::operator++()
{ {
skipping to change at line 1789 skipping to change at line 1980
Cube<eT>::is_empty() const Cube<eT>::is_empty() const
{ {
return (n_elem == 0); return (n_elem == 0);
} }
//! returns true if the given index is currently in range //! returns true if the given index is currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Cube<eT>::in_range(const u32 i) const Cube<eT>::in_range(const uword i) const
{ {
return (i < n_elem); return (i < n_elem);
} }
//! returns true if the given start and end indices are currently in range //! returns true if the given start and end indices are currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Cube<eT>::in_range(const span& x) const Cube<eT>::in_range(const span& x) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(x.whole == true) if(x.whole == true)
{ {
return true; return true;
} }
else else
{ {
const u32 a = x.a; const uword a = x.a;
const u32 b = x.b; const uword b = x.b;
return ( (a <= b) && (b < n_elem) ); return ( (a <= b) && (b < n_elem) );
} }
} }
//! returns true if the given location is currently in range //! returns true if the given location is currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Cube<eT>::in_range(const u32 in_row, const u32 in_col, const u32 in_slice) const Cube<eT>::in_range(const uword in_row, const uword in_col, const uword in_s lice) const
{ {
return ( (in_row < n_rows) && (in_col < n_cols) && (in_slice < n_slices) ); return ( (in_row < n_rows) && (in_col < n_cols) && (in_slice < n_slices) );
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
bool bool
Cube<eT>::in_range(const span& row_span, const span& col_span, const span& slice_span) const Cube<eT>::in_range(const span& row_span, const span& col_span, const span& slice_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a; const uword in_row1 = row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 in_col1 = col_span.a; const uword in_col1 = col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 in_slice1 = slice_span.a; const uword in_slice1 = slice_span.a;
const u32 in_slice2 = slice_span.b; const uword in_slice2 = slice_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (in_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (in_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (in_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (in_col2 < n_cols) );
const bool slices_ok = slice_span.whole ? true : ( (in_slice1 <= in_slice 2) && (in_slice2 < n_slices) ); const bool slices_ok = slice_span.whole ? true : ( (in_slice1 <= in_slice 2) && (in_slice2 < n_slices) );
return ( (rows_ok == true) && (cols_ok == true) && (slices_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) && (slices_ok == true) );
} }
//! returns a pointer to array of eTs used by the cube //! returns a pointer to array of eTs used by the cube
template<typename eT> template<typename eT>
skipping to change at line 1875 skipping to change at line 2066
Cube<eT>::memptr() const Cube<eT>::memptr() const
{ {
return mem; return mem;
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Cube<eT>::slice_memptr(const u32 slice) Cube<eT>::slice_memptr(const uword slice)
{ {
return const_cast<eT*>( &mem[ slice*n_elem_slice ] ); return const_cast<eT*>( &mem[ slice*n_elem_slice ] );
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const eT* const eT*
Cube<eT>::slice_memptr(const u32 slice) const Cube<eT>::slice_memptr(const uword slice) const
{ {
return &mem[ slice*n_elem_slice ]; return &mem[ slice*n_elem_slice ];
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Cube<eT>::slice_colptr(const u32 slice, const u32 col) Cube<eT>::slice_colptr(const uword slice, const uword col)
{ {
return const_cast<eT*>( &mem[ slice*n_elem_slice + col*n_rows] ); return const_cast<eT*>( &mem[ slice*n_elem_slice + col*n_rows] );
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const eT* const eT*
Cube<eT>::slice_colptr(const u32 slice, const u32 col) const Cube<eT>::slice_colptr(const uword slice, const uword col) const
{ {
return &mem[ slice*n_elem_slice + col*n_rows ]; return &mem[ slice*n_elem_slice + col*n_rows ];
} }
//! print contents of the cube (to the cout stream), //! print contents of the cube (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::print(const std::string extra_text) const Cube<eT>::impl_print(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
cout << extra_text << '\n'; cout << extra_text << '\n';
} }
arma_ostream::print(cout, *this, true); arma_ostream::print(cout, *this, true);
} }
//! print contents of the cube to a user specified stream, //! print contents of the cube to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::print(std::ostream& user_stream, const std::string extra_text) co nst Cube<eT>::impl_print(std::ostream& user_stream, const std::string& extra_te xt) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
} }
arma_ostream::print(user_stream, *this, true); arma_ostream::print(user_stream, *this, true);
} }
//! print contents of the cube (to the cout stream), //! print contents of the cube (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified //! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::raw_print(const std::string extra_text) const Cube<eT>::impl_raw_print(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
cout << extra_text << '\n'; cout << extra_text << '\n';
} }
arma_ostream::print(cout, *this, false); arma_ostream::print(cout, *this, false);
} }
//! print contents of the cube to a user specified stream, //! print contents of the cube to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified. //! the stream's state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::raw_print(std::ostream& user_stream, const std::string extra_text ) const Cube<eT>::impl_raw_print(std::ostream& user_stream, const std::string& extr a_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
} }
arma_ostream::print(user_stream, *this, false); arma_ostream::print(user_stream, *this, false);
} }
//! change the cube to have user specified dimensions (data is not preserve d) //! change the cube to have user specified dimensions (data is not preserve d)
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n _slices) Cube<eT>::set_size(const uword in_n_rows, const uword in_n_cols, const uwor d in_n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(in_n_rows, in_n_cols, in_n_slices); init_warm(in_n_rows, in_n_cols, in_n_slices);
} }
//! change the cube to have user specified dimensions (data is preserved) //! change the cube to have user specified dimensions (data is preserved)
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::reshape(const u32 in_rows, const u32 in_cols, const u32 in_slices , const u32 dim) Cube<eT>::reshape(const uword in_rows, const uword in_cols, const uword in_ slices, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
*this = arma::reshape(*this, in_rows, in_cols, in_slices, dim); *this = arma::reshape(*this, in_rows, in_cols, in_slices, dim);
} }
//! change the cube (without preserving data) to have the same dimensions a s the given cube //! change the cube (without preserving data) to have the same dimensions a s the given cube
template<typename eT> template<typename eT>
template<typename eT2> template<typename eT2>
inline inline
void void
Cube<eT>::copy_size(const Cube<eT2>& m) Cube<eT>::copy_size(const Cube<eT2>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(m.n_rows, m.n_cols, m.n_slices); init_warm(m.n_rows, m.n_cols, m.n_slices);
} }
//! fill the cube with the specified value //! fill the cube with the specified value
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::fill(const eT val) Cube<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2046 skipping to change at line 2237
Cube<eT>::zeros() Cube<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).fill(eT(0)); return (*this).fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::zeros(const u32 in_rows, const u32 in_cols, const u32 in_slices) Cube<eT>::zeros(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols, in_slices); set_size(in_rows, in_cols, in_slices);
return (*this).fill(eT(0)); return (*this).fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
skipping to change at line 2068 skipping to change at line 2259
Cube<eT>::ones() Cube<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).fill(eT(1)); return (*this).fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::ones(const u32 in_rows, const u32 in_cols, const u32 in_slices) Cube<eT>::ones(const uword in_rows, const uword in_cols, const uword in_sli ces)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols, in_slices); set_size(in_rows, in_cols, in_slices);
return (*this).fill(eT(1)); return (*this).fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randu() Cube<eT>::randu()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 N = n_elem; const uword N = n_elem;
eT* ptr = memptr(); eT* ptr = memptr();
u32 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)
{ {
ptr[i] = eT(eop_aux_randu<eT>()); ptr[i] = eT(eop_aux_randu<eT>());
ptr[j] = eT(eop_aux_randu<eT>()); ptr[j] = eT(eop_aux_randu<eT>());
} }
if(i < N) if(i < N)
{ {
ptr[i] = eT(eop_aux_randu<eT>()); ptr[i] = eT(eop_aux_randu<eT>());
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randu(const u32 in_rows, const u32 in_cols, const u32 in_slices) Cube<eT>::randu(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols, in_slices); set_size(in_rows, in_cols, in_slices);
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randn() Cube<eT>::randn()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 N = n_elem; const uword N = n_elem;
eT* ptr = memptr(); eT* ptr = memptr();
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
ptr[i] = eT(eop_aux_randn<eT>()); ptr[i] = eT(eop_aux_randn<eT>());
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randn(const u32 in_rows, const u32 in_cols, const u32 in_slices) Cube<eT>::randn(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols, in_slices); set_size(in_rows, in_cols, in_slices);
return (*this).randn(); return (*this).randn();
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::reset() Cube<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0,0); init_warm(0,0,0);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Cube<eT>::set_real(const BaseCube<typename Cube<eT>::pod_type,T1>& X) Cube<eT>::set_real(const BaseCube<typename Cube<eT>::pod_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2206 skipping to change at line 2397
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
return op_max::direct_max(memptr(), n_elem); return op_max::direct_max(memptr(), n_elem);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Cube<eT>::min(u32& index_of_min_val) const Cube<eT>::min(uword& index_of_min_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "min(): object has no elements" ); arma_debug_check( (n_elem == 0), "min(): object has no elements" );
return op_min::direct_min(memptr(), n_elem, index_of_min_val); return op_min::direct_min(memptr(), n_elem, index_of_min_val);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Cube<eT>::max(u32& index_of_max_val) const Cube<eT>::max(uword& index_of_max_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
return op_max::direct_max(memptr(), n_elem, index_of_max_val); return op_max::direct_max(memptr(), n_elem, index_of_max_val);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Cube<eT>::min(u32& row_of_min_val, u32& col_of_min_val, u32& slice_of_min_v al) const Cube<eT>::min(uword& row_of_min_val, uword& col_of_min_val, uword& slice_of _min_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "min(): object has no elements" ); arma_debug_check( (n_elem == 0), "min(): object has no elements" );
u32 i; uword i;
eT val = op_min::direct_min(memptr(), n_elem, i); eT val = op_min::direct_min(memptr(), n_elem, i);
const u32 in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const u32 j = i - offset; const uword j = i - offset;
row_of_min_val = j % n_rows; row_of_min_val = j % n_rows;
col_of_min_val = j / n_rows; col_of_min_val = j / n_rows;
slice_of_min_val = in_slice; slice_of_min_val = in_slice;
return val; return val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Cube<eT>::max(u32& row_of_max_val, u32& col_of_max_val, u32& slice_of_max_v al) const Cube<eT>::max(uword& row_of_max_val, uword& col_of_max_val, uword& slice_of _max_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
u32 i; uword i;
eT val = op_max::direct_max(memptr(), n_elem, i); eT val = op_max::direct_max(memptr(), n_elem, i);
const u32 in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const u32 j = i - offset; const uword j = i - offset;
row_of_max_val = j % n_rows; row_of_max_val = j % n_rows;
col_of_max_val = j / n_rows; col_of_max_val = j / n_rows;
slice_of_max_val = in_slice; slice_of_max_val = in_slice;
return val; return val;
} }
//! save the cube to a file //! save the cube to a file
template<typename eT> template<typename eT>
skipping to change at line 2570 skipping to change at line 2761
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>::slice_iterator typename Cube<eT>::slice_iterator
Cube<eT>::begin_slice(const u32 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);
} }
template<typename eT> template<typename eT>
inline inline
typename Cube<eT>::const_slice_iterator typename Cube<eT>::const_slice_iterator
Cube<eT>::begin_slice(const u32 slice_num) const Cube<eT>::begin_slice(const uword slice_num) const
{ {
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);
} }
template<typename eT> template<typename eT>
inline inline
typename Cube<eT>::slice_iterator typename Cube<eT>::slice_iterator
Cube<eT>::end_slice(const u32 slice_num) Cube<eT>::end_slice(const uword slice_num)
{ {
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<typename eT>
inline inline
typename Cube<eT>::const_slice_iterator typename Cube<eT>::const_slice_iterator
Cube<eT>::end_slice(const u32 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<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols, u32 fixed_n_slices> template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices>
arma_inline arma_inline
void void
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::mem_setup() Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::mem_setup()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) if(fixed_n_elem > 0)
{ {
access::rw(Cube<eT>::n_rows) = fixed_n_rows; access::rw(Cube<eT>::n_rows) = fixed_n_rows;
access::rw(Cube<eT>::n_cols) = fixed_n_cols; access::rw(Cube<eT>::n_cols) = fixed_n_cols;
skipping to change at line 2656 skipping to change at line 2847
access::rw(Cube<eT>::mem) = 0; access::rw(Cube<eT>::mem) = 0;
} }
} }
//! 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 u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
++(memptr[i]); ++(memptr[i]);
++(memptr[j]); ++(memptr[j]);
} }
if(i < n_elem) if(i < n_elem)
{ {
++(memptr[i]); ++(memptr[i]);
skipping to change at line 2689 skipping to change at line 2880
x += T(1); x += T(1);
} }
//! postfix ++ //! postfix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Cube_aux::postfix_pp(Cube<eT>& x) Cube_aux::postfix_pp(Cube<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
(memptr[i])++; (memptr[i])++;
(memptr[j])++; (memptr[j])++;
} }
if(i < n_elem) if(i < n_elem)
{ {
(memptr[i])++; (memptr[i])++;
skipping to change at line 2721 skipping to change at line 2912
x += T(1); x += T(1);
} }
//! prefix -- //! prefix --
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Cube_aux::prefix_mm(Cube<eT>& x) Cube_aux::prefix_mm(Cube<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
--(memptr[i]); --(memptr[i]);
--(memptr[j]); --(memptr[j]);
} }
if(i < n_elem) if(i < n_elem)
{ {
--(memptr[i]); --(memptr[i]);
skipping to change at line 2753 skipping to change at line 2944
x -= T(1); x -= T(1);
} }
//! postfix -- //! postfix --
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Cube_aux::postfix_mm(Cube<eT>& x) Cube_aux::postfix_mm(Cube<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
(memptr[i])--; (memptr[i])--;
(memptr[j])--; (memptr[j])--;
} }
if(i < n_elem) if(i < n_elem)
{ {
(memptr[i])--; (memptr[i])--;
skipping to change at line 2820 skipping to change at line 3011
const ProxyCube<T1> A(X.get_ref()); const ProxyCube<T1> A(X.get_ref());
arma_debug_assert_same_size arma_debug_assert_same_size
( (
out.n_rows, out.n_cols, out.n_slices, out.n_rows, out.n_cols, out.n_slices,
A.get_n_rows(), A.get_n_cols(), A.get_n_slices(), A.get_n_rows(), A.get_n_cols(), A.get_n_slices(),
"Cube::set_real()" "Cube::set_real()"
); );
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
//out_mem[i].real() = PA[i]; //out_mem[i].real() = PA[i];
out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() ); out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() );
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
Cube_aux::set_imag(Cube< std::complex<T> >& out, const BaseCube<T,T1>& X) Cube_aux::set_imag(Cube< std::complex<T> >& out, const BaseCube<T,T1>& X)
skipping to change at line 2850 skipping to change at line 3041
const ProxyCube<T1> A(X.get_ref()); const ProxyCube<T1> A(X.get_ref());
arma_debug_assert_same_size arma_debug_assert_same_size
( (
out.n_rows, out.n_cols, out.n_slices, out.n_rows, out.n_cols, out.n_slices,
A.get_n_rows(), A.get_n_cols(), A.get_n_slices(), A.get_n_rows(), A.get_n_cols(), A.get_n_slices(),
"Cube::set_imag()" "Cube::set_imag()"
); );
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
//out_mem[i].imag() = PA[i]; //out_mem[i].imag() = PA[i];
out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] ); out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] );
} }
} }
#ifdef ARMA_EXTRA_CUBE_MEAT #ifdef ARMA_EXTRA_CUBE_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_MEAT)
#endif #endif
 End of changes. 182 change blocks. 
386 lines changed or deleted 585 lines changed or added


 Glue_bones.hpp   Glue_bones.hpp 
skipping to change at line 36 skipping to change at line 36
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class Glue : public Base<typename T1::elem_type, Glue<T1, T2, glue_type> > class Glue : public Base<typename T1::elem_type, Glue<T1, T2, glue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
arma_inline Glue(const T1& in_A, const T2& in_B); arma_inline Glue(const T1& in_A, const T2& in_B);
arma_inline Glue(const T1& in_A, const T2& in_B, const u32 in_aux_u32); arma_inline Glue(const T1& in_A, const T2& in_B, const uword in_aux_uwor d);
arma_inline ~Glue(); arma_inline ~Glue();
const T1& A; //!< first operand const T1& A; //!< first operand
const T2& B; //!< second operand const T2& B; //!< second operand
const u32 aux_u32; //!< storage of auxiliary data, u32 format uword aux_uword; //!< storage of auxiliary data, uword format
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
4 lines changed or deleted 4 lines changed or added


 Glue_meat.hpp   Glue_meat.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Glue //! \addtogroup Glue
//! @{ //! @{
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Glue<T1,T2,glue_type>::Glue(const T1& in_A, const T2& in_B) Glue<T1,T2,glue_type>::Glue(const T1& in_A, const T2& in_B)
: A(in_A) : A(in_A)
, B(in_B) , B(in_B)
, aux_u32(aux_u32)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Glue<T1,T2,glue_type>::Glue(const T1& in_A, const T2& in_B, const u32 in_au x_u32) Glue<T1,T2,glue_type>::Glue(const T1& in_A, const T2& in_B, const uword in_ aux_uword)
: A(in_A) : A(in_A)
, B(in_B) , B(in_B)
, aux_u32(in_aux_u32) , aux_uword(in_aux_uword)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Glue<T1,T2,glue_type>::~Glue() Glue<T1,T2,glue_type>::~Glue()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
 End of changes. 3 change blocks. 
3 lines changed or deleted 2 lines changed or added


 Mat_bones.hpp   Mat_bones.hpp 
skipping to change at line 26 skipping to change at line 26
//! Dense matrix class //! Dense matrix class
template<typename eT> template<typename eT>
class Mat : public Base< eT, Mat<eT> > class Mat : public Base< eT, Mat<eT> >
{ {
public: public:
typedef eT elem_type; //!< the type of el ements stored in the matrix typedef eT elem_type; //!< the type of el ements stored in the matrix
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-c omplex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-c omplex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex
const u32 n_rows; //!< number of rows in the matrix (read-only) const uword n_rows; //!< number of rows in the matrix (read-only)
const u32 n_cols; //!< number of columns in the matrix (read-only) const uword n_cols; //!< number of columns in the matrix (read-only)
const u32 n_elem; //!< number of elements in the matrix (read-only) const uword n_elem; //!< number of elements in the matrix (read-only)
const u16 vec_state; //!< 0: matrix layout; 1: column vector layout; 2: r const uhword vec_state; //!< 0: matrix layout; 1: column vector layout; 2
ow vector layout : row vector layout
const u16 mem_state; const uhword mem_state;
// mem_state = 0: normal matrix that can be resized; // mem_state = 0: normal matrix that can be resized;
// mem_state = 1: use auxiliary memory until change in the number of elem ents is requested; // mem_state = 1: use auxiliary memory until change in the number of elem ents is requested;
// mem_state = 2: use auxiliary memory and don't allow the number of elem ents to be changed; // mem_state = 2: use auxiliary memory and don't allow the number of elem ents to be changed;
// mem_state = 3: fixed size (e.g. via template based size specification) . // mem_state = 3: fixed size (e.g. via template based size specification) .
arma_aligned const eT* const mem; //!< pointer to the memory used by the matrix (memory is read-only) arma_aligned const eT* const mem; //!< pointer to the memory used by the matrix (memory is read-only)
protected: protected:
arma_aligned eT mem_local[ arma_config::mat_prealloc ]; arma_aligned eT mem_local[ arma_config::mat_prealloc ];
public: public:
inline ~Mat(); inline ~Mat();
inline Mat(); inline Mat();
inline Mat(const u32 in_rows, const u32 in_cols); inline Mat(const uword in_rows, const uword in_cols);
inline Mat(const char* text); inline Mat(const char* text);
inline const Mat& operator=(const char* text); inline const Mat& operator=(const char* text);
inline Mat(const std::string& text); inline Mat(const std::string& text);
inline const Mat& operator=(const std::string& text); inline const Mat& operator=(const std::string& text);
inline Mat( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, #if defined(ARMA_USE_CXX11)
const bool copy_aux_mem = true, const bool strict = true); inline Mat(const std::initializer_list<eT>& list);
inline Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) inline const Mat& operator=(const std::initializer_list<eT>& list);
; #endif
inline Mat( eT* aux_mem, const uword aux_n_rows, const uword aux_n_c
ols, const bool copy_aux_mem = true, const bool strict = true);
inline Mat(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_c
ols);
arma_inline const Mat& operator=(const eT val); arma_inline const Mat& operator=(const eT val);
arma_inline const Mat& operator+=(const eT val); arma_inline const Mat& operator+=(const eT val);
arma_inline const Mat& operator-=(const eT val); arma_inline const Mat& operator-=(const eT val);
arma_inline const Mat& operator*=(const eT val); arma_inline const Mat& operator*=(const eT val);
arma_inline const Mat& operator/=(const eT val); arma_inline const Mat& operator/=(const eT val);
inline Mat(const Mat& m); inline Mat(const Mat& m);
inline const Mat& operator=(const Mat& m); inline const Mat& operator=(const Mat& m);
inline const Mat& operator+=(const Mat& m); inline const Mat& operator+=(const Mat& m);
skipping to change at line 119 skipping to change at line 125
template<typename T1> inline const Mat& operator= (const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator= (const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator+=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator+=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator-=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator-=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator*=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator*=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator%=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator%=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator/=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator/=(const subview_elem1<eT ,T1>& X);
inline mat_injector<Mat> operator<<(const eT val); inline mat_injector<Mat> operator<<(const eT val);
inline mat_injector<Mat> operator<<(const injector_end_of_row& x); inline mat_injector<Mat> operator<<(const injector_end_of_row& x);
arma_inline subview_row<eT> row(const u32 row_num); arma_inline subview_row<eT> row(const uword row_num);
arma_inline const subview_row<eT> row(const u32 row_num) const; arma_inline const subview_row<eT> row(const uword row_num) const;
inline subview_row<eT> operator()(const u32 row_num, const spa inline subview_row<eT> operator()(const uword row_num, const s
n& col_span); pan& col_span);
inline const subview_row<eT> operator()(const u32 row_num, const spa inline const subview_row<eT> operator()(const uword row_num, const s
n& col_span) const; pan& col_span) const;
arma_inline subview_col<eT> col(const u32 col_num); arma_inline subview_col<eT> col(const uword col_num);
arma_inline const subview_col<eT> col(const u32 col_num) const; arma_inline const subview_col<eT> col(const uword col_num) const;
inline subview_col<eT> operator()(const span& row_span, const inline subview_col<eT> operator()(const span& row_span, const
u32 col_num); uword col_num);
inline const subview_col<eT> operator()(const span& row_span, const inline const subview_col<eT> operator()(const span& row_span, const
u32 col_num) const; uword col_num) const;
inline Col<eT> unsafe_col(const u32 col_num); inline Col<eT> unsafe_col(const uword col_num);
inline const Col<eT> unsafe_col(const u32 col_num) const; inline const Col<eT> unsafe_col(const uword col_num) const;
arma_inline subview<eT> rows(const u32 in_row1, const u32 in_row2); arma_inline subview<eT> rows(const uword in_row1, const uword in_ro
arma_inline const subview<eT> rows(const u32 in_row1, const u32 in_row2) w2);
const; arma_inline const subview<eT> rows(const uword in_row1, const uword in_ro
w2) const;
arma_inline subview<eT> cols(const u32 in_col1, const u32 in_col2); arma_inline subview<eT> cols(const uword in_col1, const uword in_co
arma_inline const subview<eT> cols(const u32 in_col1, const u32 in_col2) l2);
const; arma_inline const subview<eT> cols(const uword in_col1, const uword in_co
l2) const;
arma_inline subview<eT> submat(const u32 in_row1, const u32 in_col1 arma_inline subview<eT> submat(const uword in_row1, const uword in_
, const u32 in_row2, const u32 in_col2); col1, const uword in_row2, const uword in_col2);
arma_inline const subview<eT> submat(const u32 in_row1, const u32 in_col1 arma_inline const subview<eT> submat(const uword in_row1, const uword in_
, const u32 in_row2, const u32 in_col2) const; col1, const uword in_row2, const uword in_col2) const;
inline subview<eT> submat (const span& row_span, const span & col_span); inline subview<eT> submat (const span& row_span, const span & col_span);
inline const subview<eT> submat (const span& row_span, const span & col_span) const; inline const subview<eT> submat (const span& row_span, const span & col_span) const;
inline subview<eT> operator()(const span& row_span, const span & col_span); inline subview<eT> operator()(const span& row_span, const span & col_span);
inline const subview<eT> operator()(const span& row_span, const span & col_span) const; inline const subview<eT> operator()(const span& row_span, const span & col_span) const;
template<typename T1> arma_inline subview_elem1<eT,T1> elem(const B template<typename T1> arma_inline subview_elem1<eT,T1> elem(const B
ase<u32,T1>& a); ase<uword,T1>& a);
template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const B template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const B
ase<u32,T1>& a) const; ase<uword,T1>& a) const;
// template<typename T1, typename T2> arma_inline subview_elem2<eT,
T1,T2> submat(const Base<uword,T1>& a, const Base<uword,T2>& b);
// template<typename T1, typename T2> arma_inline const subview_elem2<eT,
T1,T2> submat(const Base<uword,T1>& a, const Base<uword,T2>& b) const;
// template<typename T1, typename T2> arma_inline subview_elem2<eT, arma_inline diagview<eT> diag(const sword in_id = 0);
T1,T2> submat(const Base<u32,T1>& a, const Base<u32,T2>& b); arma_inline const diagview<eT> diag(const sword in_id = 0) const;
// template<typename T1, typename T2> arma_inline const subview_elem2<eT,
T1,T2> submat(const Base<u32,T1>& a, const Base<u32,T2>& b) const;
arma_inline diagview<eT> diag(const s32 in_id = 0); inline void swap_rows(const uword in_row1, const uword in_row2);
arma_inline const diagview<eT> diag(const s32 in_id = 0) const; inline void swap_cols(const uword in_col1, const uword in_col2);
inline void swap_rows(const u32 in_row1, const u32 in_row2); inline void shed_row(const uword row_num);
inline void swap_cols(const u32 in_col1, const u32 in_col2); inline void shed_col(const uword col_num);
inline void shed_row(const u32 row_num); inline void shed_rows(const uword in_row1, const uword in_row2);
inline void shed_col(const u32 col_num); inline void shed_cols(const uword in_col1, const uword in_col2);
inline void shed_rows(const u32 in_row1, const u32 in_row2); inline void insert_rows(const uword row_num, const uword N, const bool se
inline void shed_cols(const u32 in_col1, const u32 in_col2); t_to_zero = true);
inline void insert_cols(const uword col_num, const uword N, const bool se
t_to_zero = true);
inline void insert_rows(const u32 row_num, const u32 N, const bool set_to template<typename T1> inline void insert_rows(const uword row_num, const
_zero = true); Base<eT,T1>& X);
inline void insert_cols(const u32 col_num, const u32 N, const bool set_to template<typename T1> inline void insert_cols(const uword col_num, const
_zero = true); Base<eT,T1>& X);
template<typename T1> inline void insert_rows(const u32 row_num, const Ba template<typename gen_type> inline Mat(const Gen<eT, ge
se<eT,T1>& X); n_type>& X);
template<typename T1> inline void insert_cols(const u32 col_num, const Ba template<typename gen_type> inline const Mat& operator=(const Gen<eT, ge
se<eT,T1>& X); n_type>& X);
template<typename gen_type> inline const Mat& operator+=(const Gen<eT, ge
n_type>& X);
template<typename gen_type> inline const Mat& operator-=(const Gen<eT, ge
n_type>& X);
template<typename gen_type> inline const Mat& operator*=(const Gen<eT, ge
n_type>& X);
template<typename gen_type> inline const Mat& operator%=(const Gen<eT, ge
n_type>& X);
template<typename gen_type> inline const Mat& operator/=(const Gen<eT, ge
n_type>& X);
template<typename T1, typename op_type> inline Mat(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline Mat(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator+=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator+=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator-=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator-=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator*=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator*=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator%=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator%=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator/=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator/=(cons t Op<T1, op_type>& X);
template<typename T1, typename eop_type> inline Mat(con st eOp<T1, eop_type>& X); template<typename T1, typename eop_type> inline Mat(con st eOp<T1, eop_type>& X);
skipping to change at line 224 skipping to change at line 238
template<typename T1, typename T2, typename eglue_type> inline const Mat& operator/=(const eGlue<T1, T2, eglue_type>& X); template<typename T1, typename T2, typename eglue_type> inline const Mat& operator/=(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X);
arma_inline arma_warn_unused eT& operator[] (const u32 i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const u32 i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const u32 i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const u32 i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const u32 i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 in_row, const u32 arma_inline arma_warn_unused eT& at (const uword in_row, const uw
in_col); ord in_col);
arma_inline arma_warn_unused eT at (const u32 in_row, const u32 arma_inline arma_warn_unused eT at (const uword in_row, const uw
in_col) const; ord in_col) const;
arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u32 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw
in_col); ord in_col);
arma_inline arma_warn_unused eT operator() (const u32 in_row, const u32 arma_inline arma_warn_unused eT operator() (const uword in_row, const uw
in_col) const; ord in_col) const;
arma_inline const Mat& operator++(); arma_inline const Mat& operator++();
arma_inline void operator++(int); arma_inline void operator++(int);
arma_inline const Mat& operator--(); arma_inline const Mat& operator--();
arma_inline void operator--(int); arma_inline void operator--(int);
arma_inline arma_warn_unused bool is_empty() const; arma_inline arma_warn_unused bool is_empty() const;
arma_inline arma_warn_unused bool is_vec() const; arma_inline arma_warn_unused bool is_vec() const;
arma_inline arma_warn_unused bool is_rowvec() const; arma_inline arma_warn_unused bool is_rowvec() const;
arma_inline arma_warn_unused bool is_colvec() const; arma_inline arma_warn_unused bool is_colvec() const;
arma_inline arma_warn_unused bool is_square() const; arma_inline arma_warn_unused bool is_square() const;
inline arma_warn_unused bool is_finite() const; inline arma_warn_unused bool is_finite() const;
arma_inline arma_warn_unused bool in_range(const u32 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 u32 in_row, const u3 arma_inline arma_warn_unused bool in_range(const uword in_row, const uw
2 in_col ) const; ord in_col) const;
arma_inline arma_warn_unused bool in_range(const span& row_span, const u3 arma_inline arma_warn_unused bool in_range(const span& row_span, const uw
2 in_col ) const; ord in_col) const;
arma_inline arma_warn_unused bool in_range(const u32 in_row, const sp arma_inline arma_warn_unused bool in_range(const uword in_row, const sp
an& 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;
arma_inline arma_warn_unused eT* colptr(const u32 in_col); arma_inline arma_warn_unused eT* colptr(const uword in_col);
arma_inline arma_warn_unused const eT* colptr(const u32 in_col) const; 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;
inline void print(const std::string extra_text = "") const; inline void impl_print(const std::string& extra_text) const;
inline void print(std::ostream& user_stream, const std::string extra_text inline void impl_print(std::ostream& user_stream, const std::string& extr
= "") const; a_text) const;
inline void print_trans(const std::string extra_text = "") const; inline void impl_print_trans(const std::string& extra_text) const;
inline void print_trans(std::ostream& user_stream, const std::string extr inline void impl_print_trans(std::ostream& user_stream, const std::string
a_text = "") const; & extra_text) const;
inline void raw_print(const std::string extra_text = "") const; inline void impl_raw_print(const std::string& extra_text) const;
inline void raw_print(std::ostream& user_stream, const std::string extra_ inline void impl_raw_print(std::ostream& user_stream, const std::string&
text = "") const; extra_text) const;
inline void raw_print_trans(const std::string extra_text = "") const; inline void impl_raw_print_trans(const std::string& extra_text) const;
inline void raw_print_trans(std::ostream& user_stream, const std::string inline void impl_raw_print_trans(std::ostream& user_stream, const std::st
extra_text = "") const; ring& extra_text) const;
template<typename eT2> template<typename eT2>
inline void copy_size(const Mat<eT2>& m); inline void copy_size(const Mat<eT2>& m);
inline void set_size(const u32 in_elem); inline void set_size(const uword in_elem);
inline void set_size(const u32 in_rows, const u32 in_cols); inline void set_size(const uword in_rows, const uword in_cols);
inline void reshape(const u32 in_rows, const u32 in_cols, const u32 dim inline void reshape(const uword in_rows, const uword in_cols, const uwo
= 0); rd dim = 0);
arma_hot inline const Mat& fill(const eT val); arma_hot inline const Mat& fill(const eT val);
inline const Mat& zeros(); inline const Mat& zeros();
inline const Mat& zeros(const u32 in_elem); inline const Mat& zeros(const uword in_elem);
inline const Mat& zeros(const u32 in_rows, const u32 in_cols); inline const Mat& zeros(const uword in_rows, const uword in_cols);
inline const Mat& ones(); inline const Mat& ones();
inline const Mat& ones(const u32 in_elem); inline const Mat& ones(const uword in_elem);
inline const Mat& ones(const u32 in_rows, const u32 in_cols); inline const Mat& ones(const uword in_rows, const uword in_cols);
inline const Mat& randu(); inline const Mat& randu();
inline const Mat& randu(const u32 in_elem); inline const Mat& randu(const uword in_elem);
inline const Mat& randu(const u32 in_rows, const u32 in_cols); inline const Mat& randu(const uword in_rows, const uword in_cols);
inline const Mat& randn(); inline const Mat& randn();
inline const Mat& randn(const u32 in_elem); inline const Mat& randn(const uword in_elem);
inline const Mat& randn(const u32 in_rows, const u32 in_cols); inline const Mat& randn(const uword in_rows, const uword in_cols);
inline const Mat& eye(); inline const Mat& eye();
inline const Mat& eye(const u32 in_rows, const u32 in_cols); inline const Mat& eye(const uword in_rows, const uword in_cols);
inline void reset(); inline void reset();
template<typename T1> inline void set_real(const Base<pod_type,T1>& X); template<typename T1> inline void set_real(const Base<pod_type,T1>& X);
template<typename T1> inline void set_imag(const Base<pod_type,T1>& X); template<typename T1> inline void set_imag(const Base<pod_type,T1>& X);
inline arma_warn_unused eT min() const; inline arma_warn_unused eT min() const;
inline arma_warn_unused eT max() const; inline arma_warn_unused eT max() const;
inline eT min(u32& index_of_min_val) const; inline eT min(uword& index_of_min_val) const;
inline eT max(u32& index_of_max_val) const; inline eT max(uword& index_of_max_val) const;
inline eT min(u32& row_of_min_val, u32& col_of_min_val) const; inline eT min(uword& row_of_min_val, uword& col_of_min_val) const;
inline eT max(u32& row_of_max_val, u32& col_of_max_val) const; inline eT max(uword& row_of_max_val, uword& col_of_max_val) 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);
// for container-like functionality // for container-like functionality
typedef eT value_type; typedef eT value_type;
typedef u32 size_type; typedef uword size_type;
typedef eT* iterator; typedef eT* iterator;
typedef const eT* const_iterator; typedef const eT* const_iterator;
typedef eT* col_iterator; typedef eT* col_iterator;
typedef const eT* const_col_iterator; typedef const eT* const_col_iterator;
class row_iterator class row_iterator
{ {
public: public:
inline row_iterator(Mat<eT>& in_M, const u32 in_row); inline row_iterator(Mat<eT>& in_M, const uword in_row);
inline eT& operator* (); inline eT& operator* ();
inline row_iterator& operator++(); inline row_iterator& operator++();
inline void operator++(int); inline void operator++(int);
inline row_iterator& operator--(); inline row_iterator& operator--();
inline void operator--(int); inline void operator--(int);
inline bool operator!=(const row_iterator& X) const; inline bool operator!=(const row_iterator& X) const;
inline bool operator==(const row_iterator& X) const; inline bool operator==(const row_iterator& X) const;
arma_aligned Mat<eT>& M; arma_aligned Mat<eT>& M;
arma_aligned u32 row; arma_aligned uword row;
arma_aligned u32 col; arma_aligned uword col;
}; };
class const_row_iterator class const_row_iterator
{ {
public: public:
const_row_iterator(const Mat<eT>& in_M, const u32 in_row); const_row_iterator(const Mat<eT>& in_M, const uword in_row);
const_row_iterator(const row_iterator& X); const_row_iterator(const row_iterator& X);
inline eT operator*() const; inline eT operator*() const;
inline const_row_iterator& operator++(); inline const_row_iterator& operator++();
inline void operator++(int); inline void operator++(int);
inline const_row_iterator& operator--(); inline const_row_iterator& operator--();
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 u32 row; arma_aligned uword row;
arma_aligned u32 col; arma_aligned uword col;
}; };
inline iterator begin(); inline iterator begin();
inline const_iterator begin() const; inline const_iterator begin() const;
inline iterator end(); inline iterator end();
inline const_iterator end() const; inline const_iterator end() const;
inline col_iterator begin_col(const u32 col_num); inline col_iterator begin_col(const uword col_num);
inline const_col_iterator begin_col(const u32 col_num) const; inline const_col_iterator begin_col(const uword col_num) const;
inline col_iterator end_col (const u32 col_num); inline col_iterator end_col (const uword col_num);
inline const_col_iterator end_col (const u32 col_num) const; inline const_col_iterator end_col (const uword col_num) const;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const uword row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const uword row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const uword row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const uword row_num) const;
inline void clear(); inline void clear();
inline bool empty() const; inline bool empty() const;
inline u32 size() const; inline uword size() const;
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
class fixed : public Mat<eT> class fixed : public Mat<eT>
{ {
private: private:
static const u32 fixed_n_elem = fixed_n_rows * fixed_n_cols; static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols;
static const bool use_extra = (fixed_n_elem > arma_config::mat_preal static const bool use_extra = (fixed_n_elem > arma_config::mat_prea
loc); lloc);
arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
arma_inline void mem_setup(); arma_inline void mem_setup();
public: public:
static const u32 n_rows = fixed_n_rows; static const uword n_rows = fixed_n_rows;
static const u32 n_cols = fixed_n_cols; static const uword n_cols = fixed_n_cols;
static const u32 n_elem = fixed_n_elem; static const uword n_elem = fixed_n_elem;
arma_inline fixed(); arma_inline fixed();
arma_inline fixed(const fixed<fixed_n_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( eT* aux_mem, const bool copy_aux_mem = true); inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
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);
// TODO: handling of initializer_list ?
template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A) ; template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A) ;
inline const Mat& operator=(const eT val); inline const Mat& operator=(const eT val);
inline const Mat& operator=(const char* text); inline const Mat& operator=(const char* text);
inline const Mat& operator=(const std::string& text); inline const Mat& operator=(const std::string& text);
inline subview_row<eT> operator()(const u32 row_num, const spa inline subview_row<eT> operator()(const uword row_num, const spa
n& col_span); n& col_span);
inline const subview_row<eT> operator()(const u32 row_num, const spa inline const subview_row<eT> operator()(const uword row_num, const spa
n& col_span) const; n& col_span) const;
inline subview_col<eT> operator()(const span& row_span, const u32 inline subview_col<eT> operator()(const span& row_span, const uwo
col_num ); rd col_num);
inline const subview_col<eT> operator()(const span& row_span, const u32 inline const subview_col<eT> operator()(const span& row_span, const uwo
col_num ) const; rd col_num) const;
inline subview<eT> operator()(const span& row_span, const spa n& col_span); inline subview<eT> operator()(const span& row_span, const spa n& col_span);
inline const subview<eT> operator()(const span& row_span, const spa n& col_span) const; inline const subview<eT> operator()(const span& row_span, const spa n& col_span) const;
arma_inline arma_warn_unused eT& operator[] (const u32 i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const u32 i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const u32 i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const u32 i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const u32 i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 in_row, const u3 arma_inline arma_warn_unused eT& at (const uword in_row, const
2 in_col); uword in_col);
arma_inline arma_warn_unused eT at (const u32 in_row, const u3 arma_inline arma_warn_unused eT at (const uword in_row, const
2 in_col) const; uword in_col) const;
arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u3 arma_inline arma_warn_unused eT& operator() (const uword in_row, const
2 in_col); uword in_col);
arma_inline arma_warn_unused eT operator() (const u32 in_row, const u3 arma_inline arma_warn_unused eT operator() (const uword in_row, const
2 in_col) const; uword in_col) 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();
}; };
protected: protected:
inline void init(u32 in_rows, u32 in_cols); inline void init_cold();
inline void init_warm(uword in_rows, uword in_cols);
inline void init(const std::string& text); inline void init(const std::string& text);
inline void init(const Mat& x);
#if defined(ARMA_USE_CXX11)
inline void init(const std::initializer_list<eT>& list);
#endif
template<typename T1, typename T2> template<typename T1, typename T2>
inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
inline void steal_mem(Mat& X); inline void steal_mem(Mat& X);
inline Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons t u32 aux_n_cols); inline Mat(const char junk, const eT* aux_mem, const uword aux_n_rows, co nst uword aux_n_cols);
friend class Cube<eT>; friend class Cube<eT>;
friend class glue_join; friend class glue_join;
friend class op_strans;
friend class op_htrans;
public: public:
#ifdef ARMA_EXTRA_MAT_PROTO #ifdef ARMA_EXTRA_MAT_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO)
#endif #endif
}; };
class Mat_aux class Mat_aux
{ {
 End of changes. 57 change blocks. 
164 lines changed or deleted 196 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 26 skipping to change at line 26
template<typename eT> template<typename eT>
inline inline
Mat<eT>::~Mat() Mat<eT>::~Mat()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(mem_state == 0) if(mem_state == 0)
{ {
if(n_elem > arma_config::mat_prealloc) if(n_elem > arma_config::mat_prealloc)
{ {
delete [] mem; #if defined(ARMA_USE_TBB_ALLOC)
scalable_free((void *)(mem));
#else
delete [] mem;
#endif
} }
} }
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
// try to expose buggy user code that accesses deleted objects // try to expose buggy user code that accesses deleted objects
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
access::rw(n_elem) = 0; access::rw(n_elem) = 0;
access::rw(mem) = 0; access::rw(mem) = 0;
} }
arma_type_check< is_supported_elem_type<eT>::value == false >::apply(); arma_type_check(( is_supported_elem_type<eT>::value == false ));
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat() Mat<eT>::Mat()
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
//! construct the matrix to have user specified dimensions //! construct the matrix to have user specified dimensions
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const u32 in_n_rows, const u32 in_n_cols) Mat<eT>::Mat(const uword in_n_rows, const uword in_n_cols)
: n_rows(0) : n_rows(in_n_rows)
, n_cols(0) , n_cols(in_n_cols)
, n_elem(0) , n_elem(in_n_rows*in_n_cols)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(in_n_rows, in_n_cols); init_cold();
}
template<typename eT>
inline
void
Mat<eT>::init_cold()
{
arma_extra_debug_sigprint( arma_boost::format("n_rows = %d, n_cols = %d")
% n_rows % n_cols );
// ensure that n_elem can hold the result of (n_rows * n_cols)
arma_debug_check
(
(
( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
? ( (float(n_rows) * float(n_cols)) > float(ARMA_MAX_UWORD) )
: false
),
"Mat::init(): requested size is too large"
);
if(n_elem <= arma_config::mat_prealloc)
{
access::rw(mem) = mem_local;
}
else
{
arma_extra_debug_print("Mat::init(): allocating memory");
#if defined(ARMA_USE_TBB_ALLOC)
access::rw(mem) = (eT *) scalable_malloc(sizeof(eT)*n_elem);
#else
access::rw(mem) = new(std::nothrow) eT[n_elem];
#endif
arma_check_bad_alloc( (mem == 0), "Mat::init(): out of memory" );
}
} }
//! internal matrix construction; if the requested size is small enough, me mory from the stack is used. otherwise memory is allocated via 'new' //! internal matrix construction; if the requested size is small enough, me mory from the stack is used. otherwise memory is allocated via 'new'
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init(u32 in_n_rows, u32 in_n_cols) Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols );
const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) ) if( (n_rows == in_n_rows) && (n_cols == in_n_cols) )
;
if(same_size == false)
{ {
const u32 t_vec_state = vec_state; return;
const u32 t_mem_state = mem_state; }
bool err_state = false; bool err_state = false;
char* err_msg = 0; char* err_msg = 0;
arma_debug_set_error const uhword t_vec_state = vec_state;
( const uhword t_mem_state = mem_state;
err_state,
err_msg,
(t_mem_state == 3),
"Mat::init(): size is fixed and hence cannot be changed"
);
if(t_vec_state > 0) arma_debug_set_error
(
err_state,
err_msg,
(t_mem_state == 3),
"Mat::init(): size is fixed and hence cannot be changed"
);
if(t_vec_state > 0)
{
if( (in_n_rows == 0) && (in_n_cols == 0) )
{ {
if( (in_n_rows == 0) && (in_n_cols == 0) ) if(t_vec_state == 1)
{ {
if(t_vec_state == 1) in_n_cols = 1;
{
in_n_cols = 1;
}
else
if(t_vec_state == 2)
{
in_n_rows = 1;
}
} }
else else
if(t_vec_state == 2)
{ {
arma_debug_set_error in_n_rows = 1;
(
err_state,
err_msg,
( ((t_vec_state == 1) && (in_n_cols != 1)) || ((t_vec_state == 2)
&& (in_n_rows != 1)) ),
"Mat::init(): object is a vector; requested size is not compatibl
e"
);
} }
} }
else
{
arma_debug_set_error
(
err_state,
err_msg,
( ((t_vec_state == 1) && (in_n_cols != 1)) || ((t_vec_state == 2) &
& (in_n_rows != 1)) ),
"Mat::init(): object is a vector; requested size is not compatible"
);
}
}
// ensure that n_elem can hold the result of (n_rows * n_cols)
// ensure that n_elem can hold the result of (n_rows * n_cols) arma_debug_set_error
// (due to a limitation in the C++98 standard: there is no official "lo (
ng long" variable type) err_state,
arma_debug_set_error err_msg,
( (
err_state, ( (in_n_rows > ARMA_MAX_UHWORD) || (in_n_cols > ARMA_MAX_UHWORD) )
err_msg, ? ( (float(in_n_rows) * float(in_n_cols)) > float(ARMA_MAX_UWORD) )
(double(in_n_rows) * double(in_n_cols)) > double(0xFFFFFFFF), : false
"Mat::init(): requested size is too large" ),
); "Mat::init(): requested size is too large"
);
arma_debug_check(err_state, err_msg); arma_debug_check(err_state, err_msg);
const u32 old_n_elem = n_elem; const uword old_n_elem = n_elem;
const u32 new_n_elem = in_n_rows * in_n_cols; const uword new_n_elem = in_n_rows * in_n_cols;
if(old_n_elem == new_n_elem) if(old_n_elem == new_n_elem)
{ {
arma_extra_debug_print("Mat::init(): reusing memory"); arma_extra_debug_print("Mat::init(): reusing memory");
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
} }
else else
{ {
arma_debug_check arma_debug_check
( (
(t_mem_state == 2), (t_mem_state == 2),
"Mat::init(): mismatch between size of auxiliary memory and request "Mat::init(): mismatch between size of auxiliary memory and requested
ed size" size"
); );
if(t_mem_state == 0) if(t_mem_state == 0)
{
if(old_n_elem > arma_config::mat_prealloc)
{ {
if(old_n_elem > arma_config::mat_prealloc) arma_extra_debug_print("Mat::init(): freeing memory");
{
arma_extra_debug_print("Mat::init(): freeing memory");
#if defined(ARMA_USE_TBB_ALLOC)
scalable_free((void *)(mem));
#else
delete [] mem; delete [] mem;
} #endif
} }
}
if(new_n_elem <= arma_config::mat_prealloc) if(new_n_elem <= arma_config::mat_prealloc)
{ {
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
else else
{ {
arma_extra_debug_print("Mat::init(): allocating memory"); arma_extra_debug_print("Mat::init(): allocating memory");
#if defined(ARMA_USE_TBB_ALLOC)
access::rw(mem) = (eT *) scalable_malloc(sizeof(eT)*new_n_elem);
#else
access::rw(mem) = new(std::nothrow) eT[new_n_elem]; access::rw(mem) = new(std::nothrow) eT[new_n_elem];
#endif
arma_check_bad_alloc( (mem == 0), "Mat::init(): out of memory" ); arma_check_bad_alloc( (mem == 0), "Mat::init(): out of memory" );
}
access::rw(n_elem) = new_n_elem;
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(mem_state) = 0;
} }
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem) = new_n_elem;
access::rw(mem_state) = 0;
} }
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const char* text) Mat<eT>::Mat(const char* text)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init( std::string(text) ); init( std::string(text) );
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
skipping to change at line 224 skipping to change at line 274
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const std::string& text) Mat<eT>::Mat(const std::string& text)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(text); init(text);
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
skipping to change at line 255 skipping to change at line 304
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init(const std::string& text) Mat<eT>::init(const std::string& text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// //
// work out the size // work out the size
u32 t_n_rows = 0; uword t_n_rows = 0;
u32 t_n_cols = 0; uword t_n_cols = 0;
bool t_n_cols_found = false; bool t_n_cols_found = false;
std::string token; std::string token;
std::string::size_type line_start = 0; std::string::size_type line_start = 0;
std::string::size_type line_end = 0; std::string::size_type line_end = 0;
while( line_start < text.length() ) while( line_start < text.length() )
{ {
line_end = text.find(';', line_start); line_end = text.find(';', line_start);
if(line_end == std::string::npos) if(line_end == std::string::npos)
line_end = text.length()-1; line_end = text.length()-1;
std::string::size_type line_len = line_end - line_start + 1; std::string::size_type line_len = line_end - line_start + 1;
std::stringstream line_stream( text.substr(line_start,line_len) ); std::stringstream line_stream( text.substr(line_start,line_len) );
u32 line_n_cols = 0; uword line_n_cols = 0;
while(line_stream >> token) while(line_stream >> token)
{ {
++line_n_cols; ++line_n_cols;
} }
if(line_n_cols > 0) if(line_n_cols > 0)
{ {
if(t_n_cols_found == false) if(t_n_cols_found == false)
{ {
t_n_cols = line_n_cols; t_n_cols = line_n_cols;
skipping to change at line 304 skipping to change at line 353
line_start = line_end+1; line_start = line_end+1;
} }
Mat<eT>& x = *this; Mat<eT>& x = *this;
x.set_size(t_n_rows, t_n_cols); x.set_size(t_n_rows, t_n_cols);
line_start = 0; line_start = 0;
line_end = 0; line_end = 0;
u32 row = 0; uword row = 0;
while( line_start < text.length() ) while( line_start < text.length() )
{ {
line_end = text.find(';', line_start); line_end = text.find(';', line_start);
if(line_end == std::string::npos) if(line_end == std::string::npos)
line_end = text.length()-1; line_end = text.length()-1;
std::string::size_type line_len = line_end - line_start + 1; std::string::size_type line_len = line_end - line_start + 1;
std::stringstream line_stream( text.substr(line_start,line_len) ); std::stringstream line_stream( text.substr(line_start,line_len) );
// u32 col = 0; // uword col = 0;
// while(line_stream >> token) // while(line_stream >> token)
// { // {
// x.at(row,col) = strtod(token.c_str(), 0); // x.at(row,col) = strtod(token.c_str(), 0);
// ++col; // ++col;
// } // }
u32 col = 0; uword col = 0;
eT val; eT val;
while(line_stream >> val) while(line_stream >> val)
{ {
x.at(row,col) = val; x.at(row,col) = val;
++col; ++col;
} }
++row; ++row;
line_start = line_end+1; line_start = line_end+1;
} }
} }
#if defined(ARMA_USE_CXX11)
template<typename eT>
inline
Mat<eT>::Mat(const std::initializer_list<eT>& list)
: n_rows(0)
, n_cols(0)
, n_elem(0)
, vec_state(0)
, mem_state(0)
, mem()
{
arma_extra_debug_sigprint_this(this);
init(list);
}
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator=(const std::initializer_list<eT>& list)
{
arma_extra_debug_sigprint();
init(list);
return *this;
}
#endif
//! Set the matrix to be equal to the specified scalar. //! Set the matrix to be equal to the specified scalar.
//! NOTE: the size of the matrix will be 1x1 //! NOTE: the size of the matrix will be 1x1
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eT val) Mat<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(1,1); init_warm(1,1);
access::rw(mem[0]) = val; access::rw(mem[0]) = val;
return *this; return *this;
} }
//! In-place addition of a scalar to all elements of the matrix //! In-place addition of a scalar to all elements of the matrix
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const eT val) Mat<eT>::operator+=(const eT val)
{ {
skipping to change at line 408 skipping to change at line 488
arrayops::inplace_div( memptr(), val, n_elem ); arrayops::inplace_div( memptr(), val, n_elem );
return *this; return *this;
} }
//! construct a matrix from a given matrix //! construct a matrix from a given matrix
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const Mat<eT>& in_mat) Mat<eT>::Mat(const Mat<eT>& in_mat)
: n_rows(0) : n_rows(in_mat.n_rows)
, n_cols(0) , n_cols(in_mat.n_cols)
, n_elem(0) , n_elem(in_mat.n_elem)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") % this % &in_mat); arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") % this % &in_mat);
init(in_mat); init_cold();
arrayops::copy( memptr(), in_mat.mem, in_mat.n_elem );
} }
//! construct a matrix from a given matrix //! construct a matrix from a given matrix
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const Mat<eT>& x) Mat<eT>::operator=(const Mat<eT>& in_mat)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") %
this % &in_mat);
if(this != &in_mat)
{
init_warm(in_mat.n_rows, in_mat.n_cols);
arrayops::copy( memptr(), in_mat.mem, in_mat.n_elem );
}
init(x);
return *this; return *this;
} }
//! construct a matrix from a given matrix #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init(const Mat<eT>& x) Mat<eT>::init(const std::initializer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) const uword N = list.size();
{
init(x.n_rows, x.n_cols); set_size(1, N);
arrayops::copy( memptr(), x.mem, x.n_elem );
} arrayops::copy( memptr(), list.begin(), N );
} }
#endif
//! for constructing a complex matrix out of two non-complex matrices //! for constructing a complex matrix out of two non-complex matrices
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
Mat<eT>::init Mat<eT>::init
( (
const Base<typename Mat<eT>::pod_type, T1>& A, const Base<typename Mat<eT>::pod_type, T1>& A,
const Base<typename Mat<eT>::pod_type, T2>& B const Base<typename Mat<eT>::pod_type, T2>& B
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type T; typedef typename T1::elem_type 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;
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil arma_type_check(( is_complex<eT>::value == false )); //!< compile-time
e-time abort if eT isn't std::complex abort if eT isn't std::complex
arma_type_check< is_complex< T>::value == true >::apply(); //!< compil arma_type_check(( is_complex< T>::value == true )); //!< compile-time
e-time abort if T is std::complex abort if T is std::complex
arma_type_check< is_same_type< std::complex<T>, eT >::value == false >::a pply(); //!< 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> X(A.get_ref()); const Proxy<T1> X(A.get_ref());
const Proxy<T2> Y(B.get_ref()); const Proxy<T2> Y(B.get_ref());
arma_assert_same_size(X, Y, "Mat()"); arma_assert_same_size(X, Y, "Mat()");
init(X.get_n_rows(), X.get_n_cols()); init_warm(X.get_n_rows(), X.get_n_cols());
const u32 N = n_elem; const uword N = n_elem;
eT* out_mem = memptr(); eT* out_mem = memptr();
ea_type1 PX = X.get_ea(); ea_type1 PX = X.get_ea();
ea_type2 PY = Y.get_ea(); ea_type2 PY = Y.get_ea();
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out_mem[i] = std::complex<T>(PX[i], PY[i]); out_mem[i] = std::complex<T>(PX[i], PY[i]);
} }
} }
//! try to steal the memory from a given matrix; //! try to steal the memory from a given matrix;
//! if memory can't be stolen, copy the given matrix //! if memory can't be stolen, copy the given matrix
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::steal_mem(Mat<eT>& x) Mat<eT>::steal_mem(Mat<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
const u32 x_n_elem = x.n_elem; const uword x_n_elem = x.n_elem;
const u32 x_vec_state = x.vec_state; const uword x_vec_state = x.vec_state;
const u32 x_mem_state = x.mem_state; const uword x_mem_state = x.mem_state;
const u32 t_vec_state = vec_state; const uword t_vec_state = vec_state;
bool layout_ok = false; bool layout_ok = false;
if(t_vec_state == x_vec_state) if(t_vec_state == x_vec_state)
{ {
layout_ok = true; layout_ok = true;
} }
else else
{ {
if( (t_vec_state == 1) && ( x_n_cols == 1) ) if( (t_vec_state == 1) && ( x_n_cols == 1) )
skipping to change at line 543 skipping to change at line 633
access::rw(n_elem) = x_n_elem; access::rw(n_elem) = x_n_elem;
access::rw(mem) = x.mem; access::rw(mem) = x.mem;
access::rw(x.n_rows) = 0; access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0; access::rw(x.n_cols) = 0;
access::rw(x.n_elem) = 0; access::rw(x.n_elem) = 0;
access::rw(x.mem) = 0; access::rw(x.mem) = 0;
} }
else else
{ {
init(x); (*this).operator=(x);
} }
} }
} }
//! construct a matrix from a given auxiliary array of eTs. //! construct a matrix from a given auxiliary array of eTs.
//! if copy_aux_mem is true, new memory is allocated and the array is copie d. //! if copy_aux_mem is true, new memory is allocated and the array is copie d.
//! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying). //! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying).
//! the default is to copy the array. //! the default is to copy the array.
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const Mat<eT>::Mat(eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, c
bool copy_aux_mem, const bool strict) onst bool copy_aux_mem, const bool strict)
: n_rows (copy_aux_mem ? 0 : aux_n_rows ) : n_rows ( aux_n_rows )
, n_cols (copy_aux_mem ? 0 : aux_n_cols ) , n_cols ( aux_n_cols )
, n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols) , n_elem ( aux_n_rows*aux_n_cols )
, vec_state( 0 ) , vec_state( 0 )
, mem_state(copy_aux_mem ? 0 : ( strict ? 2 : 1 ) ) , mem_state( copy_aux_mem ? 0 : ( strict ? 2 : 1 ) )
, mem (copy_aux_mem ? mem : aux_mem ) , mem ( copy_aux_mem ? 0 : aux_mem )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(copy_aux_mem == true) if(copy_aux_mem == true)
{ {
init(aux_n_rows, aux_n_cols); init_cold();
arrayops::copy( memptr(), aux_mem, n_elem ); arrayops::copy( memptr(), aux_mem, n_elem );
} }
} }
//! construct a matrix from a given auxiliary read-only array of eTs. //! construct a matrix from a given auxiliary read-only array of eTs.
//! the array is copied. //! the array is copied.
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) Mat<eT>::Mat(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_c
: n_rows(0) ols)
, n_cols(0) : n_rows(aux_n_rows)
, n_elem(0) , n_cols(aux_n_cols)
, n_elem(aux_n_rows*aux_n_cols)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(aux_n_rows, aux_n_cols); init_cold();
arrayops::copy( memptr(), aux_mem, n_elem ); arrayops::copy( memptr(), aux_mem, n_elem );
} }
//! DANGEROUS! Construct a temporary matrix, using auxiliary memory. //! DANGEROUS! Construct a temporary matrix, using auxiliary memory.
//! This constructor is NOT intended for usage by user code. //! This constructor is NOT intended for usage by user code.
//! Its sole purpose is to be used by the Cube class. //! Its sole purpose is to be used by the Cube class.
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons t u32 aux_n_cols) Mat<eT>::Mat(const char junk, const eT* aux_mem, const uword aux_n_rows, co nst uword aux_n_cols)
: n_rows (aux_n_rows ) : n_rows (aux_n_rows )
, n_cols (aux_n_cols ) , n_cols (aux_n_cols )
, n_elem (aux_n_rows*aux_n_cols) , n_elem (aux_n_rows*aux_n_cols)
, vec_state(0 ) , vec_state(0 )
, mem_state(3 ) , mem_state(3 )
, mem (aux_mem ) , mem (aux_mem )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_ignore(junk); arma_ignore(junk);
} }
skipping to change at line 693 skipping to change at line 782
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
Mat<eT>::Mat(const BaseCube<eT,T1>& X) Mat<eT>::Mat(const BaseCube<eT,T1>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
, mem(mem) //, mem(0) , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
(*this).operator=(X); (*this).operator=(X);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
const Mat<eT>& const Mat<eT>&
skipping to change at line 715 skipping to change at line 804
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& out = *this; Mat<eT>& out = *this;
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& in = tmp.M; const Cube<eT>& in = tmp.M;
arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false); arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ) ; arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ) ;
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if(in_n_cols == 1) if(in_n_cols == 1)
{ {
out.set_size(in_n_rows, in_n_slices); out.set_size(in_n_rows, in_n_slices);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ) ; arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ) ;
} }
} }
else else
if(in_n_rows == 1) if(in_n_rows == 1)
{ {
out.set_size(in_n_slices, in_n_cols); out.set_size(in_n_slices, in_n_cols);
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] = in.at(0, col, i); out_colptr[i] = in.at(0, col, i);
} }
} }
} }
} }
else else
{ {
out.set_size(in_n_slices); out.set_size(in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] = in.at(0, 0, i); out_mem[i] = in.at(0, 0, i);
} }
} }
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
skipping to change at line 790 skipping to change at line 879
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& out = *this; Mat<eT>& out = *this;
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& in = tmp.M; const Cube<eT>& in = tmp.M;
arma_debug_assert_cube_as_mat(out, in, "addition", true); arma_debug_assert_cube_as_mat(out, in, "addition", true);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_ n_rows ); arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_ n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_plus( out.colptr(i), in.slice_colptr(i, 0), in_ n_rows ); arrayops::inplace_plus( out.colptr(i), in.slice_colptr(i, 0), in_ n_rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] += in.at(0, col, i); out_colptr[i] += in.at(0, col, i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] += in.at(0, 0, i); out_mem[i] += in.at(0, 0, i);
} }
} }
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
skipping to change at line 859 skipping to change at line 948
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& out = *this; Mat<eT>& out = *this;
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& in = tmp.M; const Cube<eT>& in = tmp.M;
arma_debug_assert_cube_as_mat(out, in, "subtraction", true); arma_debug_assert_cube_as_mat(out, in, "subtraction", true);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in _n_rows ); arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in _n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_minus( out.colptr(i), in.slice_colptr(i, 0), in _n_rows ); arrayops::inplace_minus( out.colptr(i), in.slice_colptr(i, 0), in _n_rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] -= in.at(0, col, i); out_colptr[i] -= in.at(0, col, i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] -= in.at(0, 0, i); out_mem[i] -= in.at(0, 0, i);
} }
} }
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
skipping to change at line 943 skipping to change at line 1032
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& out = *this; Mat<eT>& out = *this;
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& in = tmp.M; const Cube<eT>& in = tmp.M;
arma_debug_assert_cube_as_mat(out, in, "element-wise multiplication", tru e); arma_debug_assert_cube_as_mat(out, in, "element-wise multiplication", tru e);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n _rows ); arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n _rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_mul( out.colptr(i), in.slice_colptr(i, 0), in_n _rows ); arrayops::inplace_mul( out.colptr(i), in.slice_colptr(i, 0), in_n _rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] *= in.at(0, col, i); out_colptr[i] *= in.at(0, col, i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] *= in.at(0, 0, i); out_mem[i] *= in.at(0, 0, i);
} }
} }
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
skipping to change at line 1012 skipping to change at line 1101
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& out = *this; Mat<eT>& out = *this;
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& in = tmp.M; const Cube<eT>& in = tmp.M;
arma_debug_assert_cube_as_mat(out, in, "element-wise division", true); arma_debug_assert_cube_as_mat(out, in, "element-wise division", true);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n _rows ); arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n _rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n _rows ); arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n _rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] /= in.at(0, col, i); out_colptr[i] /= in.at(0, col, i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] /= in.at(0, 0, i); out_mem[i] /= in.at(0, 0, i);
} }
} }
} }
return *this; return *this;
} }
//! for constructing a complex matrix out of two non-complex matrices //! for constructing a complex matrix out of two non-complex matrices
skipping to change at line 1080 skipping to change at line 1169
Mat<eT>::Mat Mat<eT>::Mat
( (
const Base<typename Mat<eT>::pod_type,T1>& A, const Base<typename Mat<eT>::pod_type,T1>& A,
const Base<typename Mat<eT>::pod_type,T2>& B const Base<typename Mat<eT>::pod_type,T2>& B
) )
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(A,B); init(A,B);
} }
//! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation) //! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation)
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const subview<eT>& X) Mat<eT>::Mat(const subview<eT>& X)
: n_rows(0) : n_rows(X.n_rows)
, n_cols(0) , n_cols(X.n_cols)
, n_elem(0) , n_elem(X.n_elem)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); init_cold();
subview<eT>::extract(*this, X);
} }
//! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation) //! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const subview<eT>& X) Mat<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::extract(*this, X); const bool alias = (this == &(X.m));
if(alias == false)
{
init_warm(X.n_rows, X.n_cols);
subview<eT>::extract(*this, X);
}
else
{
Mat<eT> tmp(X);
steal_mem(tmp);
}
return *this; return *this;
} }
//! in-place matrix addition (using a submatrix on the right-hand-side) //! in-place matrix addition (using a submatrix on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const subview<eT>& X) Mat<eT>::operator+=(const subview<eT>& X)
{ {
skipping to change at line 1192 skipping to change at line 1294
//! construct a matrix from a subview_cube instance //! construct a matrix from a subview_cube instance
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const subview_cube<eT>& x) Mat<eT>::Mat(const subview_cube<eT>& x)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(x); this->operator=(x);
} }
//! construct a matrix from a subview_cube instance //! construct a matrix from a subview_cube instance
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
skipping to change at line 1283 skipping to change at line 1384
subview_cube<eT>::div_inplace(*this, X); subview_cube<eT>::div_inplace(*this, X);
return *this; return *this;
} }
//! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation) //! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation)
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const diagview<eT>& X) Mat<eT>::Mat(const diagview<eT>& X)
: n_rows(0) : n_rows(X.n_rows)
, n_cols(0) , n_cols(X.n_cols)
, n_elem(0) , n_elem(X.n_elem)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); init_cold();
diagview<eT>::extract(*this, X);
} }
//! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation) //! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const diagview<eT>& X) Mat<eT>::operator=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>::extract(*this, X); const bool alias = (this == &(X.m));
if(alias == false)
{
init_warm(X.n_rows, X.n_cols);
diagview<eT>::extract(*this, X);
}
else
{
Mat<eT> tmp(X);
steal_mem(tmp);
}
return *this; return *this;
} }
//! in-place matrix addition (using a diagview on the right-hand-side) //! in-place matrix addition (using a diagview on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const diagview<eT>& X) Mat<eT>::operator+=(const diagview<eT>& X)
{ {
skipping to change at line 1383 skipping to change at line 1498
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
Mat<eT>::Mat(const subview_elem1<eT,T1>& X) Mat<eT>::Mat(const subview_elem1<eT,T1>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
const Mat<eT>& const Mat<eT>&
skipping to change at line 1489 skipping to change at line 1603
mat_injector< Mat<eT> > mat_injector< Mat<eT> >
Mat<eT>::operator<<(const injector_end_of_row& x) Mat<eT>::operator<<(const injector_end_of_row& x)
{ {
return mat_injector< Mat<eT> >(*this, x); return mat_injector< Mat<eT> >(*this, x);
} }
//! creation of subview (row vector) //! creation of subview (row vector)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT> subview_row<eT>
Mat<eT>::row(const u32 row_num) Mat<eT>::row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "Mat::row(): out of bounds" ); arma_debug_check( row_num >= n_rows, "Mat::row(): out of bounds" );
return subview_row<eT>(*this, row_num); return subview_row<eT>(*this, row_num);
} }
//! creation of subview (row vector) //! creation of subview (row vector)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_row<eT> const subview_row<eT>
Mat<eT>::row(const u32 row_num) const Mat<eT>::row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "Mat::row(): out of bounds" ); arma_debug_check( row_num >= n_rows, "Mat::row(): out of bounds" );
return subview_row<eT>(*this, row_num); return subview_row<eT>(*this, row_num);
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT> subview_row<eT>
Mat<eT>::operator()(const u32 row_num, const span& col_span) Mat<eT>::operator()(const uword row_num, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check arma_debug_check
( (
(row_num >= n_rows) (row_num >= n_rows)
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"Mat::operator(): indices out of bounds or incorrectly used" "Mat::operator(): indices out of bounds or incorrectly used"
); );
return subview_row<eT>(*this, row_num, in_col1, submat_n_cols); return subview_row<eT>(*this, row_num, in_col1, submat_n_cols);
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
Mat<eT>::operator()(const u32 row_num, const span& col_span) const Mat<eT>::operator()(const uword row_num, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check arma_debug_check
( (
(row_num >= n_rows) (row_num >= n_rows)
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"Mat::operator(): indices out of bounds or incorrectly used" "Mat::operator(): indices out of bounds or incorrectly used"
); );
return subview_row<eT>(*this, row_num, in_col1, submat_n_cols); return subview_row<eT>(*this, row_num, in_col1, submat_n_cols);
} }
//! creation of subview (column vector) //! creation of subview (column vector)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_col<eT> subview_col<eT>
Mat<eT>::col(const u32 col_num) Mat<eT>::col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "Mat::col(): out of bounds"); arma_debug_check( col_num >= n_cols, "Mat::col(): out of bounds");
return subview_col<eT>(*this, col_num); return subview_col<eT>(*this, col_num);
} }
//! creation of subview (column vector) //! creation of subview (column vector)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_col<eT> const subview_col<eT>
Mat<eT>::col(const u32 col_num) const Mat<eT>::col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "Mat::col(): out of bounds"); arma_debug_check( col_num >= n_cols, "Mat::col(): out of bounds");
return subview_col<eT>(*this, col_num); return subview_col<eT>(*this, col_num);
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT> subview_col<eT>
Mat<eT>::operator()(const span& row_span, const u32 col_num) Mat<eT>::operator()(const span& row_span, const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
arma_debug_check arma_debug_check
( (
(col_num >= n_cols) (col_num >= n_cols)
|| ||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
, ,
"Mat::operator(): indices out of bounds or incorrectly used" "Mat::operator(): indices out of bounds or incorrectly used"
); );
return subview_col<eT>(*this, col_num, in_row1, submat_n_rows); return subview_col<eT>(*this, col_num, in_row1, submat_n_rows);
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
Mat<eT>::operator()(const span& row_span, const u32 col_num) const Mat<eT>::operator()(const span& row_span, const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
arma_debug_check arma_debug_check
( (
(col_num >= n_cols) (col_num >= n_cols)
|| ||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
, ,
"Mat::operator(): indices out of bounds or incorrectly used" "Mat::operator(): indices out of bounds or incorrectly used"
); );
skipping to change at line 1653 skipping to change at line 1767
} }
//! create a Col object which uses memory from an existing matrix object. //! create a Col object which uses memory from an existing matrix object.
//! this approach is currently not alias safe //! this approach is currently not alias safe
//! and does not take into account that the parent matrix object could be d eleted. //! and does not take into account that the parent matrix object could be d eleted.
//! if deleted memory is accessed by the created Col object, //! if deleted memory is accessed by the created Col object,
//! it will cause memory corruption and/or a crash //! it will cause memory corruption and/or a crash
template<typename eT> template<typename eT>
inline inline
Col<eT> Col<eT>
Mat<eT>::unsafe_col(const u32 col_num) Mat<eT>::unsafe_col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "Mat::unsafe_col(): out of bounds"); arma_debug_check( col_num >= n_cols, "Mat::unsafe_col(): out of bounds");
return Col<eT>(colptr(col_num), n_rows, false, true); return Col<eT>(colptr(col_num), n_rows, false, true);
} }
//! create a Col object which uses memory from an existing matrix object. //! create a Col object which uses memory from an existing matrix object.
//! this approach is currently not alias safe //! this approach is currently not alias safe
//! and does not take into account that the parent matrix object could be d eleted. //! and does not take into account that the parent matrix object could be d eleted.
//! if deleted memory is accessed by the created Col object, //! if deleted memory is accessed by the created Col object,
//! it will cause memory corruption and/or a crash //! it will cause memory corruption and/or a crash
template<typename eT> template<typename eT>
inline inline
const Col<eT> const Col<eT>
Mat<eT>::unsafe_col(const u32 col_num) const Mat<eT>::unsafe_col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "Mat::unsafe_col(): out of bounds"); arma_debug_check( col_num >= n_cols, "Mat::unsafe_col(): out of bounds");
return Col<eT>(const_cast<eT*>(colptr(col_num)), n_rows, false, true); typedef const Col<eT> out_type;
return out_type(const_cast<eT*>(colptr(col_num)), n_rows, false, true);
} }
//! creation of subview (submatrix comprised of specified row vectors) //! creation of subview (submatrix comprised of specified row vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview<eT> subview<eT>
Mat<eT>::rows(const u32 in_row1, const u32 in_row2) Mat<eT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"Mat::rows(): indices out of bounds or incorrectly used" "Mat::rows(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
return subview<eT>(*this, in_row1, 0, subview_n_rows, n_cols ); return subview<eT>(*this, in_row1, 0, subview_n_rows, n_cols );
} }
//! creation of subview (submatrix comprised of specified row vectors) //! creation of subview (submatrix comprised of specified row vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview<eT> const subview<eT>
Mat<eT>::rows(const u32 in_row1, const u32 in_row2) const Mat<eT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"Mat::rows(): indices out of bounds or incorrectly used" "Mat::rows(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
return subview<eT>(*this, in_row1, 0, subview_n_rows, n_cols ); return subview<eT>(*this, in_row1, 0, subview_n_rows, n_cols );
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview<eT> subview<eT>
Mat<eT>::cols(const u32 in_col1, const u32 in_col2) Mat<eT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"Mat::cols(): indices out of bounds or incorrectly used" "Mat::cols(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview<eT>(*this, 0, in_col1, n_rows, subview_n_cols); return subview<eT>(*this, 0, in_col1, n_rows, subview_n_cols);
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview<eT> const subview<eT>
Mat<eT>::cols(const u32 in_col1, const u32 in_col2) const Mat<eT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"Mat::cols(): indices out of bounds or incorrectly used" "Mat::cols(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview<eT>(*this, 0, in_col1, n_rows, subview_n_cols); return subview<eT>(*this, 0, in_col1, n_rows, subview_n_cols);
} }
//! creation of subview (submatrix) //! creation of subview (submatrix)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview<eT> subview<eT>
Mat<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2, co nst u32 in_col2) Mat<eT>::submat(const uword in_row1, const uword in_col1, const uword in_ro w2, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols),
"Mat::submat(): indices out of bounds or incorrectly used" "Mat::submat(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_col s); return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_col s);
} }
//! creation of subview (generic submatrix) //! creation of subview (generic submatrix)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview<eT> const subview<eT>
Mat<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2, co nst u32 in_col2) const Mat<eT>::submat(const uword in_row1, const uword in_col1, const uword in_ro w2, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols),
"Mat::submat(): indices out of bounds or incorrectly used" "Mat::submat(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_col s); return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_col s);
} }
//! creation of subview (submatrix) //! creation of subview (submatrix)
template<typename eT> template<typename eT>
inline inline
subview<eT> subview<eT>
Mat<eT>::submat(const span& row_span, const span& col_span) Mat<eT>::submat(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword in_col2 = col_span.b;
const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"Mat::submat(): indices out of bounds or incorrectly used" "Mat::submat(): indices out of bounds or incorrectly used"
); );
skipping to change at line 1840 skipping to change at line 1956
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
Mat<eT>::submat(const span& row_span, const span& col_span) const Mat<eT>::submat(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword in_col2 = col_span.b;
const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"Mat::submat(): indices out of bounds or incorrectly used" "Mat::submat(): indices out of bounds or incorrectly used"
); );
skipping to change at line 1887 skipping to change at line 2003
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).submat(row_span, col_span); return (*this).submat(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
arma_inline arma_inline
subview_elem1<eT,T1> subview_elem1<eT,T1>
Mat<eT>::elem(const Base<u32,T1>& a) Mat<eT>::elem(const Base<uword,T1>& a)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a); return subview_elem1<eT,T1>(*this, a);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
arma_inline arma_inline
const subview_elem1<eT,T1> const subview_elem1<eT,T1>
Mat<eT>::elem(const Base<u32,T1>& a) const Mat<eT>::elem(const Base<uword,T1>& a) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a); return subview_elem1<eT,T1>(*this, a);
} }
// template<typename eT> // template<typename eT>
// template<typename T1, typename T2> // template<typename T1, typename T2>
// arma_inline // arma_inline
// subview_elem2<eT,T1,T2> // subview_elem2<eT,T1,T2>
// Mat<eT>::elem(const Base<u32,T1>& a, const Base<u32,T2>& b) // Mat<eT>::elem(const Base<uword,T1>& a, const Base<uword,T2>& b)
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// return subview_elem2<eT,T1,T2>(*this, a, b); // return subview_elem2<eT,T1,T2>(*this, a, b);
// } // }
// //
// //
// //
// template<typename eT> // template<typename eT>
// template<typename T1, typename T2> // template<typename T1, typename T2>
// arma_inline // arma_inline
// const subview_elem2<eT,T1,T2> // const subview_elem2<eT,T1,T2>
// Mat<eT>::elem(const Base<u32,T1>& a, const Base<u32,T2>& b) const // Mat<eT>::elem(const Base<uword,T1>& a, const Base<uword,T2>& b) const
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// return subview_elem2<eT,T1,T2>(*this, a, b); // return subview_elem2<eT,T1,T2>(*this, a, b);
// } // }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT> diagview<eT>
Mat<eT>::diag(const s32 in_id) Mat<eT>::diag(const sword in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; const uword row_offset = (in_id < 0) ? uword(-in_id) : 0;
const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; const uword col_offset = (in_id > 0) ? uword( in_id) : 0;
arma_debug_check arma_debug_check
( (
((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)), ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)),
"Mat::diag(): requested diagonal out of bounds" "Mat::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const uword len = (std::min)(n_rows - row_offset, n_cols - col_offset);
return diagview<eT>(*this, row_offset, col_offset, len); return diagview<eT>(*this, row_offset, col_offset, len);
} }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
arma_inline arma_inline
const diagview<eT> const diagview<eT>
Mat<eT>::diag(const s32 in_id) const Mat<eT>::diag(const sword in_id) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0; const uword row_offset = (in_id < 0) ? -in_id : 0;
const u32 col_offset = (in_id > 0) ? in_id : 0; const uword col_offset = (in_id > 0) ? in_id : 0;
arma_debug_check arma_debug_check
( (
((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)), ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)),
"Mat::diag(): requested diagonal out of bounds" "Mat::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const uword len = (std::min)(n_rows - row_offset, n_cols - col_offset);
return diagview<eT>(*this, row_offset, col_offset, len); return diagview<eT>(*this, row_offset, col_offset, len);
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2) Mat<eT>::swap_rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 >= n_rows) || (in_row2 >= n_rows), (in_row1 >= n_rows) || (in_row2 >= n_rows),
"Mat::swap_rows(): out of bounds" "Mat::swap_rows(): out of bounds"
); );
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
const u32 offset = col*n_rows; const uword offset = col*n_rows;
const u32 pos1 = in_row1 + offset; const uword pos1 = in_row1 + offset;
const u32 pos2 = in_row2 + offset; const uword pos2 = in_row2 + offset;
const eT tmp = mem[pos1]; const eT tmp = mem[pos1];
access::rw(mem[pos1]) = mem[pos2]; access::rw(mem[pos1]) = mem[pos2];
access::rw(mem[pos2]) = tmp; access::rw(mem[pos2]) = tmp;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::swap_cols(const u32 in_col1, const u32 in_col2) Mat<eT>::swap_cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 >= n_cols) || (in_col2 >= n_cols), (in_col1 >= n_cols) || (in_col2 >= n_cols),
"Mat::swap_cols(): out of bounds" "Mat::swap_cols(): out of bounds"
); );
if(n_elem > 0) if(n_elem > 0)
{ {
eT* ptr1 = colptr(in_col1); eT* ptr1 = colptr(in_col1);
eT* ptr2 = colptr(in_col2); eT* ptr2 = colptr(in_col2);
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
const eT tmp = ptr1[row]; const eT tmp = ptr1[row];
ptr1[row] = ptr2[row]; ptr1[row] = ptr2[row];
ptr2[row] = tmp; ptr2[row] = tmp;
} }
} }
} }
//! remove specified row //! remove specified row
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::shed_row(const u32 row_num) Mat<eT>::shed_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "Mat::shed_row(): out of bounds"); arma_debug_check( row_num >= n_rows, "Mat::shed_row(): out of bounds");
shed_rows(row_num, row_num); shed_rows(row_num, row_num);
} }
//! remove specified column //! remove specified column
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::shed_col(const u32 col_num) Mat<eT>::shed_col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "Mat::shed_col(): out of bounds"); arma_debug_check( col_num >= n_cols, "Mat::shed_col(): out of bounds");
shed_cols(col_num, col_num); shed_cols(col_num, col_num);
} }
//! remove specified rows //! remove specified rows
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::shed_rows(const u32 in_row1, const u32 in_row2) Mat<eT>::shed_rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"Mat::shed_rows(): indices out of bounds or incorrectly used" "Mat::shed_rows(): indices out of bounds or incorrectly used"
); );
const u32 n_keep_front = in_row1; const uword n_keep_front = in_row1;
const u32 n_keep_back = n_rows - (in_row2 + 1); const uword n_keep_back = n_rows - (in_row2 + 1);
Mat<eT> X(n_keep_front + n_keep_back, n_cols); Mat<eT> X(n_keep_front + n_keep_back, n_cols);
if(n_keep_front > 0) if(n_keep_front > 0)
{ {
X.rows( 0, (n_keep_front-1) ) = rows( 0, (in_row1-1) ); X.rows( 0, (n_keep_front-1) ) = rows( 0, (in_row1-1) );
} }
if(n_keep_back > 0) if(n_keep_back > 0)
{ {
X.rows( n_keep_front, (n_keep_front+n_keep_back-1) ) = rows( (in_row2+ 1), (n_rows-1) ); X.rows( n_keep_front, (n_keep_front+n_keep_back-1) ) = rows( (in_row2+ 1), (n_rows-1) );
} }
steal_mem(X); steal_mem(X);
} }
//! remove specified columns //! remove specified columns
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::shed_cols(const u32 in_col1, const u32 in_col2) Mat<eT>::shed_cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"Mat::shed_cols(): indices out of bounds or incorrectly used" "Mat::shed_cols(): indices out of bounds or incorrectly used"
); );
const u32 n_keep_front = in_col1; const uword n_keep_front = in_col1;
const u32 n_keep_back = n_cols - (in_col2 + 1); const uword n_keep_back = n_cols - (in_col2 + 1);
Mat<eT> X(n_rows, n_keep_front + n_keep_back); Mat<eT> X(n_rows, n_keep_front + n_keep_back);
if(n_keep_front > 0) if(n_keep_front > 0)
{ {
X.cols( 0, (n_keep_front-1) ) = cols( 0, (in_col1-1) ); X.cols( 0, (n_keep_front-1) ) = cols( 0, (in_col1-1) );
} }
if(n_keep_back > 0) if(n_keep_back > 0)
{ {
skipping to change at line 2121 skipping to change at line 2237
} }
steal_mem(X); steal_mem(X);
} }
//! insert N rows at the specified row position, //! insert N rows at the specified row position,
//! optionally setting the elements of the inserted rows to zero //! optionally setting the elements of the inserted rows to zero
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::insert_rows(const u32 row_num, const u32 N, const bool set_to_zero ) Mat<eT>::insert_rows(const uword row_num, const uword N, const bool set_to_ zero)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 t_n_rows = n_rows; const uword t_n_rows = n_rows;
const u32 t_n_cols = n_cols; const uword t_n_cols = n_cols;
const u32 A_n_rows = row_num; const uword A_n_rows = row_num;
const u32 B_n_rows = t_n_rows - row_num; const uword B_n_rows = t_n_rows - row_num;
// insertion at row_num == n_rows is in effect an append operation // insertion at row_num == n_rows is in effect an append operation
arma_debug_check( (row_num > t_n_rows), "Mat::insert_rows(): out of bound s"); arma_debug_check( (row_num > t_n_rows), "Mat::insert_rows(): out of bound s");
if(N > 0) if(N > 0)
{ {
Mat<eT> out(t_n_rows + N, t_n_cols); Mat<eT> out(t_n_rows + N, t_n_cols);
if(A_n_rows > 0) if(A_n_rows > 0)
{ {
skipping to change at line 2162 skipping to change at line 2278
steal_mem(out); steal_mem(out);
} }
} }
//! insert N columns at the specified column position, //! insert N columns at the specified column position,
//! optionally setting the elements of the inserted columns to zero //! optionally setting the elements of the inserted columns to zero
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::insert_cols(const u32 col_num, const u32 N, const bool set_to_zero ) Mat<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_ zero)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 t_n_rows = n_rows; const uword t_n_rows = n_rows;
const u32 t_n_cols = n_cols; const uword t_n_cols = n_cols;
const u32 A_n_cols = col_num; const uword A_n_cols = col_num;
const u32 B_n_cols = t_n_cols - col_num; const uword B_n_cols = t_n_cols - col_num;
// insertion at col_num == n_cols is in effect an append operation // insertion at col_num == n_cols is in effect an append operation
arma_debug_check( (col_num > t_n_cols), "Mat::insert_cols(): out of bound s"); arma_debug_check( (col_num > t_n_cols), "Mat::insert_cols(): out of bound s");
if(N > 0) if(N > 0)
{ {
Mat<eT> out(t_n_rows, t_n_cols + N); Mat<eT> out(t_n_rows, t_n_cols + N);
if(A_n_cols > 0) if(A_n_cols > 0)
{ {
skipping to change at line 2204 skipping to change at line 2320
steal_mem(out); steal_mem(out);
} }
} }
//! insert the given object at the specified row position; //! insert the given object at the specified row position;
//! the given object must have the same number of columns as the matrix //! the given object must have the same number of columns as the matrix
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Mat<eT>::insert_rows(const u32 row_num, const Base<eT,T1>& X) Mat<eT>::insert_rows(const uword row_num, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& C = tmp.M; const Mat<eT>& C = tmp.M;
const u32 C_n_rows = C.n_rows; const uword C_n_rows = C.n_rows;
const u32 C_n_cols = C.n_cols; const uword C_n_cols = C.n_cols;
const u32 t_n_rows = n_rows; const uword t_n_rows = n_rows;
const u32 t_n_cols = n_cols; const uword t_n_cols = n_cols;
const u32 A_n_rows = row_num; const uword A_n_rows = row_num;
const u32 B_n_rows = t_n_rows - row_num; const uword B_n_rows = t_n_rows - row_num;
bool err_state = false; bool err_state = false;
char* err_msg = 0; char* err_msg = 0;
// insertion at row_num == n_rows is in effect an append operation // insertion at row_num == n_rows is in effect an append operation
arma_debug_set_error arma_debug_set_error
( (
err_state, err_state,
err_msg, err_msg,
skipping to change at line 2275 skipping to change at line 2391
steal_mem(out); steal_mem(out);
} }
} }
//! insert the given object at the specified column position; //! insert the given object at the specified column position;
//! the given object must have the same number of rows as the matrix //! the given object must have the same number of rows as the matrix
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Mat<eT>::insert_cols(const u32 col_num, const Base<eT,T1>& X) Mat<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& C = tmp.M; const Mat<eT>& C = tmp.M;
const u32 C_n_rows = C.n_rows; const uword C_n_rows = C.n_rows;
const u32 C_n_cols = C.n_cols; const uword C_n_cols = C.n_cols;
const u32 t_n_rows = n_rows; const uword t_n_rows = n_rows;
const u32 t_n_cols = n_cols; const uword t_n_cols = n_cols;
const u32 A_n_cols = col_num; const uword A_n_cols = col_num;
const u32 B_n_cols = t_n_cols - col_num; const uword B_n_cols = t_n_cols - col_num;
bool err_state = false; bool err_state = false;
char* err_msg = 0; char* err_msg = 0;
// insertion at col_num == n_cols is in effect an append operation // insertion at col_num == n_cols is in effect an append operation
arma_debug_set_error arma_debug_set_error
( (
err_state, err_state,
err_msg, err_msg,
skipping to change at line 2340 skipping to change at line 2456
if(C_n_rows > 0) if(C_n_rows > 0)
{ {
out.cols(col_num, col_num + C_n_cols - 1) = C; out.cols(col_num, col_num + C_n_cols - 1) = C;
} }
steal_mem(out); steal_mem(out);
} }
} }
template<typename eT>
template<typename gen_type>
inline
Mat<eT>::Mat(const Gen<eT, gen_type>& X)
: n_rows(X.n_rows)
, n_cols(X.n_cols)
, n_elem(n_rows*n_cols)
, vec_state(0)
, mem_state(0)
, mem()
{
arma_extra_debug_sigprint_this(this);
init_cold();
X.apply(*this);
}
template<typename eT>
template<typename gen_type>
inline
const Mat<eT>&
Mat<eT>::operator=(const Gen<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
init_warm(X.n_rows, X.n_cols);
X.apply(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Mat<eT>&
Mat<eT>::operator+=(const Gen<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_plus(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Mat<eT>&
Mat<eT>::operator-=(const Gen<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_minus(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Mat<eT>&
Mat<eT>::operator*=(const Gen<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
const Mat<eT> tmp(X);
return (*this).operator*=(tmp);
}
template<typename eT>
template<typename gen_type>
inline
const Mat<eT>&
Mat<eT>::operator%=(const Gen<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_schur(*this);
return *this;
}
template<typename eT>
template<typename gen_type>
inline
const Mat<eT>&
Mat<eT>::operator/=(const Gen<eT, gen_type>& X)
{
arma_extra_debug_sigprint();
X.apply_inplace_div(*this);
return *this;
}
//! create a matrix from Op, i.e. run the previously delayed unary operatio ns //! create a matrix from Op, i.e. run the previously delayed unary operatio ns
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Mat<eT>::Mat(const Op<T1, op_type>& X) Mat<eT>::Mat(const Op<T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! create a matrix from Op, i.e. run the previously delayed unary operatio ns //! create a matrix from Op, i.e. run the previously delayed unary operatio ns
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const Op<T1, op_type>& X) Mat<eT>::operator=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
op_type::apply(*this, X); op_type::apply(*this, X);
return *this; return *this;
} }
//! in-place matrix addition, with the right-hand-side operand having delay ed operations //! in-place matrix addition, with the right-hand-side operand having delay ed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Op<T1, op_type>& X) Mat<eT>::operator+=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place matrix subtraction, with the right-hand-side operand having de layed operations //! in-place matrix subtraction, with the right-hand-side operand having de layed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Op<T1, op_type>& X) Mat<eT>::operator-=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place matrix multiplication, with the right-hand-side operand having delayed operations //! in-place matrix multiplication, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const Op<T1, op_type>& X) Mat<eT>::operator*=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix element-wise multiplication, with the right-hand-side o perand having delayed operations //! in-place matrix element-wise multiplication, with the right-hand-side o perand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const Op<T1, op_type>& X) Mat<eT>::operator%=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place matrix element-wise division, with the right-hand-side operand having delayed operations //! in-place matrix element-wise division, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const Op<T1, op_type>& X) Mat<eT>::operator/=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! create a matrix from eOp, i.e. run the previously delayed unary operati ons //! create a matrix from eOp, i.e. run the previously delayed unary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
Mat<eT>::Mat(const eOp<T1, eop_type>& X) Mat<eT>::Mat(const eOp<T1, eop_type>& X)
: n_rows(0) : n_rows(X.get_n_rows())
, n_cols(0) , n_cols(X.get_n_cols())
, n_elem(0) , n_elem(X.get_n_elem())
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
init_cold();
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
//! create a matrix from eOp, i.e. run the previously delayed unary operati ons //! create a matrix from eOp, i.e. run the previously delayed unary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eOp<T1, eop_type>& X) Mat<eT>::operator=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const bool bad_alias = (X.P.has_subview && X.P.is_alias(*this)); const bool bad_alias = (X.P.has_subview && X.P.is_alias(*this));
if(bad_alias == false) if(bad_alias == false)
{ {
init_warm(X.get_n_rows(), X.get_n_cols());
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
else else
{ {
Mat<eT> tmp(X); Mat<eT> tmp(X);
steal_mem(tmp); steal_mem(tmp);
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const eOp<T1, eop_type>& X) Mat<eT>::operator+=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_plus(*this, X); eop_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const eOp<T1, eop_type>& X) Mat<eT>::operator-=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_minus(*this, X); eop_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const eOp<T1, eop_type>& X) Mat<eT>::operator*=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const eOp<T1, eop_type>& X) Mat<eT>::operator%=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_schur(*this, X); eop_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const eOp<T1, eop_type>& X) Mat<eT>::operator/=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply(); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
eop_type::apply_inplace_div(*this, X); eop_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Mat<eT>::Mat(const mtOp<eT, T1, op_type>& X) Mat<eT>::Mat(const mtOp<eT, T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
skipping to change at line 2690 skipping to change at line 2905
//! create a matrix from Glue, i.e. run the previously delayed binary opera tions //! create a matrix from Glue, i.e. run the previously delayed binary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Mat<eT>::Mat(const Glue<T1, T2, glue_type>& X) Mat<eT>::Mat(const Glue<T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
glue_type::apply(*this, X); glue_type::apply(*this, X);
} }
//! create a matrix from Glue, i.e. run the previously delayed binary opera tions //! create a matrix from Glue, i.e. run the previously delayed binary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
glue_type::apply(*this, X); glue_type::apply(*this, X);
return *this; return *this;
} }
//! in-place matrix addition, with the right-hand-side operands having dela yed operations //! in-place matrix addition, with the right-hand-side operands having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator+=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place matrix subtraction, with the right-hand-side operands having d elayed operations //! in-place matrix subtraction, with the right-hand-side operands having d elayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator-=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place matrix multiplications, with the right-hand-side operands havi ng delayed operations //! in-place matrix multiplications, with the right-hand-side operands havi ng delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator*=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix element-wise multiplication, with the right-hand-side o perands having delayed operations //! in-place matrix element-wise multiplication, with the right-hand-side o perands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator%=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place matrix element-wise division, with the right-hand-side operand s having delayed operations //! in-place matrix element-wise division, with the right-hand-side operand s having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator/=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Glue<T1, T2, glue_times>& X) Mat<eT>::operator+=(const Glue<T1, T2, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
glue_times::apply_inplace_plus(*this, X, s32(+1)); glue_times::apply_inplace_plus(*this, X, sword(+1));
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Glue<T1, T2, glue_times>& X) Mat<eT>::operator-=(const Glue<T1, T2, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
glue_times::apply_inplace_plus(*this, X, s32(-1)); glue_times::apply_inplace_plus(*this, X, sword(-1));
return *this; return *this;
} }
//! create a matrix from eGlue, i.e. run the previously delayed binary oper ations //! create a matrix from eGlue, i.e. run the previously delayed binary oper ations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
Mat<eT>::Mat(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::Mat(const eGlue<T1, T2, eglue_type>& X)
: n_rows(0) : n_rows(X.get_n_rows())
, n_cols(0) , n_cols(X.get_n_cols())
, n_elem(0) , n_elem(X.get_n_elem())
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
init_cold();
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
} }
//! create a matrix from eGlue, i.e. run the previously delayed binary oper ations //! create a matrix from eGlue, i.e. run the previously delayed binary oper ations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
const bool bad_alias = ( (X.P1.has_subview && X.P1.is_alias(*this)) || ( X.P2.has_subview && X.P2.is_alias(*this)) ); const bool bad_alias = ( (X.P1.has_subview && X.P1.is_alias(*this)) || ( X.P2.has_subview && X.P2.is_alias(*this)) );
if(bad_alias == false) if(bad_alias == false)
{ {
init_warm(X.get_n_rows(), X.get_n_cols());
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
} }
else else
{ {
Mat<eT> tmp(X); Mat<eT> tmp(X);
steal_mem(tmp); steal_mem(tmp);
} }
return *this; return *this;
skipping to change at line 2887 skipping to change at line 3104
//! in-place matrix addition, with the right-hand-side operands having dela yed operations //! in-place matrix addition, with the right-hand-side operands having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator+=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_plus(*this, X); eglue_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
//! in-place matrix subtraction, with the right-hand-side operands having d elayed operations //! in-place matrix subtraction, with the right-hand-side operands having d elayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator-=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_minus(*this, X); eglue_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator*=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator%=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_schur(*this, X); eglue_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator/=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
se >::apply(); lse ));
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa
se >::apply(); lse ));
eglue_type::apply_inplace_div(*this, X); eglue_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL: create a matrix from mtGlue, i.e. run the previously dela yed binary operations //! EXPERIMENTAL: create a matrix from mtGlue, i.e. run the previously dela yed binary operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X) Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) , mem()
, mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
glue_type::apply(*this, X); glue_type::apply(*this, X);
} }
//! EXPERIMENTAL: create a matrix from Glue, i.e. run the previously delaye d binary operations //! EXPERIMENTAL: create a matrix from Glue, i.e. run the previously delaye d binary operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
skipping to change at line 3066 skipping to change at line 3282
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::operator() (const u32 i) Mat<eT>::operator() (const uword i)
{ {
arma_debug_check( (i >= n_elem), "Mat::operator(): out of bounds"); arma_debug_check( (i >= n_elem), "Mat::operator(): out of bounds");
return access::rw(mem[i]); return access::rw(mem[i]);
} }
//! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::operator() (const u32 i) const Mat<eT>::operator() (const uword i) const
{ {
arma_debug_check( (i >= n_elem), "Mat::operator(): out of bounds"); arma_debug_check( (i >= n_elem), "Mat::operator(): out of bounds");
return mem[i]; return mem[i];
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k. //! linear element accessor (treats the matrix as a vector); no bounds chec k.
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::operator[] (const u32 i) Mat<eT>::operator[] (const uword i)
{ {
return access::rw(mem[i]); return access::rw(mem[i]);
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k //! linear element accessor (treats the matrix as a vector); no bounds chec k
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::operator[] (const u32 i) const Mat<eT>::operator[] (const uword i) const
{ {
return mem[i]; return mem[i];
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k. //! linear element accessor (treats the matrix as a vector); no bounds chec k.
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::at(const u32 i) Mat<eT>::at(const uword i)
{ {
return access::rw(mem[i]); return access::rw(mem[i]);
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k //! linear element accessor (treats the matrix as a vector); no bounds chec k
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::at(const u32 i) const Mat<eT>::at(const uword i) const
{ {
return mem[i]; return mem[i];
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::operator() (const u32 in_row, const u32 in_col) Mat<eT>::operator() (const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "Mat::opera tor(): out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "Mat::opera tor(): out of bounds");
return access::rw(mem[in_row + in_col*n_rows]); return access::rw(mem[in_row + in_col*n_rows]);
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::operator() (const u32 in_row, const u32 in_col) const Mat<eT>::operator() (const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "Mat::opera tor(): out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "Mat::opera tor(): out of bounds");
return mem[in_row + in_col*n_rows]; return mem[in_row + in_col*n_rows];
} }
//! element accessor; no bounds check //! element accessor; no bounds check
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::at(const u32 in_row, const u32 in_col) Mat<eT>::at(const uword in_row, const uword in_col)
{ {
return access::rw( mem[in_row + in_col*n_rows] ); return access::rw( mem[in_row + in_col*n_rows] );
} }
//! element accessor; no bounds check //! element accessor; no bounds check
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::at(const u32 in_row, const u32 in_col) const Mat<eT>::at(const uword in_row, const uword in_col) const
{ {
return mem[in_row + in_col*n_rows]; return mem[in_row + in_col*n_rows];
} }
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator++() Mat<eT>::operator++()
{ {
skipping to change at line 3268 skipping to change at line 3484
Mat<eT>::is_finite() const Mat<eT>::is_finite() const
{ {
return arrayops::is_finite( memptr(), n_elem ); return arrayops::is_finite( memptr(), n_elem );
} }
//! returns true if the given index is currently in range //! returns true if the given index is currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const u32 i) const Mat<eT>::in_range(const uword i) const
{ {
return (i < n_elem); return (i < n_elem);
} }
//! returns true if the given start and end indices are currently in range //! returns true if the given start and end indices are currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const span& x) const Mat<eT>::in_range(const span& x) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(x.whole == true) if(x.whole == true)
{ {
return true; return true;
} }
else else
{ {
const u32 a = x.a; const uword a = x.a;
const u32 b = x.b; const uword b = x.b;
return ( (a <= b) && (b < n_elem) ); return ( (a <= b) && (b < n_elem) );
} }
} }
//! returns true if the given location is currently in range //! returns true if the given location is currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const u32 in_row, const u32 in_col) const Mat<eT>::in_range(const uword in_row, const uword in_col) const
{ {
return ( (in_row < n_rows) && (in_col < n_cols) ); return ( (in_row < n_rows) && (in_col < n_cols) );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const span& row_span, const u32 in_col) const Mat<eT>::in_range(const span& row_span, const uword in_col) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(row_span.whole == true) if(row_span.whole == true)
{ {
return (in_col < n_cols); return (in_col < n_cols);
} }
else else
{ {
const u32 in_row1 = row_span.a; const uword in_row1 = row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
return ( (in_row1 <= in_row2) && (in_row2 < n_rows) && (in_col < n_cols ) ); return ( (in_row1 <= in_row2) && (in_row2 < n_rows) && (in_col < n_cols ) );
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const u32 in_row, const span& col_span) const Mat<eT>::in_range(const uword in_row, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(col_span.whole == true) if(col_span.whole == true)
{ {
return (in_row < n_rows); return (in_row < n_rows);
} }
else else
{ {
const u32 in_col1 = col_span.a; const uword in_col1 = col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
return ( (in_row < n_rows) && (in_col1 <= in_col2) && (in_col2 < n_cols ) ); return ( (in_row < n_rows) && (in_col1 <= in_col2) && (in_col2 < n_cols ) );
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const span& row_span, const span& col_span) const Mat<eT>::in_range(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a; const uword in_row1 = row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 in_col1 = col_span.a; const uword in_col1 = col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) );
return ( (rows_ok == true) && (cols_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) );
} }
//! returns a pointer to array of eTs for a specified column; no bounds che ck //! returns a pointer to array of eTs for a specified column; no bounds che ck
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Mat<eT>::colptr(const u32 in_col) Mat<eT>::colptr(const uword in_col)
{ {
return & access::rw(mem[in_col*n_rows]); return & access::rw(mem[in_col*n_rows]);
} }
//! returns a pointer to array of eTs for a specified column; no bounds che ck //! returns a pointer to array of eTs for a specified column; no bounds che ck
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const eT* const eT*
Mat<eT>::colptr(const u32 in_col) const Mat<eT>::colptr(const uword in_col) const
{ {
return & mem[in_col*n_rows]; return & mem[in_col*n_rows];
} }
//! returns a pointer to array of eTs used by the matrix //! returns a pointer to array of eTs used by the matrix
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Mat<eT>::memptr() Mat<eT>::memptr()
skipping to change at line 3414 skipping to change at line 3630
return mem; return mem;
} }
//! print contents of the matrix (to the cout stream), //! print contents of the matrix (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print(const std::string extra_text) const Mat<eT>::impl_print(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = cout.width(); const std::streamsize orig_width = cout.width();
cout << extra_text << '\n'; cout << extra_text << '\n';
cout.width(orig_width); cout.width(orig_width);
skipping to change at line 3437 skipping to change at line 3653
arma_ostream::print(cout, *this, true); arma_ostream::print(cout, *this, true);
} }
//! print contents of the matrix to a user specified stream, //! print contents of the matrix to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print(std::ostream& user_stream, const std::string extra_text) con st Mat<eT>::impl_print(std::ostream& user_stream, const std::string& extra_tex t) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = user_stream.width(); const std::streamsize orig_width = user_stream.width();
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
user_stream.width(orig_width); user_stream.width(orig_width);
} }
arma_ostream::print(user_stream, *this, true); arma_ostream::print(user_stream, *this, true);
} }
//! print contents of the transposed version of the matrix (to the cout str //! DEPRECATED FUNCTION
eam),
//! optionally preceding with a user specified line of text.
//! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print_trans(const std::string extra_text) const Mat<eT>::impl_print_trans(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.print(extra_text); tmp.impl_print(extra_text);
} }
//! print contents of the transposed version of matrix to a user specified //! DEPRECATED FUNCTION
stream,
//! optionally preceding with a user specified line of text.
//! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print_trans(std::ostream& user_stream, const std::string extra_tex t) const Mat<eT>::impl_print_trans(std::ostream& user_stream, const std::string& ext ra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.print(user_stream, extra_text); tmp.impl_print(user_stream, extra_text);
} }
//! print contents of the matrix (to the cout stream), //! print contents of the matrix (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified //! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print(const std::string extra_text) const Mat<eT>::impl_raw_print(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = cout.width(); const std::streamsize orig_width = cout.width();
cout << extra_text << '\n'; cout << extra_text << '\n';
cout.width(orig_width); cout.width(orig_width);
skipping to change at line 3517 skipping to change at line 3727
arma_ostream::print(cout, *this, false); arma_ostream::print(cout, *this, false);
} }
//! print contents of the matrix to a user specified stream, //! print contents of the matrix to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified. //! the stream's state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print(std::ostream& user_stream, const std::string extra_text) const Mat<eT>::impl_raw_print(std::ostream& user_stream, const std::string& extra _text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = user_stream.width(); const std::streamsize orig_width = user_stream.width();
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
user_stream.width(orig_width); user_stream.width(orig_width);
} }
arma_ostream::print(user_stream, *this, false); arma_ostream::print(user_stream, *this, false);
} }
//! print contents of the transposed version of the matrix (to the cout str //! DEPRECATED FUNCTION
eam),
//! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print_trans(const std::string extra_text) const Mat<eT>::impl_raw_print_trans(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.raw_print(extra_text); tmp.impl_raw_print(extra_text);
} }
//! print contents of the transposed version of the matrix to a user specif //! DEPRECATED FUNCTION
ied stream,
//! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print_trans(std::ostream& user_stream, const std::string extra _text) const Mat<eT>::impl_raw_print_trans(std::ostream& user_stream, const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.raw_print(user_stream, extra_text); tmp.impl_raw_print(user_stream, extra_text);
} }
//! change the matrix to have user specified dimensions (data is not preser ved) //! change the matrix to have user specified dimensions (data is not preser ved)
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::set_size(const u32 in_elem) Mat<eT>::set_size(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(vec_state) switch(vec_state)
{ {
case 0: case 0:
case 1: case 1:
init(in_elem, 1); init_warm(in_elem, 1);
break; break;
case 2: case 2:
init(1, in_elem); init_warm(1, in_elem);
break; break;
default: default:
; ;
} }
} }
//! change the matrix to have user specified dimensions (data is not preser ved) //! change the matrix to have user specified dimensions (data is not preser ved)
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::set_size(const u32 in_rows, const u32 in_cols) Mat<eT>::set_size(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(in_rows, in_cols); init_warm(in_rows, in_cols);
} }
//! change the matrix to have user specified dimensions (data is preserved) //! change the matrix to have user specified dimensions (data is preserved)
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::reshape(const u32 in_rows, const u32 in_cols, const u32 dim) Mat<eT>::reshape(const uword in_rows, const uword in_cols, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
*this = arma::reshape(*this, in_rows, in_cols, dim); *this = arma::reshape(*this, in_rows, in_cols, dim);
} }
//! change the matrix (without preserving data) to have the same dimensions as the given matrix //! change the matrix (without preserving data) to have the same dimensions as the given matrix
template<typename eT> template<typename eT>
template<typename eT2> template<typename eT2>
inline inline
void void
Mat<eT>::copy_size(const Mat<eT2>& m) Mat<eT>::copy_size(const Mat<eT2>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(m.n_rows, m.n_cols); init_warm(m.n_rows, m.n_cols);
} }
//! fill the matrix with the specified value //! fill the matrix with the specified value
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fill(const eT val) Mat<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 3652 skipping to change at line 3856
Mat<eT>::zeros() Mat<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return fill(eT(0)); return fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::zeros(const u32 in_elem) Mat<eT>::zeros(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_elem); set_size(in_elem);
return fill(eT(0)); return fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::zeros(const u32 in_rows, const u32 in_cols) Mat<eT>::zeros(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
return fill(eT(0)); return fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
skipping to change at line 3686 skipping to change at line 3890
Mat<eT>::ones() Mat<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return fill(eT(1)); return fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::ones(const u32 in_elem) Mat<eT>::ones(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_elem); set_size(in_elem);
return fill(eT(1)); return fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::ones(const u32 in_rows, const u32 in_cols) Mat<eT>::ones(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
return fill(eT(1)); return fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu() Mat<eT>::randu()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 N = n_elem; const uword N = n_elem;
eT* ptr = memptr(); eT* ptr = memptr();
u32 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)
{ {
ptr[i] = eT(eop_aux_randu<eT>()); const eT tmp_i = eT(eop_aux_randu<eT>());
ptr[j] = eT(eop_aux_randu<eT>()); const eT tmp_j = eT(eop_aux_randu<eT>());
ptr[i] = tmp_i;
ptr[j] = tmp_j;
} }
if(i < N) if(i < N)
{ {
ptr[i] = eT(eop_aux_randu<eT>()); ptr[i] = eT(eop_aux_randu<eT>());
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu(const u32 in_elem) Mat<eT>::randu(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_elem); set_size(in_elem);
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu(const u32 in_rows, const u32 in_cols) Mat<eT>::randu(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn() Mat<eT>::randn()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 N = n_elem; const uword N = n_elem;
eT* ptr = memptr(); eT* ptr = memptr();
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
ptr[i] = eT(eop_aux_randn<eT>()); ptr[i] = eT(eop_aux_randn<eT>());
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn(const u32 in_elem) Mat<eT>::randn(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_elem); set_size(in_elem);
return (*this).randn(); return (*this).randn();
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn(const u32 in_rows, const u32 in_cols) Mat<eT>::randn(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
return (*this).randn(); return (*this).randn();
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::eye() Mat<eT>::eye()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); fill(eT(0));
const u32 N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
at(i,i) = eT(1); at(i,i) = eT(1);
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::eye(const u32 in_rows, const u32 in_cols) Mat<eT>::eye(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
return (*this).eye(); return (*this).eye();
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::reset() Mat<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(vec_state) switch(vec_state)
{ {
default: default:
init(0, 0); init_warm(0, 0);
break; break;
case 1: case 1:
init(0, 1); init_warm(0, 1);
break; break;
case 2: case 2:
init(1, 0); init_warm(1, 0);
break; break;
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Mat<eT>::set_real(const Base<typename Mat<eT>::pod_type,T1>& X) Mat<eT>::set_real(const Base<typename Mat<eT>::pod_type,T1>& X)
{ {
skipping to change at line 3904 skipping to change at line 4111
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
return op_max::direct_max(memptr(), n_elem); return op_max::direct_max(memptr(), n_elem);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Mat<eT>::min(u32& index_of_min_val) const Mat<eT>::min(uword& index_of_min_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "min(): object has no elements" ); arma_debug_check( (n_elem == 0), "min(): object has no elements" );
return op_min::direct_min(memptr(), n_elem, index_of_min_val); return op_min::direct_min(memptr(), n_elem, index_of_min_val);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Mat<eT>::max(u32& index_of_max_val) const Mat<eT>::max(uword& index_of_max_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
return op_max::direct_max(memptr(), n_elem, index_of_max_val); return op_max::direct_max(memptr(), n_elem, index_of_max_val);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Mat<eT>::min(u32& row_of_min_val, u32& col_of_min_val) const Mat<eT>::min(uword& row_of_min_val, uword& col_of_min_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "min(): object has no elements" ); arma_debug_check( (n_elem == 0), "min(): object has no elements" );
u32 i; uword i;
eT val = op_min::direct_min(memptr(), n_elem, i); eT val = op_min::direct_min(memptr(), n_elem, i);
row_of_min_val = i % n_rows; row_of_min_val = i % n_rows;
col_of_min_val = i / n_rows; col_of_min_val = i / n_rows;
return val; return val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Mat<eT>::max(u32& row_of_max_val, u32& col_of_max_val) const Mat<eT>::max(uword& row_of_max_val, uword& col_of_max_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
u32 i; uword i;
eT val = op_max::direct_max(memptr(), n_elem, i); eT val = op_max::direct_max(memptr(), n_elem, i);
row_of_max_val = i % n_rows; row_of_max_val = i % n_rows;
col_of_max_val = i / n_rows; col_of_max_val = i / n_rows;
return val; return val;
} }
//! save the matrix to a file //! save the matrix to a file
skipping to change at line 4233 skipping to change at line 4440
bool bool
Mat<eT>::quiet_load(std::istream& is, const file_type type) Mat<eT>::quiet_load(std::istream& is, const file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).load(is, type, false); return (*this).load(is, type, false);
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::row_iterator::row_iterator(Mat<eT>& in_M, const u32 in_row) Mat<eT>::row_iterator::row_iterator(Mat<eT>& in_M, const uword in_row)
: M (in_M ) : M (in_M )
, row(in_row) , row(in_row)
, col(0 ) , col(0 )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
skipping to change at line 4320 skipping to change at line 4527
template<typename eT> template<typename eT>
inline inline
bool bool
Mat<eT>::row_iterator::operator==(const typename Mat<eT>::row_iterator& X) const Mat<eT>::row_iterator::operator==(const typename Mat<eT>::row_iterator& X) const
{ {
return ( (row == X.row) && (col == X.col) ) ? true : false; return ( (row == X.row) && (col == X.col) ) ? true : false;
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::const_row_iterator::const_row_iterator(const Mat<eT>& in_M, const u32 in_row) Mat<eT>::const_row_iterator::const_row_iterator(const Mat<eT>& in_M, const uword in_row)
: M (in_M ) : M (in_M )
, row(in_row) , row(in_row)
, col(0 ) , col(0 )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::const_row_iterator::const_row_iterator(const typename Mat<eT>::row _iterator& X) Mat<eT>::const_row_iterator::const_row_iterator(const typename Mat<eT>::row _iterator& X)
skipping to change at line 4458 skipping to change at line 4665
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>::col_iterator typename Mat<eT>::col_iterator
Mat<eT>::begin_col(const u32 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);
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::const_col_iterator typename Mat<eT>::const_col_iterator
Mat<eT>::begin_col(const u32 col_num) const Mat<eT>::begin_col(const uword col_num) const
{ {
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);
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::col_iterator typename Mat<eT>::col_iterator
Mat<eT>::end_col(const u32 col_num) Mat<eT>::end_col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (col_num >= n_cols), "end_col(): index out of bounds"); arma_debug_check( (col_num >= n_cols), "end_col(): index out of bounds");
return colptr(col_num) + n_rows; return colptr(col_num) + n_rows;
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::const_col_iterator typename Mat<eT>::const_col_iterator
Mat<eT>::end_col(const u32 col_num) const Mat<eT>::end_col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (col_num >= n_cols), "end_col(): index out of bounds"); arma_debug_check( (col_num >= n_cols), "end_col(): index out of bounds");
return colptr(col_num) + n_rows; return colptr(col_num) + n_rows;
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::row_iterator typename Mat<eT>::row_iterator
Mat<eT>::begin_row(const u32 row_num) Mat<eT>::begin_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "Mat::begin_row(): index out of bo unds" ); arma_debug_check( (row_num >= n_rows), "Mat::begin_row(): index out of bo unds" );
return typename Mat<eT>::row_iterator(*this, row_num); return typename Mat<eT>::row_iterator(*this, row_num);
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::const_row_iterator typename Mat<eT>::const_row_iterator
Mat<eT>::begin_row(const u32 row_num) const Mat<eT>::begin_row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "Mat::begin_row(): index out of bo unds" ); arma_debug_check( (row_num >= n_rows), "Mat::begin_row(): index out of bo unds" );
return typename Mat<eT>::const_row_iterator(*this, row_num); return typename Mat<eT>::const_row_iterator(*this, row_num);
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::row_iterator typename Mat<eT>::row_iterator
Mat<eT>::end_row(const u32 row_num) Mat<eT>::end_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "Mat::end_row(): index out of boun ds" ); arma_debug_check( (row_num >= n_rows), "Mat::end_row(): index out of boun ds" );
return typename Mat<eT>::row_iterator(*this, row_num + 1); return typename Mat<eT>::row_iterator(*this, row_num + 1);
} }
template<typename eT> template<typename eT>
inline inline
typename Mat<eT>::const_row_iterator typename Mat<eT>::const_row_iterator
Mat<eT>::end_row(const u32 row_num) const Mat<eT>::end_row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "Mat::end_row(): index out of boun ds" ); arma_debug_check( (row_num >= n_rows), "Mat::end_row(): index out of boun ds" );
return typename Mat<eT>::const_row_iterator(*this, row_num + 1); return typename Mat<eT>::const_row_iterator(*this, row_num + 1);
} }
//! resets this matrix to an empty matrix //! resets this matrix to an empty matrix
template<typename eT> template<typename eT>
skipping to change at line 4572 skipping to change at line 4779
inline inline
bool bool
Mat<eT>::empty() const Mat<eT>::empty() const
{ {
return (n_elem == 0); return (n_elem == 0);
} }
//! returns the number of elements in this matrix //! returns the number of elements in this matrix
template<typename eT> template<typename eT>
inline inline
u32 uword
Mat<eT>::size() const Mat<eT>::size() const
{ {
return n_elem; return n_elem;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
void void
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::mem_setup() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::mem_setup()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = fixed_n_rows; access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols; access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem; access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0; access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3; access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : mem_loca l; access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : mem_loca l;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const fixed<fixed_n_rows, fixed_n_cols>& X) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const fixed<fixed_n_rows, fixed_n_cols>& X)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
eT* dest = (use_extra) ? mem_local_extra : mem_local; eT* dest = (use_extra) ? mem_local_extra : mem_local;
arrayops::copy( dest, X.mem, fixed_n_elem ); arrayops::copy( dest, X.mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
template<typename T1> template<typename T1>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const Base<eT,T1>& A) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const Base<eT,T1>& A)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Mat<eT>::operator=(A.get_ref()); Mat<eT>::operator=(A.get_ref());
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Mat<eT>::init(A,B); Mat<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(eT* aux_mem, const bool c opy_aux_mem) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(eT* aux_mem, const bool c opy_aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
access::rw(Mat<eT>::n_rows) = fixed_n_rows; access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols; access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem; access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0; access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3; access::rw(Mat<eT>::mem_state) = 3;
skipping to change at line 4672 skipping to change at line 4879
arrayops::copy( dest, aux_mem, fixed_n_elem ); arrayops::copy( dest, aux_mem, fixed_n_elem );
} }
else else
{ {
access::rw(Mat<eT>::mem) = aux_mem; access::rw(Mat<eT>::mem) = aux_mem;
} }
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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 eT* aux_mem) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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 char* text) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const char* text)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
template<typename T1> template<typename T1>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const Base<eT,T1>& A) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const Base<eT,T1>& A)
{ {
Mat<eT>::operator=(A.get_ref()); Mat<eT>::operator=(A.get_ref());
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const eT val) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(val); Mat<eT>::operator=(val);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const char* text) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::string& te xt) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::string& te xt)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
subview_row<eT> subview_row<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const u32 row_num, c onst span& col_span) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const uword row_num, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); return Mat<eT>::operator()(row_num, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const subview_row<eT> const subview_row<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const u32 row_num, c onst span& col_span) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const uword row_num, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); return Mat<eT>::operator()(row_num, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
subview_col<eT> subview_col<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const u32 col_num) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); return Mat<eT>::operator()(row_span, col_num);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const subview_col<eT> const subview_col<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const u32 col_num) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); return Mat<eT>::operator()(row_span, col_num);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
subview<eT> subview<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const span& col_span) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const subview<eT> const subview<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const span& col_span) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span , const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::operator[] (const u32 i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::operator[] (const u32 i) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword i) cons t
{ {
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::at(const u32 i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::at(const u32 i) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::operator() (const u32 i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword i)
{ {
arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo unds");
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::operator() (const u32 i) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword i) cons t
{ {
arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo unds");
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::at(const u32 in_row, const u32 in_col) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col)
{ {
const u32 i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::at(const u32 in_row, const u32 in_col) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col) const
{ {
const u32 i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::operator() (const u32 in_row, c onst u32 in_col) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::fixed::operator(): out of bounds"); arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::fixed::operator(): out of bounds");
const u32 i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 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>::operator() (const u32 in_row, c onst u32 in_col) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::fixed::operator(): out of bounds"); arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::fixed::operator(): out of bounds");
const u32 i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> 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();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) ; arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) ;
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> 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>::zeros() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem ); arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> 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>::ones() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem ); arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem );
return *this; return *this;
} }
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::prefix_pp(Mat<eT>& x) Mat_aux::prefix_pp(Mat<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
++(memptr[i]); ++(memptr[i]);
++(memptr[j]); ++(memptr[j]);
} }
if(i < n_elem) if(i < n_elem)
{ {
++(memptr[i]); ++(memptr[i]);
skipping to change at line 5020 skipping to change at line 5227
{ {
x += T(1); x += T(1);
} }
//! postfix ++ //! postfix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::postfix_pp(Mat<eT>& x) Mat_aux::postfix_pp(Mat<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
(memptr[i])++; (memptr[i])++;
(memptr[j])++; (memptr[j])++;
} }
if(i < n_elem) if(i < n_elem)
{ {
(memptr[i])++; (memptr[i])++;
skipping to change at line 5052 skipping to change at line 5259
{ {
x += T(1); x += T(1);
} }
//! prefix -- //! prefix --
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::prefix_mm(Mat<eT>& x) Mat_aux::prefix_mm(Mat<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
--(memptr[i]); --(memptr[i]);
--(memptr[j]); --(memptr[j]);
} }
if(i < n_elem) if(i < n_elem)
{ {
--(memptr[i]); --(memptr[i]);
skipping to change at line 5084 skipping to change at line 5291
{ {
x -= T(1); x -= T(1);
} }
//! postfix -- //! postfix --
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::postfix_mm(Mat<eT>& x) Mat_aux::postfix_mm(Mat<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const uword n_elem = x.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
(memptr[i])--; (memptr[i])--;
(memptr[j])--; (memptr[j])--;
} }
if(i < n_elem) if(i < n_elem)
{ {
(memptr[i])--; (memptr[i])--;
skipping to change at line 5147 skipping to change at line 5354
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
arma_debug_assert_same_size( out, A, "Mat::set_real()" ); arma_debug_assert_same_size( out, A, "Mat::set_real()" );
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
//out_mem[i].real() = PA[i]; //out_mem[i].real() = PA[i];
out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() ); out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() );
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
Mat_aux::set_imag(Mat< std::complex<T> >& out, const Base<T,T1>& X) Mat_aux::set_imag(Mat< std::complex<T> >& out, const Base<T,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
arma_debug_assert_same_size( out, A, "Mat::set_imag()" ); arma_debug_assert_same_size( out, A, "Mat::set_imag()" );
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
//out_mem[i].imag() = PA[i]; //out_mem[i].imag() = PA[i];
out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] ); out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] );
} }
} }
#ifdef ARMA_EXTRA_MAT_MEAT #ifdef ARMA_EXTRA_MAT_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_MEAT)
#endif #endif
 End of changes. 362 change blocks. 
600 lines changed or deleted 811 lines changed or added


 OpCube_bones.hpp   OpCube_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
template<typename T1, typename op_type> template<typename T1, typename op_type>
class OpCube : public BaseCube<typename T1::elem_type, OpCube<T1, op_type> > class OpCube : public BaseCube<typename T1::elem_type, OpCube<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline explicit OpCube(const BaseCube<typename T1::elem_type, T1>& in_m); inline explicit OpCube(const BaseCube<typename T1::elem_type, T1>& in_m);
inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const elem_type in_aux); inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const elem_type in_aux);
inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b); const elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uwor
inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, d_b, const uword in_aux_uword_c);
const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c); inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b);
const elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32_b, con inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
st u32 in_aux_u32_c); const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_
inline OpCube(const u32 in_aux_u32_a, const u32 in_aux_u32_b, co uword_c);
nst u32 in_aux_u32_c); inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_
uword_c, const uword in_aux_uword_d, const char junk);
inline ~OpCube(); inline ~OpCube();
arma_aligned const T1& m; //!< storage of reference to the arma_aligned const T1& m; //!< storage of reference to t
operand (e.g. a cube) he operand (e.g. a cube)
arma_aligned const elem_type aux; //!< storage of auxiliary data, arma_aligned elem_type aux; //!< storage of auxiliary data
user defined format , user defined format
arma_aligned const u32 aux_u32_a; //!< storage of auxiliary data, arma_aligned uword aux_uword_a; //!< storage of auxiliary data
u32 format , uword format
arma_aligned const u32 aux_u32_b; //!< storage of auxiliary data, arma_aligned uword aux_uword_b; //!< storage of auxiliary data
u32 format , uword format
arma_aligned const u32 aux_u32_c; //!< storage of auxiliary data, arma_aligned uword aux_uword_c; //!< storage of auxiliary data
u32 format , uword format
arma_aligned uword aux_uword_d; //!< storage of auxiliary data
, uword format
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
21 lines changed or deleted 25 lines changed or added


 OpCube_meat.hpp   OpCube_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup OpCube //! \addtogroup OpCube
//! @{ //! @{
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m) OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m)
: m(in_m.get_ref()) : m(in_m.get_ref())
, aux(aux) // don't tell mum
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
, aux_u32_c(aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const typename T1::elem_type in_aux) OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const typename T1::elem_type in_aux)
: m(in_m.get_ref()) : m(in_m.get_ref())
, aux(in_aux) , aux(in_aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
, aux_u32_c(aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const u32 in_aux_u32_a, const u32 in_aux_u32_b) OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const typename T1::elem_type in_aux, const uword in_aux_uword_a, const u word in_aux_uword_b, const uword in_aux_uword_c)
: m(in_m.get_ref()) : m(in_m.get_ref())
, aux(aux) , aux(in_aux)
, aux_u32_a(in_aux_u32_a) , aux_uword_a(in_aux_uword_a)
, aux_u32_b(in_aux_u32_b) , aux_uword_b(in_aux_uword_b)
, aux_u32_c(aux_u32_c) , aux_uword_c(in_aux_uword_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c) OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const uword in_aux_uword_a, const uword in_aux_uword_b)
: m(in_m.get_ref()) : m(in_m.get_ref())
, aux(aux) , aux_uword_a(in_aux_uword_a)
, aux_u32_a(in_aux_u32_a) , aux_uword_b(in_aux_uword_b)
, aux_u32_b(in_aux_u32_b)
, aux_u32_c(in_aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u32 i n_aux_u32_b, const u32 in_aux_u32_c) OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_a ux_uword_c)
: m(in_m.get_ref()) : m(in_m.get_ref())
, aux(in_aux) , aux_uword_a(in_aux_uword_a)
, aux_u32_a(in_aux_u32_a) , aux_uword_b(in_aux_uword_b)
, aux_u32_b(in_aux_u32_b) , aux_uword_c(in_aux_uword_c)
, aux_u32_c(in_aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::OpCube(const u32 in_aux_u32_a, const u32 in_aux_u32_b, OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_
const u32 in_aux_u32_c) m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_a
: m(m) ux_uword_c, const uword in_aux_uword_d, const char)
, aux(aux) : m(in_m.get_ref())
, aux_u32_a(in_aux_u32_a) , aux_uword_a(in_aux_uword_a)
, aux_u32_b(in_aux_u32_b) , aux_uword_b(in_aux_uword_b)
, aux_u32_c(in_aux_u32_c) , aux_uword_c(in_aux_uword_c)
, aux_uword_d(in_aux_uword_d)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
OpCube<T1, op_type>::~OpCube() OpCube<T1, op_type>::~OpCube()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
 End of changes. 10 change blocks. 
31 lines changed or deleted 22 lines changed or added


 Op_bones.hpp   Op_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 36 skipping to change at line 36
template<typename T1, typename op_type> template<typename T1, typename op_type>
class Op : public Base<typename T1::elem_type, Op<T1, op_type> > class Op : public Base<typename T1::elem_type, Op<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline explicit Op(const T1& in_m); inline explicit Op(const T1& in_m);
inline Op(const T1& in_m, const elem_type in_aux); inline Op(const T1& in_m, const elem_type in_aux);
inline Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_a inline Op(const T1& in_m, const elem_type in_aux, const
ux_u32_b); uword in_aux_uword_a, const uword in_aux_uword_b);
inline Op(const T1& in_m, const elem_type in_aux, const u32 in_a inline Op(const T1& in_m, const uword in_aux_uword_a, const
ux_u32_a, const u32 in_aux_u32_b); uword in_aux_uword_b);
inline Op(const T1& in_m, const uword in_aux_uword_a, const
uword in_aux_uword_b, const uword in_aux_uword_c, const char junk);
inline ~Op(); inline ~Op();
arma_aligned const T1& m; //!< storage of reference to the arma_aligned const T1& m; //!< storage of reference to t
operand (e.g. a matrix) he operand (eg. a matrix)
arma_aligned const elem_type aux; //!< storage of auxiliary data, arma_aligned elem_type aux; //!< storage of auxiliary data
user defined format , user defined format
arma_aligned const u32 aux_u32_a; //!< storage of auxiliary data, arma_aligned uword aux_uword_a; //!< storage of auxiliary data
u32 format , uword format
arma_aligned const u32 aux_u32_b; //!< storage of auxiliary data, arma_aligned uword aux_uword_b; //!< storage of auxiliary data
u32 format , uword format
arma_aligned uword aux_uword_c; //!< storage of auxiliary data
, uword format
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
14 lines changed or deleted 18 lines changed or added


 Op_meat.hpp   Op_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Op //! \addtogroup Op
//! @{ //! @{
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Op<T1, op_type>::Op(const T1& in_m) Op<T1, op_type>::Op(const T1& in_m)
: m(in_m) : m(in_m)
, aux(aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux) Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux)
: m(in_m) : m(in_m)
, aux(in_aux) , aux(in_aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Op<T1, op_type>::Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_au x_u32_b) Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux, co nst uword in_aux_uword_a, const uword in_aux_uword_b)
: m(in_m) : m(in_m)
, aux(aux) , aux(in_aux)
, aux_u32_a(in_aux_u32_a) , aux_uword_a(in_aux_uword_a)
, aux_u32_b(in_aux_u32_b) , aux_uword_b(in_aux_uword_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux, co nst u32 in_aux_u32_a, const u32 in_aux_u32_b) Op<T1, op_type>::Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b)
: m(in_m) : m(in_m)
, aux(in_aux) , aux_uword_a(in_aux_uword_a)
, aux_u32_a(in_aux_u32_a) , aux_uword_b(in_aux_uword_b)
, aux_u32_b(in_aux_u32_b) {
arma_extra_debug_sigprint();
}
template<typename T1, typename op_type>
inline
Op<T1, op_type>::Op(const T1& in_m, const uword in_aux_uword_a, const uword
in_aux_uword_b, const uword in_aux_uword_c, const char)
: m(in_m)
, aux_uword_a(in_aux_uword_a)
, aux_uword_b(in_aux_uword_b)
, aux_uword_c(in_aux_uword_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Op<T1, op_type>::~Op() Op<T1, op_type>::~Op()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
 End of changes. 7 change blocks. 
15 lines changed or deleted 21 lines changed or added


 Proxy.hpp   Proxy.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup Proxy //! \addtogroup Proxy
//! @{ //! @{
template<typename T1> template<typename T1>
class Proxy class Proxy
{ {
public: public:
inline Proxy(const T1& A) inline Proxy(const T1& A)
{ {
arma_type_check< is_arma_type<T1>::value == false >::apply(); arma_type_check(( is_arma_type<T1>::value == false ));
} }
}; };
// ea_type is the "element accessor" type, // ea_type is the "element accessor" type,
// which can provide access to elements via operator[] // which can provide access to elements via operator[]
template<typename eT> template<typename eT>
class Proxy< Mat<eT> > class Proxy< Mat<eT> >
{ {
public: public:
skipping to change at line 50 skipping to change at line 50
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Mat<eT>& Q; arma_aligned const Mat<eT>& Q;
inline explicit Proxy(const Mat<eT>& A) inline explicit Proxy(const Mat<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X); } arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X); }
}; };
template<typename eT> template<typename eT>
class Proxy< Col<eT> > class Proxy< Col<eT> >
{ {
public: public:
skipping to change at line 82 skipping to change at line 82
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Col<eT>& Q; arma_aligned const Col<eT>& Q;
inline explicit Proxy(const Col<eT>& A) inline explicit Proxy(const Col<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return 1; } arma_inline uword get_n_cols() const { return 1; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X); } arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X); }
}; };
template<typename eT> template<typename eT>
class Proxy< Row<eT> > class Proxy< Row<eT> >
{ {
public: public:
skipping to change at line 114 skipping to change at line 114
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Row<eT>& Q; arma_aligned const Row<eT>& Q;
inline explicit Proxy(const Row<eT>& A) inline explicit Proxy(const Row<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return 1; } arma_inline uword get_n_rows() const { return 1; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X); } arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &X); }
}; };
template<typename eT, typename gen_type>
class Proxy< Gen<eT, gen_type > >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef Gen<eT, gen_type> stored_type;
typedef const Gen<eT, gen_type>& ea_type;
static const bool prefer_at_accessor = Gen<eT, gen_type>::prefer_at_acces
sor;
static const bool has_subview = false;
arma_aligned const Gen<eT, gen_type>& Q;
inline explicit Proxy(const Gen<eT, gen_type>& A)
: Q(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols; }
arma_inline elem_type operator[] (const uword i) const
{ return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q;
}
arma_inline bool is_alias(const Mat<elem_type>&) const { return false;
}
};
template<typename T1, typename op_type> template<typename T1, typename op_type>
class Proxy< Op<T1, op_type> > class Proxy< Op<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
skipping to change at line 146 skipping to change at line 178
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Op<T1, op_type>& A) inline explicit Proxy(const Op<T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memp tr(); } arma_inline ea_type get_ea() const { return Q.memp tr(); }
arma_inline bool is_alias(const Mat<elem_type>&) const { return false; } arma_inline bool is_alias(const Mat<elem_type>&) const { return false; }
}; };
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class Proxy< Glue<T1, T2, glue_type> > class Proxy< Glue<T1, T2, glue_type> >
{ {
public: public:
skipping to change at line 178 skipping to change at line 210
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Glue<T1, T2, glue_type>& A) inline explicit Proxy(const Glue<T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memp tr(); } arma_inline ea_type get_ea() const { return Q.memp tr(); }
arma_inline bool is_alias(const Mat<elem_type>&) const { return false; } arma_inline bool is_alias(const Mat<elem_type>&) const { return false; }
}; };
template<typename eT> template<typename eT>
class Proxy< subview<eT> > class Proxy< subview<eT> >
{ {
public: public:
skipping to change at line 210 skipping to change at line 242
static const bool has_subview = true; static const bool has_subview = true;
arma_aligned const subview<eT>& Q; arma_aligned const subview<eT>& Q;
inline explicit Proxy(const subview<eT>& A) inline explicit Proxy(const subview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
arma_inline bool is_alias(const Mat<eT>& X) const { return (&(Q.m) == &X); } arma_inline bool is_alias(const Mat<eT>& X) const { return (&(Q.m) == &X); }
}; };
template<typename eT, typename T1> template<typename eT, typename T1>
class Proxy< subview_elem1<eT,T1> > class Proxy< subview_elem1<eT,T1> >
{ {
public: public:
skipping to change at line 242 skipping to change at line 274
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Mat<eT> Q; arma_aligned const Mat<eT> Q;
inline explicit Proxy(const subview_elem1<eT,T1>& A) inline explicit Proxy(const subview_elem1<eT,T1>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return 1; } arma_inline uword get_n_cols() const { return 1; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
arma_inline bool is_alias(const Mat<eT>&) const { return false; } arma_inline bool is_alias(const Mat<eT>&) const { return false; }
}; };
template<typename eT> template<typename eT>
class Proxy< diagview<eT> > class Proxy< diagview<eT> >
{ {
public: public:
skipping to change at line 274 skipping to change at line 306
static const bool has_subview = true; static const bool has_subview = true;
arma_aligned const diagview<eT>& Q; arma_aligned const diagview<eT>& Q;
inline explicit Proxy(const diagview<eT>& A) inline explicit Proxy(const diagview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return 1; } arma_inline uword get_n_cols() const { return 1; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
arma_inline bool is_alias(const Mat<eT>& X) const { return (&(Q.m) == &X); } arma_inline bool is_alias(const Mat<eT>& X) const { return (&(Q.m) == &X); }
}; };
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
class Proxy< eOp<T1, eop_type > > class Proxy< eOp<T1, eop_type > >
{ {
public: public:
skipping to change at line 306 skipping to change at line 338
static const bool has_subview = eOp<T1, eop_type>::has_subview; static const bool has_subview = eOp<T1, eop_type>::has_subview;
arma_aligned const eOp<T1, eop_type>& Q; arma_aligned const eOp<T1, eop_type>& Q;
inline explicit Proxy(const eOp<T1, eop_type>& A) inline explicit Proxy(const eOp<T1, eop_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline uword get_n_rows() const { return Q.get_n_rows(); }
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } arma_inline uword get_n_cols() const { return Q.get_n_cols(); }
arma_inline u32 get_n_elem() const { return Q.get_n_elem(); } arma_inline uword get_n_elem() const { return Q.get_n_elem(); }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
arma_inline bool is_alias(const Mat<elem_type>& X) const { return Q.P. is_alias(X); } arma_inline bool is_alias(const Mat<elem_type>& X) const { return Q.P. is_alias(X); }
}; };
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
class Proxy< eGlue<T1, T2, eglue_type > > class Proxy< eGlue<T1, T2, eglue_type > >
{ {
public: public:
skipping to change at line 338 skipping to change at line 370
static const bool has_subview = eGlue<T1, T2, eglue_type>::has_sub view; static const bool has_subview = eGlue<T1, T2, eglue_type>::has_sub view;
arma_aligned const eGlue<T1, T2, eglue_type>& Q; arma_aligned const eGlue<T1, T2, eglue_type>& Q;
inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A) inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline uword get_n_rows() const { return Q.get_n_rows(); }
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } arma_inline uword get_n_cols() const { return Q.get_n_cols(); }
arma_inline u32 get_n_elem() const { return Q.get_n_elem(); } arma_inline uword get_n_elem() const { return Q.get_n_elem(); }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row, col); } { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
arma_inline bool is_alias(const Mat<elem_type>& X) const { return (Q.P 1.is_alias(X) || Q.P2.is_alias(X)); } arma_inline bool is_alias(const Mat<elem_type>& X) const { return (Q.P 1.is_alias(X) || Q.P2.is_alias(X)); }
}; };
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class Proxy< mtOp<out_eT, T1, op_type> > class Proxy< mtOp<out_eT, T1, op_type> >
{ {
public: public:
skipping to change at line 370 skipping to change at line 402
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A) inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row,col); } { return Q.at(row,col); }
arma_inline ea_type get_ea() const { return Q.memptr( ); } arma_inline ea_type get_ea() const { return Q.memptr( ); }
arma_inline bool is_alias(const Mat<out_eT>&) const { return false; } arma_inline bool is_alias(const Mat<out_eT>&) const { return false; }
}; };
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class Proxy< mtGlue<out_eT, T1, T2, glue_type > > class Proxy< mtGlue<out_eT, T1, T2, glue_type > >
{ {
public: public:
skipping to change at line 402 skipping to change at line 434
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A) inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn Q[i]; } { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn Q.at(row,col); } { return Q.at(row,col); }
arma_inline ea_type get_ea() const { return Q.memptr( ); } arma_inline ea_type get_ea() const { return Q.memptr( ); }
arma_inline bool is_alias(const Mat<out_eT>&) const { return false; } arma_inline bool is_alias(const Mat<out_eT>&) const { return false; }
}; };
//! @} //! @}
 End of changes. 26 change blocks. 
85 lines changed or deleted 122 lines changed or added


 ProxyCube.hpp   ProxyCube.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup ProxyCube //! \addtogroup ProxyCube
//! @{ //! @{
template<typename T1> template<typename T1>
class ProxyCube class ProxyCube
{ {
public: public:
inline ProxyCube(const T1& A) inline ProxyCube(const T1& A)
{ {
arma_type_check< is_arma_type<T1>::value == false >::apply(); arma_type_check(( is_arma_cube_type<T1>::value == false ));
} }
}; };
// ea_type is the "element accessor" type, // ea_type is the "element accessor" type,
// which can provide access to elements via operator[] // which can provide access to elements via operator[]
template<typename eT> template<typename eT>
class ProxyCube< Cube<eT> > class ProxyCube< Cube<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Cube<eT> stored_type; typedef Cube<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false;
arma_aligned const Cube<eT>& Q; arma_aligned const Cube<eT>& Q;
inline explicit ProxyCube(const Cube<eT>& A) inline explicit ProxyCube(const Cube<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem_slice() const { return Q.n_elem_slice; } arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
arma_inline u32 get_n_slices() const { return Q.n_slices; } arma_inline uword get_n_slices() const { return Q.n_slices; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.m
emptr(); }
arma_inline bool is_alias(const Cube<elem_type>& X) const { return (&Q
== &X); }
};
template<typename eT, typename gen_type>
class ProxyCube< GenCube<eT, gen_type > >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef GenCube<eT, gen_type> stored_type;
typedef const GenCube<eT, gen_type>& ea_type;
static const bool prefer_at_accessor = false;
static const bool has_subview = false;
arma_aligned const GenCube<eT, gen_type>& Q;
inline explicit ProxyCube(const GenCube<eT, gen_type>& A)
: Q(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return Q.n_rows;
}
arma_inline uword get_n_cols() const { return Q.n_cols;
}
arma_inline uword get_n_elem_slice() const { return Q.n_rows*Q.n_cols;
}
arma_inline uword get_n_slices() const { return Q.n_slices;
}
arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols*Q.n
_slices; }
arma_inline elem_type operator[] (const uword i)
const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col, const
uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q;
}
arma_inline bool is_alias(const Cube<elem_type>&) const { return false
; }
}; };
template<typename T1, typename op_type> template<typename T1, typename op_type>
class ProxyCube< OpCube<T1, op_type> > class ProxyCube< OpCube<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Cube<elem_type> stored_type; typedef Cube<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false;
arma_aligned const Cube<elem_type> Q; arma_aligned const Cube<elem_type> Q;
inline explicit ProxyCube(const OpCube<T1, op_type>& A) inline explicit ProxyCube(const OpCube<T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem_slice() const { return Q.n_elem_slice; } arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
arma_inline u32 get_n_slices() const { return Q.n_slices; } arma_inline uword get_n_slices() const { return Q.n_slices; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.mem
ptr(); }
arma_inline bool is_alias(const Cube<elem_type>&) const { return false
; }
}; };
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class ProxyCube< GlueCube<T1, T2, glue_type> > class ProxyCube< GlueCube<T1, T2, glue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Cube<elem_type> stored_type; typedef Cube<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false;
arma_aligned const Cube<elem_type> Q; arma_aligned const Cube<elem_type> Q;
inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A) inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem_slice() const { return Q.n_elem_slice; } arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
arma_inline u32 get_n_slices() const { return Q.n_slices; } arma_inline uword get_n_slices() const { return Q.n_slices; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.mem
ptr(); }
arma_inline bool is_alias(const Cube<elem_type>&) const { return false
; }
}; };
template<typename eT> template<typename eT>
class ProxyCube< subview_cube<eT> > class ProxyCube< subview_cube<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview_cube<eT> stored_type; typedef subview_cube<eT> stored_type;
typedef const subview_cube<eT>& ea_type; typedef const subview_cube<eT>& ea_type;
static const bool prefer_at_accessor = true; static const bool prefer_at_accessor = true;
static const bool has_subview = true;
arma_aligned const subview_cube<eT>& Q; arma_aligned const subview_cube<eT>& Q;
inline explicit ProxyCube(const subview_cube<eT>& A) inline explicit ProxyCube(const subview_cube<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem_slice() const { return Q.n_elem_slice; } arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
arma_inline u32 get_n_slices() const { return Q.n_slices; } arma_inline uword get_n_slices() const { return Q.n_slices; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q;
}
arma_inline bool is_alias(const Cube<elem_type>& X) const { return (&(
Q.m) == &X); }
}; };
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
class ProxyCube< eOpCube<T1, eop_type > > class ProxyCube< eOpCube<T1, eop_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eOpCube<T1, eop_type> stored_type; typedef eOpCube<T1, eop_type> stored_type;
typedef const eOpCube<T1, eop_type>& ea_type; typedef const eOpCube<T1, eop_type>& ea_type;
static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_a ccessor; static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_a ccessor;
static const bool has_subview = eOpCube<T1, eop_type>::has_subview ;
arma_aligned const eOpCube<T1, eop_type>& Q; arma_aligned const eOpCube<T1, eop_type>& Q;
inline explicit ProxyCube(const eOpCube<T1, eop_type>& A) inline explicit ProxyCube(const eOpCube<T1, eop_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline uword get_n_rows() const { return Q.get_n_rows();
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } }
arma_inline u32 get_n_elem_slice() const { return Q.get_n_elem_slice(); } arma_inline uword get_n_cols() const { return Q.get_n_cols();
arma_inline u32 get_n_slices() const { return Q.get_n_slices(); } }
arma_inline u32 get_n_elem() const { return Q.get_n_elem(); } arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice();
}
arma_inline uword get_n_slices() const { return Q.get_n_slices();
}
arma_inline uword get_n_elem() const { return Q.get_n_elem();
}
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q;
}
arma_inline bool is_alias(const Cube<elem_type>& X) const { return Q.P
.is_alias(X); }
}; };
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
class ProxyCube< eGlueCube<T1, T2, eglue_type > > class ProxyCube< eGlueCube<T1, T2, eglue_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eGlueCube<T1, T2, eglue_type> stored_type; typedef eGlueCube<T1, T2, eglue_type> stored_type;
typedef const eGlueCube<T1, T2, eglue_type>& ea_type; typedef const eGlueCube<T1, T2, eglue_type>& ea_type;
static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::pre fer_at_accessor; static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::pre fer_at_accessor;
static const bool has_subview = eGlueCube<T1, T2, eglue_type>::has _subview;
arma_aligned const eGlueCube<T1, T2, eglue_type>& Q; arma_aligned const eGlueCube<T1, T2, eglue_type>& Q;
inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A) inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline uword get_n_rows() const { return Q.get_n_rows();
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } }
arma_inline u32 get_n_elem_slice() const { return Q.get_n_elem_slice(); } arma_inline uword get_n_cols() const { return Q.get_n_cols();
arma_inline u32 get_n_slices() const { return Q.get_n_slices(); } }
arma_inline u32 get_n_elem() const { return Q.get_n_elem(); } arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice();
}
arma_inline uword get_n_slices() const { return Q.get_n_slices();
}
arma_inline uword get_n_elem() const { return Q.get_n_elem();
}
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q;
}
arma_inline bool is_alias(const Cube<elem_type>& X) const { return (Q.
P1.is_alias(X) || Q.P2.is_alias(X)); }
}; };
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class ProxyCube< mtOpCube<out_eT, T1, op_type> > class ProxyCube< mtOpCube<out_eT, T1, op_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Cube<out_eT> stored_type; typedef Cube<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false;
arma_aligned const Cube<out_eT> Q; arma_aligned const Cube<out_eT> Q;
inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A) inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem_slice() const { return Q.n_elem_slice; } arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
arma_inline u32 get_n_slices() const { return Q.n_slices; } arma_inline uword get_n_slices() const { return Q.n_slices; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr
(); }
arma_inline bool is_alias(const Cube<out_eT>&) const { return false;
}
}; };
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > > class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Cube<out_eT> stored_type; typedef Cube<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false;
arma_aligned const Cube<out_eT> Q; arma_aligned const Cube<out_eT> Q;
inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A) inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline u32 get_n_elem_slice() const { return Q.n_elem_slice; } arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
arma_inline u32 get_n_slices() const { return Q.n_slices; } arma_inline uword get_n_slices() const { return Q.n_slices; }
arma_inline u32 get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const { return Q[i]; } const { return Q[i]; }
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const { return Q.at(row, col, slice); } uword slice) const { return Q.at(row, col, slice); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr
(); }
arma_inline bool is_alias(const Cube<out_eT>&) const { return false;
}
}; };
//! @} //! @}
 End of changes. 33 change blocks. 
81 lines changed or deleted 166 lines changed or added


 Row_bones.hpp   Row_bones.hpp 
skipping to change at line 27 skipping to change at line 27
template<typename eT> template<typename eT>
class Row : public Mat<eT> class Row : public Mat<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
inline Row(); inline Row();
inline explicit Row(const u32 N); inline explicit Row(const uword N);
inline Row(const u32 in_rows, const u32 in_cols); inline Row(const uword in_rows, const uword in_cols);
inline Row(const char* text); inline Row(const char* text);
inline const Row& operator=(const char* text); inline const Row& operator=(const char* text);
inline Row(const std::string& text); inline Row(const std::string& text);
inline const Row& operator=(const std::string& text); inline const Row& operator=(const std::string& text);
#if defined(ARMA_USE_CXX11)
inline Row(const std::initializer_list<eT>& list);
inline const Row& operator=(const std::initializer_list<eT>& list);
#endif
inline const Row& operator=(const eT val); inline const Row& operator=(const eT val);
template<typename T1> inline Row(const Base<eT,T1>& X); template<typename T1> inline Row(const Base<eT,T1>& X);
template<typename T1> inline const Row& operator=(const Base<eT,T1>& X); template<typename T1> inline const Row& operator=(const Base<eT,T1>& X);
inline Row( eT* aux_mem, const u32 aux_length, const bool copy_aux_m inline Row( eT* aux_mem, const uword aux_length, const bool copy_aux
em = true, const bool strict = true); _mem = true, const bool strict = true);
inline Row(const eT* aux_mem, const u32 aux_length); inline Row(const eT* aux_mem, const uword aux_length);
template<typename T1, typename T2> template<typename T1, typename T2>
inline explicit Row(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Row(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
template<typename T1> inline Row(const BaseCube<eT,T1>& X); template<typename T1> inline Row(const BaseCube<eT,T1>& X);
template<typename T1> inline const Row& operator=(const BaseCube<eT,T1>& X); template<typename T1> inline const Row& operator=(const BaseCube<eT,T1>& X);
inline Row(const subview_cube<eT>& X); inline Row(const subview_cube<eT>& X);
inline const Row& operator=(const subview_cube<eT>& X); inline const Row& operator=(const subview_cube<eT>& X);
inline mat_injector<Row> operator<<(const eT val); inline mat_injector<Row> operator<<(const eT val);
arma_inline eT& col(const u32 col_num); arma_inline eT& col(const uword col_num);
arma_inline eT col(const u32 col_num) const; arma_inline eT col(const uword col_num) const;
arma_inline subview_row<eT> cols(const u32 in_col1, const u32 in_co arma_inline subview_row<eT> cols(const uword in_col1, const uword i
l2); n_col2);
arma_inline const subview_row<eT> cols(const u32 in_col1, const u32 in_co arma_inline const subview_row<eT> cols(const uword in_col1, const uword i
l2) const; n_col2) const;
arma_inline subview_row<eT> subvec(const u32 in_col1, const u32 in_ arma_inline subview_row<eT> subvec(const uword in_col1, const uword
col2); in_col2);
arma_inline const subview_row<eT> subvec(const u32 in_col1, const u32 in_ arma_inline const subview_row<eT> subvec(const uword in_col1, const uword
col2) const; in_col2) const;
arma_inline subview_row<eT> subvec(const span& col_span); arma_inline subview_row<eT> subvec(const span& col_span);
arma_inline const subview_row<eT> subvec(const span& col_span) const; arma_inline const subview_row<eT> subvec(const span& col_span) const;
// arma_inline subview_row<eT> operator()(const span& col_span); // arma_inline subview_row<eT> operator()(const span& col_span);
// arma_inline const subview_row<eT> operator()(const span& col_span) con st; // arma_inline const subview_row<eT> operator()(const span& col_span) con st;
inline void shed_col (const u32 col_num); inline void shed_col (const uword col_num);
inline void shed_cols(const u32 in_col1, const u32 in_col2); inline void shed_cols(const uword in_col1, const uword in_col2);
inline void insert_cols(const u32 col_num, const u3 inline void insert_cols(const uword col_num, const
2 N, const bool set_to_zero = true); uword N, const bool set_to_zero = true);
template<typename T1> inline void insert_cols(const u32 col_num, const Ba template<typename T1> inline void insert_cols(const uword col_num, const
se<eT,T1>& X); Base<eT,T1>& X);
typedef eT* row_iterator; typedef eT* row_iterator;
typedef const eT* const_row_iterator; typedef const eT* const_row_iterator;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const uword row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const uword row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const uword row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const uword row_num) const;
template<u32 fixed_n_elem> template<uword fixed_n_elem>
class fixed : public Row<eT> class fixed : public Row<eT>
{ {
private: private:
static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc ); static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc );
arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
arma_inline void mem_setup(); arma_inline void mem_setup();
public: public:
static const u32 n_rows = 1; static const uword n_rows = 1;
static const u32 n_cols = fixed_n_elem; static const uword n_cols = fixed_n_elem;
static const u32 n_elem = fixed_n_elem; static const uword n_elem = fixed_n_elem;
arma_inline fixed(); arma_inline fixed();
arma_inline fixed(const fixed<fixed_n_elem>& X); arma_inline fixed(const fixed<fixed_n_elem>& X);
inline fixed(const subview_cube<eT>& X); inline fixed(const subview_cube<eT>& X);
template<typename T1> inline fixed(const Base<eT,T1>& A); template<typename T1> inline fixed(const Base<eT,T1>& A);
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B); template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B);
inline fixed( eT* aux_mem, const bool copy_aux_mem = true); inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
inline fixed(const eT* aux_mem); inline fixed(const eT* aux_mem);
skipping to change at line 121 skipping to change at line 127
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);
inline subview_row<eT> operator()(const u32 row_num, const spa inline subview_row<eT> operator()(const uword row_num, const s
n& col_span); pan& col_span);
inline const subview_row<eT> operator()(const u32 row_num, const spa inline const subview_row<eT> operator()(const uword row_num, const s
n& col_span) const; pan& col_span) const;
inline subview_col<eT> operator()(const span& row_span, const u32 inline subview_col<eT> operator()(const span& row_span, const uwo
col_num ); rd col_num );
inline const subview_col<eT> operator()(const span& row_span, const u32 inline const subview_col<eT> operator()(const span& row_span, const uwo
col_num ) const; rd col_num ) const;
inline subview<eT> operator()(const span& row_span, const spa n& col_span); inline subview<eT> operator()(const span& row_span, const spa n& col_span);
inline const subview<eT> operator()(const span& row_span, const spa n& col_span) const; inline const subview<eT> operator()(const span& row_span, const spa n& col_span) const;
arma_inline arma_warn_unused eT& operator[] (const u32 i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const u32 i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const u32 i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const u32 i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const u32 i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const u32 in_row, const u3 arma_inline arma_warn_unused eT& at (const uword in_row, const
2 in_col); uword in_col);
arma_inline arma_warn_unused eT at (const u32 in_row, const u3 arma_inline arma_warn_unused eT at (const uword in_row, const
2 in_col) const; uword in_col) const;
arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u3 arma_inline arma_warn_unused eT& operator() (const uword in_row, const
2 in_col); uword in_col);
arma_inline arma_warn_unused eT operator() (const u32 in_row, const u3 arma_inline arma_warn_unused eT operator() (const uword in_row, const
2 in_col) const; uword in_col) const;
arma_hot inline const Row<eT>& fill(const eT val); arma_hot inline const Row<eT>& fill(const eT val);
arma_hot inline const Row<eT>& zeros(); arma_hot inline const Row<eT>& zeros();
arma_hot inline const Row<eT>& ones(); arma_hot inline const Row<eT>& ones();
}; };
#ifdef ARMA_EXTRA_ROW_PROTO #ifdef ARMA_EXTRA_ROW_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_PROTO) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_PROTO)
#endif #endif
 End of changes. 16 change blocks. 
52 lines changed or deleted 58 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Row //! \addtogroup Row
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row() Row<eT>::Row()
: Mat<eT>(1, 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const u32 in_n_elem) Row<eT>::Row(const uword in_n_elem)
: Mat<eT>(1, in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::init(1, in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::Row(const uword in_n_rows, const uword in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::init(in_n_rows, in_n_cols); Mat<eT>::init_warm(in_n_rows, in_n_cols);
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const char* text) Row<eT>::Row(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
skipping to change at line 94 skipping to change at line 93
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const std::string& text) Row<eT>::operator=(const std::string& text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
return *this; return *this;
} }
#if defined(ARMA_USE_CXX11)
template<typename eT>
inline
Row<eT>::Row(const std::initializer_list<eT>& list)
{
arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(list);
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator=(const std::initializer_list<eT>& list)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(list);
return *this;
}
#endif
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const eT val) Row<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(val); Mat<eT>::operator=(val);
return *this; return *this;
skipping to change at line 134 skipping to change at line 160
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X.get_ref()); Mat<eT>::operator=(X.get_ref());
return *this; return *this;
} }
//! construct a row vector from a given auxiliary array //! construct a row vector from a given auxiliary array
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co nst bool strict) Row<eT>::Row(eT* aux_mem, const uword aux_length, const bool copy_aux_mem, const bool strict)
: Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict) : Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
} }
//! construct a row vector from a given auxiliary array //! construct a row vector from a given auxiliary array
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const eT* aux_mem, const u32 aux_length) Row<eT>::Row(const eT* aux_mem, const uword aux_length)
: Mat<eT>(aux_mem, 1, aux_length) : Mat<eT>(aux_mem, 1, aux_length)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 228 skipping to change at line 254
inline inline
mat_injector< Row<eT> > mat_injector< Row<eT> >
Row<eT>::operator<<(const eT val) Row<eT>::operator<<(const eT val)
{ {
return mat_injector< Row<eT> >(*this, val); return mat_injector< Row<eT> >(*this, val);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
Row<eT>::col(const u32 col_num) Row<eT>::col(const uword col_num)
{ {
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound s" ); arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound s" );
return access::rw(Mat<eT>::mem[col_num]); return access::rw(Mat<eT>::mem[col_num]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
Row<eT>::col(const u32 col_num) const Row<eT>::col(const uword col_num) const
{ {
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound s" ); arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound s" );
return Mat<eT>::mem[col_num]; return Mat<eT>::mem[col_num];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT> subview_row<eT>
Row<eT>::cols(const u32 in_col1, const u32 in_col2) Row<eT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview_row<eT>(*this, 0, in_col1, subview_n_cols); return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_row<eT> const subview_row<eT>
Row<eT>::cols(const u32 in_col1, const u32 in_col2) const Row<eT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview_row<eT>(*this, 0, in_col1, subview_n_cols); return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT> subview_row<eT>
Row<eT>::subvec(const u32 in_col1, const u32 in_col2) Row<eT>::subvec(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview_row<eT>(*this, 0, in_col1, subview_n_cols); return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_row<eT> const subview_row<eT>
Row<eT>::subvec(const u32 in_col1, const u32 in_col2) const Row<eT>::subvec(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview_row<eT>(*this, 0, in_col1, subview_n_cols); return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT> subview_row<eT>
Row<eT>::subvec(const span& col_span) Row<eT>::subvec(const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_cols = Mat<eT>::n_cols; const uword local_n_cols = Mat<eT>::n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly use d"); arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly use d");
return subview_row<eT>(*this, 0, in_col1, subvec_n_cols); return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview_row<eT> const subview_row<eT>
Row<eT>::subvec(const span& col_span) const Row<eT>::subvec(const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_cols = Mat<eT>::n_cols; const uword local_n_cols = Mat<eT>::n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly use d"); arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly use d");
return subview_row<eT>(*this, 0, in_col1, subvec_n_cols); return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
} }
// template<typename eT> // template<typename eT>
// arma_inline // arma_inline
// subview_row<eT> // subview_row<eT>
// Row<eT>::operator()(const span& col_span) // Row<eT>::operator()(const span& col_span)
skipping to change at line 367 skipping to change at line 393
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// return subvec(col_span); // return subvec(col_span);
// } // }
//! remove specified columns //! remove specified columns
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::shed_col(const u32 col_num) Row<eT>::shed_col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): out of bo unds"); arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): out of bo unds");
shed_cols(col_num, col_num); shed_cols(col_num, col_num);
} }
//! remove specified columns //! remove specified columns
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::shed_cols(const u32 in_col1, const u32 in_col2) Row<eT>::shed_cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols), (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols),
"Row::shed_cols(): indices out of bounds or incorrectly used" "Row::shed_cols(): indices out of bounds or incorrectly used"
); );
const u32 n_keep_front = in_col1; const uword n_keep_front = in_col1;
const u32 n_keep_back = Mat<eT>::n_cols - (in_col2 + 1); const uword n_keep_back = Mat<eT>::n_cols - (in_col2 + 1);
Row<eT> X(n_keep_front + n_keep_back); Row<eT> X(n_keep_front + n_keep_back);
eT* X_mem = X.memptr(); eT* X_mem = X.memptr();
const eT* t_mem = (*this).memptr(); const eT* t_mem = (*this).memptr();
if(n_keep_front > 0) if(n_keep_front > 0)
{ {
arrayops::copy( X_mem, t_mem, n_keep_front ); arrayops::copy( X_mem, t_mem, n_keep_front );
} }
skipping to change at line 416 skipping to change at line 442
} }
Mat<eT>::steal_mem(X); Mat<eT>::steal_mem(X);
} }
//! insert N cols at the specified col position, //! insert N cols at the specified col position,
//! optionally setting the elements of the inserted cols to zero //! optionally setting the elements of the inserted cols to zero
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::insert_cols(const u32 col_num, const u32 N, const bool set_to_zero ) Row<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_ zero)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 t_n_cols = Mat<eT>::n_cols; const uword t_n_cols = Mat<eT>::n_cols;
const u32 A_n_cols = col_num; const uword A_n_cols = col_num;
const u32 B_n_cols = t_n_cols - col_num; const uword B_n_cols = t_n_cols - col_num;
// insertion at col_num == n_cols is in effect an append operation // insertion at col_num == n_cols is in effect an append operation
arma_debug_check( (col_num > t_n_cols), "Row::insert_cols(): out of bound s"); arma_debug_check( (col_num > t_n_cols), "Row::insert_cols(): out of bound s");
if(N > 0) if(N > 0)
{ {
Row<eT> out(t_n_cols + N); Row<eT> out(t_n_cols + N);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* t_mem = (*this).memptr(); const eT* t_mem = (*this).memptr();
skipping to change at line 460 skipping to change at line 486
Mat<eT>::steal_mem(out); Mat<eT>::steal_mem(out);
} }
} }
//! insert the given object at the specified col position; //! insert the given object at the specified col position;
//! the given object must have one row //! the given object must have one row
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
Row<eT>::insert_cols(const u32 col_num, const Base<eT,T1>& X) Row<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::insert_cols(col_num, X); Mat<eT>::insert_cols(col_num, X);
} }
template<typename eT> template<typename eT>
inline inline
typename Row<eT>::row_iterator typename Row<eT>::row_iterator
Row<eT>::begin_row(const u32 row_num) Row<eT>::begin_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds");
return Mat<eT>::memptr(); return Mat<eT>::memptr();
} }
template<typename eT> template<typename eT>
inline inline
typename Row<eT>::const_row_iterator typename Row<eT>::const_row_iterator
Row<eT>::begin_row(const u32 row_num) const Row<eT>::begin_row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds");
return Mat<eT>::memptr(); return Mat<eT>::memptr();
} }
template<typename eT> template<typename eT>
inline inline
typename Row<eT>::row_iterator typename Row<eT>::row_iterator
Row<eT>::end_row(const u32 row_num) Row<eT>::end_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
return Mat<eT>::memptr() + Mat<eT>::n_cols; return Mat<eT>::memptr() + Mat<eT>::n_cols;
} }
template<typename eT> template<typename eT>
inline inline
typename Row<eT>::const_row_iterator typename Row<eT>::const_row_iterator
Row<eT>::end_row(const u32 row_num) const Row<eT>::end_row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
return Mat<eT>::memptr() + Mat<eT>::n_cols; return Mat<eT>::memptr() + Mat<eT>::n_cols;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
void void
Row<eT>::fixed<fixed_n_elem>::mem_setup() Row<eT>::fixed<fixed_n_elem>::mem_setup()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = 1; access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = fixed_n_elem; access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem; access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3; access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>: :mem_local; access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>: :mem_local;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed() Row<eT>::fixed<fixed_n_elem>::fixed()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X) Row<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
arrayops::copy( dest, X.mem, fixed_n_elem ); arrayops::copy( dest, X.mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X) Row<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::operator=(X); Row<eT>::operator=(X);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
template<typename T1> template<typename T1>
arma_inline arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A) Row<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::operator=(A.get_ref()); Row<eT>::operator=(A.get_ref());
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base< pod_type,T2>& B) Row<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base< pod_type,T2>& B)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::init(A,B); Row<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
access::rw(Mat<eT>::n_rows) = 1; access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = fixed_n_elem; access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem; access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3; access::rw(Mat<eT>::mem_state) = 3;
skipping to change at line 621 skipping to change at line 647
arrayops::copy( dest, aux_mem, fixed_n_elem ); arrayops::copy( dest, aux_mem, fixed_n_elem );
} }
else else
{ {
access::rw(Mat<eT>::mem) = aux_mem; access::rw(Mat<eT>::mem) = aux_mem;
} }
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(const char* text) Row<eT>::fixed<fixed_n_elem>::fixed(const char* text)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::operator=(text); Row<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(const std::string& text) Row<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::operator=(text); Row<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview_row<eT> subview_row<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col _span) Row<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c ol_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); return Mat<eT>::operator()(row_num, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
template<typename T1> template<typename T1>
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A) Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(A.get_ref()); Row<eT>::operator=(A.get_ref());
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const eT val) Row<eT>::fixed<fixed_n_elem>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(val); Row<eT>::operator=(val);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const char* text) Row<eT>::fixed<fixed_n_elem>::operator=(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(text); Row<eT>::operator=(text);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const std::string& text) Row<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(text); Row<eT>::operator=(text);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X) Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(X); Row<eT>::operator=(X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_row<eT> const subview_row<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col _span) const Row<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c ol_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); return Mat<eT>::operator()(row_num, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview_col<eT> subview_col<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co l_num) Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); return Mat<eT>::operator()(row_span, col_num);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_col<eT> const subview_col<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co l_num) const Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); return Mat<eT>::operator()(row_span, col_num);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview<eT> subview<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview<eT> const subview<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) const Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) const Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::at(const u32 i) Row<eT>::fixed<fixed_n_elem>::at(const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::at(const u32 i) const Row<eT>::fixed<fixed_n_elem>::at(const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 i) Row<eT>::fixed<fixed_n_elem>::operator() (const uword i)
{ {
arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo unds");
return access::rw( Mat<eT>::mem[i] ); return access::rw( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 i) const Row<eT>::fixed<fixed_n_elem>::operator() (const uword i) const
{ {
arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo unds");
return ( Mat<eT>::mem[i] ); return ( Mat<eT>::mem[i] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col)
{ {
return access::rw( Mat<eT>::mem[in_col] ); return access::rw( Mat<eT>::mem[in_col] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) const Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) co nst
{ {
return ( Mat<eT>::mem[in_col] ); return ( Mat<eT>::mem[in_col] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co l) Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col)
{ {
arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe d::operator(): out of bounds" );
return access::rw( Mat<eT>::mem[in_col] ); return access::rw( Mat<eT>::mem[in_col] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co l) const Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) const
{ {
arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe d::operator(): out of bounds" );
return ( Mat<eT>::mem[in_col] ); return ( Mat<eT>::mem[in_col] );
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::fill(const eT val) Row<eT>::fixed<fixed_n_elem>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) ; arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) ;
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::zeros() Row<eT>::fixed<fixed_n_elem>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem ); arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::ones() Row<eT>::fixed<fixed_n_elem>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem ); arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem );
return *this; return *this;
 End of changes. 82 change blocks. 
87 lines changed or deleted 115 lines changed or added


 arma_config.hpp   arma_config.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_config //! \addtogroup arma_config
//! @{ //! @{
struct arma_config struct arma_config
{ {
#if defined(ARMA_MAT_PREALLOC) #if defined(ARMA_MAT_PREALLOC)
static const u32 mat_prealloc = (s32(ARMA_MAT_PREALLOC) > 0) ? u32(ARMA _MAT_PREALLOC) : 1; static const uword mat_prealloc = (sword(ARMA_MAT_PREALLOC) > 0) ? uwor d(ARMA_MAT_PREALLOC) : 1;
#else #else
static const u32 mat_prealloc = 16; static const uword mat_prealloc = 16;
#endif #endif
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
static const bool atlas = true; static const bool atlas = true;
#else #else
static const bool atlas = false; static const bool atlas = false;
#endif #endif
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
static const bool lapack = true; static const bool lapack = true;
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 arma_ostream_bones.hpp   arma_ostream_bones.hpp 
skipping to change at line 36 skipping to change at line 36
inline arma_ostream_state(const std::ostream& o); inline arma_ostream_state(const std::ostream& o);
inline void restore(std::ostream& o) const; inline void restore(std::ostream& o) const;
}; };
class arma_ostream class arma_ostream
{ {
public: public:
template<typename eT> inline static std::streamsize modify_stream(std::os template<typename eT> inline static std::streamsize modify_stream(std::os
tream& o, const eT* data, const u32 n_elem); tream& o, const eT* data, const uword n_elem);
template<typename T> inline static std::streamsize modify_stream(std::os template<typename T> inline static std::streamsize modify_stream(std::os
tream& o, const std::complex<T>* data, const u32 n_elem); tream& o, const std::complex<T>* data, const uword n_elem);
template<typename eT> inline static void print_elem_zero(std::ostream& o) ; template<typename eT> inline static void print_elem_zero(std::ostream& o) ;
template<typename eT> arma_inline static void print_elem(std::ostream& o, const eT& x); template<typename eT> arma_inline static void print_elem(std::ostream& o, const eT& x);
template<typename T> inline static void print_elem(std::ostream& o, const std::complex<T>& x); template<typename T> inline static void print_elem(std::ostream& o, const std::complex<T>& x);
template<typename eT> inline static void print(std::ostream& o, const Ma t<eT>& m, const bool modify); template<typename eT> inline static void print(std::ostream& o, const Ma t<eT>& m, const bool modify);
template<typename eT> inline static void print(std::ostream& o, const Cub e<eT>& m, const bool modify); template<typename eT> inline static void print(std::ostream& o, const Cub e<eT>& m, const bool modify);
template<typename oT> inline static void print(std::ostream& o, const fie ld<oT>& m); template<typename oT> inline static void print(std::ostream& o, const fie ld<oT>& m);
 End of changes. 1 change blocks. 
4 lines changed or deleted 4 lines changed or added


 arma_ostream_meat.hpp   arma_ostream_meat.hpp 
skipping to change at line 41 skipping to change at line 41
o.width (orig_width); o.width (orig_width);
o.fill (orig_fill); o.fill (orig_fill);
} }
// //
// //
template<typename eT> template<typename eT>
inline inline
std::streamsize std::streamsize
arma_ostream::modify_stream(std::ostream& o, const eT* data, const u32 n_el em) arma_ostream::modify_stream(std::ostream& o, const eT* data, const uword n_ elem)
{ {
o.unsetf(ios::showbase); o.unsetf(ios::showbase);
o.unsetf(ios::uppercase); o.unsetf(ios::uppercase);
o.unsetf(ios::showpos); o.unsetf(ios::showpos);
o.fill(' '); o.fill(' ');
std::streamsize cell_width; std::streamsize cell_width;
bool use_layout_B = false; bool use_layout_B = false;
bool use_layout_C = false; bool use_layout_C = false;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT val = data[i]; const eT val = data[i];
if( if(
val >= eT(+100) || val >= eT(+100) ||
( (is_signed<eT>::value == true) && (val <= eT(-100)) ) || ( (is_signed<eT>::value == true) && (val <= eT(-100)) ) ||
( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT (+1e-4)) ) || ( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT (+1e-4)) ) ||
( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == tr ue) && (val < eT(0)) && (val >= eT(-1e-4)) ) ( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == tr ue) && (val < eT(0)) && (val >= eT(-1e-4)) )
) )
{ {
skipping to change at line 110 skipping to change at line 110
cell_width = 9; cell_width = 9;
} }
return cell_width; return cell_width;
} }
//! "better than nothing" settings for complex numbers //! "better than nothing" settings for complex numbers
template<typename T> template<typename T>
inline inline
std::streamsize std::streamsize
arma_ostream::modify_stream(std::ostream& o, const std::complex<T>* data, c onst u32 n_elem) arma_ostream::modify_stream(std::ostream& o, const std::complex<T>* data, c onst uword n_elem)
{ {
arma_ignore(data); arma_ignore(data);
arma_ignore(n_elem); arma_ignore(n_elem);
o.unsetf(ios::showbase); o.unsetf(ios::showbase);
o.unsetf(ios::uppercase); o.unsetf(ios::uppercase);
o.fill(' '); o.fill(' ');
o.setf(ios::scientific); o.setf(ios::scientific);
o.setf(ios::showpos); o.setf(ios::showpos);
skipping to change at line 196 skipping to change at line 196
inline inline
void void
arma_ostream::print(std::ostream& o, const Mat<eT>& m, const bool modify) arma_ostream::print(std::ostream& o, const Mat<eT>& m, const bool modify)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , m.memptr(), m.n_elem) : o.width(); const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , m.memptr(), m.n_elem) : o.width();
const u32 m_n_rows = m.n_rows; const uword m_n_rows = m.n_rows;
const u32 m_n_cols = m.n_cols; const uword m_n_cols = m.n_cols;
if(m.is_empty() == false) if(m.is_empty() == false)
{ {
if(m_n_cols > 0) if(m_n_cols > 0)
{ {
if(cell_width > 0) if(cell_width > 0)
{ {
for(u32 row=0; row < m_n_rows; ++row) for(uword row=0; row < m_n_rows; ++row)
{ {
for(u32 col=0; col < m_n_cols; ++col) for(uword col=0; col < m_n_cols; ++col)
{ {
// the cell width appears to be reset after each element is pri nted, // the cell width appears to be reset after each element is pri nted,
// hence we need to restore it // hence we need to restore it
o.width(cell_width); o.width(cell_width);
arma_ostream::print_elem(o, m.at(row,col)); arma_ostream::print_elem(o, m.at(row,col));
} }
o << '\n'; o << '\n';
} }
} }
else else
{ {
for(u32 row=0; row < m_n_rows; ++row) for(uword row=0; row < m_n_rows; ++row)
{ {
for(u32 col=0; col < m_n_cols-1; ++col) for(uword col=0; col < m_n_cols-1; ++col)
{ {
arma_ostream::print_elem(o, m.at(row,col)); arma_ostream::print_elem(o, m.at(row,col));
o << ' '; o << ' ';
} }
arma_ostream::print_elem(o, m.at(row, m_n_cols-1)); arma_ostream::print_elem(o, m.at(row, m_n_cols-1));
o << '\n'; o << '\n';
} }
} }
} }
skipping to change at line 257 skipping to change at line 257
arma_ostream::print(std::ostream& o, const Cube<eT>& x, const bool modify) arma_ostream::print(std::ostream& o, const Cube<eT>& x, const bool modify)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , x.memptr(), x.n_elem) : o.width(); const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , x.memptr(), x.n_elem) : o.width();
if(x.is_empty() == false) if(x.is_empty() == false)
{ {
for(u32 slice=0; slice < x.n_slices; ++slice) for(uword slice=0; slice < x.n_slices; ++slice)
{ {
o << "[cube slice " << slice << ']' << '\n'; o << "[cube slice " << slice << ']' << '\n';
o.width(cell_width); o.width(cell_width);
arma_ostream::print(o, x.slice(slice), false); arma_ostream::print(o, x.slice(slice), false);
o << '\n'; o << '\n';
} }
} }
else else
{ {
o << "[cube size: " << x.n_rows << 'x' << x.n_cols << 'x' << x.n_slices << "]\n"; o << "[cube size: " << x.n_rows << 'x' << x.n_cols << 'x' << x.n_slices << "]\n";
skipping to change at line 286 skipping to change at line 286
inline inline
void void
arma_ostream::print(std::ostream& o, const field<oT>& x) arma_ostream::print(std::ostream& o, const field<oT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = o.width(); const std::streamsize cell_width = o.width();
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
if(x.is_empty() == false) if(x.is_empty() == false)
{ {
for(u32 col=0; col<x_n_cols; ++col) for(uword col=0; col<x_n_cols; ++col)
{ {
o << "[field column " << col << ']' << '\n'; o << "[field column " << col << ']' << '\n';
for(u32 row=0; row<x_n_rows; ++row) for(uword row=0; row<x_n_rows; ++row)
{ {
o.width(cell_width); o.width(cell_width);
o << x.at(row,col) << '\n'; o << x.at(row,col) << '\n';
} }
o << '\n'; o << '\n';
} }
} }
else else
{ {
skipping to change at line 326 skipping to change at line 326
inline inline
void void
arma_ostream::print(std::ostream& o, const subview_field<oT>& x) arma_ostream::print(std::ostream& o, const subview_field<oT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = o.width(); const std::streamsize cell_width = o.width();
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
for(u32 col=0; col<x_n_cols; ++col) for(uword col=0; col<x_n_cols; ++col)
{ {
o << "[field column " << col << ']' << '\n'; o << "[field column " << col << ']' << '\n';
for(u32 row=0; row<x_n_rows; ++row) for(uword row=0; row<x_n_rows; ++row)
{ {
o.width(cell_width); o.width(cell_width);
o << x.at(row,col) << '\n'; o << x.at(row,col) << '\n';
} }
o << '\n'; o << '\n';
} }
o.flush(); o.flush();
stream_state.restore(o); stream_state.restore(o);
 End of changes. 15 change blocks. 
18 lines changed or deleted 18 lines changed or added


 arma_version.hpp   arma_version.hpp 
skipping to change at line 17 skipping to change at line 17
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 2 #define ARMA_VERSION_MAJOR 2
#define ARMA_VERSION_MINOR 2 #define ARMA_VERSION_MINOR 3
#define ARMA_VERSION_PATCH 5 #define ARMA_VERSION_PATCH 91
#define ARMA_VERSION_NAME "Blue Skies Debauchery" #define ARMA_VERSION_NAME "Loco Lounge Lizard (Beta 1)"
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 3 lines changed or added


 armadillo   armadillo 
skipping to change at line 32 skipping to change at line 32
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <limits> #include <limits>
#include <algorithm> #include <algorithm>
#include <complex> #include <complex>
#include <vector> #include <vector>
#include "armadillo_bits/config.hpp" #include "armadillo_bits/config.hpp"
#include "armadillo_bits/compiler_setup.hpp" #include "armadillo_bits/compiler_setup.hpp"
#include "armadillo_bits/undefine_conflicts.hpp"
#if defined(ARMA_USE_CXX11)
#include <initializer_list>
#endif
#if defined(ARMA_HAVE_GETTIMEOFDAY) #if defined(ARMA_HAVE_GETTIMEOFDAY)
#include <sys/time.h> #include <sys/time.h>
#undef ARMA_USE_BOOST_DATE #undef ARMA_USE_BOOST_DATE
#endif #endif
#if defined(ARMA_USE_BOOST_DATE) #if defined(ARMA_USE_BOOST_DATE)
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#endif #endif
#if defined(ARMA_HAVE_STD_TR1) #if defined(ARMA_HAVE_STD_TR1)
// TODO: add handling of this functionality when use of C++11 is enabled
#include <tr1/cmath> #include <tr1/cmath>
#include <tr1/complex> #include <tr1/complex>
#elif defined(ARMA_USE_BOOST) #elif defined(ARMA_USE_BOOST)
#include <boost/math/complex.hpp> #include <boost/math/complex.hpp>
#include <boost/math/special_functions/acosh.hpp> #include <boost/math/special_functions/acosh.hpp>
#include <boost/math/special_functions/asinh.hpp> #include <boost/math/special_functions/asinh.hpp>
#include <boost/math/special_functions/atanh.hpp> #include <boost/math/special_functions/atanh.hpp>
#endif #endif
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
skipping to change at line 90 skipping to change at line 96
} }
#undef ARMA_STR1 #undef ARMA_STR1
#undef ARMA_STR2 #undef ARMA_STR2
#undef ARMA_CBLAS #undef ARMA_CBLAS
#undef ARMA_CLAPACK #undef ARMA_CLAPACK
#endif #endif
#endif #endif
#include "armadillo_bits/itpp_wrap.hpp" #include "armadillo_bits/itpp_wrap.hpp"
#include "armadillo_bits/undefine_conflicts.hpp"
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
// preliminaries // preliminaries
#include "armadillo_bits/forward_bones.hpp" #include "armadillo_bits/forward_bones.hpp"
#include "armadillo_bits/arma_static_assert.hpp" #include "armadillo_bits/arma_static_check.hpp"
#include "armadillo_bits/typedef.hpp" #include "armadillo_bits/typedef.hpp"
//#include "armadillo_bits/typedef_u64.hpp"
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/format_wrap.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
#include "armadillo_bits/span.hpp" #include "armadillo_bits/span.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
// //
// class prototypes // class prototypes
#include "armadillo_bits/Base.hpp" #include "armadillo_bits/Base_bones.hpp"
#include "armadillo_bits/BaseCube.hpp" #include "armadillo_bits/BaseCube_bones.hpp"
#include "armadillo_bits/blas_bones.hpp" #include "armadillo_bits/blas_bones.hpp"
#include "armadillo_bits/lapack_bones.hpp" #include "armadillo_bits/lapack_bones.hpp"
#include "armadillo_bits/atlas_bones.hpp" #include "armadillo_bits/atlas_bones.hpp"
#include "armadillo_bits/arrayops_bones.hpp" #include "armadillo_bits/arrayops_bones.hpp"
#include "armadillo_bits/podarray_bones.hpp" #include "armadillo_bits/podarray_bones.hpp"
#include "armadillo_bits/auxlib_bones.hpp" #include "armadillo_bits/auxlib_bones.hpp"
#include "armadillo_bits/injector_bones.hpp" #include "armadillo_bits/injector_bones.hpp"
skipping to change at line 168 skipping to change at line 172
#include "armadillo_bits/eGlue_bones.hpp" #include "armadillo_bits/eGlue_bones.hpp"
#include "armadillo_bits/mtGlue_bones.hpp" #include "armadillo_bits/mtGlue_bones.hpp"
#include "armadillo_bits/GlueCube_bones.hpp" #include "armadillo_bits/GlueCube_bones.hpp"
#include "armadillo_bits/eGlueCube_bones.hpp" #include "armadillo_bits/eGlueCube_bones.hpp"
#include "armadillo_bits/mtGlueCube_bones.hpp" #include "armadillo_bits/mtGlueCube_bones.hpp"
#include "armadillo_bits/eop_core_bones.hpp" #include "armadillo_bits/eop_core_bones.hpp"
#include "armadillo_bits/eglue_core_bones.hpp" #include "armadillo_bits/eglue_core_bones.hpp"
#include "armadillo_bits/Gen_bones.hpp"
#include "armadillo_bits/GenCube_bones.hpp"
#include "armadillo_bits/op_diagmat_bones.hpp" #include "armadillo_bits/op_diagmat_bones.hpp"
#include "armadillo_bits/op_diagvec_bones.hpp" #include "armadillo_bits/op_diagvec_bones.hpp"
#include "armadillo_bits/op_dot_bones.hpp" #include "armadillo_bits/op_dot_bones.hpp"
#include "armadillo_bits/op_inv_bones.hpp" #include "armadillo_bits/op_inv_bones.hpp"
#include "armadillo_bits/op_htrans_bones.hpp" #include "armadillo_bits/op_htrans_bones.hpp"
#include "armadillo_bits/op_max_bones.hpp" #include "armadillo_bits/op_max_bones.hpp"
#include "armadillo_bits/op_min_bones.hpp" #include "armadillo_bits/op_min_bones.hpp"
#include "armadillo_bits/op_mean_bones.hpp" #include "armadillo_bits/op_mean_bones.hpp"
#include "armadillo_bits/op_median_bones.hpp" #include "armadillo_bits/op_median_bones.hpp"
#include "armadillo_bits/op_sort_bones.hpp" #include "armadillo_bits/op_sort_bones.hpp"
skipping to change at line 256 skipping to change at line 263
#include "armadillo_bits/eOp_meat.hpp" #include "armadillo_bits/eOp_meat.hpp"
#include "armadillo_bits/eOpCube_meat.hpp" #include "armadillo_bits/eOpCube_meat.hpp"
#include "armadillo_bits/eGlue_meat.hpp" #include "armadillo_bits/eGlue_meat.hpp"
#include "armadillo_bits/eGlueCube_meat.hpp" #include "armadillo_bits/eGlueCube_meat.hpp"
#include "armadillo_bits/mtGlue_meat.hpp" #include "armadillo_bits/mtGlue_meat.hpp"
#include "armadillo_bits/mtGlueCube_meat.hpp" #include "armadillo_bits/mtGlueCube_meat.hpp"
#include "armadillo_bits/Base_meat.hpp"
#include "armadillo_bits/BaseCube_meat.hpp"
#include "armadillo_bits/Gen_meat.hpp"
#include "armadillo_bits/GenCube_meat.hpp"
// //
// ostream // ostream
#include "armadillo_bits/arma_ostream_bones.hpp" #include "armadillo_bits/arma_ostream_bones.hpp"
#include "armadillo_bits/arma_ostream_meat.hpp" #include "armadillo_bits/arma_ostream_meat.hpp"
// //
// operators // operators
#include "armadillo_bits/operator_plus.hpp" #include "armadillo_bits/operator_plus.hpp"
 End of changes. 8 change blocks. 
5 lines changed or deleted 18 lines changed or added


 arrayops_bones.hpp   arrayops_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup arrayops //! \addtogroup arrayops
//! @{ //! @{
class arrayops class arrayops
{ {
public: public:
template<typename eT> template<typename eT>
arma_hot arma_inline static void arma_hot arma_inline static void
copy(eT* dest, const eT* src, const u32 n_elem); copy(eT* dest, const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
static inline void static inline void
copy_big(eT* dest, const eT* src, const u32 n_elem); copy_big(eT* dest, const eT* src, const uword n_elem);
// //
// array = convert(array) // array = convert(array)
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_inline static void arma_hot arma_inline static void
convert_cx_scalar(out_eT& out, const in_eT& in, const typename arma_not_ cx<out_eT>::result* junk1 = 0, const typename arma_not_cx< in_eT>::result* junk2 = 0); convert_cx_scalar(out_eT& out, const in_eT& in, const typename arma_not_ cx<out_eT>::result* junk1 = 0, const typename arma_not_cx< in_eT>::result* junk2 = 0);
template<typename out_eT, typename in_T> template<typename out_eT, typename in_T>
arma_hot arma_inline static void arma_hot arma_inline static void
convert_cx_scalar(out_eT& out, const std::complex<in_T>& in, const typena me arma_not_cx<out_eT>::result* junk = 0); convert_cx_scalar(out_eT& out, const std::complex<in_T>& in, const typena me arma_not_cx<out_eT>::result* junk = 0);
template<typename out_T, typename in_T> template<typename out_T, typename in_T>
arma_hot arma_inline static void arma_hot arma_inline static void
convert_cx_scalar(std::complex<out_T>& out, const std::complex< in_T>& in ); convert_cx_scalar(std::complex<out_T>& out, const std::complex< in_T>& in );
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot inline static void arma_hot inline static void
convert(out_eT* dest, const in_eT* src, const u32 n_elem); convert(out_eT* dest, const in_eT* src, const uword n_elem);
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot inline static void arma_hot inline static void
convert_cx(out_eT* dest, const in_eT* src, const u32 n_elem); convert_cx(out_eT* dest, const in_eT* src, const uword n_elem);
// //
// array op= array // array op= array
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_plus(eT* dest, const eT* src, const u32 n_elem); inplace_plus(eT* dest, const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_minus(eT* dest, const eT* src, const u32 n_elem); inplace_minus(eT* dest, const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_mul(eT* dest, const eT* src, const u32 n_elem); inplace_mul(eT* dest, const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_div(eT* dest, const eT* src, const u32 n_elem); inplace_div(eT* dest, const eT* src, const uword n_elem);
// //
// array op= scalar // array op= scalar
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_set(eT* dest, const eT val, const u32 n_elem); inplace_set(eT* dest, const eT val, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_plus(eT* dest, const eT val, const u32 n_elem); inplace_plus(eT* dest, const eT val, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_minus(eT* dest, const eT val, const u32 n_elem); inplace_minus(eT* dest, const eT val, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static void arma_hot inline static void
inplace_mul(eT* dest, const eT val, const u32 n_elem); inplace_mul(eT* dest, const eT val, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_div(eT* dest, const eT val, const u32 n_elem); inplace_div(eT* dest, const eT val, const uword n_elem);
// //
// scalar = op(array) // scalar = op(array)
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
eT eT
accumulate(const eT* src, const u32 n_elem); accumulate(const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
eT eT
product(const eT* src, const u32 n_elem); product(const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
bool bool
is_finite(const eT* src, const u32 n_elem); is_finite(const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
norm_1(const eT* src, const u32 n_elem); norm_1(const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
eT eT
norm_2(const eT* src, const u32 n_elem, const typename arma_not_cx<eT>::r esult* junk = 0); norm_2(const eT* src, const uword n_elem, const typename arma_not_cx<eT>: :result* junk = 0);
template<typename T> template<typename T>
arma_hot arma_pure inline static arma_hot arma_pure inline static
T T
norm_2(const std::complex<T>* src, const u32 n_elem); norm_2(const std::complex<T>* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
norm_k(const eT* src, const u32 n_elem, const int k); norm_k(const eT* src, const uword n_elem, const int k);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
norm_max(const eT* src, const u32 n_elem); norm_max(const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static arma_hot arma_pure inline static
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
norm_min(const eT* src, const u32 n_elem); norm_min(const eT* src, const uword n_elem);
}; };
//! @} //! @}
 End of changes. 22 change blocks. 
22 lines changed or deleted 22 lines changed or added


 arrayops_meat.hpp   arrayops_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arrayops //! \addtogroup arrayops
//! @{ //! @{
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_inline arma_inline
void void
arrayops::copy(eT* dest, const eT* src, const u32 n_elem) arrayops::copy(eT* dest, const eT* src, const uword n_elem)
{ {
switch(n_elem) switch(n_elem)
{ {
default: default:
arrayops::copy_big(dest, src, n_elem); arrayops::copy_big(dest, src, n_elem);
break; break;
case 8: case 8:
dest[7] = src[7]; dest[7] = src[7];
case 7: case 7:
dest[6] = src[6]; dest[6] = src[6];
skipping to change at line 49 skipping to change at line 49
case 2: case 2:
dest[1] = src[1]; dest[1] = src[1];
case 1: case 1:
dest[0] = src[0]; dest[0] = src[0];
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
arrayops::copy_big(eT* dest, const eT* src, const u32 n_elem) arrayops::copy_big(eT* dest, const eT* src, const uword n_elem)
{ {
switch(n_elem) switch(n_elem)
{ {
default: default:
std::memcpy(dest, src, n_elem*sizeof(eT)); std::memcpy(dest, src, n_elem*sizeof(eT));
break; break;
case 32: case 32:
dest[31] = src[31]; dest[31] = src[31];
case 31: case 31:
dest[30] = src[30]; dest[30] = src[30];
skipping to change at line 176 skipping to change at line 176
{ {
typedef std::complex<out_T> out_eT; typedef std::complex<out_T> out_eT;
out = out_eT(in); out = out_eT(in);
} }
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_hot
inline inline
void void
arrayops::convert(out_eT* dest, const in_eT* src, const u32 n_elem) arrayops::convert(out_eT* dest, const in_eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] = out_eT( src[i] ); dest[i] = out_eT( src[i] );
dest[j] = out_eT( src[j] ); dest[j] = out_eT( src[j] );
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] = out_eT( src[i] ); dest[i] = out_eT( src[i] );
} }
} }
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_hot
inline inline
void void
arrayops::convert_cx(out_eT* dest, const in_eT* src, const u32 n_elem) arrayops::convert_cx(out_eT* dest, const in_eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
arrayops::convert_cx_scalar( dest[i], src[i] ); arrayops::convert_cx_scalar( dest[i], src[i] );
arrayops::convert_cx_scalar( dest[j], src[j] ); arrayops::convert_cx_scalar( dest[j], src[j] );
} }
if(i < n_elem) if(i < n_elem)
{ {
arrayops::convert_cx_scalar( dest[i], src[i] ); arrayops::convert_cx_scalar( dest[i], src[i] );
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_plus(eT* dest, const eT* src, const u32 n_elem) arrayops::inplace_plus(eT* dest, const eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] += src[i]; dest[i] += src[i];
dest[j] += src[j]; dest[j] += src[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] += src[i]; dest[i] += src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_minus(eT* dest, const eT* src, const u32 n_elem) arrayops::inplace_minus(eT* dest, const eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] -= src[i]; dest[i] -= src[i];
dest[j] -= src[j]; dest[j] -= src[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] -= src[i]; dest[i] -= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_mul(eT* dest, const eT* src, const u32 n_elem) arrayops::inplace_mul(eT* dest, const eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] *= src[i]; dest[i] *= src[i];
dest[j] *= src[j]; dest[j] *= src[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] *= src[i]; dest[i] *= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_div(eT* dest, const eT* src, const u32 n_elem) arrayops::inplace_div(eT* dest, const eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] /= src[i]; dest[i] /= src[i];
dest[j] /= src[j]; dest[j] /= src[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] /= src[i]; dest[i] /= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_set(eT* dest, const eT val, const u32 n_elem) arrayops::inplace_set(eT* dest, const eT val, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] = val; dest[i] = val;
dest[j] = val; dest[j] = val;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] = val; dest[i] = val;
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_plus(eT* dest, const eT val, const u32 n_elem) arrayops::inplace_plus(eT* dest, const eT val, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] += val; dest[i] += val;
dest[j] += val; dest[j] += val;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] += val; dest[i] += val;
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_minus(eT* dest, const eT val, const u32 n_elem) arrayops::inplace_minus(eT* dest, const eT val, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] -= val; dest[i] -= val;
dest[j] -= val; dest[j] -= val;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] -= val; dest[i] -= val;
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_mul(eT* dest, const eT val, const u32 n_elem) arrayops::inplace_mul(eT* dest, const eT val, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] *= val; dest[i] *= val;
dest[j] *= val; dest[j] *= val;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] *= val; dest[i] *= val;
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_div(eT* dest, const eT val, const u32 n_elem) arrayops::inplace_div(eT* dest, const eT val, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] /= val; dest[i] /= val;
dest[j] /= val; dest[j] /= val;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] /= val; dest[i] /= val;
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
eT eT
arrayops::accumulate(const eT* src, const u32 n_elem) arrayops::accumulate(const eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
eT acc1 = eT(0); eT acc1 = eT(0);
eT acc2 = eT(0); eT acc2 = eT(0);
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
acc1 += src[i]; acc1 += src[i];
acc2 += src[j]; acc2 += src[j];
} }
skipping to change at line 423 skipping to change at line 423
} }
return acc1 + acc2; return acc1 + acc2;
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
eT eT
arrayops::product(const eT* src, const u32 n_elem) arrayops::product(const eT* src, const uword n_elem)
{ {
eT val1 = eT(1); eT val1 = eT(1);
eT val2 = eT(1); eT val2 = eT(1);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val1 *= src[i]; val1 *= src[i];
val2 *= src[j]; val2 *= src[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
val1 *= src[i]; val1 *= src[i];
} }
return val1 * val2; return val1 * val2;
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
bool bool
arrayops::is_finite(const eT* src, const u32 n_elem) arrayops::is_finite(const eT* src, const uword n_elem)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT val_i = src[i]; const eT val_i = src[i];
const eT val_j = src[j]; const eT val_j = src[j];
if( (arma_isfinite(val_i) == false) || (arma_isfinite(val_j) == false) ) if( (arma_isfinite(val_i) == false) || (arma_isfinite(val_j) == false) )
{ {
return false; return false;
} }
skipping to change at line 481 skipping to change at line 481
return true; return true;
} }
// TODO: this function is currently not used // TODO: this function is currently not used
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
arrayops::norm_1(const eT* src, const u32 n_elem) arrayops::norm_1(const eT* src, const uword n_elem)
{ {
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
T acc = T(0); T acc = T(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
acc += std::abs(src[i]); acc += std::abs(src[i]);
acc += std::abs(src[j]); acc += std::abs(src[j]);
} }
if(i < n_elem) if(i < n_elem)
{ {
acc += std::abs(src[i]); acc += std::abs(src[i]);
skipping to change at line 509 skipping to change at line 509
return acc; return acc;
} }
// TODO: this function is currently not used // TODO: this function is currently not used
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
eT eT
arrayops::norm_2(const eT* src, const u32 n_elem, const typename arma_not_c x<eT>::result* junk) arrayops::norm_2(const eT* src, const uword n_elem, const typename arma_not _cx<eT>::result* junk)
{ {
arma_ignore(junk); arma_ignore(junk);
eT acc = eT(0); eT acc = eT(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = src[i]; const eT tmp_i = src[i];
const eT tmp_j = src[j]; const eT tmp_j = src[j];
acc += tmp_i * tmp_i; acc += tmp_i * tmp_i;
acc += tmp_j * tmp_j; acc += tmp_j * tmp_j;
} }
skipping to change at line 542 skipping to change at line 542
return std::sqrt(acc); return std::sqrt(acc);
} }
// TODO: this function is currently not used // TODO: this function is currently not used
template<typename T> template<typename T>
arma_hot arma_hot
arma_pure arma_pure
inline inline
T T
arrayops::norm_2(const std::complex<T>* src, const u32 n_elem) arrayops::norm_2(const std::complex<T>* src, const uword n_elem)
{ {
T acc = T(0); T acc = T(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const T tmp_i = std::abs(src[i]); const T tmp_i = std::abs(src[i]);
const T tmp_j = std::abs(src[j]); const T tmp_j = std::abs(src[j]);
acc += tmp_i * tmp_i; acc += tmp_i * tmp_i;
acc += tmp_j * tmp_j; acc += tmp_j * tmp_j;
} }
skipping to change at line 573 skipping to change at line 573
return std::sqrt(acc); return std::sqrt(acc);
} }
// TODO: this function is currently not used // TODO: this function is currently not used
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
arrayops::norm_k(const eT* src, const u32 n_elem, const int k) arrayops::norm_k(const eT* src, const uword n_elem, const int k)
{ {
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
T acc = T(0); T acc = T(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
acc += std::pow(std::abs(src[i]), k); acc += std::pow(std::abs(src[i]), k);
acc += std::pow(std::abs(src[j]), k); acc += std::pow(std::abs(src[j]), k);
} }
if(i < n_elem) if(i < n_elem)
{ {
acc += std::pow(std::abs(src[i]), k); acc += std::pow(std::abs(src[i]), k);
skipping to change at line 601 skipping to change at line 601
return std::pow(acc, T(1)/T(k)); return std::pow(acc, T(1)/T(k));
} }
// TODO: this function is currently not used // TODO: this function is currently not used
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
arrayops::norm_max(const eT* src, const u32 n_elem) arrayops::norm_max(const eT* src, const uword n_elem)
{ {
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
T max_val = std::abs(src[0]); T max_val = std::abs(src[0]);
u32 i,j; uword i,j;
for(i=1, j=2; j<n_elem; i+=2, j+=2) for(i=1, j=2; j<n_elem; i+=2, j+=2)
{ {
const T tmp_i = std::abs(src[i]); const T tmp_i = std::abs(src[i]);
const T tmp_j = std::abs(src[j]); const T tmp_j = std::abs(src[j]);
if(max_val < tmp_i) { max_val = tmp_i; } if(max_val < tmp_i) { max_val = tmp_i; }
if(max_val < tmp_j) { max_val = tmp_j; } if(max_val < tmp_j) { max_val = tmp_j; }
} }
skipping to change at line 634 skipping to change at line 634
return max_val; return max_val;
} }
// TODO: this function is currently not used // TODO: this function is currently not used
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
arrayops::norm_min(const eT* src, const u32 n_elem) arrayops::norm_min(const eT* src, const uword n_elem)
{ {
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
T min_val = std::abs(src[0]); T min_val = std::abs(src[0]);
u32 i,j; uword i,j;
for(i=1, j=2; j<n_elem; i+=2, j+=2) for(i=1, j=2; j<n_elem; i+=2, j+=2)
{ {
const T tmp_i = std::abs(src[i]); const T tmp_i = std::abs(src[i]);
const T tmp_j = std::abs(src[j]); const T tmp_j = std::abs(src[j]);
if(min_val > tmp_i) { min_val = tmp_i; } if(min_val > tmp_i) { min_val = tmp_i; }
if(min_val > tmp_j) { min_val = tmp_j; } if(min_val > tmp_j) { min_val = tmp_j; }
} }
 End of changes. 42 change blocks. 
42 lines changed or deleted 42 lines changed or added


 atlas_bones.hpp   atlas_bones.hpp 
skipping to change at line 59 skipping to change at line 59
inline static const eT& tmp_real(const eT& X) { return X; } inline static const eT& tmp_real(const eT& X) { return X; }
template<typename T> template<typename T>
inline static const T& tmp_real(const std::complex<T>& X) { return X.rea l(); } inline static const T& tmp_real(const std::complex<T>& X) { return X.rea l(); }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
cblas_dot(const int N, const eT* X, const eT* Y) cblas_dot(const int N, const eT* X, const eT* Y)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
return eT( cblas_sdot(N, (const T*)X, 1, (const T*)Y, 1) ); return eT( cblas_sdot(N, (const T*)X, 1, (const T*)Y, 1) );
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 83 skipping to change at line 83
{ {
return eT(0); return eT(0);
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
cx_cblas_dot(const int N, const eT* X, const eT* Y) cx_cblas_dot(const int N, const eT* X, const eT* Y)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_supported_complex_float<eT>::value == true) if(is_supported_complex_float<eT>::value == true)
{ {
typedef typename std::complex<float> T; typedef typename std::complex<float> T;
T out; T out;
cblas_cdotu_sub(N, (const T*)X, 1, (const T*)Y, 1, &out); cblas_cdotu_sub(N, (const T*)X, 1, (const T*)Y, 1, &out);
return eT(out); return eT(out);
} }
skipping to change at line 124 skipping to change at line 124
( (
const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const int M, const int N, const int M, const int N,
const eT alpha, const eT alpha,
const eT *A, const int lda, const eT *A, const int lda,
const eT *X, const int incX, const eT *X, const int incX,
const eT beta, const eT beta,
eT *Y, const int incY eT *Y, const int incY
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
cblas_sgemv(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*) A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY); cblas_sgemv(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*) A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 163 skipping to change at line 163
void void
cblas_gemm cblas_gemm
( (
const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const enum CBLAS_TRANSPOSE TransB, const int M, const int N, const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
const int K, const eT alpha, const eT *A, const int K, const eT alpha, const eT *A,
const int lda, const eT *B, const int ldb, const int lda, const eT *B, const int ldb,
const eT beta, eT *C, const int ldc const eT beta, eT *C, const int ldc
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
cblas_sgemm(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc); cblas_sgemm(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 199 skipping to change at line 199
template<typename eT> template<typename eT>
inline inline
int int
clapack_getrf clapack_getrf
( (
const enum CBLAS_ORDER Order, const int M, const int N, const enum CBLAS_ORDER Order, const int M, const int N,
eT *A, const int lda, int *ipiv eT *A, const int lda, int *ipiv
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
return clapack_sgetrf(Order, M, N, (T*)A, lda, ipiv); return clapack_sgetrf(Order, M, N, (T*)A, lda, ipiv);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 239 skipping to change at line 239
template<typename eT> template<typename eT>
inline inline
int int
clapack_getri clapack_getri
( (
const enum CBLAS_ORDER Order, const int N, eT *A, const enum CBLAS_ORDER Order, const int N, eT *A,
const int lda, const int *ipiv const int lda, const int *ipiv
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
return clapack_sgetri(Order, N, (T*)A, lda, ipiv); return clapack_sgetri(Order, N, (T*)A, lda, ipiv);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 auxlib_bones.hpp   auxlib_bones.hpp 
skipping to change at line 23 skipping to change at line 23
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup auxlib //! \addtogroup auxlib
//! @{ //! @{
//! wrapper for accessing external functions defined in ATLAS, LAPACK or BL AS libraries //! wrapper for accessing external functions defined in ATLAS, LAPACK or BL AS libraries
class auxlib class auxlib
{ {
public: public:
template<const u32 row, const u32 col> template<const uword row, const uword col>
struct pos struct pos
{ {
static const u32 n2 = row + col*2; static const uword n2 = row + col*2;
static const u32 n3 = row + col*3; static const uword n3 = row + col*3;
static const u32 n4 = row + col*4; static const uword n4 = row + col*4;
}; };
// //
// inv // inv
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slo w = false); inline static bool inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slo w = false);
template<typename eT> template<typename eT>
inline static bool inv(Mat<eT>& out, const Mat<eT>& A, const bool slow = false); inline static bool inv(Mat<eT>& out, const Mat<eT>& A, const bool slow = false);
template<typename eT> template<typename eT>
inline static bool inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, co nst u32 N); inline static bool inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, co nst uword N);
template<typename eT> template<typename eT>
inline static bool inv_inplace_tinymat(Mat<eT>& out, const u32 N); inline static bool inv_inplace_tinymat(Mat<eT>& out, const uword N);
template<typename eT> template<typename eT>
inline static bool inv_inplace_lapack(Mat<eT>& out); inline static bool inv_inplace_lapack(Mat<eT>& out);
// //
// inv_tr // inv_tr
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const u32 l ayout); inline static bool inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const uword layout);
// //
// inv_sym // inv_sym
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout); inline static bool inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const uwor d layout);
// //
// inv_sympd // inv_sympd
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const u3 2 layout); inline static bool inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const uw ord layout);
// //
// det // det
template<typename eT, typename T1> template<typename eT, typename T1>
inline static eT det(const Base<eT,T1>& X, const bool slow = false); inline static eT det(const Base<eT,T1>& X, const bool slow = false);
template<typename eT> template<typename eT>
inline static eT det_tinymat(const Mat<eT>& X, const u32 N); inline static eT det_tinymat(const Mat<eT>& X, const uword N);
template<typename eT> template<typename eT>
inline static eT det_lapack(const Mat<eT>& X, const bool make_copy); inline static eT det_lapack(const Mat<eT>& X, const bool make_copy);
// //
// log_det // log_det
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool log_det(eT& out_val, typename get_pod_type<eT>::result & out_sign, const Base<eT,T1>& X); inline static bool log_det(eT& out_val, typename get_pod_type<eT>::result & out_sign, const Base<eT,T1>& X);
skipping to change at line 134 skipping to change at line 134
// //
// qr // qr
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X); inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X);
// //
// svd // svd
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd(Col<eT>& S, const Base<eT,T1>& X, u32& n_rows, u32 & n_cols); inline static bool svd(Col<eT>& S, const Base<eT,T1>& X, uword& n_rows, u word& n_cols);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X, u32 & n_rows, u32& n_cols); inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X, uwo rd& n_rows, uword& n_cols);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd(Col<eT>& S, const Base<eT,T1>& X); inline static bool svd(Col<eT>& S, const Base<eT,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X); inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT, T1>& X); inline static bool svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT, T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::co mplex<T> >& V, const Base< std::complex<T>, T1>& X); inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::co mplex<T> >& V, const Base< std::complex<T>, T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd_thin(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Bas e<eT,T1>& X, const char mode); inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Bas e<eT,T1>& X, const char mode);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd_thin(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode); inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode);
// //
// solve // solve
template<typename eT> template<typename eT>
inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, c onst bool slow = false); inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, c onst bool slow = false);
template<typename eT> template<typename eT>
inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B); inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B);
template<typename eT> template<typename eT>
inline static bool solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B); inline static bool solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B);
// //
// solve_tr // solve_tr
template<typename eT> template<typename eT>
inline static bool solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT> & B, const u32 layout); inline static bool solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT> & B, const uword layout);
// //
// Schur decomposition // Schur decomposition
template<typename eT> template<typename eT>
inline static bool schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A); inline static bool schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A);
template<typename cT> template<typename cT>
inline static bool schur_dec(Mat<std::complex<cT> >& Z, Mat<std::complex< cT> >& T, const Mat<std::complex<cT> >& A); inline static bool schur_dec(Mat<std::complex<cT> >& Z, Mat<std::complex< cT> >& T, const Mat<std::complex<cT> >& A);
 End of changes. 13 change blocks. 
15 lines changed or deleted 15 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
skipping to change at line 33 skipping to change at line 33
auxlib::inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slow) auxlib::inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slow)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
bool status = false; bool status = false;
const u32 N = out.n_rows; const uword N = out.n_rows;
if( (N <= 4) && (slow == false) ) if( (N <= 4) && (slow == false) )
{ {
status = auxlib::inv_inplace_tinymat(out, N); status = auxlib::inv_inplace_tinymat(out, N);
} }
if( (N > 4) || (status == false) ) if( (N > 4) || (status == false) )
{ {
status = auxlib::inv_inplace_lapack(out); status = auxlib::inv_inplace_lapack(out);
} }
skipping to change at line 59 skipping to change at line 59
inline inline
bool bool
auxlib::inv(Mat<eT>& out, const Mat<eT>& X, const bool slow) auxlib::inv(Mat<eT>& out, const Mat<eT>& X, const bool slow)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s quare" ); arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s quare" );
bool status = false; bool status = false;
const u32 N = X.n_rows; const uword N = X.n_rows;
if( (N <= 4) && (slow == false) ) if( (N <= 4) && (slow == false) )
{ {
status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib ::inv_inplace_tinymat(out, N); status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib ::inv_inplace_tinymat(out, N);
} }
if( (N > 4) || (status == false) ) if( (N > 4) || (status == false) )
{ {
out = X; out = X;
status = auxlib::inv_inplace_lapack(out); status = auxlib::inv_inplace_lapack(out);
} }
return status; return status;
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, const u32 N) auxlib::inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, const uword N)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool det_ok = true; bool det_ok = true;
out.set_size(N,N); out.set_size(N,N);
switch(N) switch(N)
{ {
case 1: case 1:
skipping to change at line 210 skipping to change at line 210
default: default:
; ;
} }
return det_ok; return det_ok;
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::inv_inplace_tinymat(Mat<eT>& X, const u32 N) auxlib::inv_inplace_tinymat(Mat<eT>& X, const uword N)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool det_ok = true; bool det_ok = true;
// for more info, see: // for more info, see:
// http://www.dr-lex.34sp.com/random/matrix_inv.html // http://www.dr-lex.34sp.com/random/matrix_inv.html
// http://www.cvl.iis.u-tokyo.ac.jp/~miyazaki/tech/teche23.html // http://www.cvl.iis.u-tokyo.ac.jp/~miyazaki/tech/teche23.html
// http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/f ourD/index.htm // http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/f ourD/index.htm
// http://www.geometrictools.com//LibFoundation/Mathematics/Wm4Matrix4.in l // http://www.geometrictools.com//LibFoundation/Mathematics/Wm4Matrix4.in l
skipping to change at line 379 skipping to change at line 379
podarray<blas_int> ipiv(out.n_rows); podarray<blas_int> ipiv(out.n_rows);
// 84 was empirically found -- it is the maximum value suggested by LAP ACK (as provided by ATLAS v3.6) // 84 was empirically found -- it is the maximum value suggested by LAP ACK (as provided by ATLAS v3.6)
// based on tests with various matrix types on 32-bit and 64-bit machin es // based on tests with various matrix types on 32-bit and 64-bit machin es
// //
// the "work" array is deliberately long so that a secondary (time-cons uming) // the "work" array is deliberately long so that a secondary (time-cons uming)
// memory allocation is avoided, if possible // memory allocation is avoided, if possible
blas_int work_len = (std::max)(blas_int(1), n_rows*84); blas_int work_len = (std::max)(blas_int(1), n_rows*84);
podarray<eT> work( static_cast<u32>(work_len) ); podarray<eT> work( static_cast<uword>(work_len) );
lapack::getrf(&n_rows, &n_cols, out.memptr(), &n_rows, ipiv.memptr(), & info); lapack::getrf(&n_rows, &n_cols, out.memptr(), &n_rows, ipiv.memptr(), & info);
if(info == 0) if(info == 0)
{ {
// query for optimum size of work_len // query for optimum size of work_len
blas_int work_len_tmp = -1; blas_int work_len_tmp = -1;
lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &work_len_tmp, &info); lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &work_len_tmp, &info);
if(info == 0) if(info == 0)
{ {
blas_int proposed_work_len = static_cast<blas_int>(access::tmp_real (work[0])); blas_int proposed_work_len = static_cast<blas_int>(access::tmp_real (work[0]));
// if necessary, allocate more memory // if necessary, allocate more memory
if(work_len < proposed_work_len) if(work_len < proposed_work_len)
{ {
work_len = proposed_work_len; work_len = proposed_work_len;
work.set_size( static_cast<u32>(work_len) ); work.set_size( static_cast<uword>(work_len) );
} }
} }
lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &work_len, &info); lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &work_len, &info);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_stop("inv(): use of ATLAS or LAPACK needs to be enabled"); arma_stop("inv(): use of ATLAS or LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout) auxlib::inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const uword layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
if(out.is_empty()) if(out.is_empty())
{ {
return true; return true;
skipping to change at line 473 skipping to change at line 473
out = trimatl(out); out = trimatl(out);
} }
} }
return status; return status;
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout) auxlib::inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const uword layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
if(out.is_empty()) if(out.is_empty())
{ {
return true; return true;
skipping to change at line 499 skipping to change at line 499
{ {
char uplo = (layout == 0) ? 'U' : 'L'; char uplo = (layout == 0) ? 'U' : 'L';
blas_int n = blas_int(out.n_rows); blas_int n = blas_int(out.n_rows);
blas_int lwork = n*n; // TODO: use lwork = -1 to determine optimal size blas_int lwork = n*n; // TODO: use lwork = -1 to determine optimal size
blas_int info = 0; blas_int info = 0;
podarray<blas_int> ipiv; podarray<blas_int> ipiv;
ipiv.set_size(out.n_rows); ipiv.set_size(out.n_rows);
podarray<eT> work; podarray<eT> work;
work.set_size( u32(lwork) ); work.set_size( uword(lwork) );
lapack::sytrf(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr() , &lwork, &info); lapack::sytrf(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr() , &lwork, &info);
status = (info == 0); status = (info == 0);
if(status == true) if(status == true)
{ {
lapack::sytri(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr (), &info); lapack::sytri(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr (), &info);
out = (layout == 0) ? symmatu(out) : symmatl(out); out = (layout == 0) ? symmatu(out) : symmatl(out);
skipping to change at line 528 skipping to change at line 528
status = false; status = false;
} }
#endif #endif
return status; return status;
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout) auxlib::inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const uword layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
if(out.is_empty()) if(out.is_empty())
{ {
return true; return true;
skipping to change at line 587 skipping to change at line 587
{ {
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "det(): matrix is not square" ); arma_debug_check( (A.is_square() == false), "det(): matrix is not square" );
const bool make_copy = (is_Mat<T1>::value == true) ? true : false; const bool make_copy = (is_Mat<T1>::value == true) ? true : false;
if(slow == false) if(slow == false)
{ {
const u32 N = A.n_rows; const uword N = A.n_rows;
switch(N) switch(N)
{ {
case 0: case 0:
case 1: case 1:
case 2: case 2:
return auxlib::det_tinymat(A, N); return auxlib::det_tinymat(A, N);
break; break;
case 3: case 3:
skipping to change at line 618 skipping to change at line 618
} }
else else
{ {
return auxlib::det_lapack(A, make_copy); return auxlib::det_lapack(A, make_copy);
} }
} }
template<typename eT> template<typename eT>
inline inline
eT eT
auxlib::det_tinymat(const Mat<eT>& X, const u32 N) auxlib::det_tinymat(const Mat<eT>& X, const uword N)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(N) switch(N)
{ {
case 0: case 0:
return eT(1); return eT(1);
break; break;
case 1: case 1:
skipping to change at line 741 skipping to change at line 741
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
podarray<int> ipiv(tmp.n_rows); podarray<int> ipiv(tmp.n_rows);
//const int info = //const int info =
atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp. memptr(), tmp.n_rows, ipiv.memptr()); atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp. memptr(), tmp.n_rows, ipiv.memptr());
// on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero
eT val = tmp.at(0,0); eT val = tmp.at(0,0);
for(u32 i=1; i < tmp.n_rows; ++i) for(uword i=1; i < tmp.n_rows; ++i)
{ {
val *= tmp.at(i,i); val *= tmp.at(i,i);
} }
int sign = +1; int sign = +1;
for(u32 i=0; i < tmp.n_rows; ++i) for(uword i=0; i < tmp.n_rows; ++i)
{ {
if( int(i) != ipiv.mem[i] ) // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0 if( int(i) != ipiv.mem[i] ) // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0
{ {
sign *= -1; sign *= -1;
} }
} }
return ( (sign < 0) ? -val : val ); return ( (sign < 0) ? -val : val );
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
skipping to change at line 769 skipping to change at line 769
podarray<blas_int> ipiv(tmp.n_rows); podarray<blas_int> ipiv(tmp.n_rows);
blas_int info = 0; blas_int info = 0;
blas_int n_rows = blas_int(tmp.n_rows); blas_int n_rows = blas_int(tmp.n_rows);
blas_int n_cols = blas_int(tmp.n_cols); blas_int n_cols = blas_int(tmp.n_cols);
lapack::getrf(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr(), & info); lapack::getrf(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr(), & info);
// on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero
eT val = tmp.at(0,0); eT val = tmp.at(0,0);
for(u32 i=1; i < tmp.n_rows; ++i) for(uword i=1; i < tmp.n_rows; ++i)
{ {
val *= tmp.at(i,i); val *= tmp.at(i,i);
} }
blas_int sign = +1; blas_int sign = +1;
for(u32 i=0; i < tmp.n_rows; ++i) for(uword i=0; i < tmp.n_rows; ++i)
{ {
if( blas_int(i) != (ipiv.mem[i] - 1) ) // NOTE: adjustment of -1 is required as Fortran counts from 1 if( blas_int(i) != (ipiv.mem[i] - 1) ) // NOTE: adjustment of -1 is required as Fortran counts from 1
{ {
sign *= -1; sign *= -1;
} }
} }
return ( (sign < 0) ? -val : val ); return ( (sign < 0) ? -val : val );
} }
#else #else
skipping to change at line 824 skipping to change at line 824
out_sign = T(1); out_sign = T(1);
return true; return true;
} }
podarray<int> ipiv(tmp.n_rows); podarray<int> ipiv(tmp.n_rows);
const int info = atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp.memptr(), tmp.n_rows, ipiv.memptr()); const int info = atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp.memptr(), tmp.n_rows, ipiv.memptr());
// on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero
s32 sign = (is_complex<eT>::value == false) ? ( (access::tmp_real( tmp. at(0,0) ) < T(0)) ? -1 : +1 ) : +1; sword sign = (is_complex<eT>::value == false) ? ( (access::tmp_real( tm p.at(0,0) ) < T(0)) ? -1 : +1 ) : +1;
eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_re al( tmp.at(0,0) ) < T(0)) ? tmp.at(0,0)*T(-1) : tmp.at(0,0) ) : std::log( t mp.at(0,0) ); eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_re al( tmp.at(0,0) ) < T(0)) ? tmp.at(0,0)*T(-1) : tmp.at(0,0) ) : std::log( t mp.at(0,0) );
for(u32 i=1; i < tmp.n_rows; ++i) for(uword i=1; i < tmp.n_rows; ++i)
{ {
const eT x = tmp.at(i,i); const eT x = tmp.at(i,i);
sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T (0)) ? -1 : +1 ) : +1; sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T (0)) ? -1 : +1 ) : +1;
val += (is_complex<eT>::value == false) ? std::log( (access::tmp_rea l(x) < T(0)) ? x*T(-1) : x ) : std::log(x); val += (is_complex<eT>::value == false) ? std::log( (access::tmp_rea l(x) < T(0)) ? x*T(-1) : x ) : std::log(x);
} }
for(u32 i=0; i < tmp.n_rows; ++i) for(uword i=0; i < tmp.n_rows; ++i)
{ {
if( int(i) != ipiv.mem[i] ) // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0 if( int(i) != ipiv.mem[i] ) // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0
{ {
sign *= -1; sign *= -1;
} }
} }
out_val = val; out_val = val;
out_sign = T(sign); out_sign = T(sign);
skipping to change at line 870 skipping to change at line 870
podarray<blas_int> ipiv(tmp.n_rows); podarray<blas_int> ipiv(tmp.n_rows);
blas_int info = 0; blas_int info = 0;
blas_int n_rows = blas_int(tmp.n_rows); blas_int n_rows = blas_int(tmp.n_rows);
blas_int n_cols = blas_int(tmp.n_cols); blas_int n_cols = blas_int(tmp.n_cols);
lapack::getrf(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr(), & info); lapack::getrf(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr(), & info);
// on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero
s32 sign = (is_complex<eT>::value == false) ? ( (access::tmp_real( tmp. at(0,0) ) < T(0)) ? -1 : +1 ) : +1; sword sign = (is_complex<eT>::value == false) ? ( (access::tmp_real( tm p.at(0,0) ) < T(0)) ? -1 : +1 ) : +1;
eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_re al( tmp.at(0,0) ) < T(0)) ? tmp.at(0,0)*T(-1) : tmp.at(0,0) ) : std::log( t mp.at(0,0) ); eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_re al( tmp.at(0,0) ) < T(0)) ? tmp.at(0,0)*T(-1) : tmp.at(0,0) ) : std::log( t mp.at(0,0) );
for(u32 i=1; i < tmp.n_rows; ++i) for(uword i=1; i < tmp.n_rows; ++i)
{ {
const eT x = tmp.at(i,i); const eT x = tmp.at(i,i);
sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T (0)) ? -1 : +1 ) : +1; sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T (0)) ? -1 : +1 ) : +1;
val += (is_complex<eT>::value == false) ? std::log( (access::tmp_rea l(x) < T(0)) ? x*T(-1) : x ) : std::log(x); val += (is_complex<eT>::value == false) ? std::log( (access::tmp_rea l(x) < T(0)) ? x*T(-1) : x ) : std::log(x);
} }
for(u32 i=0; i < tmp.n_rows; ++i) for(uword i=0; i < tmp.n_rows; ++i)
{ {
if( blas_int(i) != (ipiv.mem[i] - 1) ) // NOTE: adjustment of -1 is required as Fortran counts from 1 if( blas_int(i) != (ipiv.mem[i] - 1) ) // NOTE: adjustment of -1 is required as Fortran counts from 1
{ {
sign *= -1; sign *= -1;
} }
} }
out_val = val; out_val = val;
out_sign = T(sign); out_sign = T(sign);
skipping to change at line 916 skipping to change at line 916
//! immediate LU decomposition of a matrix using ATLAS or LAPACK //! immediate LU decomposition of a matrix using ATLAS or LAPACK
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, const Base<eT, T1>& X) auxlib::lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, const Base<eT, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
U = X.get_ref(); U = X.get_ref();
const u32 U_n_rows = U.n_rows; const uword U_n_rows = U.n_rows;
const u32 U_n_cols = U.n_cols; const uword U_n_cols = U.n_cols;
if(U.is_empty()) if(U.is_empty())
{ {
L.set_size(U_n_rows, 0); L.set_size(U_n_rows, 0);
U.set_size(0, U_n_cols); U.set_size(0, U_n_cols);
ipiv.reset(); ipiv.reset();
return true; return true;
} }
#if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK)
skipping to change at line 959 skipping to change at line 959
// take into account that Fortran counts from 1 // take into account that Fortran counts from 1
arrayops::inplace_minus(ipiv.memptr(), blas_int(1), ipiv.n_elem); arrayops::inplace_minus(ipiv.memptr(), blas_int(1), ipiv.n_elem);
status = (info == 0); status = (info == 0);
} }
#endif #endif
L.copy_size(U); L.copy_size(U);
for(u32 col=0; col < U_n_cols; ++col) for(uword col=0; col < U_n_cols; ++col)
{ {
for(u32 row=0; (row < col) && (row < U_n_rows); ++row) for(uword row=0; (row < col) && (row < U_n_rows); ++row)
{ {
L.at(row,col) = eT(0); L.at(row,col) = eT(0);
} }
if( L.in_range(col,col) == true ) if( L.in_range(col,col) == true )
{ {
L.at(col,col) = eT(1); L.at(col,col) = eT(1);
} }
for(u32 row = (col+1); row < U_n_rows; ++row) for(uword row = (col+1); row < U_n_rows; ++row)
{ {
L.at(row,col) = U.at(row,col); L.at(row,col) = U.at(row,col);
U.at(row,col) = eT(0); U.at(row,col) = eT(0);
} }
} }
return status; return status;
} }
#else #else
{ {
skipping to change at line 1008 skipping to change at line 1008
if(status == true) if(status == true)
{ {
if(U.is_empty()) if(U.is_empty())
{ {
// L and U have been already set to the correct empty matrices // L and U have been already set to the correct empty matrices
P.eye(L.n_rows, L.n_rows); P.eye(L.n_rows, L.n_rows);
return true; return true;
} }
const u32 n = ipiv1.n_elem; const uword n = ipiv1.n_elem;
const u32 P_rows = U.n_rows; const uword P_rows = U.n_rows;
podarray<blas_int> ipiv2(P_rows); podarray<blas_int> ipiv2(P_rows);
const blas_int* ipiv1_mem = ipiv1.memptr(); const blas_int* ipiv1_mem = ipiv1.memptr();
blas_int* ipiv2_mem = ipiv2.memptr(); blas_int* ipiv2_mem = ipiv2.memptr();
for(u32 i=0; i<P_rows; ++i) for(uword i=0; i<P_rows; ++i)
{ {
ipiv2_mem[i] = blas_int(i); ipiv2_mem[i] = blas_int(i);
} }
for(u32 i=0; i<n; ++i) for(uword i=0; i<n; ++i)
{ {
const u32 k = static_cast<u32>(ipiv1_mem[i]); const uword k = static_cast<uword>(ipiv1_mem[i]);
if( ipiv2_mem[i] != ipiv2_mem[k] ) if( ipiv2_mem[i] != ipiv2_mem[k] )
{ {
std::swap( ipiv2_mem[i], ipiv2_mem[k] ); std::swap( ipiv2_mem[i], ipiv2_mem[k] );
} }
} }
P.zeros(P_rows, P_rows); P.zeros(P_rows, P_rows);
for(u32 row=0; row<P_rows; ++row) for(uword row=0; row<P_rows; ++row)
{ {
P.at(row, static_cast<u32>(ipiv2_mem[row])) = eT(1); P.at(row, static_cast<uword>(ipiv2_mem[row])) = eT(1);
} }
if(L.n_cols > U.n_rows) if(L.n_cols > U.n_rows)
{ {
L.shed_cols(U.n_rows, L.n_cols-1); L.shed_cols(U.n_rows, L.n_cols-1);
} }
if(U.n_rows > L.n_cols) if(U.n_rows > L.n_cols)
{ {
U.shed_rows(L.n_cols, U.n_rows-1); U.shed_rows(L.n_cols, U.n_rows-1);
skipping to change at line 1070 skipping to change at line 1070
const bool status = auxlib::lu(L, U, ipiv1, X); const bool status = auxlib::lu(L, U, ipiv1, X);
if(status == true) if(status == true)
{ {
if(U.is_empty()) if(U.is_empty())
{ {
// L and U have been already set to the correct empty matrices // L and U have been already set to the correct empty matrices
return true; return true;
} }
const u32 n = ipiv1.n_elem; const uword n = ipiv1.n_elem;
const u32 P_rows = U.n_rows; const uword P_rows = U.n_rows;
podarray<blas_int> ipiv2(P_rows); podarray<blas_int> ipiv2(P_rows);
const blas_int* ipiv1_mem = ipiv1.memptr(); const blas_int* ipiv1_mem = ipiv1.memptr();
blas_int* ipiv2_mem = ipiv2.memptr(); blas_int* ipiv2_mem = ipiv2.memptr();
for(u32 i=0; i<P_rows; ++i) for(uword i=0; i<P_rows; ++i)
{ {
ipiv2_mem[i] = blas_int(i); ipiv2_mem[i] = blas_int(i);
} }
for(u32 i=0; i<n; ++i) for(uword i=0; i<n; ++i)
{ {
const u32 k = static_cast<u32>(ipiv1_mem[i]); const uword k = static_cast<uword>(ipiv1_mem[i]);
if( ipiv2_mem[i] != ipiv2_mem[k] ) if( ipiv2_mem[i] != ipiv2_mem[k] )
{ {
std::swap( ipiv2_mem[i], ipiv2_mem[k] ); std::swap( ipiv2_mem[i], ipiv2_mem[k] );
L.swap_rows( static_cast<u32>(ipiv2_mem[i]), static_cast<u32>(ipiv2 _mem[k]) ); L.swap_rows( static_cast<uword>(ipiv2_mem[i]), static_cast<uword>(i piv2_mem[k]) );
} }
} }
if(L.n_cols > U.n_rows) if(L.n_cols > U.n_rows)
{ {
L.shed_cols(U.n_rows, L.n_cols-1); L.shed_cols(U.n_rows, L.n_cols-1);
} }
if(U.n_rows > L.n_cols) if(U.n_rows > L.n_cols)
{ {
skipping to change at line 1137 skipping to change at line 1137
// rudimentary "better-than-nothing" test for symmetry // rudimentary "better-than-nothing" test for symmetry
//arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" ); //arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" );
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = A.n_rows; blas_int n_rows = A.n_rows;
blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1); blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1);
eigval.set_size( static_cast<u32>(n_rows) ); eigval.set_size( static_cast<uword>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr( ), work.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr( ), work.memptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
skipping to change at line 1185 skipping to change at line 1185
return true; return true;
} }
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = A.n_rows; blas_int n_rows = A.n_rows;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork
eigval.set_size( static_cast<u32>(n_rows) ); eigval.set_size( static_cast<uword>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows - podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
2)) ); - 2)) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(), work.memptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(), work.memptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
skipping to change at line 1237 skipping to change at line 1237
// rudimentary "better-than-nothing" test for symmetry // rudimentary "better-than-nothing" test for symmetry
//arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" ); //arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" );
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = eigvec.n_rows; blas_int n_rows = eigvec.n_rows;
blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1); blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1);
eigval.set_size( static_cast<u32>(n_rows) ); eigval.set_size( static_cast<uword>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me mptr(), work.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me mptr(), work.memptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
skipping to change at line 1288 skipping to change at line 1288
return true; return true;
} }
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = eigvec.n_rows; blas_int n_rows = eigvec.n_rows;
blas_int lda = eigvec.n_rows; blas_int lda = eigvec.n_rows;
blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork
eigval.set_size( static_cast<u32>(n_rows) ); eigval.set_size( static_cast<uword>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows - podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
2)) ); - 2)) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt r(), work.memptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt r(), work.memptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
skipping to change at line 1371 skipping to change at line 1371
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" );
if(A.is_empty()) if(A.is_empty())
{ {
eigval.reset(); eigval.reset();
l_eigvec.reset(); l_eigvec.reset();
r_eigvec.reset(); r_eigvec.reset();
return true; return true;
} }
u32 A_n_rows = A.n_rows; uword A_n_rows = A.n_rows;
blas_int n_rows = A_n_rows; blas_int n_rows = A_n_rows;
blas_int lda = A_n_rows; blas_int lda = A_n_rows;
blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size(A_n_rows, A_n_rows);
podarray<T> work( static_cast<u32>(lwork) ); podarray<T> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows)) podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows)
); ) );
podarray<T> wr(A_n_rows); podarray<T> wr(A_n_rows);
podarray<T> wi(A_n_rows); podarray<T> wi(A_n_rows);
Mat<T> A_copy = A; Mat<T> A_copy = A;
blas_int info; blas_int info;
arma_extra_debug_print("lapack::geev()"); arma_extra_debug_print("lapack::geev()");
lapack::geev(&jobvl, &jobvr, &n_rows, A_copy.memptr(), &lda, wr.memptr( ), wi.memptr(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, wor k.memptr(), &lwork, &info); lapack::geev(&jobvl, &jobvr, &n_rows, A_copy.memptr(), &lda, wr.memptr( ), wi.memptr(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, wor k.memptr(), &lwork, &info);
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
for(u32 i=0; i<A_n_rows; ++i) for(uword i=0; i<A_n_rows; ++i)
{ {
eigval[i] = std::complex<T>(wr[i], wi[i]); eigval[i] = std::complex<T>(wr[i], wi[i]);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(l_eigvec); arma_ignore(l_eigvec);
skipping to change at line 1476 skipping to change at line 1476
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" );
if(A.is_empty()) if(A.is_empty())
{ {
eigval.reset(); eigval.reset();
l_eigvec.reset(); l_eigvec.reset();
r_eigvec.reset(); r_eigvec.reset();
return true; return true;
} }
u32 A_n_rows = A.n_rows; uword A_n_rows = A.n_rows;
blas_int n_rows = A_n_rows; blas_int n_rows = A_n_rows;
blas_int lda = A_n_rows; blas_int lda = A_n_rows;
blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size(A_n_rows, A_n_rows);
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows)) podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows
); // was 2,3 )) ); // was 2,3
blas_int info; blas_int info;
arma_extra_debug_print("lapack::cx_geev()"); arma_extra_debug_print("lapack::cx_geev()");
lapack::cx_geev(&jobvl, &jobvr, &n_rows, A.memptr(), &lda, eigval.mempt r(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, work.memptr(), &lwork, rwork.memptr(), &info); lapack::cx_geev(&jobvl, &jobvr, &n_rows, A.memptr(), &lda, eigval.mempt r(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, work.memptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
skipping to change at line 1527 skipping to change at line 1527
{ {
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "chol(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "chol(): given matrix is not square" );
if(out.is_empty()) if(out.is_empty())
{ {
return true; return true;
} }
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
char uplo = 'U'; char uplo = 'U';
blas_int n = out_n_rows; blas_int n = out_n_rows;
blas_int info; blas_int info;
lapack::potrf(&uplo, &n, out.memptr(), &n, &info); lapack::potrf(&uplo, &n, out.memptr(), &n, &info);
for(u32 col=0; col<out_n_rows; ++col) for(uword col=0; col<out_n_rows; ++col)
{ {
eT* colptr = out.colptr(col); eT* colptr = out.colptr(col);
for(u32 row=(col+1); row < out_n_rows; ++row) for(uword row=(col+1); row < out_n_rows; ++row)
{ {
colptr[row] = eT(0); colptr[row] = eT(0);
} }
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
skipping to change at line 1567 skipping to change at line 1567
inline inline
bool bool
auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X) auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
R = X.get_ref(); R = X.get_ref();
const u32 R_n_rows = R.n_rows; const uword R_n_rows = R.n_rows;
const u32 R_n_cols = R.n_cols; const uword R_n_cols = R.n_cols;
if(R.is_empty()) if(R.is_empty())
{ {
Q.eye(R_n_rows, R_n_rows); Q.eye(R_n_rows, R_n_rows);
return true; return true;
} }
blas_int m = static_cast<blas_int>(R_n_rows); blas_int m = static_cast<blas_int>(R_n_rows);
blas_int n = static_cast<blas_int>(R_n_cols); blas_int n = static_cast<blas_int>(R_n_cols);
blas_int work_len = (std::max)(blas_int(1),n); blas_int work_len = (std::max)(blas_int(1),n);
blas_int work_len_tmp; blas_int work_len_tmp;
blas_int k = (std::min)(m,n); blas_int k = (std::min)(m,n);
blas_int info; blas_int info;
podarray<eT> tau( static_cast<u32>(k) ); podarray<eT> tau( static_cast<uword>(k) );
podarray<eT> work( static_cast<u32>(work_len) ); podarray<eT> work( static_cast<uword>(work_len) );
// query for the optimum value of work_len // query for the optimum value of work_len
work_len_tmp = -1; work_len_tmp = -1;
lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len_tmp, &info); lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len_tmp, &info);
if(info == 0) if(info == 0)
{ {
work_len = static_cast<blas_int>(access::tmp_real(work[0])); work_len = static_cast<blas_int>(access::tmp_real(work[0]));
work.set_size( static_cast<u32>(work_len) ); work.set_size( static_cast<uword>(work_len) );
} }
lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len, &info); lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len, &info);
Q.set_size(R_n_rows, R_n_rows); Q.set_size(R_n_rows, R_n_rows);
arrayops::copy( Q.memptr(), R.memptr(), (std::min)(Q.n_elem, R.n_elem) ); arrayops::copy( Q.memptr(), R.memptr(), (std::min)(Q.n_elem, R.n_elem) );
// //
// construct R // construct R
for(u32 col=0; col < R_n_cols; ++col) for(uword col=0; col < R_n_cols; ++col)
{ {
for(u32 row=(col+1); row < R_n_rows; ++row) for(uword row=(col+1); row < R_n_rows; ++row)
{ {
R.at(row,col) = eT(0); R.at(row,col) = eT(0);
} }
} }
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
// query for the optimum value of work_len // query for the optimum value of work_len
work_len_tmp = -1; work_len_tmp = -1;
lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len_tmp, &info); lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len_tmp, &info);
if(info == 0) if(info == 0)
{ {
work_len = static_cast<blas_int>(access::tmp_real(work[0])); work_len = static_cast<blas_int>(access::tmp_real(work[0]));
work.set_size( static_cast<u32>(work_len) ); work.set_size( static_cast<uword>(work_len) );
} }
lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len, &info); lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len, &info);
} }
else else
if( (is_supported_complex_float<eT>::value == true) || (is_supported_co mplex_double<eT>::value == true) ) if( (is_supported_complex_float<eT>::value == true) || (is_supported_co mplex_double<eT>::value == true) )
{ {
// query for the optimum value of work_len // query for the optimum value of work_len
work_len_tmp = -1; work_len_tmp = -1;
lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len_tmp, &info); lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len_tmp, &info);
if(info == 0) if(info == 0)
{ {
work_len = static_cast<blas_int>(access::tmp_real(work[0])); work_len = static_cast<blas_int>(access::tmp_real(work[0]));
work.set_size( static_cast<u32>(work_len) ); work.set_size( static_cast<uword>(work_len) );
} }
lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len, &info); lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len, &info);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(Q); arma_ignore(Q);
skipping to change at line 1659 skipping to change at line 1659
arma_ignore(X); arma_ignore(X);
arma_stop("qr(): use of LAPACK needs to be enabled"); arma_stop("qr(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, u32& X_n_rows, u32& X_n_cols) auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, uword& X_n_rows, uword& X_n_c ols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
X_n_rows = A.n_rows; X_n_rows = A.n_rows;
X_n_cols = A.n_cols; X_n_cols = A.n_cols;
skipping to change at line 1690 skipping to change at line 1690
char jobvt = 'N'; char jobvt = 'N';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldu = U.n_rows; blas_int ldu = U.n_rows;
blas_int ldvt = V.n_rows; blas_int ldvt = V.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) (m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) (m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) );
blas_int info; blas_int info;
S.set_size( static_cast<u32>((std::min)(m, n)) ); S.set_size( static_cast<uword>((std::min)(m, n)) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m,&n, &m,&n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 1716 skipping to change at line 1716
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(work[0]); blas_int proposed_lwork = static_cast<blas_int>(work[0]);
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<u32>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
skipping to change at line 1749 skipping to change at line 1749
arma_ignore(X_n_cols); arma_ignore(X_n_cols);
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X, u32& X_n_rows, u 32& X_n_cols) auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X, uword& X_n_rows, uword& X_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
X_n_rows = A.n_rows; X_n_rows = A.n_rows;
skipping to change at line 1782 skipping to change at line 1782
char jobvt = 'N'; char jobvt = 'N';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldu = U.n_rows; blas_int ldu = U.n_rows;
blas_int ldvt = V.n_rows; blas_int ldvt = V.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) ); blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) );
blas_int info; blas_int info;
S.set_size( static_cast<u32>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>(5*(std::min)(m,n)) ); podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 1809 skipping to change at line 1809
rwork.memptr(), rwork.memptr(),
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(real(work[0])); blas_int proposed_lwork = static_cast<blas_int>(real(work[0]));
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<u32>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
skipping to change at line 1848 skipping to change at line 1848
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd(Col<eT>& S, const Base<eT,T1>& X) auxlib::svd(Col<eT>& S, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 junk; uword junk;
return auxlib::svd(S, X, junk, junk); return auxlib::svd(S, X, junk, junk);
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X) auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 junk; uword junk;
return auxlib::svd(S, X, junk, junk); return auxlib::svd(S, X, junk, junk);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X) auxlib::svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1896 skipping to change at line 1896
char jobvt = 'A'; char jobvt = 'A';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldu = U.n_rows; blas_int ldu = U.n_rows;
blas_int ldvt = V.n_rows; blas_int ldvt = V.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) (m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) (m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) );
blas_int info; blas_int info;
S.set_size( static_cast<u32>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 1920 skipping to change at line 1920
work.memptr(), &lwork_tmp, work.memptr(), &lwork_tmp,
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(work[0]); blas_int proposed_lwork = static_cast<blas_int>(work[0]);
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<u32>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
skipping to change at line 1987 skipping to change at line 1987
char jobvt = 'A'; char jobvt = 'A';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldu = U.n_rows; blas_int ldu = U.n_rows;
blas_int ldvt = V.n_rows; blas_int ldvt = V.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) ); blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) );
blas_int info; blas_int info;
S.set_size( static_cast<u32>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>(5*(std::min)(m,n)) ); podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
skipping to change at line 2013 skipping to change at line 2013
rwork.memptr(), rwork.memptr(),
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(real(work[0])); blas_int proposed_lwork = static_cast<blas_int>(real(work[0]));
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<u32>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
skipping to change at line 2050 skipping to change at line 2050
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd_thin(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X, const char mode) auxlib::svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X, const char mode)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
S.set_size( static_cast<u32>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
blas_int ldu = 0; blas_int ldu = 0;
blas_int ldvt = 0; blas_int ldvt = 0;
char jobu; char jobu;
char jobvt; char jobvt;
switch(mode) switch(mode)
{ {
case 'l': case 'l':
jobu = 'S'; jobu = 'S';
jobvt = 'N'; jobvt = 'N';
ldu = m; ldu = m;
ldvt = 1; ldvt = 1;
U.set_size( static_cast<u32>(ldu), static_cast<u32>((std::min)(m,n) ) ); U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min)( m,n)) );
V.reset(); V.reset();
break; break;
case 'r': case 'r':
jobu = 'N'; jobu = 'N';
jobvt = 'S'; jobvt = 'S';
ldu = 1; ldu = 1;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
U.reset(); U.reset();
V.set_size( static_cast<u32>(ldvt), static_cast<u32>(n) ); V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n) );
break; break;
case 'b': case 'b':
jobu = 'S'; jobu = 'S';
jobvt = 'S'; jobvt = 'S';
ldu = m; ldu = m;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
U.set_size( static_cast<u32>(ldu), static_cast<u32>((std::min)(m,n U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min)
)) ); (m,n)) );
V.set_size( static_cast<u32>(ldvt), static_cast<u32>(n) V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n)
); );
break; break;
default: default:
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
return false; return false;
} }
skipping to change at line 2126 skipping to change at line 2126
{ {
U.eye(); U.eye();
S.reset(); S.reset();
V.eye(); V.eye();
return true; return true;
} }
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)( m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)( m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 2149 skipping to change at line 2149
work.memptr(), &lwork_tmp, work.memptr(), &lwork_tmp,
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(work[0]); blas_int proposed_lwork = static_cast<blas_int>(work[0]);
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<u32>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
skipping to change at line 2185 skipping to change at line 2185
arma_ignore(mode); arma_ignore(mode);
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::svd_thin(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode) auxlib::svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
S.set_size( static_cast<u32>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
blas_int ldu = 0; blas_int ldu = 0;
blas_int ldvt = 0; blas_int ldvt = 0;
char jobu; char jobu;
char jobvt; char jobvt;
switch(mode) switch(mode)
{ {
case 'l': case 'l':
jobu = 'S'; jobu = 'S';
jobvt = 'N'; jobvt = 'N';
ldu = m; ldu = m;
ldvt = 1; ldvt = 1;
U.set_size( static_cast<u32>(ldu), static_cast<u32>((std::min)(m,n) ) ); U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min)( m,n)) );
V.reset(); V.reset();
break; break;
case 'r': case 'r':
jobu = 'N'; jobu = 'N';
jobvt = 'S'; jobvt = 'S';
ldu = 1; ldu = 1;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
U.reset(); U.reset();
V.set_size( static_cast<u32>(ldvt), static_cast<u32>(n) ); V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n) );
break; break;
case 'b': case 'b':
jobu = 'S'; jobu = 'S';
jobvt = 'S'; jobvt = 'S';
ldu = m; ldu = m;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
U.set_size( static_cast<u32>(ldu), static_cast<u32>((std::min)(m,n U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min)
)) ); (m,n)) );
V.set_size( static_cast<u32>(ldvt), static_cast<u32>(n) V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n)
); );
break; break;
default: default:
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
return false; return false;
} }
skipping to change at line 2263 skipping to change at line 2263
{ {
U.eye(); U.eye();
S.reset(); S.reset();
V.eye(); V.eye();
return true; return true;
} }
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)( m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)( m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<u32>(5*(std::min)(m,n)) ); podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 2288 skipping to change at line 2288
rwork.memptr(), rwork.memptr(),
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(real(work[0])); blas_int proposed_lwork = static_cast<blas_int>(real(work[0]));
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<u32>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
skipping to change at line 2338 skipping to change at line 2338
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty()) if(A.is_empty() || B.is_empty())
{ {
out.zeros(A.n_cols, B.n_cols); out.zeros(A.n_cols, B.n_cols);
return true; return true;
} }
else else
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
bool status = false; bool status = false;
if( (A_n_rows <= 4) && (slow == false) ) if( (A_n_rows <= 4) && (slow == false) )
{ {
Mat<eT> A_inv; Mat<eT> A_inv;
status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows); status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows);
if(status == true) if(status == true)
skipping to change at line 2417 skipping to change at line 2417
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldb = A.n_rows; blas_int ldb = A.n_rows;
blas_int nrhs = B.n_cols; blas_int nrhs = B.n_cols;
blas_int lwork = n + (std::max)(n, nrhs); blas_int lwork = n + (std::max)(n, nrhs);
blas_int info; blas_int info;
Mat<eT> tmp = B; Mat<eT> tmp = B;
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
arma_extra_debug_print("lapack::gels()"); arma_extra_debug_print("lapack::gels()");
// NOTE: the dgels() function in the lapack library supplied by ATLAS 3 .6 seems to have problems // NOTE: the dgels() function in the lapack library supplied by ATLAS 3 .6 seems to have problems
lapack::gels<eT> lapack::gels<eT>
( (
&trans, &m, &n, &nrhs, &trans, &m, &n, &nrhs,
A.memptr(), &lda, A.memptr(), &lda,
tmp.memptr(), &ldb, tmp.memptr(), &ldb,
work.memptr(), &lwork, work.memptr(), &lwork,
&info &info
); );
arma_extra_debug_print("lapack::gels() -- finished"); arma_extra_debug_print("lapack::gels() -- finished");
out.set_size(A.n_cols, B.n_cols); out.set_size(A.n_cols, B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols );
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
skipping to change at line 2484 skipping to change at line 2484
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldb = A.n_cols; blas_int ldb = A.n_cols;
blas_int nrhs = B.n_cols; blas_int nrhs = B.n_cols;
blas_int lwork = m + (std::max)(m,nrhs); blas_int lwork = m + (std::max)(m,nrhs);
blas_int info; blas_int info;
Mat<eT> tmp; Mat<eT> tmp;
tmp.zeros(A.n_cols, B.n_cols); tmp.zeros(A.n_cols, B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
eT* tmp_colmem = tmp.colptr(col); eT* tmp_colmem = tmp.colptr(col);
arrayops::copy( tmp_colmem, B.colptr(col), B.n_rows ); arrayops::copy( tmp_colmem, B.colptr(col), B.n_rows );
for(u32 row=B.n_rows; row<A.n_cols; ++row) for(uword row=B.n_rows; row<A.n_cols; ++row)
{ {
tmp_colmem[row] = eT(0); tmp_colmem[row] = eT(0);
} }
} }
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
arma_extra_debug_print("lapack::gels()"); arma_extra_debug_print("lapack::gels()");
// NOTE: the dgels() function in the lapack library supplied by ATLAS 3 .6 seems to have problems // NOTE: the dgels() function in the lapack library supplied by ATLAS 3 .6 seems to have problems
lapack::gels<eT> lapack::gels<eT>
( (
&trans, &m, &n, &nrhs, &trans, &m, &n, &nrhs,
A.memptr(), &lda, A.memptr(), &lda,
tmp.memptr(), &ldb, tmp.memptr(), &ldb,
work.memptr(), &lwork, work.memptr(), &lwork,
&info &info
); );
arma_extra_debug_print("lapack::gels() -- finished"); arma_extra_debug_print("lapack::gels() -- finished");
out.set_size(A.n_cols, B.n_cols); out.set_size(A.n_cols, B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols );
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
skipping to change at line 2539 skipping to change at line 2539
} }
#endif #endif
} }
// //
// solve_tr // solve_tr
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const u3 2 layout) auxlib::solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const uw ord layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
if(A.is_empty() || B.is_empty()) if(A.is_empty() || B.is_empty())
{ {
out.zeros(A.n_cols, B.n_cols); out.zeros(A.n_cols, B.n_cols);
return true; return true;
} }
skipping to change at line 2597 skipping to change at line 2597
{ {
arma_debug_check( (A.is_square() == false), "schur_dec(): matrix A is n ot square" ); arma_debug_check( (A.is_square() == false), "schur_dec(): matrix A is n ot square" );
if(A.is_empty()) if(A.is_empty())
{ {
Z.reset(); Z.reset();
T.reset(); T.reset();
return true; return true;
} }
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
char jobvs = 'V'; // get Schur vectors (Z) char jobvs = 'V'; // get Schur vectors (Z)
char sort = 'N'; // do not sort eigenvalues/vecto rs char sort = 'N'; // do not sort eigenvalues/vecto rs
blas_int* select = 0; // pointer to sorting function blas_int* select = 0; // pointer to sorting function
blas_int n = blas_int(A_n_rows); blas_int n = blas_int(A_n_rows);
blas_int sdim = 0; // output for sorting blas_int sdim = 0; // output for sorting
blas_int lwork = 3 * n; // workspace must be at least 3 * n (if set to -1, optimal size is output in work(0) and nothing else is do ne blas_int lwork = 3 * n; // workspace must be at least 3 * n (if set to -1, optimal size is output in work(0) and nothing else is do ne
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<blas_int> bwork(A_n_rows); podarray<blas_int> bwork(A_n_rows);
blas_int info = 0; blas_int info = 0;
Z.set_size(A_n_rows, A_n_rows); Z.set_size(A_n_rows, A_n_rows);
T = A; T = A;
podarray<eT> wr(A_n_rows); // output for eigenvalues podarray<eT> wr(A_n_rows); // output for eigenvalues
podarray<eT> wi(A_n_rows); // output for eigenvalues podarray<eT> wi(A_n_rows); // output for eigenvalues
skipping to change at line 2652 skipping to change at line 2652
if(A.is_empty()) if(A.is_empty())
{ {
Z.reset(); Z.reset();
T.reset(); T.reset();
return true; return true;
} }
typedef std::complex<cT> eT; typedef std::complex<cT> eT;
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
char jobvs = 'V'; // get Schur vectors (Z) char jobvs = 'V'; // get Schur vectors (Z)
char sort = 'N'; // do not sort eigenvalues/vect ors char sort = 'N'; // do not sort eigenvalues/vect ors
blas_int* select = 0; // pointer to sorting function blas_int* select = 0; // pointer to sorting function
blas_int n = blas_int(A_n_rows); blas_int n = blas_int(A_n_rows);
blas_int sdim = 0; // output for sorting blas_int sdim = 0; // output for sorting
blas_int lwork = 3 * n; // workspace must be at least 3 * n (if set to -1, optimal size is output in work(0) and nothing else is d one blas_int lwork = 3 * n; // workspace must be at least 3 * n (if set to -1, optimal size is output in work(0) and nothing else is d one
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<blas_int> bwork(A_n_rows); podarray<blas_int> bwork(A_n_rows);
blas_int info = 0; blas_int info = 0;
Z.set_size(A_n_rows, A_n_rows); Z.set_size(A_n_rows, A_n_rows);
T = A; T = A;
podarray<eT> w(A_n_rows); // output for eigenvalues podarray<eT> w(A_n_rows); // output for eigenvalues
podarray<cT> rwork(A_n_rows); podarray<cT> rwork(A_n_rows);
 End of changes. 99 change blocks. 
124 lines changed or deleted 124 lines changed or added


 blas_bones.hpp   blas_bones.hpp 
skipping to change at line 75 skipping to change at line 75
// void arma_fortran(arma_dswap)(const blas_int* n, double* x, const blas_int* incx, double* y, const blas_int* incy); // void arma_fortran(arma_dswap)(const blas_int* n, double* x, const blas_int* incx, double* y, const blas_int* incy);
// void arma_fortran(arma_dscal)(const blas_int* n, const double* alp ha, double* x, const blas_int* incx); // void arma_fortran(arma_dscal)(const blas_int* n, const double* alp ha, double* x, const blas_int* incx);
// void arma_fortran(arma_dcopy)(const blas_int* n, const double* x, const blas_int* incx, double* y, const blas_int* incy); // void arma_fortran(arma_dcopy)(const blas_int* n, const double* x, const blas_int* incx, double* y, const blas_int* incy);
// void arma_fortran(arma_daxpy)(const blas_int* n, const double* alp ha, const double* x, const blas_int* incx, double* y, const blas_int* incy) ; // void arma_fortran(arma_daxpy)(const blas_int* n, const double* alp ha, const double* x, const blas_int* incx, double* y, const blas_int* incy) ;
// void arma_fortran(arma_dger )(const blas_int* m, const blas_int* n , const double* alpha, const double* x, const blas_int* incx, const double* y, const blas_int* incy, double* A, const blas_int* ldA); // void arma_fortran(arma_dger )(const blas_int* m, const blas_int* n , const double* alpha, const double* x, const blas_int* incx, const double* y, const blas_int* incy, double* A, const blas_int* ldA);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
dot(const u32 n_elem, const eT* x, const eT* y) dot(const uword n_elem, const eT* x, const eT* y)
{ {
arma_ignore(n_elem); arma_ignore(n_elem);
arma_ignore(x); arma_ignore(x);
arma_ignore(y); arma_ignore(y);
return eT(0); return eT(0);
} }
template<> template<>
inline inline
float float
dot(const u32 n_elem, const float* x, const float* y) dot(const uword n_elem, const float* x, const float* y)
{ {
blas_int n = blas_int(n_elem); blas_int n = blas_int(n_elem);
blas_int inc = blas_int(1); blas_int inc = blas_int(1);
return arma_fortran(arma_sdot)(&n, x, &inc, y, &inc); return arma_fortran(arma_sdot)(&n, x, &inc, y, &inc);
} }
template<> template<>
inline inline
double double
dot(const u32 n_elem, const double* x, const double* y) dot(const uword n_elem, const double* x, const double* y)
{ {
blas_int n = blas_int(n_elem); blas_int n = blas_int(n_elem);
blas_int inc = blas_int(1); blas_int inc = blas_int(1);
return arma_fortran(arma_ddot)(&n, x, &inc, y, &inc); return arma_fortran(arma_ddot)(&n, x, &inc, y, &inc);
} }
template<typename eT> template<typename eT>
inline inline
void void
gemv(const char* transA, const blas_int* m, const blas_int* n, const eT* alpha, const eT* A, const blas_int* ldA, const eT* x, const blas_int* incx, const eT* beta, eT* y, const blas_int* incy) gemv(const char* transA, const blas_int* m, const blas_int* n, const eT* alpha, const eT* A, const blas_int* ldA, const eT* x, const blas_int* incx, const eT* beta, eT* y, const blas_int* incy)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy); arma_fortran(arma_sgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 144 skipping to change at line 144
arma_fortran(arma_zgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy); arma_fortran(arma_zgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
gemm(const char* transA, const char* transB, const blas_int* m, const bla s_int* n, const blas_int* k, const eT* alpha, const eT* A, const blas_int* ldA, const eT* B, const blas_int* ldB, const eT* beta, eT* C, const blas_in t* ldC) gemm(const char* transA, const char* transB, const blas_int* m, const bla s_int* n, const blas_int* k, const eT* alpha, const eT* A, const blas_int* ldA, const eT* B, const blas_int* ldB, const eT* beta, eT* C, const blas_in t* ldC)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check((is_supported_blas_type<eT>::value == false));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgemm)(transA, transB, m, n, k, (const T*)alpha, (c onst T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC); arma_fortran(arma_sgemm)(transA, transB, m, n, k, (const T*)alpha, (c onst T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 compiler_setup.hpp   compiler_setup.hpp 
skipping to change at line 77 skipping to change at line 77
#define arma_deprecated __attribute__((deprecated)) #define arma_deprecated __attribute__((deprecated))
#if (ARMA_GCC_VERSION >= 40200) #if (ARMA_GCC_VERSION >= 40200)
#if defined(_GLIBCXX_USE_C99_MATH_TR1) && defined(_GLIBCXX_USE_C99_COMP LEX_TR1) #if defined(_GLIBCXX_USE_C99_MATH_TR1) && defined(_GLIBCXX_USE_C99_COMP LEX_TR1)
#define ARMA_HAVE_STD_TR1 #define ARMA_HAVE_STD_TR1
#endif #endif
#endif #endif
#if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__GXX_EXPERIMENTAL_CXX0X__)
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#if !defined(ARMA_USE_CXX11)
#define ARMA_USE_CXX11
#endif
#endif #endif
#if defined(__clang__) #if defined(__clang__)
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#endif #endif
#if (ARMA_GCC_VERSION >= 40300) #if (ARMA_GCC_VERSION >= 40300)
#undef arma_hot #undef arma_hot
#undef arma_cold #undef arma_cold
skipping to change at line 136 skipping to change at line 140
#endif #endif
#if defined(__SUNPRO_CC) #if defined(__SUNPRO_CC)
#undef ARMA_HAVE_STD_ISFINITE #undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_SNPRINTF #undef ARMA_HAVE_STD_SNPRINTF
#undef ARMA_HAVE_LOG1P #undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF #undef ARMA_HAVE_STD_ISINF
#undef ARMA_HAVE_STD_ISNAN #undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#endif #endif
//
// whoever defined macros with the names "min" and "max" should be permanen
tly removed from the gene pool
#if defined(min)
#undef min
#if defined(__GNUG__)
#warning "detected 'min' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header"
#elif defined(_MSC_VER)
#pragma message ("detected 'min' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header")
#endif
#endif
#if defined(max)
#undef max
#if defined(__GNUG__)
#warning "detected 'max' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header"
#elif defined(_MSC_VER)
#pragma message ("detected 'max' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header")
#endif
#endif
 End of changes. 2 change blocks. 
0 lines changed or deleted 4 lines changed or added


 config.hpp   config.hpp 
skipping to change at line 13 skipping to change at line 13
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
// #define ARMA_64BIT_WORD
//// Uncomment the above line if you require matrices/vectors capable of ho
lding more than 4 billion elements.
//// Your machine and compiler must have support for 64 bit integers (eg. v
ia "long" or "long long")
// #define ARMA_USE_CXX11
//// Uncomment the above line if you have a C++ compiler that supports the
C++11 standard
//// This will enable additional features, such as use of initialiser lists
#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 fast replacement for LAPACK, //// Uncomment the above line if you have LAPACK or a fast replacement for LAPACK,
//// such as Intel's MKL, AMD's ACML, or the Accelerate framework. //// such as Intel's MKL, AMD's 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 fast replacement for BL AS, //// Uncomment the above line if you have BLAS or a fast replacement for BL AS,
skipping to change at line 49 skipping to change at line 57
//// 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)
#if !defined(ARMA_MAT_PREALLOC) #if !defined(ARMA_MAT_PREALLOC)
#define ARMA_MAT_PREALLOC 16 #define ARMA_MAT_PREALLOC 16
#endif #endif
//// This is the number of preallocated elements used by matrices and vecto rs; //// This is the number of preallocated elements used by matrices and vecto rs;
//// it must be an integer that is at least 1. //// it must be an integer that is at least 1.
//// If you mainly use lots of very small vectors (eg. <= 4 elements), //// If you mainly use lots of very small vectors (eg. <= 4 elements),
//// change the number to the size of your vectors. //// change the number to the size of your vectors.
// #define ARMA_USE_TBB_ALLOC
//// Uncomment the above line if you want to use Intel TBB scalable_malloc(
) and scalable_free() instead of standard new[] and delete[]
#define ARMA_USE_ATLAS #define ARMA_USE_ATLAS
#define ARMA_ATLAS_INCLUDE_DIR /usr/include/ #define ARMA_ATLAS_INCLUDE_DIR /usr/include/
//// If you're using ATLAS and the compiler can't find cblas.h and/or clapa ck.h //// If you're using ATLAS and the compiler can't find cblas.h and/or clapa ck.h
//// uncomment the above define and specify the appropriate include directo ry. //// uncomment the above define and specify the appropriate include directo ry.
//// Make sure the directory has a trailing / //// Make sure the directory has a trailing /
#define ARMA_USE_BOOST #define ARMA_USE_BOOST
#define ARMA_USE_BOOST_DATE #define ARMA_USE_BOOST_DATE
#define ARMA_PRINT_LOGIC_ERRORS #define ARMA_PRINT_LOGIC_ERRORS
 End of changes. 2 change blocks. 
0 lines changed or deleted 15 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 345 skipping to change at line 345
err_msg = const_cast<char*>(message); err_msg = const_cast<char*>(message);
} }
} }
// //
// functions for generating strings indicating size errors // functions for generating strings indicating size errors
inline inline
std::string std::string
arma_cold arma_cold
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_rows, const u32 B_n_cols, const char* x) arma_incompat_size_string(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char* x)
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << x << ": incompatible matrix dimensions: " << A_n_rows << 'x' << A_ n_cols << " and " << B_n_rows << 'x' << B_n_cols; tmp << x << ": incompatible matrix dimensions: " << A_n_rows << 'x' << A_ n_cols << " and " << B_n_rows << 'x' << B_n_cols;
return tmp.str(); return tmp.str();
} }
inline inline
arma_cold arma_cold
std::string std::string
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 A_n_slices, const u32 B_n_rows, const u32 B_n_cols, const u32 B_n_slices, const char* x) arma_incompat_size_string(const uword A_n_rows, const uword A_n_cols, const uword A_n_slices, const uword B_n_rows, const uword B_n_cols, const uword B_n_slices, const char* x)
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << x << ": incompatible cube dimensions: " << A_n_rows << 'x' << A_n_ cols << 'x' << A_n_slices << " and " << B_n_rows << 'x' << B_n_cols << 'x' << B_n_slices; tmp << x << ": incompatible cube dimensions: " << A_n_rows << 'x' << A_n_ cols << 'x' << A_n_slices << " and " << B_n_rows << 'x' << B_n_cols << 'x' << B_n_slices;
return tmp.str(); return tmp.str();
} }
template<typename eT> template<typename eT>
inline inline
skipping to change at line 393 skipping to change at line 393
return tmp.str(); return tmp.str();
} }
// //
// functions for checking whether two matrices have the same dimensions // functions for checking whether two matrices have the same dimensions
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n _rows, const u32 B_n_cols, const char* x) arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uwo rd B_n_rows, const uword B_n_cols, const char* x)
{ {
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
//! stop if given matrices have different sizes //! stop if given matrices have different sizes
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x) arma_assert_same_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x)
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
//! stop if given proxies have different sizes //! stop if given proxies have different sizes
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const Proxy<eT1>& A, const Proxy<eT2>& B, const char* x) arma_assert_same_size(const Proxy<eT1>& A, const Proxy<eT2>& B, const char* x)
{ {
const u32 A_n_rows = A.get_n_rows(); const uword A_n_rows = A.get_n_rows();
const u32 A_n_cols = A.get_n_cols(); const uword A_n_cols = A.get_n_cols();
const u32 B_n_rows = B.get_n_rows(); const uword B_n_rows = B.get_n_rows();
const u32 B_n_cols = B.get_n_cols(); const uword B_n_cols = B.get_n_cols();
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const subview<eT1>& A, const subview<eT2>& B, const c har* x) arma_assert_same_size(const subview<eT1>& A, const subview<eT2>& B, const c har* x)
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const Mat<eT1>& A, const subview<eT2>& B, const char* x) arma_assert_same_size(const Mat<eT1>& A, const subview<eT2>& B, const char* x)
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const subview<eT1>& A, const Mat<eT2>& B, const char* x) arma_assert_same_size(const subview<eT1>& A, const Mat<eT2>& B, const char* x)
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const Mat<eT1>& A, const Proxy<eT2>& B, const char* x ) arma_assert_same_size(const Mat<eT1>& A, const Proxy<eT2>& B, const char* x )
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.get_n_rows(); const uword B_n_rows = B.get_n_rows();
const u32 B_n_cols = B.get_n_cols(); const uword B_n_cols = B.get_n_cols();
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const Proxy<eT1>& A, const Mat<eT2>& B, const char* x ) arma_assert_same_size(const Proxy<eT1>& A, const Mat<eT2>& B, const char* x )
{ {
const u32 A_n_rows = A.get_n_rows(); const uword A_n_rows = A.get_n_rows();
const u32 A_n_cols = A.get_n_cols(); const uword A_n_cols = A.get_n_cols();
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const Proxy<eT1>& A, const subview<eT2>& B, const cha r* x) arma_assert_same_size(const Proxy<eT1>& A, const subview<eT2>& B, const cha r* x)
{ {
const u32 A_n_rows = A.get_n_rows(); const uword A_n_rows = A.get_n_rows();
const u32 A_n_cols = A.get_n_cols(); const uword A_n_cols = A.get_n_cols();
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const subview<eT1>& A, const Proxy<eT2>& B, const cha r* x) arma_assert_same_size(const subview<eT1>& A, const Proxy<eT2>& B, const cha r* x)
{ {
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.get_n_rows(); const uword B_n_rows = B.get_n_rows();
const u32 B_n_cols = B.get_n_cols(); const uword B_n_cols = B.get_n_cols();
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{ {
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) );
} }
} }
// //
// functions for checking whether two cubes have the same dimensions // functions for checking whether two cubes have the same dimensions
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const u32 A_n_rows, const u32 A_n_cols, const u32 A_n _slices, const u32 B_n_rows, const u32 B_n_cols, const u32 B_n_slices, cons t char* x) arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uwo rd A_n_slices, const uword B_n_rows, const uword B_n_cols, const uword B_n_ slices, const char* x)
{ {
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_ n_slices) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_ n_slices) )
{ {
arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_ n_rows, B_n_cols, B_n_slices, x) ); arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_ n_rows, B_n_cols, B_n_slices, x) );
} }
} }
//! stop if given cubes have different sizes //! stop if given cubes have different sizes
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
skipping to change at line 635 skipping to change at line 635
} }
} }
//! stop if given cube proxies have different sizes //! stop if given cube proxies have different sizes
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const ProxyCube<eT1>& A, const ProxyCube<eT2>& B, con st char* x) arma_assert_same_size(const ProxyCube<eT1>& A, const ProxyCube<eT2>& B, con st char* x)
{ {
const u32 A_n_rows = A.get_n_rows(); const uword A_n_rows = A.get_n_rows();
const u32 A_n_cols = A.get_n_cols(); const uword A_n_cols = A.get_n_cols();
const u32 A_n_slices = A.get_n_slices(); const uword A_n_slices = A.get_n_slices();
const u32 B_n_rows = B.get_n_rows(); const uword B_n_rows = B.get_n_rows();
const u32 B_n_cols = B.get_n_cols(); const uword B_n_cols = B.get_n_cols();
const u32 B_n_slices = B.get_n_slices(); const uword B_n_slices = B.get_n_slices();
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_ n_slices)) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_ n_slices))
{ {
arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_ n_rows, B_n_cols, B_n_slices, x) ); arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_ n_rows, B_n_cols, B_n_slices, x) );
} }
} }
// //
// functions for checking whether a cube or subcube can be interpreted as a matrix (i.e. single slice) // functions for checking whether a cube or subcube can be interpreted as a matrix (i.e. single slice)
skipping to change at line 705 skipping to change at line 705
{ {
arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, 1, B.n_rows, B .n_cols, B.n_slices, x) ); arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, 1, B.n_rows, B .n_cols, B.n_slices, x) );
} }
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
arma_assert_cube_as_mat(const Mat<eT>& M, const T1& Q, const char* x, const bool check_compat_size) arma_assert_cube_as_mat(const Mat<eT>& M, const T1& Q, const char* x, const bool check_compat_size)
{ {
const u32 Q_n_rows = Q.n_rows; const uword Q_n_rows = Q.n_rows;
const u32 Q_n_cols = Q.n_cols; const uword Q_n_cols = Q.n_cols;
const u32 Q_n_slices = Q.n_slices; const uword Q_n_slices = Q.n_slices;
const u32 M_vec_state = M.vec_state; const uword M_vec_state = M.vec_state;
if(M_vec_state == 0) if(M_vec_state == 0)
{ {
if( ( (Q_n_rows == 1) || (Q_n_cols == 1) || (Q_n_slices == 1) ) == fals e ) if( ( (Q_n_rows == 1) || (Q_n_cols == 1) || (Q_n_slices == 1) ) == fals e )
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << x tmp << x
<< ": can't interpret cube with dimensions " << ": can't interpret cube with dimensions "
<< Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
skipping to change at line 771 skipping to change at line 771
<< Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
<< " as a vector"; << " as a vector";
arma_stop( tmp.str() ); arma_stop( tmp.str() );
} }
} }
} }
if(check_compat_size == true) if(check_compat_size == true)
{ {
const u32 M_n_rows = M.n_rows; const uword M_n_rows = M.n_rows;
const u32 M_n_cols = M.n_cols; const uword M_n_cols = M.n_cols;
if(M_vec_state == 0) if(M_vec_state == 0)
{ {
if( if(
( (
( (Q_n_rows == M_n_rows) && (Q_n_cols == M_n_cols) ) ( (Q_n_rows == M_n_rows) && (Q_n_cols == M_n_cols) )
|| ||
( (Q_n_rows == M_n_rows) && (Q_n_slices == M_n_cols) ) ( (Q_n_rows == M_n_rows) && (Q_n_slices == M_n_cols) )
|| ||
( (Q_n_cols == M_n_cols) && (Q_n_slices == M_n_rows) ) ( (Q_n_cols == M_n_cols) && (Q_n_slices == M_n_rows) )
skipping to change at line 853 skipping to change at line 853
} }
} }
} }
// //
// functions for checking whether two matrices have dimensions that are com patible with the matrix multiply operation // functions for checking whether two matrices have dimensions that are com patible with the matrix multiply operation
inline inline
void void
arma_hot arma_hot
arma_assert_mul_size(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_ rows, const u32 B_n_cols, const char* x) arma_assert_mul_size(const uword A_n_rows, const uword A_n_cols, const uwor d B_n_rows, const uword B_n_cols, 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) );
} }
} }
//! stop if given matrices are incompatible for multiplication //! stop if given matrices are incompatible for multiplication
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_mul_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x) arma_assert_mul_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x)
{ {
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
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) );
} }
} }
//! stop if given matrices are incompatible for multiplication //! stop if given matrices are incompatible for multiplication
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
arma_assert_mul_size(const Mat<eT1>& A, const Mat<eT2>& B, const bool do_tr ans_A, const bool do_trans_B, const char* x) arma_assert_mul_size(const Mat<eT1>& A, const Mat<eT2>& B, const bool do_tr ans_A, const bool do_trans_B, const char* x)
{ {
const u32 final_A_n_cols = (do_trans_A == false) ? A.n_cols : A.n_rows; const uword final_A_n_cols = (do_trans_A == false) ? A.n_cols : A.n_rows;
const u32 final_B_n_rows = (do_trans_B == false) ? B.n_rows : B.n_cols; 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) if(final_A_n_cols != final_B_n_rows)
{ {
const u32 final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_col
const u32 final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; 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<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline inline
void void
arma_hot arma_hot
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)
skipping to change at line 1021 skipping to change at line 1021
const bool little_endian = (endian_test.b[0] == 1); const bool little_endian = (endian_test.b[0] == 1);
const char* nickname = ARMA_VERSION_NAME; const char* nickname = ARMA_VERSION_NAME;
std::ostream& out = get_stream_err1(); std::ostream& out = get_stream_err1();
out << "@ ---" << '\n'; out << "@ ---" << '\n';
out << "@ Armadillo " out << "@ Armadillo "
<< arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch << arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch
<< " (" << nickname << ")\n"; << " (" << nickname << ")\n";
out << "@ arma_config::mat_prealloc = " << arma_config::mat_preallo out << "@ arma_config::mat_prealloc = " << arma_config::mat_preal
c << " element(s)\n"; loc << " element(s)\n";
out << "@ arma_config::atlas = " << arma_config::atlas out << "@ arma_config::atlas = " << arma_config::atlas
<< '\n'; << '\n';
out << "@ arma_config::lapack = " << arma_config::lapack out << "@ arma_config::lapack = " << arma_config::lapack
<< '\n'; << '\n';
out << "@ arma_config::blas = " << arma_config::blas out << "@ arma_config::blas = " << arma_config::blas
<< '\n'; << '\n';
out << "@ arma_config::boost = " << arma_config::boost out << "@ arma_config::boost = " << arma_config::boost
<< '\n'; << '\n';
out << "@ arma_config::boost_date = " << arma_config::boost_date out << "@ arma_config::boost_date = " << arma_config::boost_dat
<< '\n'; e << '\n';
out << "@ arma_config::good_comp = " << arma_config::good_comp out << "@ arma_config::good_comp = " << arma_config::good_comp
<< '\n'; << '\n';
out << "@ arma_config::extra_code = " << arma_config::extra_code out << "@ arma_config::extra_code = " << arma_config::extra_cod
<< '\n'; e << '\n';
out << "@ sizeof(void*) = " << sizeof(void*) << '\n'; out << "@ sizeof(void*) = " << sizeof(void*) << '\n';
out << "@ sizeof(uword) = " << sizeof(uword) << '\n';
out << "@ sizeof(int) = " << sizeof(int) << '\n'; out << "@ sizeof(int) = " << sizeof(int) << '\n';
out << "@ sizeof(long) = " << sizeof(long) << '\n'; out << "@ sizeof(long) = " << sizeof(long) << '\n';
out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n'; out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n';
out << "@ little_endian = " << little_endian << '\n'; out << "@ little_endian = " << little_endian << '\n';
out << "@ ---" << std::endl; out << "@ ---" << std::endl;
} }
}; };
static arma_first_extra_debug_message arma_first_extra_debug_message_ru n; static arma_first_extra_debug_message arma_first_extra_debug_message_ru n;
 End of changes. 32 change blocks. 
76 lines changed or deleted 79 lines changed or added


 diagmat_proxy.hpp   diagmat_proxy.hpp 
skipping to change at line 40 skipping to change at line 40
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.get_n_rows() != P.get_n_cols()), (P_is_vec == false) && (P.get_n_rows() != P.get_n_cols()),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
arma_inline arma_inline
elem_type elem_type
operator[](const u32 i) const operator[](const uword i) const
{ {
if( (Proxy<T1>::prefer_at_accessor == true) || (P_is_vec == false) ) if( (Proxy<T1>::prefer_at_accessor == true) || (P_is_vec == false) )
{ {
return P.at(i,i); return P.at(i,i);
} }
else else
{ {
return P[i]; return P[i];
} }
} }
arma_inline arma_inline
elem_type elem_type
at(const u32 row, const u32 col) const at(const uword row, const uword col) const
{ {
if(row == col) if(row == col)
{ {
if( (Proxy<T1>::prefer_at_accessor == true) || (P_is_vec == false) ) if( (Proxy<T1>::prefer_at_accessor == true) || (P_is_vec == false) )
{ {
return P.at(row,row); return P.at(row,row);
} }
else else
{ {
return P[row]; return P[row];
} }
} }
else else
{ {
return elem_type(0); return elem_type(0);
} }
} }
const Proxy<T1> P; const Proxy<T1> P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Mat<eT> > class diagmat_proxy< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
skipping to change at line 100 skipping to change at line 100
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.n_rows != P.n_cols), (P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P_is_vec ? P[i] : P.at(i,i); { return P_is_vec ? P[i] : P.at(i,i);
} }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(
} 0); }
const Mat<eT>& P; const Mat<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Row<eT> > class diagmat_proxy< Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Row<eT>& X) inline diagmat_proxy(const Row<eT>& X)
: P(X) : P(X)
, P_is_vec(true) , P_is_vec(true)
, n_elem(P.n_elem) , n_elem(P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P[i]; { return P[i];
} }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? P[row] : elem_type(0); } { return (row == col) ? P[row] : elem_type(0); }
const Row<eT>& P; const Row<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Col<eT> > class diagmat_proxy< Col<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Col<eT>& X) inline diagmat_proxy(const Col<eT>& X)
: P(X) : P(X)
, P_is_vec(true) , P_is_vec(true)
, n_elem(P.n_elem) , n_elem(P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P[i]; } { return P[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? P[row] : elem_type(0); } { return (row == col) ? P[row] : elem_type(0); }
const Col<eT>& P; const Col<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename T1> template<typename T1>
class diagmat_proxy_check class diagmat_proxy_check
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
skipping to change at line 179 skipping to change at line 179
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(out); arma_ignore(out);
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.n_rows != P.n_cols), (P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P_is_vec ? P[i] : P.at(i,i); { return P_is_vec ? P[i] : P.at(i,i);
} }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(
} 0); }
const Mat<elem_type> P; const Mat<elem_type> P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy_check< Mat<eT> > class diagmat_proxy_check< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
skipping to change at line 218 skipping to change at line 218
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local)
{ {
delete P_local; delete P_local;
} }
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P_is_vec ? P[i] : P.at(i,i); { return P_is_vec ? P[i] : P.at(i,i);
} }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(
} 0); }
const Mat<eT>* P_local; const Mat<eT>* P_local;
const Mat<eT>& P; const Mat<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy_check< Row<eT> > class diagmat_proxy_check< Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
skipping to change at line 252 skipping to change at line 252
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local)
{ {
delete P_local; delete P_local;
} }
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P[i]; } { return P[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? P[row] : elem_type(0); } { return (row == col) ? P[row] : elem_type(0); }
const Row<eT>* P_local; const Row<eT>* P_local;
const Row<eT>& P; const Row<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy_check< Col<eT> > class diagmat_proxy_check< Col<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
skipping to change at line 286 skipping to change at line 286
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local)
{ {
delete P_local; delete P_local;
} }
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const uword i) const
eturn P[i]; } { return P[i]; }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const uword row, const uword col) const
eturn (row == col) ? P[row] : elem_type(0); } { return (row == col) ? P[row] : elem_type(0); }
const Col<eT>* P_local; const Col<eT>* P_local;
const Col<eT>& P; const Col<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const uword n_elem;
}; };
//! @} //! @}
 End of changes. 17 change blocks. 
45 lines changed or deleted 45 lines changed or added


 diagview_bones.hpp   diagview_bones.hpp 
skipping to change at line 28 skipping to change at line 28
class diagview : public Base<eT, diagview<eT> > class diagview : public Base<eT, diagview<eT> >
{ {
public: arma_aligned const Mat<eT>& m; public: arma_aligned const Mat<eT>& m;
protected: arma_aligned Mat<eT>* m_ptr; protected: arma_aligned Mat<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
const u32 row_offset; const uword row_offset;
const u32 col_offset; const uword col_offset;
const u32 n_rows; // equal to n_elem const uword n_rows; // equal to n_elem
const u32 n_cols; // always 1 const uword n_cols; // always 1
const u32 n_elem; const uword n_elem;
protected: protected:
arma_inline diagview(const Mat<eT>& in_m, const u32 in_row_offset, const arma_inline diagview(const Mat<eT>& in_m, const uword in_row_offset, cons
u32 in_col_offset, const u32 len); t uword in_col_offset, const uword len);
arma_inline diagview( Mat<eT>& in_m, const u32 in_row_offset, const arma_inline diagview( Mat<eT>& in_m, const uword in_row_offset, cons
u32 in_col_offset, const u32 len); t uword in_col_offset, const uword len);
public: public:
inline ~diagview(); inline ~diagview();
inline void operator=(const diagview& x); inline void operator=(const diagview& x);
inline void operator+=(const eT val); inline void operator+=(const eT val);
inline void operator-=(const eT val); inline void operator-=(const eT val);
inline void operator*=(const eT val); inline void operator*=(const eT val);
inline void operator/=(const eT val); inline void operator/=(const eT val);
template<typename T1> inline void operator= (const Base<eT,T1>& x); template<typename T1> inline void operator= (const Base<eT,T1>& x);
template<typename T1> inline void operator+=(const Base<eT,T1>& x); template<typename T1> inline void operator+=(const Base<eT,T1>& x);
template<typename T1> inline void operator-=(const Base<eT,T1>& x); template<typename T1> inline void operator-=(const Base<eT,T1>& x);
template<typename T1> inline void operator%=(const Base<eT,T1>& x); template<typename T1> inline void operator%=(const Base<eT,T1>& x);
template<typename T1> inline void operator/=(const Base<eT,T1>& x); template<typename T1> inline void operator/=(const Base<eT,T1>& x);
arma_inline eT& operator[](const u32 i); arma_inline eT& operator[](const uword i);
arma_inline eT operator[](const u32 i) const; arma_inline eT operator[](const uword i) const;
arma_inline eT& at(const u32 i); arma_inline eT& at(const uword i);
arma_inline eT at(const u32 i) const; arma_inline eT at(const uword i) const;
arma_inline eT& operator()(const u32 i); arma_inline eT& operator()(const uword i);
arma_inline eT operator()(const u32 i) const; arma_inline eT operator()(const uword i) const;
arma_inline eT& at(const u32 in_n_row, const u32 in_n_col); arma_inline eT& at(const uword in_n_row, const uword in_n_col);
arma_inline eT at(const u32 in_n_row, const u32 in_n_col) const; arma_inline eT at(const uword in_n_row, const uword in_n_col) co
nst;
arma_inline eT& operator()(const u32 in_n_row, const u32 in_n_col); arma_inline eT& operator()(const uword in_n_row, const uword in_n_col);
arma_inline eT operator()(const u32 in_n_row, const u32 in_n_col) const; arma_inline eT operator()(const uword in_n_row, const uword in_n_col) co
nst;
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void ones(); inline void ones();
inline static void extract(Mat<eT>& out, const diagview& in); inline static void extract(Mat<eT>& out, const diagview& in);
inline static void plus_inplace(Mat<eT>& out, const diagview& in); inline static void plus_inplace(Mat<eT>& out, const diagview& in);
inline static void minus_inplace(Mat<eT>& out, const diagview& in); inline static void minus_inplace(Mat<eT>& out, const diagview& in);
inline static void schur_inplace(Mat<eT>& out, const diagview& in); inline static void schur_inplace(Mat<eT>& out, const diagview& in);
 End of changes. 8 change blocks. 
19 lines changed or deleted 21 lines changed or added


 diagview_meat.hpp   diagview_meat.hpp 
skipping to change at line 25 skipping to change at line 25
template<typename eT> template<typename eT>
inline inline
diagview<eT>::~diagview() diagview<eT>::~diagview()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT>::diagview(const Mat<eT>& in_m, const u32 in_row_offset, const u32 in_col_offset, const u32 in_len) diagview<eT>::diagview(const Mat<eT>& in_m, const uword in_row_offset, cons t uword in_col_offset, const uword in_len)
: m(in_m) : m(in_m)
, m_ptr(0) , m_ptr(0)
, row_offset(in_row_offset) , row_offset(in_row_offset)
, col_offset(in_col_offset) , col_offset(in_col_offset)
, n_rows(in_len) , n_rows(in_len)
, n_cols(1) , n_cols(1)
, n_elem(in_len) , n_elem(in_len)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT>::diagview(Mat<eT>& in_m, const u32 in_row_offset, const u32 in _col_offset, const u32 in_len) diagview<eT>::diagview(Mat<eT>& in_m, const uword in_row_offset, const uwor d in_col_offset, const uword in_len)
: m(in_m) : m(in_m)
, m_ptr(&in_m) , m_ptr(&in_m)
, row_offset(in_row_offset) , row_offset(in_row_offset)
, col_offset(in_col_offset) , col_offset(in_col_offset)
, n_rows(in_len) , n_rows(in_len)
, n_cols(1) , n_cols(1)
, n_elem(in_len) , n_elem(in_len)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
skipping to change at line 66 skipping to change at line 66
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check( (t.n_elem != x.n_elem), "diagview: diagonals have incom patible lengths"); arma_debug_check( (t.n_elem != x.n_elem), "diagview: diagonals have incom patible lengths");
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = *(t.m_ptr);
const Mat<eT>& x_m = x.m; const Mat<eT>& x_m = x.m;
const u32 t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const u32 t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const u32 t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const u32 x_row_offset = x.row_offset; const uword x_row_offset = x.row_offset;
const u32 x_col_offset = x.col_offset; const uword x_col_offset = x.col_offset;
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at(i + t_row_offset, i + t_col_offset) = x_m.at(i + x_row_offset, i + x_col_offset); t_m.at(i + t_row_offset, i + t_col_offset) = x_m.at(i + x_row_offset, i + x_col_offset);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator+=(const eT val) diagview<eT>::operator+=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem; const uword t_n_elem = n_elem;
const u32 t_row_offset = row_offset; const uword t_row_offset = row_offset;
const u32 t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) += val; t_m.at( i + t_row_offset, i + t_col_offset) += val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator-=(const eT val) diagview<eT>::operator-=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem; const uword t_n_elem = n_elem;
const u32 t_row_offset = row_offset; const uword t_row_offset = row_offset;
const u32 t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) -= val; t_m.at( i + t_row_offset, i + t_col_offset) -= val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator*=(const eT val) diagview<eT>::operator*=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem; const uword t_n_elem = n_elem;
const u32 t_row_offset = row_offset; const uword t_row_offset = row_offset;
const u32 t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) *= val; t_m.at( i + t_row_offset, i + t_col_offset) *= val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator/=(const eT val) diagview<eT>::operator/=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem; const uword t_n_elem = n_elem;
const u32 t_row_offset = row_offset; const uword t_row_offset = row_offset;
const u32 t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) /= val; t_m.at( i + t_row_offset, i + t_col_offset) /= val;
} }
} }
//! set a diagonal of our matrix using data from a foreign object //! set a diagonal of our matrix using data from a foreign object
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 177 skipping to change at line 177
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = *(t.m_ptr);
const u32 t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const u32 t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const u32 t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) = x_mem[i]; t_m.at( i + t_row_offset, i + t_col_offset) = x_mem[i];
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator+=(const Base<eT,T1>& o) diagview<eT>::operator+=(const Base<eT,T1>& o)
skipping to change at line 210 skipping to change at line 210
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = *(t.m_ptr);
const u32 t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const u32 t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const u32 t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) += x_mem[i]; t_m.at( i + t_row_offset, i + t_col_offset) += x_mem[i];
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator-=(const Base<eT,T1>& o) diagview<eT>::operator-=(const Base<eT,T1>& o)
skipping to change at line 243 skipping to change at line 243
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = *(t.m_ptr);
const u32 t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const u32 t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const u32 t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) -= x_mem[i]; t_m.at( i + t_row_offset, i + t_col_offset) -= x_mem[i];
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator%=(const Base<eT,T1>& o) diagview<eT>::operator%=(const Base<eT,T1>& o)
skipping to change at line 276 skipping to change at line 276
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = *(t.m_ptr);
const u32 t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const u32 t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const u32 t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) *= x_mem[i]; t_m.at( i + t_row_offset, i + t_col_offset) *= x_mem[i];
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator/=(const Base<eT,T1>& o) diagview<eT>::operator/=(const Base<eT,T1>& o)
skipping to change at line 309 skipping to change at line 309
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = *(t.m_ptr);
const u32 t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const u32 t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const u32 t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) /= x_mem[i]; t_m.at( i + t_row_offset, i + t_col_offset) /= x_mem[i];
} }
} }
//! extract a diagonal and store it as a column vector //! extract a diagonal and store it as a column vector
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::extract(Mat<eT>& actual_out, const diagview<eT>& in) diagview<eT>::extract(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& in_m = in.m; // NOTE: we're assuming that the matrix has already been set to the corre
const bool alias = (&actual_out == &in_m); ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o
Mat<eT>* tmp = (alias) ? new Mat<eT> : 0; r operator=()
Mat<eT>& out = (alias) ? (*tmp) : actual_out;
const u32 in_n_elem = in.n_elem; const Mat<eT>& in_m = in.m;
const u32 in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset;
out.set_size( in_n_elem, in.n_cols ); const uword in_n_elem = in.n_elem;
const uword in_row_offset = in.row_offset;
const uword in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(uword i=0; i<in_n_elem; ++i)
{ {
out_mem[i] = in_m.at(i+in_row_offset, i+in_col_offset); out_mem[i] = in_m.at(i+in_row_offset, i+in_col_offset);
} }
if(alias)
{
actual_out = out;
delete tmp;
}
} }
//! X += Y.diagview(...) //! X += Y.diagview(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::plus_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::plus_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "addition"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "addition");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const uword in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const uword in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const uword in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(uword i=0; i<in_n_elem; ++i)
{ {
out_mem[i] += in_m.at(i+in_row_offset, i+in_col_offset); out_mem[i] += in_m.at(i+in_row_offset, i+in_col_offset);
} }
} }
//! X -= Y.diagview(...) //! X -= Y.diagview(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::minus_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::minus_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "subtraction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "subtraction");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const uword in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const uword in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const uword in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(uword i=0; i<in_n_elem; ++i)
{ {
out_mem[i] -= in_m.at(i+in_row_offset, i+in_col_offset); out_mem[i] -= in_m.at(i+in_row_offset, i+in_col_offset);
} }
} }
//! X %= Y.submat(...) //! X %= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::schur_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::schur_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "element-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "element-wise multiplication");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const uword in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const uword in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const uword in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(uword i=0; i<in_n_elem; ++i)
{ {
out_mem[i] *= in_m.at(i+in_row_offset, i+in_col_offset); out_mem[i] *= in_m.at(i+in_row_offset, i+in_col_offset);
} }
} }
//! X /= Y.diagview(...) //! X /= Y.diagview(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::div_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::div_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "element-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "element-wise division");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const uword in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const uword in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const uword in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(uword i=0; i<in_n_elem; ++i)
{ {
out_mem[i] /= in_m.at(i+in_row_offset, i+in_col_offset); out_mem[i] /= in_m.at(i+in_row_offset, i+in_col_offset);
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator[](const u32 i) diagview<eT>::operator[](const uword i)
{ {
return (*m_ptr).at(i+row_offset, i+col_offset); return (*m_ptr).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator[](const u32 i) const diagview<eT>::operator[](const uword i) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const u32 i) diagview<eT>::at(const uword i)
{ {
return (*m_ptr).at(i+row_offset, i+col_offset); return (*m_ptr).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::at(const u32 i) const diagview<eT>::at(const uword i) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator()(const u32 i) diagview<eT>::operator()(const uword i)
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" );
return (*m_ptr).at(i+row_offset, i+col_offset); return (*m_ptr).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator()(const u32 i) const diagview<eT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" );
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const u32 row, const u32 col) diagview<eT>::at(const uword row, const uword col)
{ {
return (*m_ptr).at(row+row_offset, row+col_offset); return (*m_ptr).at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::at(const u32 row, const u32 col) const diagview<eT>::at(const uword row, const uword col) const
{ {
return m.at(row+row_offset, row+col_offset); return m.at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator()(const u32 row, const u32 col) diagview<eT>::operator()(const uword row, const uword col)
{ {
arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" ); arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" );
return (*m_ptr).at(row+row_offset, row+col_offset); return (*m_ptr).at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator()(const u32 row, const u32 col) const diagview<eT>::operator()(const uword row, const uword col) const
{ {
arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" ); arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" );
return m.at(row+row_offset, row+col_offset); return m.at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::fill(const eT val) diagview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& x = (*m_ptr); Mat<eT>& x = (*m_ptr);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
x.at(i+row_offset, i+col_offset) = val; x.at(i+row_offset, i+col_offset) = val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::zeros() diagview<eT>::zeros()
{ {
 End of changes. 48 change blocks. 
88 lines changed or deleted 81 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 27 skipping to change at line 27
//! Generate the first line of the header used for saving matrices in text format. //! Generate the first line of the header used for saving matrices in text format.
//! Format: "ARMA_MAT_TXT_ABXYZ". //! Format: "ARMA_MAT_TXT_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_txt_header(const Mat<eT>& x) diskio::gen_txt_header(const Mat<eT>& x)
{ {
arma_type_check< is_supported_elem_type<eT>::value == false >::apply(); arma_type_check(( is_supported_elem_type<eT>::value == false ));
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_IU001"); return std::string("ARMA_MAT_TXT_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 60 skipping to change at line 60
else else
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_IU004"); return std::string("ARMA_MAT_TXT_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_IS004"); return std::string("ARMA_MAT_TXT_IS004");
} }
// else #if defined(ARMA_64BIT_WORD)
// if(is_u64<eT>::value == true) else
// { if(is_u64<eT>::value == true)
// return std::string("ARMA_MAT_TXT_IU008"); {
// } return std::string("ARMA_MAT_TXT_IU008");
}
else
if(is_s64<eT>::value == true)
{
return std::string("ARMA_MAT_TXT_IS008");
}
#endif
else else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_FN004"); return std::string("ARMA_MAT_TXT_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_FN008"); return std::string("ARMA_MAT_TXT_FN008");
} }
skipping to change at line 102 skipping to change at line 109
//! Generate the first line of the header used for saving matrices in binar y format. //! Generate the first line of the header used for saving matrices in binar y format.
//! Format: "ARMA_MAT_BIN_ABXYZ". //! Format: "ARMA_MAT_BIN_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_bin_header(const Mat<eT>& x) diskio::gen_bin_header(const Mat<eT>& x)
{ {
arma_type_check< is_supported_elem_type<eT>::value == false >::apply(); arma_type_check(( is_supported_elem_type<eT>::value == false ));
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_IU001"); return std::string("ARMA_MAT_BIN_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 135 skipping to change at line 142
else else
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_IU004"); return std::string("ARMA_MAT_BIN_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_IS004"); return std::string("ARMA_MAT_BIN_IS004");
} }
// else #if defined(ARMA_64BIT_WORD)
// if(is_u64<eT>::value == true) else
// { if(is_u64<eT>::value == true)
// return std::string("ARMA_MAT_BIN_IU008"); {
// } return std::string("ARMA_MAT_BIN_IU008");
}
else
if(is_s64<eT>::value == true)
{
return std::string("ARMA_MAT_BIN_IS008");
}
#endif
else else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_FN004"); return std::string("ARMA_MAT_BIN_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_FN008"); return std::string("ARMA_MAT_BIN_FN008");
} }
skipping to change at line 177 skipping to change at line 191
//! Generate the first line of the header used for saving cubes in text for mat. //! Generate the first line of the header used for saving cubes in text for mat.
//! Format: "ARMA_CUB_TXT_ABXYZ". //! Format: "ARMA_CUB_TXT_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_txt_header(const Cube<eT>& x) diskio::gen_txt_header(const Cube<eT>& x)
{ {
arma_type_check< is_supported_elem_type<eT>::value == false >::apply(); arma_type_check(( is_supported_elem_type<eT>::value == false ));
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_IU001"); return std::string("ARMA_CUB_TXT_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 210 skipping to change at line 224
else else
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_IU004"); return std::string("ARMA_CUB_TXT_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_IS004"); return std::string("ARMA_CUB_TXT_IS004");
} }
// else #if defined(ARMA_64BIT_WORD)
// if(is_u64<eT>::value == true) else
// { if(is_u64<eT>::value == true)
// return std::string("ARMA_CUB_TXT_IU008"); {
// } return std::string("ARMA_CUB_TXT_IU008");
}
else
if(is_s64<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IS008");
}
#endif
else else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_FN004"); return std::string("ARMA_CUB_TXT_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_FN008"); return std::string("ARMA_CUB_TXT_FN008");
} }
skipping to change at line 252 skipping to change at line 273
//! Generate the first line of the header used for saving cubes in binary f ormat. //! Generate the first line of the header used for saving cubes in binary f ormat.
//! Format: "ARMA_CUB_BIN_ABXYZ". //! Format: "ARMA_CUB_BIN_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_bin_header(const Cube<eT>& x) diskio::gen_bin_header(const Cube<eT>& x)
{ {
arma_type_check< is_supported_elem_type<eT>::value == false >::apply(); arma_type_check(( is_supported_elem_type<eT>::value == false ));
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_IU001"); return std::string("ARMA_CUB_BIN_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 285 skipping to change at line 306
else else
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_IU004"); return std::string("ARMA_CUB_BIN_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_IS004"); return std::string("ARMA_CUB_BIN_IS004");
} }
// else #if defined(ARMA_64BIT_WORD)
// if(is_u64<eT>::value == true) else
// { if(is_u64<eT>::value == true)
// return std::string("ARMA_CUB_BIN_IU008"); {
// } return std::string("ARMA_CUB_BIN_IU008");
}
else
if(is_s64<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IS008");
}
#endif
else else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_FN004"); return std::string("ARMA_CUB_BIN_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_FN008"); return std::string("ARMA_CUB_BIN_FN008");
} }
skipping to change at line 332 skipping to change at line 360
f.clear(); f.clear();
const std::fstream::pos_type pos1 = f.tellg(); const std::fstream::pos_type pos1 = f.tellg();
f.clear(); f.clear();
f.seekg(0, ios::end); f.seekg(0, ios::end);
f.clear(); f.clear();
const std::fstream::pos_type pos2 = f.tellg(); const std::fstream::pos_type pos2 = f.tellg();
const u32 N = ( (pos1 >= 0) && (pos2 >= 0) ) ? u32(pos2 - pos1) : 0; const uword N = ( (pos1 >= 0) && (pos2 >= 0) ) ? uword(pos2 - pos1) : 0;
f.clear(); f.clear();
f.seekg(pos1); f.seekg(pos1);
podarray<unsigned char> data(N); podarray<unsigned char> data(N);
unsigned char* ptr = data.memptr(); unsigned char* ptr = data.memptr();
f.clear(); f.clear();
f.read( reinterpret_cast<char*>(ptr), std::streamsize(N) ); f.read( reinterpret_cast<char*>(ptr), std::streamsize(N) );
skipping to change at line 354 skipping to change at line 382
const bool load_okay = f.good(); const bool load_okay = f.good();
f.clear(); f.clear();
f.seekg(pos1); f.seekg(pos1);
bool has_binary = false; bool has_binary = false;
bool has_comma = false; bool has_comma = false;
if(load_okay == true) if(load_okay == true)
{ {
u32 i = 0; uword i = 0;
u32 j = (N >= 2) ? 1 : 0; uword j = (N >= 2) ? 1 : 0;
for(; j<N; i+=2, j+=2) for(; j<N; i+=2, j+=2)
{ {
const unsigned char val_i = ptr[i]; const unsigned char val_i = ptr[i];
const unsigned char val_j = ptr[j]; const unsigned char val_j = ptr[j];
// the range checking can be made more elaborate // the range checking can be made more elaborate
if( ((val_i <= 8) || (val_i >= 123)) || ((val_j <= 8) || (val_j >= 12 3)) ) if( ((val_i <= 8) || (val_i >= 123)) || ((val_j <= 8) || (val_j >= 12 3)) )
{ {
has_binary = true; has_binary = true;
skipping to change at line 450 skipping to change at line 478
//! results should be reproducable and not affected //! results should be reproducable and not affected
//! by saving data. //! by saving data.
inline inline
std::string std::string
diskio::gen_tmp_name(const std::string& x) diskio::gen_tmp_name(const std::string& x)
{ {
const std::string* ptr_x = &x; const std::string* ptr_x = &x;
const u8* ptr_ptr_x = reinterpret_cast<const u8*>(&ptr_x); const u8* ptr_ptr_x = reinterpret_cast<const u8*>(&ptr_x);
const char* extra = ".tmp_"; const char* extra = ".tmp_";
const u32 extra_size = 5; const uword extra_size = 5;
const u32 tmp_size = 2*sizeof(u8*) + 2*2; const uword tmp_size = 2*sizeof(u8*) + 2*2;
char tmp[tmp_size]; char tmp[tmp_size];
u32 char_count = 0; uword char_count = 0;
for(u32 i=0; i<sizeof(u8*); ++i) for(uword i=0; i<sizeof(u8*); ++i)
{ {
conv_to_hex(&tmp[char_count], ptr_ptr_x[i]); conv_to_hex(&tmp[char_count], ptr_ptr_x[i]);
char_count += 2; char_count += 2;
} }
const u32 x_size = static_cast<u32>(x.size()); const uword x_size = static_cast<uword>(x.size());
u8 sum = 0; u8 sum = 0;
for(u32 i=0; i<x_size; ++i) for(uword i=0; i<x_size; ++i)
{ {
sum += u8(x[i]); sum += u8(x[i]);
} }
conv_to_hex(&tmp[char_count], sum); conv_to_hex(&tmp[char_count], sum);
char_count += 2; char_count += 2;
conv_to_hex(&tmp[char_count], u8(x_size)); conv_to_hex(&tmp[char_count], u8(x_size));
std::string out; std::string out;
out.resize(x_size + extra_size + tmp_size); out.resize(x_size + extra_size + tmp_size);
for(u32 i=0; i<x_size; ++i) for(uword i=0; i<x_size; ++i)
{ {
out[i] = x[i]; out[i] = x[i];
} }
for(u32 i=0; i<extra_size; ++i) for(uword i=0; i<extra_size; ++i)
{ {
out[x_size + i] = extra[i]; out[x_size + i] = extra[i];
} }
for(u32 i=0; i<tmp_size; ++i) for(uword i=0; i<tmp_size; ++i)
{ {
out[x_size + extra_size + i] = tmp[i]; out[x_size + extra_size + i] = tmp[i];
} }
return out; return out;
} }
//! Safely rename a file. //! Safely rename a file.
//! Before renaming, test if we can write to the final file. //! Before renaming, test if we can write to the final file.
//! This should prevent: //! This should prevent:
skipping to change at line 564 skipping to change at line 592
//! Save a matrix as raw text (no header, human readable). //! Save a matrix as raw text (no header, human readable).
//! Matrices can be loaded in Matlab and Octave, as long as they don't have complex elements. //! Matrices can be loaded in Matlab and Octave, as long as they don't have complex elements.
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::save_raw_ascii(const Mat<eT>& x, std::ostream& f) diskio::save_raw_ascii(const Mat<eT>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 cell_width; uword cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(10); f.precision(10);
cell_width = 18; cell_width = 18;
} }
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col); f << x.at(row,col);
} }
skipping to change at line 682 skipping to change at line 710
bool bool
diskio::save_arma_ascii(const Mat<eT>& x, std::ostream& f) diskio::save_arma_ascii(const Mat<eT>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const ios::fmtflags orig_flags = f.flags(); const ios::fmtflags orig_flags = f.flags();
f << diskio::gen_txt_header(x) << '\n'; f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << '\n'; f << x.n_rows << ' ' << x.n_cols << '\n';
u32 cell_width; uword cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(10); f.precision(10);
cell_width = 18; cell_width = 18;
} }
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col); f << x.at(row,col);
} }
skipping to change at line 765 skipping to change at line 793
const ios::fmtflags orig_flags = f.flags(); const ios::fmtflags orig_flags = f.flags();
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(10); f.precision(10);
} }
u32 x_n_rows = x.n_rows; uword x_n_rows = x.n_rows;
u32 x_n_cols = x.n_cols; uword x_n_cols = x.n_cols;
for(u32 row=0; row < x_n_rows; ++row) for(uword row=0; row < x_n_rows; ++row)
{ {
for(u32 col=0; col < x_n_cols; ++col) for(uword col=0; col < x_n_cols; ++col)
{ {
f << x.at(row,col); f << x.at(row,col);
if( col < (x_n_cols-1) ) if( col < (x_n_cols-1) )
{ {
f.put(','); f.put(',');
} }
} }
f.put('\n'); f.put('\n');
skipping to change at line 885 skipping to change at line 913
inline inline
bool bool
diskio::save_pgm_binary(const Mat<eT>& x, std::ostream& f) diskio::save_pgm_binary(const Mat<eT>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
f << "P5" << '\n'; f << "P5" << '\n';
f << x.n_cols << ' ' << x.n_rows << '\n'; f << x.n_cols << ' ' << x.n_rows << '\n';
f << 255 << '\n'; f << 255 << '\n';
const u32 n_elem = x.n_rows * x.n_cols; const uword n_elem = x.n_rows * x.n_cols;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
u32 i = 0; uword i = 0;
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
tmp[i] = u8( x.at(row,col) ); // TODO: add round() ? tmp[i] = u8( x.at(row,col) ); // TODO: add round() ?
++i; ++i;
} }
} }
f.write(reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) ) ; f.write(reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) ) ;
return f.good(); return f.good();
} }
skipping to change at line 972 skipping to change at line 1000
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = f.good(); bool load_okay = f.good();
f.clear(); f.clear();
const std::fstream::pos_type pos1 = f.tellg(); const std::fstream::pos_type pos1 = f.tellg();
// //
// work out the size // work out the size
u32 f_n_rows = 0; uword f_n_rows = 0;
u32 f_n_cols = 0; uword f_n_cols = 0;
bool f_n_cols_found = false; bool f_n_cols_found = false;
std::string line_string; std::string line_string;
std::string token; std::string token;
while( (f.good() == true) && (load_okay == true) ) while( (f.good() == true) && (load_okay == true) )
{ {
std::getline(f, line_string); std::getline(f, line_string);
if(line_string.size() == 0) if(line_string.size() == 0)
{ {
break; break;
} }
std::stringstream line_stream(line_string); std::stringstream line_stream(line_string);
u32 line_n_cols = 0; uword line_n_cols = 0;
while (line_stream >> token) while (line_stream >> token)
{ {
++line_n_cols; ++line_n_cols;
} }
if(f_n_cols_found == false) if(f_n_cols_found == false)
{ {
f_n_cols = line_n_cols; f_n_cols = line_n_cols;
f_n_cols_found = true; f_n_cols_found = true;
skipping to change at line 1024 skipping to change at line 1052
if(load_okay == true) if(load_okay == true)
{ {
f.clear(); f.clear();
f.seekg(pos1); f.seekg(pos1);
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
eT val; eT val;
for(u32 row=0; (row < x.n_rows) && (load_okay == true); ++row) for(uword row=0; (row < x.n_rows) && (load_okay == true); ++row)
{ {
for(u32 col=0; (col < x.n_cols) && (load_okay == true); ++col) for(uword col=0; (col < x.n_cols) && (load_okay == true); ++col)
{ {
f >> val; f >> val;
if(f.fail() == false) if(f.fail() == false)
{ {
x.at(row,col) = val; x.at(row,col) = val;
} }
else else
{ {
load_okay = false; load_okay = false;
skipping to change at line 1093 skipping to change at line 1121
f.clear(); f.clear();
const std::streampos pos1 = f.tellg(); const std::streampos pos1 = f.tellg();
f.clear(); f.clear();
f.seekg(0, ios::end); f.seekg(0, ios::end);
f.clear(); f.clear();
const std::streampos pos2 = f.tellg(); const std::streampos pos2 = f.tellg();
const u32 N = ( (pos1 >= 0) && (pos2 >= 0) ) ? u32(pos2 - pos1) : 0; const uword N = ( (pos1 >= 0) && (pos2 >= 0) ) ? uword(pos2 - pos1) : 0;
f.clear(); f.clear();
//f.seekg(0, ios::beg); //f.seekg(0, ios::beg);
f.seekg(pos1); f.seekg(pos1);
x.set_size(N / sizeof(eT), 1); x.set_size(N / sizeof(eT), 1);
f.clear(); f.clear();
f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(N) ); f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(N) );
skipping to change at line 1141 skipping to change at line 1169
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_arma_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg) diskio::load_arma_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; uword f_n_rows;
u32 f_n_cols; uword f_n_cols;
f >> f_header; f >> f_header;
f >> f_n_rows; f >> f_n_rows;
f >> f_n_cols; f >> f_n_cols;
if(f_header == diskio::gen_txt_header(x)) if(f_header == diskio::gen_txt_header(x))
{ {
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f >> x.at(row,col); f >> x.at(row,col);
} }
} }
load_okay = f.good(); load_okay = f.good();
} }
else else
{ {
load_okay = false; load_okay = false;
skipping to change at line 1209 skipping to change at line 1237
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = f.good(); bool load_okay = f.good();
f.clear(); f.clear();
const std::fstream::pos_type pos1 = f.tellg(); const std::fstream::pos_type pos1 = f.tellg();
// //
// work out the size // work out the size
u32 f_n_rows = 0; uword f_n_rows = 0;
u32 f_n_cols = 0; uword f_n_cols = 0;
std::string line_string; std::string line_string;
std::string token; std::string token;
while( (f.good() == true) && (load_okay == true) ) while( (f.good() == true) && (load_okay == true) )
{ {
std::getline(f, line_string); std::getline(f, line_string);
if(line_string.size() == 0) if(line_string.size() == 0)
{ {
break; break;
} }
std::stringstream line_stream(line_string); std::stringstream line_stream(line_string);
u32 line_n_cols = 0; uword line_n_cols = 0;
while(line_stream.good() == true) while(line_stream.good() == true)
{ {
getline(line_stream, token, ','); getline(line_stream, token, ',');
++line_n_cols; ++line_n_cols;
} }
if(f_n_cols < line_n_cols) if(f_n_cols < line_n_cols)
{ {
f_n_cols = line_n_cols; f_n_cols = line_n_cols;
} }
++f_n_rows; ++f_n_rows;
} }
f.clear(); f.clear();
f.seekg(pos1); f.seekg(pos1);
x.zeros(f_n_rows, f_n_cols); x.zeros(f_n_rows, f_n_cols);
u32 row = 0; uword row = 0;
while(f.good() == true) while(f.good() == true)
{ {
std::getline(f, line_string); std::getline(f, line_string);
if(line_string.size() == 0) if(line_string.size() == 0)
{ {
break; break;
} }
std::stringstream line_stream(line_string); std::stringstream line_stream(line_string);
u32 col = 0; uword col = 0;
while(line_stream.good() == true) while(line_stream.good() == true)
{ {
getline(line_stream, token, ','); getline(line_stream, token, ',');
eT val; eT val;
std::stringstream ss(token); std::stringstream ss(token);
ss >> val; ss >> val;
skipping to change at line 1319 skipping to change at line 1347
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg) diskio::load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; uword f_n_rows;
u32 f_n_cols; uword f_n_cols;
f >> f_header; f >> f_header;
f >> f_n_rows; f >> f_n_rows;
f >> f_n_cols; f >> f_n_cols;
if(f_header == diskio::gen_bin_header(x)) if(f_header == diskio::gen_bin_header(x))
{ {
//f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters //f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters
f.get(); f.get();
skipping to change at line 1401 skipping to change at line 1429
bool bool
diskio::load_pgm_binary(Mat<eT>& x, std::istream& f, std::string& err_msg) diskio::load_pgm_binary(Mat<eT>& x, std::istream& f, std::string& err_msg)
{ {
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
f >> f_header; f >> f_header;
if(f_header == "P5") if(f_header == "P5")
{ {
u32 f_n_rows = 0; uword f_n_rows = 0;
u32 f_n_cols = 0; uword f_n_cols = 0;
int f_maxval = 0; int f_maxval = 0;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_cols; f >> f_n_cols;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_rows; f >> f_n_rows;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_maxval; f >> f_maxval;
f.get(); f.get();
if( (f_maxval > 0) || (f_maxval <= 65535) ) if( (f_maxval > 0) || (f_maxval <= 65535) )
{ {
x.set_size(f_n_rows,f_n_cols); x.set_size(f_n_rows,f_n_cols);
if(f_maxval <= 255) if(f_maxval <= 255)
{ {
const u32 n_elem = f_n_cols*f_n_rows; const uword n_elem = f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el em) ); f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el em) );
u32 i = 0; uword i = 0;
//cout << "f_n_cols = " << f_n_cols << endl; //cout << "f_n_cols = " << f_n_cols << endl;
//cout << "f_n_rows = " << f_n_rows << endl; //cout << "f_n_rows = " << f_n_rows << endl;
for(u32 row=0; row < f_n_rows; ++row) for(uword row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(uword col=0; col < f_n_cols; ++col)
{ {
x.at(row,col) = eT(tmp[i]); x.at(row,col) = eT(tmp[i]);
++i; ++i;
} }
} }
} }
else else
{ {
const u32 n_elem = f_n_cols*f_n_rows; const uword n_elem = f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem); podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(n_e lem*2) ); f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(n_e lem*2) );
u32 i = 0; uword i = 0;
for(u32 row=0; row < f_n_rows; ++row) for(uword row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(uword col=0; col < f_n_cols; ++col)
{ {
x.at(row,col) = eT(tmp[i]); x.at(row,col) = eT(tmp[i]);
++i; ++i;
} }
} }
} }
} }
else else
skipping to change at line 1642 skipping to change at line 1670
} }
//! Save a cube as raw text (no header, human readable). //! Save a cube as raw text (no header, human readable).
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::save_raw_ascii(const Cube<eT>& x, std::ostream& f) diskio::save_raw_ascii(const Cube<eT>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 cell_width; uword cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(10); f.precision(10);
cell_width = 18; cell_width = 18;
} }
for(u32 slice=0; slice < x.n_slices; ++slice) for(uword slice=0; slice < x.n_slices; ++slice)
{ {
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col,slice); f << x.at(row,col,slice);
} }
skipping to change at line 1763 skipping to change at line 1791
bool bool
diskio::save_arma_ascii(const Cube<eT>& x, std::ostream& f) diskio::save_arma_ascii(const Cube<eT>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const ios::fmtflags orig_flags = f.flags(); const ios::fmtflags orig_flags = f.flags();
f << diskio::gen_txt_header(x) << '\n'; f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n'; f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
u32 cell_width; uword cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(10); f.precision(10);
cell_width = 18; cell_width = 18;
} }
for(u32 slice=0; slice < x.n_slices; ++slice) for(uword slice=0; slice < x.n_slices; ++slice)
{ {
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col,slice); f << x.at(row,col,slice);
} }
skipping to change at line 1947 skipping to change at line 1975
f.clear(); f.clear();
const std::streampos pos1 = f.tellg(); const std::streampos pos1 = f.tellg();
f.clear(); f.clear();
f.seekg(0, ios::end); f.seekg(0, ios::end);
f.clear(); f.clear();
const std::streampos pos2 = f.tellg(); const std::streampos pos2 = f.tellg();
const u32 N = ( (pos1 >= 0) && (pos2 >= 0) ) ? u32(pos2 - pos1) : 0; const uword N = ( (pos1 >= 0) && (pos2 >= 0) ) ? uword(pos2 - pos1) : 0;
f.clear(); f.clear();
//f.seekg(0, ios::beg); //f.seekg(0, ios::beg);
f.seekg(pos1); f.seekg(pos1);
x.set_size(N / sizeof(eT), 1, 1); x.set_size(N / sizeof(eT), 1, 1);
f.clear(); f.clear();
f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(N) ); f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(N) );
skipping to change at line 1995 skipping to change at line 2023
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_arma_ascii(Cube<eT>& x, std::istream& f, std::string& err_msg) diskio::load_arma_ascii(Cube<eT>& x, std::istream& f, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; uword f_n_rows;
u32 f_n_cols; uword f_n_cols;
u32 f_n_slices; uword f_n_slices;
f >> f_header; f >> f_header;
f >> f_n_rows; f >> f_n_rows;
f >> f_n_cols; f >> f_n_cols;
f >> f_n_slices; f >> f_n_slices;
if(f_header == diskio::gen_txt_header(x)) if(f_header == diskio::gen_txt_header(x))
{ {
x.set_size(f_n_rows, f_n_cols, f_n_slices); x.set_size(f_n_rows, f_n_cols, f_n_slices);
for(u32 slice=0; slice < x.n_slices; ++slice) for(uword slice=0; slice < x.n_slices; ++slice)
{ {
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f >> x.at(row,col,slice); f >> x.at(row,col,slice);
} }
} }
} }
load_okay = f.good(); load_okay = f.good();
} }
else else
{ {
skipping to change at line 2063 skipping to change at line 2091
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_arma_binary(Cube<eT>& x, std::istream& f, std::string& err_msg ) diskio::load_arma_binary(Cube<eT>& x, std::istream& f, std::string& err_msg )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; uword f_n_rows;
u32 f_n_cols; uword f_n_cols;
u32 f_n_slices; uword f_n_slices;
f >> f_header; f >> f_header;
f >> f_n_rows; f >> f_n_rows;
f >> f_n_cols; f >> f_n_cols;
f >> f_n_slices; f >> f_n_slices;
if(f_header == diskio::gen_bin_header(x)) if(f_header == diskio::gen_bin_header(x))
{ {
//f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters //f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters
f.get(); f.get();
skipping to change at line 2216 skipping to change at line 2244
return save_okay; return save_okay;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
diskio::save_arma_binary(const field<T1>& x, std::ostream& f) diskio::save_arma_binary(const field<T1>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f alse) >::apply(); arma_type_check(( (is_Mat<T1>::value == false) && (is_Cube<T1>::value == false) ));
f << "ARMA_FLD_BIN" << '\n'; f << "ARMA_FLD_BIN" << '\n';
f << x.n_rows << '\n'; f << x.n_rows << '\n';
f << x.n_cols << '\n'; f << x.n_cols << '\n';
bool save_okay = true; bool save_okay = true;
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
save_okay = diskio::save_arma_binary(x[i], f); save_okay = diskio::save_arma_binary(x[i], f);
if(save_okay == false) if(save_okay == false)
{ {
break; break;
} }
} }
return save_okay; return save_okay;
skipping to change at line 2264 skipping to change at line 2292
return load_okay; return load_okay;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
diskio::load_arma_binary(field<T1>& x, std::istream& f, std::string& err_ms g) diskio::load_arma_binary(field<T1>& x, std::istream& f, std::string& err_ms g)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f alse) >::apply(); arma_type_check(( (is_Mat<T1>::value == false) && (is_Cube<T1>::value == false) ));
bool load_okay = true; bool load_okay = true;
std::string f_type; std::string f_type;
f >> f_type; f >> f_type;
if(f_type != "ARMA_FLD_BIN") if(f_type != "ARMA_FLD_BIN")
{ {
load_okay = false; load_okay = false;
err_msg = "unsupported field type in "; err_msg = "unsupported field type in ";
} }
else else
{ {
u32 f_n_rows; uword f_n_rows;
u32 f_n_cols; uword f_n_cols;
f >> f_n_rows; f >> f_n_rows;
f >> f_n_cols; f >> f_n_cols;
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
f.get(); f.get();
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
load_okay = diskio::load_arma_binary(x[i], f, err_msg); load_okay = diskio::load_arma_binary(x[i], f, err_msg);
if(load_okay == false) if(load_okay == false)
{ {
break; break;
} }
} }
} }
skipping to change at line 2336 skipping to change at line 2364
return save_okay; return save_okay;
} }
inline inline
bool bool
diskio::save_std_string(const field<std::string>& x, std::ostream& f) diskio::save_std_string(const field<std::string>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 row=0; row<x.n_rows; ++row) for(uword row=0; row<x.n_rows; ++row)
for(u32 col=0; col<x.n_cols; ++col) for(uword col=0; col<x.n_cols; ++col)
{ {
f << x.at(row,col); f << x.at(row,col);
if(col < x.n_cols-1) if(col < x.n_cols-1)
{ {
f << ' '; f << ' ';
} }
else else
{ {
f << '\n'; f << '\n';
skipping to change at line 2384 skipping to change at line 2412
bool bool
diskio::load_std_string(field<std::string>& x, std::istream& f, std::string & err_msg) diskio::load_std_string(field<std::string>& x, std::istream& f, std::string & err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
// //
// work out the size // work out the size
u32 f_n_rows = 0; uword f_n_rows = 0;
u32 f_n_cols = 0; uword f_n_cols = 0;
bool f_n_cols_found = false; bool f_n_cols_found = false;
std::string line_string; std::string line_string;
std::string token; std::string token;
while( (f.good() == true) && (load_okay == true) ) while( (f.good() == true) && (load_okay == true) )
{ {
std::getline(f, line_string); std::getline(f, line_string);
if(line_string.size() == 0) if(line_string.size() == 0)
break; break;
std::stringstream line_stream(line_string); std::stringstream line_stream(line_string);
u32 line_n_cols = 0; uword line_n_cols = 0;
while (line_stream >> token) while (line_stream >> token)
line_n_cols++; line_n_cols++;
if(f_n_cols_found == false) if(f_n_cols_found == false)
{ {
f_n_cols = line_n_cols; f_n_cols = line_n_cols;
f_n_cols_found = true; f_n_cols_found = true;
} }
else else
{ {
skipping to change at line 2429 skipping to change at line 2457
} }
if(load_okay == true) if(load_okay == true)
{ {
f.clear(); f.clear();
f.seekg(0, ios::beg); f.seekg(0, ios::beg);
//f.seekg(start); //f.seekg(start);
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
f >> x.at(row,col); f >> x.at(row,col);
} }
} }
} }
if(f.good() == false) if(f.good() == false)
{ {
load_okay = false; load_okay = false;
} }
skipping to change at line 2476 skipping to change at line 2504
} }
//! Try to load a field by automatically determining its type //! Try to load a field by automatically determining its type
template<typename T1> template<typename T1>
inline inline
bool bool
diskio::load_auto_detect(field<T1>& x, std::istream& f, std::string& err_ms g) diskio::load_auto_detect(field<T1>& x, std::istream& f, std::string& err_ms g)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check(( is_Mat<T1>::value == false ));
static const std::string ARMA_FLD_BIN = "ARMA_FLD_BIN"; static const std::string ARMA_FLD_BIN = "ARMA_FLD_BIN";
static const std::string P6 = "P6"; static const std::string P6 = "P6";
podarray<char> raw_header(ARMA_FLD_BIN.length() + 1); podarray<char> raw_header(ARMA_FLD_BIN.length() + 1);
std::streampos pos = f.tellg(); std::streampos pos = f.tellg();
f.read( raw_header.memptr(), std::streamsize(ARMA_FLD_BIN.length()) ); f.read( raw_header.memptr(), std::streamsize(ARMA_FLD_BIN.length()) );
skipping to change at line 2548 skipping to change at line 2576
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
f >> f_header; f >> f_header;
if(f_header == "P6") if(f_header == "P6")
{ {
u32 f_n_rows = 0; uword f_n_rows = 0;
u32 f_n_cols = 0; uword f_n_cols = 0;
int f_maxval = 0; int f_maxval = 0;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_cols; f >> f_n_cols;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_rows; f >> f_n_rows;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_maxval; f >> f_maxval;
f.get(); f.get();
if( (f_maxval > 0) || (f_maxval <= 65535) ) if( (f_maxval > 0) || (f_maxval <= 65535) )
{ {
x.set_size(f_n_rows, f_n_cols, 3); x.set_size(f_n_rows, f_n_cols, 3);
if(f_maxval <= 255) if(f_maxval <= 255)
{ {
const u32 n_elem = 3*f_n_cols*f_n_rows; const uword n_elem = 3*f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el em) ); f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el em) );
u32 i = 0; uword i = 0;
//cout << "f_n_cols = " << f_n_cols << endl; //cout << "f_n_cols = " << f_n_cols << endl;
//cout << "f_n_rows = " << f_n_rows << endl; //cout << "f_n_rows = " << f_n_rows << endl;
for(u32 row=0; row < f_n_rows; ++row) for(uword row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(uword col=0; col < f_n_cols; ++col)
{ {
x.at(row,col,0) = eT(tmp[i+0]); x.at(row,col,0) = eT(tmp[i+0]);
x.at(row,col,1) = eT(tmp[i+1]); x.at(row,col,1) = eT(tmp[i+1]);
x.at(row,col,2) = eT(tmp[i+2]); x.at(row,col,2) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
else else
{ {
const u32 n_elem = 3*f_n_cols*f_n_rows; const uword n_elem = 3*f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem); podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(2*n _elem) ); f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(2*n _elem) );
u32 i = 0; uword i = 0;
for(u32 row=0; row < f_n_rows; ++row) for(uword row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(uword col=0; col < f_n_cols; ++col)
{ {
x.at(row,col,0) = eT(tmp[i+0]); x.at(row,col,0) = eT(tmp[i+0]);
x.at(row,col,1) = eT(tmp[i+1]); x.at(row,col,1) = eT(tmp[i+1]);
x.at(row,col,2) = eT(tmp[i+2]); x.at(row,col,2) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
skipping to change at line 2674 skipping to change at line 2702
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::save_ppm_binary(const Cube<eT>& x, std::ostream& f) diskio::save_ppm_binary(const Cube<eT>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (x.n_slices != 3), "diskio::save_ppm_binary(): given cu be must have exactly 3 slices" ); arma_debug_check( (x.n_slices != 3), "diskio::save_ppm_binary(): given cu be must have exactly 3 slices" );
const u32 n_elem = 3 * x.n_rows * x.n_cols; const uword n_elem = 3 * x.n_rows * x.n_cols;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
u32 i = 0; uword i = 0;
for(u32 row=0; row < x.n_rows; ++row) for(uword row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(uword col=0; col < x.n_cols; ++col)
{ {
tmp[i+0] = u8( access::tmp_real( x.at(row,col,0) ) ); tmp[i+0] = u8( access::tmp_real( x.at(row,col,0) ) );
tmp[i+1] = u8( access::tmp_real( x.at(row,col,1) ) ); tmp[i+1] = u8( access::tmp_real( x.at(row,col,1) ) );
tmp[i+2] = u8( access::tmp_real( x.at(row,col,2) ) ); tmp[i+2] = u8( access::tmp_real( x.at(row,col,2) ) );
i+=3; i+=3;
} }
} }
f << "P6" << '\n'; f << "P6" << '\n';
skipping to change at line 2731 skipping to change at line 2759
return load_okay; return load_okay;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
diskio::load_ppm_binary(field<T1>& x, std::istream& f, std::string& err_msg ) diskio::load_ppm_binary(field<T1>& x, std::istream& f, std::string& err_msg )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check(( is_Mat<T1>::value == false ));
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
f >> f_header; f >> f_header;
if(f_header == "P6") if(f_header == "P6")
{ {
u32 f_n_rows = 0; uword f_n_rows = 0;
u32 f_n_cols = 0; uword f_n_cols = 0;
int f_maxval = 0; int f_maxval = 0;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_cols; f >> f_n_cols;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_rows; f >> f_n_rows;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
skipping to change at line 2769 skipping to change at line 2797
Mat<eT>& R = x(0); Mat<eT>& R = x(0);
Mat<eT>& G = x(1); Mat<eT>& G = x(1);
Mat<eT>& B = x(2); Mat<eT>& B = x(2);
R.set_size(f_n_rows,f_n_cols); R.set_size(f_n_rows,f_n_cols);
G.set_size(f_n_rows,f_n_cols); G.set_size(f_n_rows,f_n_cols);
B.set_size(f_n_rows,f_n_cols); B.set_size(f_n_rows,f_n_cols);
if(f_maxval <= 255) if(f_maxval <= 255)
{ {
const u32 n_elem = 3*f_n_cols*f_n_rows; const uword n_elem = 3*f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el em) ); f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el em) );
u32 i = 0; uword i = 0;
//cout << "f_n_cols = " << f_n_cols << endl; //cout << "f_n_cols = " << f_n_cols << endl;
//cout << "f_n_rows = " << f_n_rows << endl; //cout << "f_n_rows = " << f_n_rows << endl;
for(u32 row=0; row < f_n_rows; ++row) for(uword row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(uword col=0; col < f_n_cols; ++col)
{ {
R.at(row,col) = eT(tmp[i+0]); R.at(row,col) = eT(tmp[i+0]);
G.at(row,col) = eT(tmp[i+1]); G.at(row,col) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]); B.at(row,col) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
else else
{ {
const u32 n_elem = 3*f_n_cols*f_n_rows; const uword n_elem = 3*f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem); podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(2*n _elem) ); f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(2*n _elem) );
u32 i = 0; uword i = 0;
for(u32 row=0; row < f_n_rows; ++row) for(uword row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(uword col=0; col < f_n_cols; ++col)
{ {
R.at(row,col) = eT(tmp[i+0]); R.at(row,col) = eT(tmp[i+0]);
G.at(row,col) = eT(tmp[i+1]); G.at(row,col) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]); B.at(row,col) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
skipping to change at line 2871 skipping to change at line 2899
return save_okay; return save_okay;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
diskio::save_ppm_binary(const field<T1>& x, std::ostream& f) diskio::save_ppm_binary(const field<T1>& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check(( is_Mat<T1>::value == false ));
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check( (x.n_elem != 3), "diskio::save_ppm_binary(): given fiel d must have exactly 3 matrices of equal size" ); arma_debug_check( (x.n_elem != 3), "diskio::save_ppm_binary(): given fiel d must have exactly 3 matrices of equal size" );
bool same_size = true; bool same_size = true;
for(u32 i=1; i<3; ++i) for(uword i=1; i<3; ++i)
{ {
if( (x(0).n_rows != x(i).n_rows) || (x(0).n_cols != x(i).n_cols) ) if( (x(0).n_rows != x(i).n_rows) || (x(0).n_cols != x(i).n_cols) )
{ {
same_size = false; same_size = false;
break; break;
} }
} }
arma_debug_check( (same_size != true), "diskio::save_ppm_binary(): given field must have exactly 3 matrices of equal size" ); arma_debug_check( (same_size != true), "diskio::save_ppm_binary(): given field must have exactly 3 matrices of equal size" );
const Mat<eT>& R = x(0); const Mat<eT>& R = x(0);
const Mat<eT>& G = x(1); const Mat<eT>& G = x(1);
const Mat<eT>& B = x(2); const Mat<eT>& B = x(2);
f << "P6" << '\n'; f << "P6" << '\n';
f << R.n_cols << '\n'; f << R.n_cols << '\n';
f << R.n_rows << '\n'; f << R.n_rows << '\n';
f << 255 << '\n'; f << 255 << '\n';
const u32 n_elem = 3 * R.n_rows * R.n_cols; const uword n_elem = 3 * R.n_rows * R.n_cols;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
u32 i = 0; uword i = 0;
for(u32 row=0; row < R.n_rows; ++row) for(uword row=0; row < R.n_rows; ++row)
{ {
for(u32 col=0; col < R.n_cols; ++col) for(uword col=0; col < R.n_cols; ++col)
{ {
tmp[i+0] = u8( access::tmp_real( R.at(row,col) ) ); tmp[i+0] = u8( access::tmp_real( R.at(row,col) ) );
tmp[i+1] = u8( access::tmp_real( G.at(row,col) ) ); tmp[i+1] = u8( access::tmp_real( G.at(row,col) ) );
tmp[i+2] = u8( access::tmp_real( B.at(row,col) ) ); tmp[i+2] = u8( access::tmp_real( B.at(row,col) ) );
i+=3; i+=3;
} }
} }
f.write( reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) ); f.write( reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) );
 End of changes. 106 change blocks. 
140 lines changed or deleted 168 lines changed or added


 eGlueCube_bones.hpp   eGlueCube_bones.hpp 
skipping to change at line 25 skipping to change at line 25
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
class eGlueCube : public BaseCube<typename T1::elem_type, eGlueCube<T1, T2, eglue_type> > class eGlueCube : public BaseCube<typename T1::elem_type, eGlueCube<T1, T2, eglue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor); static const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
static const bool has_subview = (ProxyCube<T1>::has_subview || ProxyCube<T2>::has_subview );
arma_aligned const ProxyCube<T1> P1; arma_aligned const ProxyCube<T1> P1;
arma_aligned const ProxyCube<T2> P2; arma_aligned const ProxyCube<T2> P2;
arma_inline ~eGlueCube(); arma_inline ~eGlueCube();
arma_inline eGlueCube(const T1& in_A, const T2& in_B); arma_inline eGlueCube(const T1& in_A, const T2& in_B);
arma_inline u32 get_n_rows() const; arma_inline uword get_n_rows() const;
arma_inline u32 get_n_cols() const; arma_inline uword get_n_cols() const;
arma_inline u32 get_n_elem_slice() const; arma_inline uword get_n_elem_slice() const;
arma_inline u32 get_n_slices() const; arma_inline uword get_n_slices() const;
arma_inline u32 get_n_elem() const; arma_inline uword get_n_elem() const;
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const; const;
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const; uword slice) const;
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
9 lines changed or deleted 10 lines changed or added


 eGlueCube_meat.hpp   eGlueCube_meat.hpp 
skipping to change at line 41 skipping to change at line 41
arma_assert_same_size arma_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
u32 uword
eGlueCube<T1,T2,eglue_type>::get_n_rows() const eGlueCube<T1,T2,eglue_type>::get_n_rows() const
{ {
return P1.get_n_rows(); return P1.get_n_rows();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
u32 uword
eGlueCube<T1,T2,eglue_type>::get_n_cols() const eGlueCube<T1,T2,eglue_type>::get_n_cols() const
{ {
return P1.get_n_cols(); return P1.get_n_cols();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
u32 uword
eGlueCube<T1,T2,eglue_type>::get_n_slices() const eGlueCube<T1,T2,eglue_type>::get_n_slices() const
{ {
return P1.get_n_slices(); return P1.get_n_slices();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
u32 uword
eGlueCube<T1,T2,eglue_type>::get_n_elem_slice() const eGlueCube<T1,T2,eglue_type>::get_n_elem_slice() const
{ {
return P1.get_n_elem_slice(); return P1.get_n_elem_slice();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
u32 uword
eGlueCube<T1,T2,eglue_type>::get_n_elem() const eGlueCube<T1,T2,eglue_type>::get_n_elem() const
{ {
return P1.get_n_elem(); return P1.get_n_elem();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlueCube<T1,T2,eglue_type>::operator[] (const u32 i) const eGlueCube<T1,T2,eglue_type>::operator[] (const uword i) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; }
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlueCube<T1,T2,eglue_type>::at(const u32 row, const u32 col, const u32 sli ce) const eGlueCube<T1,T2,eglue_type>::at(const uword row, const uword col, const uwo rd slice) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col,slice) + P2.at(row,col,slice); } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col,slice) + P2.at(row,col,slice); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col,slice) - P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col,slice) - P2.at(row,col,slice); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col,slice) / P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col,slice) / P2.at(row,col,slice); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col,slice) * P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col,slice) * P2.at(row,col,slice); }
} }
 End of changes. 7 change blocks. 
7 lines changed or deleted 7 lines changed or added


 eGlue_bones.hpp   eGlue_bones.hpp 
skipping to change at line 33 skipping to change at line 33
static const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor); static const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
static const bool has_subview = (Proxy<T1>::has_subview || Proxy<T2>::has_subview ); static const bool has_subview = (Proxy<T1>::has_subview || Proxy<T2>::has_subview );
arma_aligned const Proxy<T1> P1; arma_aligned const Proxy<T1> P1;
arma_aligned const Proxy<T2> P2; arma_aligned const Proxy<T2> P2;
arma_inline ~eGlue(); arma_inline ~eGlue();
arma_inline eGlue(const T1& in_A, const T2& in_B); arma_inline eGlue(const T1& in_A, const T2& in_B);
arma_inline u32 get_n_rows() const; arma_inline uword get_n_rows() const;
arma_inline u32 get_n_cols() const; arma_inline uword get_n_cols() const;
arma_inline u32 get_n_elem() const; arma_inline uword get_n_elem() const;
arma_inline elem_type operator[] (const u32 i) const; arma_inline elem_type operator[] (const uword i) const;
arma_inline elem_type at (const u32 row, const u32 col) const; arma_inline elem_type at (const uword row, const uword col) const
;
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
5 lines changed or deleted 6 lines changed or added


 eGlue_meat.hpp   eGlue_meat.hpp 
skipping to change at line 42 skipping to change at line 42
arma_debug_assert_same_size arma_debug_assert_same_size
( (
P1.get_n_rows(), P1.get_n_cols(), P1.get_n_rows(), P1.get_n_cols(),
P2.get_n_rows(), P2.get_n_cols(), P2.get_n_rows(), P2.get_n_cols(),
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
u32 uword
eGlue<T1,T2,eglue_type>::get_n_rows() const eGlue<T1,T2,eglue_type>::get_n_rows() const
{ {
return P1.get_n_rows(); return P1.get_n_rows();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
u32 uword
eGlue<T1,T2,eglue_type>::get_n_cols() const eGlue<T1,T2,eglue_type>::get_n_cols() const
{ {
return P1.get_n_cols(); return P1.get_n_cols();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
u32 uword
eGlue<T1,T2,eglue_type>::get_n_elem() const eGlue<T1,T2,eglue_type>::get_n_elem() const
{ {
return P1.get_n_elem(); return P1.get_n_elem();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlue<T1,T2,eglue_type>::operator[] (const u32 i) const eGlue<T1,T2,eglue_type>::operator[] (const uword i) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; }
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlue<T1,T2,eglue_type>::at(const u32 row, const u32 col) const eGlue<T1,T2,eglue_type>::at(const uword row, const uword col) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col) + P2.at(row,col); } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col) + P2.at(row,col); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col) - P2.at(row,col); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col) - P2.at(row,col); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col) / P2.at(row,col); } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col) / P2.at(row,col); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col) * P2.at(row,col); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col) * P2.at(row,col); }
} }
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 eOpCube_bones.hpp   eOpCube_bones.hpp 
skipping to change at line 25 skipping to change at line 25
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
class eOpCube : public BaseCube<typename T1::elem_type, eOpCube<T1, eop_typ e> > class eOpCube : public BaseCube<typename T1::elem_type, eOpCube<T1, eop_typ e> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool prefer_at_accessor = ProxyCube<T1>::prefer_at_accessor; static const bool prefer_at_accessor = ProxyCube<T1>::prefer_at_accessor;
static const bool has_subview = ProxyCube<T1>::has_subview;
arma_aligned const ProxyCube<T1> P; arma_aligned const ProxyCube<T1> P;
arma_aligned elem_type aux; //!< storage of auxiliary
arma_aligned const elem_type aux; //!< storage of auxiliary data, data, user defined format
user defined format arma_aligned uword aux_uword_a; //!< storage of auxiliary
arma_aligned const u32 aux_u32_a; //!< storage of auxiliary data, data, uword format
u32 format arma_aligned uword aux_uword_b; //!< storage of auxiliary
arma_aligned const u32 aux_u32_b; //!< storage of auxiliary data, data, uword format
u32 format arma_aligned uword aux_uword_c; //!< storage of auxiliary
arma_aligned const u32 aux_u32_c; //!< storage of auxiliary data, data, uword format
u32 format
inline ~eOpCube(); inline ~eOpCube();
inline explicit eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m) ; inline explicit eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m) ;
inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const elem_type in_aux); inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const elem_type in_aux);
inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b); const uword in_aux_uword_a, const uword in_aux_uword_b);
inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c); const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux
inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, _uword_c);
const elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32_b, co inline eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
nst u32 in_aux_u32_c); const elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uwo
inline eOpCube(const u32 in_n_rows, const u32 in_n_cols, const u rd_b, const uword in_aux_uword_c);
32 in_n_slices);
arma_inline uword get_n_rows() const;
arma_inline u32 get_n_rows() const; arma_inline uword get_n_cols() const;
arma_inline u32 get_n_cols() const; arma_inline uword get_n_elem_slice() const;
arma_inline u32 get_n_elem_slice() const; arma_inline uword get_n_slices() const;
arma_inline u32 get_n_slices() const; arma_inline uword get_n_elem() const;
arma_inline u32 get_n_elem() const;
arma_inline elem_type operator[] (const u32 i) arma_inline elem_type operator[] (const uword i)
const; const;
arma_inline elem_type at (const u32 row, const u32 col, const u32 arma_inline elem_type at (const uword row, const uword col, const
slice) const; uword slice) const;
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
28 lines changed or deleted 27 lines changed or added


 eOpCube_meat.hpp   eOpCube_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup eOpCube //! \addtogroup eOpCube
//! @{ //! @{
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m) eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m)
: P (in_m.get_ref()) : P (in_m.get_ref())
, aux (aux)
, aux_u32_a (aux_u32_a)
, aux_u32_b (aux_u32_b)
, aux_u32_c (aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const typename T1::elem_type in_aux) eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const typename T1::elem_type in_aux)
: P (in_m.get_ref()) : P (in_m.get_ref())
, aux (in_aux) , aux (in_aux)
, aux_u32_a (aux_u32_a)
, aux_u32_b (aux_u32_b)
, aux_u32_c (aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b) in_m, const uword in_aux_uword_a, const uword in_aux_uword_b)
: P (in_m.get_ref()) : P (in_m.get_ref())
, aux (aux) , aux_uword_a (in_aux_uword_a)
, aux_u32_a (in_aux_u32_a) , aux_uword_b (in_aux_uword_b)
, aux_u32_b (in_aux_u32_b)
, aux_u32_c (aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_ in_m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword i
c) n_aux_uword_c)
: P (in_m.get_ref()) : P (in_m.get_ref())
, aux (aux) , aux_uword_a (in_aux_uword_a)
, aux_u32_a (in_aux_u32_a) , aux_uword_b (in_aux_uword_b)
, aux_u32_b (in_aux_u32_b) , aux_uword_c (in_aux_uword_c)
, aux_u32_c (in_aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>& eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u3 in_m, const typename T1::elem_type in_aux, const uword in_aux_uword_a, cons
2 in_aux_u32_b, const u32 in_aux_u32_c) t uword in_aux_uword_b, const uword in_aux_uword_c)
: P (in_m.get_ref()) : P (in_m.get_ref())
, aux (in_aux) , aux (in_aux)
, aux_u32_a (in_aux_u32_a) , aux_uword_a (in_aux_uword_a)
, aux_u32_b (in_aux_u32_b) , aux_uword_b (in_aux_uword_b)
, aux_u32_c (in_aux_u32_c) , aux_uword_c (in_aux_uword_c)
{
arma_extra_debug_sigprint();
}
//! used by eop_randu, eop_randn, eop_zeros, eop_ones (i.e. element generat
ors);
//! the proxy P is invalid for generators and must not be used.
template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::eOpCube(const u32 in_n_rows, const u32 in_n_cols, co
nst u32 in_n_slices)
: P (P)
, aux (aux)
, aux_u32_a (in_n_rows)
, aux_u32_b (in_n_cols)
, aux_u32_c (in_n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOpCube<T1, eop_type>::~eOpCube() eOpCube<T1, eop_type>::~eOpCube()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOpCube<T1, eop_type>::get_n_rows() const eOpCube<T1, eop_type>::get_n_rows() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_rows() : aux_u3 2_a; return P.get_n_rows();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOpCube<T1, eop_type>::get_n_cols() const eOpCube<T1, eop_type>::get_n_cols() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_cols() : aux_u3 2_b; return P.get_n_cols();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOpCube<T1, eop_type>::get_n_elem_slice() const eOpCube<T1, eop_type>::get_n_elem_slice() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_elem_slice() : (aux_u32_a * aux_u32_b); return P.get_n_elem_slice();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOpCube<T1, eop_type>::get_n_slices() const eOpCube<T1, eop_type>::get_n_slices() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_slices() : aux_ u32_c; return P.get_n_slices();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOpCube<T1, eop_type>::get_n_elem() const eOpCube<T1, eop_type>::get_n_elem() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_elem() : (aux_u 32_a * aux_u32_b * aux_u32_c); return P.get_n_elem();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOpCube<T1, eop_type>::operator[] (const u32 i) const eOpCube<T1, eop_type>::operator[] (const uword i) const
{ {
typedef typename T1::elem_type eT; return eop_core<eop_type>::process(P[i], aux);
if(is_generator<eop_type>::value == true)
{
return eop_aux::generate<eT,eop_type>();
}
else
{
return eop_core<eop_type>::process(P[i], aux);
}
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOpCube<T1, eop_type>::at(const u32 row, const u32 col, const u32 slice) co nst eOpCube<T1, eop_type>::at(const uword row, const uword col, const uword sli ce) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_generator<eop_type>::value == true) return eop_core<eop_type>::process(P.at(row, col, slice), aux);
{
return eop_aux::generate<eT,eop_type>();
}
else
{
return eop_core<eop_type>::process(P.at(row, col, slice), aux);
}
} }
//! @} //! @}
 End of changes. 20 change blocks. 
80 lines changed or deleted 39 lines changed or added


 eOp_bones.hpp   eOp_bones.hpp 
skipping to change at line 29 skipping to change at line 29
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Proxy<T1> proxy_type; typedef Proxy<T1> proxy_type;
static const bool prefer_at_accessor = Proxy<T1>::prefer_at_accessor; static const bool prefer_at_accessor = Proxy<T1>::prefer_at_accessor;
static const bool has_subview = Proxy<T1>::has_subview; static const bool has_subview = Proxy<T1>::has_subview;
arma_aligned const Proxy<T1> P; arma_aligned const Proxy<T1> P;
arma_aligned const elem_type aux; //!< storage of auxiliary data, arma_aligned elem_type aux; //!< storage of auxiliary data
user defined format , user defined format
arma_aligned const u32 aux_u32_a; //!< storage of auxiliary data, arma_aligned uword aux_uword_a; //!< storage of auxiliary data
u32 format , uword format
arma_aligned const u32 aux_u32_b; //!< storage of auxiliary data, arma_aligned uword aux_uword_b; //!< storage of auxiliary data
u32 format , uword format
inline ~eOp(); inline ~eOp();
inline explicit eOp(const Base<typename T1::elem_type, T1>& in_m); inline explicit eOp(const Base<typename T1::elem_type, T1>& in_m);
inline eOp(const Base<typename T1::elem_type, T1>& in_m, const e lem_type in_aux); inline eOp(const Base<typename T1::elem_type, T1>& in_m, const e lem_type in_aux);
inline eOp(const Base<typename T1::elem_type, T1>& in_m, const u inline eOp(const Base<typename T1::elem_type, T1>& in_m, const u
32 in_aux_u32_a, const u32 in_aux_u32_b); word in_aux_uword_a, const uword in_aux_uword_b);
inline eOp(const Base<typename T1::elem_type, T1>& in_m, const e inline eOp(const Base<typename T1::elem_type, T1>& in_m, const e
lem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32_b); lem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b);
inline eOp(const u32 in_n_rows, const u32 in_n_cols);
arma_inline u32 get_n_rows() const;
arma_inline u32 get_n_cols() const;
arma_inline u32 get_n_elem() const;
arma_inline elem_type operator[] (const u32 i) const; arma_inline uword get_n_rows() const;
arma_inline elem_type at (const u32 row, const u32 col) const; arma_inline uword get_n_cols() const;
arma_inline uword get_n_elem() const;
arma_inline elem_type operator[] (const uword i) const
;
arma_inline elem_type at (const uword row, const uword col) const
;
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
17 lines changed or deleted 18 lines changed or added


 eOp_meat.hpp   eOp_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup eOp //! \addtogroup eOp
//! @{ //! @{
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m) eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m)
: P(in_m.get_ref()) : P(in_m.get_ref())
, aux(aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const typename T1::elem_type in_aux) eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const typename T1::elem_type in_aux)
: P(in_m.get_ref()) : P(in_m.get_ref())
, aux(in_aux) , aux(in_aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b) eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b)
: P(in_m.get_ref()) : P(in_m.get_ref())
, aux(aux) , aux_uword_a(in_aux_uword_a)
, aux_u32_a(in_aux_u32_a) , aux_uword_b(in_aux_uword_b)
, aux_u32_b(in_aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32 _b) eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const typename T1::elem_type in_aux, const uword in_aux_uword_a, const uword in_a ux_uword_b)
: P(in_m.get_ref()) : P(in_m.get_ref())
, aux(in_aux) , aux(in_aux)
, aux_u32_a(in_aux_u32_a) , aux_uword_a(in_aux_uword_a)
, aux_u32_b(in_aux_u32_b) , aux_uword_b(in_aux_uword_b)
{
arma_extra_debug_sigprint();
}
//! used by eop_randu, eop_randn, eop_zeros, eop_ones, eop_ones_diag (i.e.
element generators);
//! the proxy P is invalid for generators and must not be used.
template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const u32 in_n_rows, const u32 in_n_cols)
: P(P)
, aux(aux)
, aux_u32_a(in_n_rows)
, aux_u32_b(in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::~eOp() eOp<T1, eop_type>::~eOp()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOp<T1, eop_type>::get_n_rows() const eOp<T1, eop_type>::get_n_rows() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_rows() : aux_u3 2_a; return P.get_n_rows();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOp<T1, eop_type>::get_n_cols() const eOp<T1, eop_type>::get_n_cols() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_cols() : aux_u3 2_b; return P.get_n_cols();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
u32 uword
eOp<T1, eop_type>::get_n_elem() const eOp<T1, eop_type>::get_n_elem() const
{ {
return (is_generator<eop_type>::value == false) ? P.get_n_elem() : (aux_u 32_a * aux_u32_b); return P.get_n_elem();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOp<T1, eop_type>::operator[] (const u32 i) const eOp<T1, eop_type>::operator[] (const uword i) const
{ {
typedef typename T1::elem_type eT; return eop_core<eop_type>::process(P[i], aux);
if(is_generator<eop_type>::value == true)
{
if(is_same_type<eop_type, eop_ones_diag>::value == true)
{
return ((i % get_n_rows()) == (i / get_n_rows())) ? eT(1) : eT(0);
}
else
{
return eop_aux::generate<eT,eop_type>();
}
}
else
{
return eop_core<eop_type>::process(P[i], aux);
}
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOp<T1, eop_type>::at(const u32 row, const u32 col) const eOp<T1, eop_type>::at(const uword row, const uword col) const
{ {
typedef typename T1::elem_type eT; return eop_core<eop_type>::process(P.at(row, col), aux);
if(is_generator<eop_type>::value == true)
{
if(is_same_type<eop_type, eop_ones_diag>::value == true)
{
return (row == col) ? eT(1) : eT(0);
}
else
{
return eop_aux::generate<eT,eop_type>();
}
}
else
{
return eop_core<eop_type>::process(P.at(row, col), aux);
}
} }
//! @} //! @}
 End of changes. 17 change blocks. 
69 lines changed or deleted 18 lines changed or added


 eglue_core_meat.hpp   eglue_core_meat.hpp 
skipping to change at line 52 skipping to change at line 52
}; };
#undef arma_applier_1 #undef arma_applier_1
#undef arma_applier_2 #undef arma_applier_2
#undef arma_applier_3 #undef arma_applier_3
#undef operatorA #undef operatorA
#undef operatorB #undef operatorB
#define arma_applier_1(operatorA, operatorB) \ #define arma_applier_1(operatorA, operatorB) \
{\ {\
u32 i,j;\ uword i,j;\
\ \
for(i=0, j=1; j<n_elem; i+=2, j+=2)\ for(i=0, j=1; j<n_elem; i+=2, j+=2)\
{\ {\
eT tmp_i = P1[i];\ eT tmp_i = P1[i];\
eT tmp_j = P1[j];\ eT tmp_j = P1[j];\
\ \
tmp_i operatorB##= P2[i];\ tmp_i operatorB##= P2[i];\
tmp_j operatorB##= P2[j];\ tmp_j operatorB##= P2[j];\
\ \
out_mem[i] operatorA tmp_i;\ out_mem[i] operatorA tmp_i;\
skipping to change at line 74 skipping to change at line 74
}\ }\
\ \
if(i < n_elem)\ if(i < n_elem)\
{\ {\
out_mem[i] operatorA P1[i] operatorB P2[i];\ out_mem[i] operatorA P1[i] operatorB P2[i];\
}\ }\
} }
#define arma_applier_2(operatorA, operatorB) \ #define arma_applier_2(operatorA, operatorB) \
{\ {\
u32 count = 0;\ uword count = 0;\
\ \
for(u32 col=0; col<n_cols; ++col)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
u32 i,j;\ uword i,j;\
\ \
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\ for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\ {\
eT tmp_i = P1.at(i,col);\ eT tmp_i = P1.at(i,col);\
eT tmp_j = P1.at(j,col);\ eT tmp_j = P1.at(j,col);\
\ \
tmp_i operatorB##= P2.at(i,col);\ tmp_i operatorB##= P2.at(i,col);\
tmp_j operatorB##= P2.at(j,col);\ tmp_j operatorB##= P2.at(j,col);\
\ \
out_mem[count ] operatorA tmp_i;\ out_mem[count ] operatorA tmp_i;\
skipping to change at line 102 skipping to change at line 102
if(i < n_rows)\ if(i < n_rows)\
{\ {\
out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\ out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\
++count;\ ++count;\
}\ }\
}\ }\
} }
#define arma_applier_3(operatorA, operatorB) \ #define arma_applier_3(operatorA, operatorB) \
{\ {\
u32 count = 0;\ uword count = 0;\
\ \
for(u32 slice=0; slice<n_slices; ++slice)\ for(uword slice=0; slice<n_slices; ++slice)\
{\ {\
for(u32 col=0; col<n_cols; ++col)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
u32 i,j;\ uword i,j;\
\ \
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\ for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\ {\
eT tmp_i = P1.at(i,col,slice);\ eT tmp_i = P1.at(i,col,slice);\
eT tmp_j = P1.at(j,col,slice);\ eT tmp_j = P1.at(j,col,slice);\
\ \
tmp_i operatorB##= P2.at(i,col,slice);\ tmp_i operatorB##= P2.at(i,col,slice);\
tmp_j operatorB##= P2.at(j,col,slice);\ tmp_j operatorB##= P2.at(j,col,slice);\
\ \
out_mem[count ] operatorA tmp_i;\ out_mem[count ] operatorA tmp_i;\
skipping to change at line 147 skipping to change at line 147
inline inline
void void
eglue_core<eglue_type>::apply(Mat<typename T1::elem_type>& out, const eGlue <T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply(Mat<typename T1::elem_type>& out, const eGlue <T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
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);
const u32 n_rows = x.get_n_rows(); // NOTE: we're assuming that the matrix has already been set to the corre
const u32 n_cols = x.get_n_cols(); ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o
out.set_size(n_rows, n_cols); r operator=()
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const u32 n_elem = out.n_elem; const uword 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
{ {
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(=, *); }
} }
} }
skipping to change at line 197 skipping to change at line 198
arma_debug_assert_same_size(out, x.P1, "addition"); arma_debug_assert_same_size(out, x.P1, "addition");
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)
{ {
const u32 n_elem = out.n_elem; const uword 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
{ {
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(+=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(+=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(+=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(+=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(+=, *); }
} }
} }
skipping to change at line 241 skipping to change at line 242
arma_debug_assert_same_size(out, x.P1, "subtraction"); arma_debug_assert_same_size(out, x.P1, "subtraction");
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)
{ {
const u32 n_elem = out.n_elem; const uword 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
{ {
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(-=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(-=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(-=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(-=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(-=, *); }
} }
} }
skipping to change at line 285 skipping to change at line 286
arma_debug_assert_same_size(out, x.P1, "element-wise multiplication"); arma_debug_assert_same_size(out, x.P1, "element-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)
{ {
const u32 n_elem = out.n_elem; const uword 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
{ {
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); }
} }
} }
skipping to change at line 329 skipping to change at line 330
arma_debug_assert_same_size(out, x.P1, "element-wise division"); arma_debug_assert_same_size(out, x.P1, "element-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)
{ {
const u32 n_elem = out.n_elem; const uword 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
{ {
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); }
} }
} }
skipping to change at line 370 skipping to change at line 371
inline inline
void void
eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlu eCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlu eCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
const u32 n_rows = x.get_n_rows(); // NOTE: we're assuming that the cube has already been set to the correct
const u32 n_cols = x.get_n_cols(); size and there is no aliasing;
const u32 n_slices = x.get_n_slices(); // size setting and alias checking is done by either the Cube contructor
or operator=()
out.set_size(n_rows, n_cols, n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<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
{ {
const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
const uword n_slices = x.get_n_slices();
const ProxyCube<T1>& P1 = x.P1; const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2; const ProxyCube<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_3(=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_3(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_3(=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_3(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_3(=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_3(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_3(=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_3(=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& ou t, const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& ou t, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
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 = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<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 456 skipping to change at line 458
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
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 = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<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 501 skipping to change at line 503
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-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 = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<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 546 skipping to change at line 548
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out , const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out , const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-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 = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<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. 30 change blocks. 
47 lines changed or deleted 53 lines changed or added


 eop_aux.hpp   eop_aux.hpp 
skipping to change at line 44 skipping to change at line 44
}; };
template<typename eT> template<typename eT>
struct eop_aux_randn struct eop_aux_randn
{ {
// // rudimentary method, based on the central limit theorem // // rudimentary method, based on the central limit theorem
// // http://en.wikipedia.org/wiki/Central_limit_theorem // // http://en.wikipedia.org/wiki/Central_limit_theorem
// inline // inline
// operator eT () const // operator eT () const
// { // {
// const u32 N = 12; // N must be >= 12 and an even number // const uword N = 12; // N must be >= 12 and an even number
// const u32 N2 = N/2; // const uword N2 = N/2;
// //
// eT acc = eT(0); // eT acc = eT(0);
// //
// for(u32 i=0; i<N2; ++i) // for(uword i=0; i<N2; ++i)
// { // {
// const eT tmp1 = eT(std::rand()) / eT(RAND_MAX); // const eT tmp1 = eT(std::rand()) / eT(RAND_MAX);
// const eT tmp2 = eT(std::rand()) / eT(RAND_MAX); // const eT tmp2 = eT(std::rand()) / eT(RAND_MAX);
// acc += tmp1+tmp2; // acc += tmp1+tmp2;
// } // }
// //
// return acc - eT(N2); // return acc - eT(N2);
// } // }
// polar form of the Box-Muller transformation // polar form of the Box-Muller transformation
skipping to change at line 302 skipping to change at line 302
template<typename eT> arma_inline static template<typename eT> arma_inline static
typename arma_signed_integral_only<eT>::result arma_abs(const eT x) { return std::abs(x); } typename arma_signed_integral_only<eT>::result arma_abs(const eT x) { return std::abs(x); }
template<typename eT> arma_inline static template<typename eT> arma_inline static
typename arma_float_only<eT>::result arma_abs(const eT x) { return std::abs(x); } typename arma_float_only<eT>::result arma_abs(const eT x) { return std::abs(x); }
template<typename T> arma_inline static template<typename T> arma_inline static
typename arma_float_only<T>::result arma_abs(const std::comp lex<T> x) { return std::abs(x); } typename arma_float_only<T>::result arma_abs(const std::comp lex<T> x) { return std::abs(x); }
template<typename eT, typename eop_type>
arma_inline
static
eT
generate()
{
if(is_same_type<eop_type, eop_ones_full>::value == true) { return
eT(1); }
else if(is_same_type<eop_type, eop_zeros >::value == true) { return
eT(0); }
else if(is_same_type<eop_type, eop_randu >::value == true) { return
eT(eop_aux_randu<eT>()); }
else if(is_same_type<eop_type, eop_randn >::value == true) { return
eT(eop_aux_randn<eT>()); }
else { return
eT(); }
}
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
21 lines changed or deleted 3 lines changed or added


 eop_core_bones.hpp   eop_core_bones.hpp 
skipping to change at line 79 skipping to change at line 79
class eop_tanh : public eop_core<eop_tanh> {}; class eop_tanh : public eop_core<eop_tanh> {};
class eop_acosh : public eop_core<eop_acosh> {}; class eop_acosh : public eop_core<eop_acosh> {};
class eop_asinh : public eop_core<eop_asinh> {}; class eop_asinh : public eop_core<eop_asinh> {};
class eop_atanh : public eop_core<eop_atanh> {}; class eop_atanh : public eop_core<eop_atanh> {};
class eop_eps : public eop_core<eop_eps> {}; class eop_eps : public eop_core<eop_eps> {};
class eop_abs : public eop_core<eop_abs> {}; class eop_abs : public eop_core<eop_abs> {};
class eop_conj : public eop_core<eop_conj> {}; class eop_conj : public eop_core<eop_conj> {};
class eop_pow : public eop_core<eop_pow> {}; class eop_pow : public eop_core<eop_pow> {};
class eop_floor : public eop_core<eop_floor> {}; class eop_floor : public eop_core<eop_floor> {};
class eop_ceil : public eop_core<eop_ceil> {}; class eop_ceil : public eop_core<eop_ceil> {};
class eop_randu : public eop_core<eop_randu> {};
class eop_randn : public eop_core<eop_randn> {};
class eop_zeros : public eop_core<eop_zeros> {};
class eop_ones_full : public eop_core<eop_ones_full> {};
class eop_ones_diag : public eop_core<eop_ones_diag> {};
template<typename T1> struct is_generator { static const boo
l value = false; };
template<> struct is_generator<eop_randu> { static const boo
l value = true; };
template<> struct is_generator<eop_randn> { static const boo
l value = true; };
template<> struct is_generator<eop_zeros> { static const boo
l value = true; };
template<> struct is_generator<eop_ones_full> { static const boo
l value = true; };
template<> struct is_generator<eop_ones_diag> { static const boo
l value = true; };
//! @} //! @}
 End of changes. 1 change blocks. 
18 lines changed or deleted 0 lines changed or added


 eop_core_meat.hpp   eop_core_meat.hpp 
skipping to change at line 23 skipping to change at line 23
//! \addtogroup eop_core //! \addtogroup eop_core
//! @{ //! @{
#undef arma_applier_1 #undef arma_applier_1
#undef arma_applier_2 #undef arma_applier_2
#undef arma_applier_3 #undef arma_applier_3
#undef operatorA #undef operatorA
#define arma_applier_1(operatorA) \ #define arma_applier_1(operatorA) \
{\ {\
u32 i,j;\ uword i,j;\
\ \
for(i=0, j=1; j<n_elem; i+=2, j+=2)\ for(i=0, j=1; j<n_elem; i+=2, j+=2)\
{\ {\
eT tmp_i = P[i];\ eT tmp_i = P[i];\
eT tmp_j = P[j];\ eT tmp_j = P[j];\
\ \
tmp_i = eop_core<eop_type>::process(tmp_i, k);\ tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\ tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\ \
out_mem[i] operatorA tmp_i;\ out_mem[i] operatorA tmp_i;\
skipping to change at line 45 skipping to change at line 45
}\ }\
\ \
if(i < n_elem)\ if(i < n_elem)\
{\ {\
out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\ out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\
}\ }\
} }
#define arma_applier_2(operatorA) \ #define arma_applier_2(operatorA) \
{\ {\
u32 count = 0;\ uword count = 0;\
\ \
for(u32 col=0; col<n_cols; ++col)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
u32 i,j;\ uword i,j;\
\ \
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\ for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\ {\
eT tmp_i = P.at(i,col);\ eT tmp_i = P.at(i,col);\
eT tmp_j = P.at(j,col);\ eT tmp_j = P.at(j,col);\
\ \
tmp_i = eop_core<eop_type>::process(tmp_i, k);\ tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\ tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\ \
out_mem[count ] operatorA tmp_i;\ out_mem[count ] operatorA tmp_i;\
skipping to change at line 73 skipping to change at line 73
if(i < n_rows)\ if(i < n_rows)\
{\ {\
out_mem[count] operatorA eop_core<eop_type>::process(P.at(i,col), k); \ out_mem[count] operatorA eop_core<eop_type>::process(P.at(i,col), k); \
++count;\ ++count;\
}\ }\
}\ }\
} }
#define arma_applier_3(operatorA) \ #define arma_applier_3(operatorA) \
{\ {\
u32 count = 0;\ uword count = 0;\
\ \
for(u32 slice=0; slice<n_slices; ++slice)\ for(uword slice=0; slice<n_slices; ++slice)\
{\ {\
for(u32 col=0; col<n_cols; ++col)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
u32 i,j;\ uword i,j;\
\ \
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\ for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\ {\
eT tmp_i = P.at(i,col,slice);\ eT tmp_i = P.at(i,col,slice);\
eT tmp_j = P.at(j,col,slice);\ eT tmp_j = P.at(j,col,slice);\
\ \
tmp_i = eop_core<eop_type>::process(tmp_i, k);\ tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\ tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\ \
out_mem[count ] operatorA tmp_i;\ out_mem[count ] operatorA tmp_i;\
skipping to change at line 116 skipping to change at line 116
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, e op_type>& x) eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, e op_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = out.n_rows;
const u32 n_cols = x.get_n_cols(); const uword n_cols = out.n_cols;
const u32 n_elem = x.get_n_elem(); const uword n_elem = out.n_elem;
out.set_size(n_rows, n_cols); // NOTE: we're assuming that the matrix has already been set to the corre
ct size and there is no aliasing;
if(is_generator<eop_type>::value == true) // size setting and alias checking is done by either the Mat contructor o
{ r operator=()
if(is_same_type<eop_type, eop_ones_diag>::value == true) { out.eye
(); } const eT k = x.aux;
else if(is_same_type<eop_type, eop_ones_full>::value == true) { out.one eT* out_mem = out.memptr();
s(); }
else if(is_same_type<eop_type, eop_zeros >::value == true) { out.zer if(Proxy<T1>::prefer_at_accessor == false)
os(); } {
else if(is_same_type<eop_type, eop_randu >::value == true) { out.ran typename Proxy<T1>::ea_type P = x.P.get_ea();
du(); }
else if(is_same_type<eop_type, eop_randn >::value == true) { out.ran arma_applier_1(=);
dn(); }
} }
else else
{ {
const eT k = x.aux; const Proxy<T1>& P = x.P;
eT* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false) arma_applier_2(=);
{
typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(=);
}
else
{
const Proxy<T1>& P = x.P;
arma_applier_2(=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, co nst eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, co nst eOp<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 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");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(Proxy<T1>::prefer_at_accessor == false)
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) typename Proxy<T1>::ea_type P = x.P.get_ea();
{
const u32 N = (std::min)(n_rows, n_cols); arma_applier_1(+=);
for(u32 i=0; i<N; ++i)
{
out.at(i,i) += eT(1);
}
}
else
{
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += eop_aux::generate<eT,eop_type>();
}
}
} }
else else
{ {
const eT k = x.aux; const Proxy<T1>& P = x.P;
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(+=);
}
else
{
const Proxy<T1>& P = x.P;
arma_applier_2(+=); arma_applier_2(+=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 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");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(Proxy<T1>::prefer_at_accessor == false)
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) typename Proxy<T1>::ea_type P = x.P.get_ea();
{
const u32 N = (std::min)(n_rows, n_cols); arma_applier_1(-=);
for(u32 i=0; i<N; ++i)
{
out.at(i,i) -= eT(1);
}
}
else
{
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] -= eop_aux::generate<eT,eop_type>();
}
}
} }
else else
{ {
const eT k = x.aux; const Proxy<T1>& P = x.P;
if(Proxy<T1>::prefer_at_accessor == false) arma_applier_2(-=);
{
typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(-=);
}
else
{
const Proxy<T1>& P = x.P;
arma_applier_2(-=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 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");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(Proxy<T1>::prefer_at_accessor == false)
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) typename Proxy<T1>::ea_type P = x.P.get_ea();
{
const u32 N = (std::min)(n_rows, n_cols); arma_applier_1(*=);
for(u32 i=0; i<N; ++i)
{
for(u32 row=0; row<i; ++row) { out.at(row,i) = eT(0); }
for(u32 row=i+1; row<n_rows; ++row) { out.at(row,i) = eT(0); }
}
}
else
{
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] *= eop_aux::generate<eT,eop_type>();
}
}
} }
else else
{ {
const eT k = x.aux; const Proxy<T1>& P = x.P;
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(*=);
}
else
{
const Proxy<T1>& P = x.P;
arma_applier_2(*=); arma_applier_2(*=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, con st eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, con st eOp<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 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");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(Proxy<T1>::prefer_at_accessor == false)
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) typename Proxy<T1>::ea_type P = x.P.get_ea();
{
const u32 N = (std::min)(n_rows, n_cols); arma_applier_1(/=);
for(u32 i=0; i<N; ++i)
{
const eT zero = eT(0);
for(u32 row=0; row<i; ++row) { out.at(row,i) /= zero; }
for(u32 row=i+1; row<n_rows; ++row) { out.at(row,i) /= zero; }
}
}
else
{
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] /= eop_aux::generate<eT,eop_type>();
}
}
} }
else else
{ {
const eT k = x.aux; const Proxy<T1>& P = x.P;
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(/=);
}
else
{
const Proxy<T1>& P = x.P;
arma_applier_2(/=); arma_applier_2(/=);
}
} }
} }
// //
// cubes // cubes
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply(Cube<typename T1::elem_type>& out, const eOpCube< T1, eop_type>& x) eop_core<eop_type>::apply(Cube<typename T1::elem_type>& out, const eOpCube< T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = out.n_rows;
const u32 n_cols = x.get_n_cols(); const uword n_cols = out.n_cols;
const u32 n_slices = x.get_n_slices(); const uword n_slices = out.n_slices;
const u32 n_elem = x.get_n_elem(); const uword n_elem = out.n_elem;
out.set_size(n_rows, n_cols, n_slices); // NOTE: we're assuming that the matrix has already been set to the corre
ct size and there is no aliasing;
if(is_generator<eop_type>::value == true) // size setting and alias checking is done by either the Mat contructor o
{ r operator=()
if(is_same_type<eop_type, eop_ones_full>::value == true) { out.one
s(); } const eT k = x.aux;
else if(is_same_type<eop_type, eop_zeros >::value == true) { out.zer eT* out_mem = out.memptr();
os(); }
else if(is_same_type<eop_type, eop_randu >::value == true) { out.ran if(ProxyCube<T1>::prefer_at_accessor == false)
du(); } {
else if(is_same_type<eop_type, eop_randn >::value == true) { out.ran typename ProxyCube<T1>::ea_type P = x.P.get_ea();
dn(); }
arma_applier_1(=);
} }
else else
{ {
const eT k = x.aux; const ProxyCube<T1>& P = x.P;
eT* out_mem = out.memptr();
if(ProxyCube<T1>::prefer_at_accessor == false) arma_applier_3(=);
{
typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(=);
}
else
{
const ProxyCube<T1>& P = x.P;
arma_applier_3(=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, c onst eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, c onst eOpCube<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
for(u32 i=0; i<n_elem; ++i) typename ProxyCube<T1>::ea_type P = x.P.get_ea();
{
out_mem[i] += eop_aux::generate<eT,eop_type>(); arma_applier_1(+=);
}
} }
else else
{ {
const eT k = x.aux; const ProxyCube<T1>& P = x.P;
if(ProxyCube<T1>::prefer_at_accessor == false)
{
typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(+=);
}
else
{
const ProxyCube<T1>& P = x.P;
arma_applier_3(+=); arma_applier_3(+=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
for(u32 i=0; i<n_elem; ++i) typename ProxyCube<T1>::ea_type P = x.P.get_ea();
{
out_mem[i] -= eop_aux::generate<eT,eop_type>(); arma_applier_1(-=);
}
} }
else else
{ {
const eT k = x.aux; const ProxyCube<T1>& P = x.P;
if(ProxyCube<T1>::prefer_at_accessor == false) arma_applier_3(-=);
{
typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(-=);
}
else
{
const ProxyCube<T1>& P = x.P;
arma_applier_3(-=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
for(u32 i=0; i<n_elem; ++i) typename ProxyCube<T1>::ea_type P = x.P.get_ea();
{
out_mem[i] *= eop_aux::generate<eT,eop_type>(); arma_applier_1(*=);
}
} }
else else
{ {
const eT k = x.aux; const ProxyCube<T1>& P = x.P;
if(ProxyCube<T1>::prefer_at_accessor == false)
{
typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(*=);
}
else
{
const ProxyCube<T1>& P = x.P;
arma_applier_3(*=); arma_applier_3(*=);
}
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, co nst eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, co nst eOpCube<T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
const eT k = x.aux;
if(is_generator<eop_type>::value == true) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
for(u32 i=0; i<n_elem; ++i) typename ProxyCube<T1>::ea_type P = x.P.get_ea();
{
out_mem[i] /= eop_aux::generate<eT,eop_type>(); arma_applier_1(/=);
}
} }
else else
{ {
const eT k = x.aux; const ProxyCube<T1>& P = x.P;
if(ProxyCube<T1>::prefer_at_accessor == false)
{
typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(/=);
}
else
{
const ProxyCube<T1>& P = x.P;
arma_applier_3(/=); arma_applier_3(/=);
}
} }
} }
// //
// common // common
template<typename eop_type> template<typename eop_type>
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
 End of changes. 62 change blocks. 
301 lines changed or deleted 145 lines changed or added


 field_bones.hpp   field_bones.hpp 
skipping to change at line 19 skipping to change at line 19
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup field //! \addtogroup field
//! @{ //! @{
struct field_prealloc_n_elem struct field_prealloc_n_elem
{ {
static const u32 val = 16; static const uword val = 16;
}; };
//! A lightweight 2D container for abitrary objects //! A lightweight 2D container for abitrary objects
//! (the objects must have a copy constructor) //! (the objects must have a copy constructor)
template<typename oT> template<typename oT>
class field class field
{ {
public: public:
typedef oT object_type; typedef oT object_type;
const u32 n_rows; //!< number of rows in the field (read-only) const uword n_rows; //!< number of rows in the field (read-only)
const u32 n_cols; //!< number of columns in the field (read-only) const uword n_cols; //!< number of columns in the field (read-only)
const u32 n_elem; //!< number of elements in the field (read-only) const uword n_elem; //!< number of elements in the field (read-only)
private: private:
arma_aligned oT** mem; //!< pointer to memory used by the obj ect arma_aligned oT** mem; //!< pointer to memory used by the obj ect
arma_aligned oT* mem_local[ field_prealloc_n_elem::val ]; arma_aligned oT* mem_local[ field_prealloc_n_elem::val ];
//!< Internal memory, to avoid calling the 'new' operator for small amoun ts of memory //!< Internal memory, to avoid calling the 'new' operator for small amoun ts of memory
public: public:
inline ~field(); inline ~field();
inline field(); inline field();
inline field(const field& x); inline field(const field& x);
inline const field& operator=(const field& x); inline const field& operator=(const field& x);
inline field(const subview_field<oT>& x); inline field(const subview_field<oT>& x);
inline const field& operator=(const subview_field<oT>& x); inline const field& operator=(const subview_field<oT>& x);
inline explicit field(const u32 n_elem_in); inline explicit field(const uword n_elem_in);
inline field(const u32 n_rows_in, const u32 n_cols_in); inline field(const uword n_rows_in, const uword n_cols_in);
inline void set_size(const u32 n_obj_in); inline void set_size(const uword n_obj_in);
inline void set_size(const u32 n_rows_in, const u32 n_cols_in); inline void set_size(const uword n_rows_in, const uword n_cols_in);
template<typename oT2> template<typename oT2>
inline void copy_size(const field<oT2>& x); inline void copy_size(const field<oT2>& x);
arma_inline oT& operator[](const u32 i); arma_inline oT& operator[](const uword i);
arma_inline const oT& operator[](const u32 i) const; arma_inline const oT& operator[](const uword i) const;
arma_inline oT& at(const u32 i); arma_inline oT& at(const uword i);
arma_inline const oT& at(const u32 i) const; arma_inline const oT& at(const uword i) const;
arma_inline oT& operator()(const u32 i); arma_inline oT& operator()(const uword i);
arma_inline const oT& operator()(const u32 i) const; arma_inline const oT& operator()(const uword i) const;
arma_inline oT& at(const u32 row, const u32 col); arma_inline oT& at(const uword row, const uword col);
arma_inline const oT& at(const u32 row, const u32 col) const; arma_inline const oT& at(const uword row, const uword col) const;
arma_inline oT& operator()(const u32 row, const u32 col); arma_inline oT& operator()(const uword row, const uword col);
arma_inline const oT& operator()(const u32 row, const u32 col) const; arma_inline const oT& operator()(const uword row, const uword col) const;
inline field_injector<field> operator<<(const oT& val); inline field_injector<field> operator<<(const oT& val);
inline field_injector<field> operator<<(const injector_end_of_row& x); inline field_injector<field> operator<<(const injector_end_of_row& x);
inline subview_field<oT> row(const u32 row_num); inline subview_field<oT> row(const uword row_num);
inline const subview_field<oT> row(const u32 row_num) const; inline const subview_field<oT> row(const uword row_num) const;
inline subview_field<oT> col(const u32 col_num); inline subview_field<oT> col(const uword col_num);
inline const subview_field<oT> col(const u32 col_num) const; inline const subview_field<oT> col(const uword col_num) const;
inline subview_field<oT> rows(const u32 in_row1, const u32 in_row2) inline subview_field<oT> rows(const uword in_row1, const uword in_r
; ow2);
inline const subview_field<oT> rows(const u32 in_row1, const u32 in_row2) inline const subview_field<oT> rows(const uword in_row1, const uword in_r
const; ow2) const;
inline subview_field<oT> cols(const u32 in_col1, const u32 in_col2) inline subview_field<oT> cols(const uword in_col1, const uword in_c
; ol2);
inline const subview_field<oT> cols(const u32 in_col1, const u32 in_col2) inline const subview_field<oT> cols(const uword in_col1, const uword in_c
const; ol2) const;
inline subview_field<oT> subfield(const u32 in_row1, const u32 in_c inline subview_field<oT> subfield(const uword in_row1, const uword
ol1, const u32 in_row2, const u32 in_col2); in_col1, const uword in_row2, const uword in_col2);
inline const subview_field<oT> subfield(const u32 in_row1, const u32 in_c inline const subview_field<oT> subfield(const uword in_row1, const uword
ol1, const u32 in_row2, const u32 in_col2) const; in_col1, const uword in_row2, const uword in_col2) const;
inline subview_field<oT> subfield (const span& row_span, const spa n& col_span); inline subview_field<oT> subfield (const span& row_span, const spa n& col_span);
inline const subview_field<oT> subfield (const span& row_span, const spa n& col_span) const; inline const subview_field<oT> subfield (const span& row_span, const spa n& col_span) const;
inline subview_field<oT> operator()(const span& row_span, const spa n& col_span); inline subview_field<oT> operator()(const span& row_span, const spa n& col_span);
inline const subview_field<oT> operator()(const span& row_span, const spa n& col_span) const; inline const subview_field<oT> operator()(const span& row_span, const spa n& col_span) const;
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 u32 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 u32 in_row, const u3 arma_inline arma_warn_unused bool in_range(const uword in_row, const
2 in_col ) const; uword in_col ) const;
arma_inline arma_warn_unused bool in_range(const span& row_span, const u3 arma_inline arma_warn_unused bool in_range(const span& row_span, const uw
2 in_col ) const; ord in_col ) const;
arma_inline arma_warn_unused bool in_range(const u32 in_row, const sp arma_inline arma_warn_unused bool in_range(const uword in_row, const
an& col_span) const; span& 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;
skipping to change at line 151 skipping to change at line 151
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 u32 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 173 skipping to change at line 173
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 u32 i; arma_aligned uword i;
}; };
inline iterator begin(); inline iterator begin();
inline const_iterator begin() const; inline const_iterator begin() const;
inline iterator end(); inline iterator end();
inline const_iterator end() const; inline const_iterator end() const;
private: private:
inline void init(const field<oT>& x); inline void init(const field<oT>& x);
inline void init(const u32 n_rows_in, const u32 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;
friend class subview_field<oT>; friend class subview_field<oT>;
public: public:
#ifdef ARMA_EXTRA_FIELD_PROTO #ifdef ARMA_EXTRA_FIELD_PROTO
 End of changes. 19 change blocks. 
44 lines changed or deleted 44 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 107 skipping to change at line 107
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_field<oT>::extract(*this, X); subview_field<oT>::extract(*this, X);
return *this; return *this;
} }
//! construct the field with the specified number of elements, //! construct the field with the specified number of elements,
//! assuming a column-major layout //! assuming a column-major layout
template<typename oT> template<typename oT>
inline inline
field<oT>::field(const u32 n_elem_in) field<oT>::field(const uword n_elem_in)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, mem(0) , mem(0)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(n_elem_in, 1); init(n_elem_in, 1);
} }
//! construct the field with the specified dimensions //! construct the field with the specified dimensions
template<typename oT> template<typename oT>
inline inline
field<oT>::field(const u32 n_rows_in, const u32 n_cols_in) field<oT>::field(const uword n_rows_in, const uword n_cols_in)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, mem(0) , mem(0)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(n_rows_in, n_cols_in); init(n_rows_in, n_cols_in);
} }
//! change the field to have the specified number of elements, //! change the field to have the specified number of elements,
//! assuming a column-major layout (data is not preserved) //! assuming a column-major layout (data is not preserved)
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::set_size(const u32 n_elem_in) field<oT>::set_size(const uword n_elem_in)
{ {
arma_extra_debug_sigprint(arma_boost::format("n_elem_in = %d") % n_elem_i n); arma_extra_debug_sigprint(arma_boost::format("n_elem_in = %d") % n_elem_i n);
init(n_elem_in, 1); init(n_elem_in, 1);
} }
//! change the field to have the specified dimensions (data is not preserve d) //! change the field to have the specified dimensions (data is not preserve d)
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::set_size(const u32 n_rows_in, const u32 n_cols_in) field<oT>::set_size(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);
init(n_rows_in, n_cols_in); init(n_rows_in, n_cols_in);
} }
//! change the field to have the specified dimensions (data is not preserve d) //! change the field to have the specified dimensions (data is not preserve d)
template<typename oT> template<typename oT>
template<typename oT2> template<typename oT2>
inline inline
skipping to change at line 171 skipping to change at line 171
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(x.n_rows, x.n_cols); init(x.n_rows, x.n_cols);
} }
//! linear element accessor (treats the field as a vector); no bounds check //! linear element accessor (treats the field as a vector); no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
field<oT>::operator[] (const u32 i) field<oT>::operator[] (const uword i)
{ {
return (*mem[i]); return (*mem[i]);
} }
//! linear element accessor (treats the field as a vector); no bounds check //! linear element accessor (treats the field as a vector); no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
field<oT>::operator[] (const u32 i) const field<oT>::operator[] (const uword i) const
{ {
return (*mem[i]); return (*mem[i]);
} }
//! linear element accessor (treats the field as a vector); no bounds check //! linear element accessor (treats the field as a vector); no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
field<oT>::at(const u32 i) field<oT>::at(const uword i)
{ {
return (*mem[i]); return (*mem[i]);
} }
//! linear element accessor (treats the field as a vector); no bounds check //! linear element accessor (treats the field as a vector); no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
field<oT>::at(const u32 i) const field<oT>::at(const uword i) const
{ {
return (*mem[i]); return (*mem[i]);
} }
//! linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
field<oT>::operator() (const u32 i) field<oT>::operator() (const uword i)
{ {
arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds" ); arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds" );
return (*mem[i]); return (*mem[i]);
} }
//! linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
field<oT>::operator() (const u32 i) const field<oT>::operator() (const uword i) const
{ {
arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds" ); arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds" );
return (*mem[i]); return (*mem[i]);
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
field<oT>::operator() (const u32 in_row, const u32 in_col) field<oT>::operator() (const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::ope rator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::ope rator(): index out of bounds");
return (*mem[in_row + in_col*n_rows]); return (*mem[in_row + in_col*n_rows]);
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
field<oT>::operator() (const u32 in_row, const u32 in_col) const field<oT>::operator() (const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::ope rator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::ope rator(): index out of bounds");
return (*mem[in_row + in_col*n_rows]); return (*mem[in_row + in_col*n_rows]);
} }
//! element accessor; no bounds check //! element accessor; no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
field<oT>::at(const u32 in_row, const u32 in_col) field<oT>::at(const uword in_row, const uword in_col)
{ {
return (*mem[in_row + in_col*n_rows]); return (*mem[in_row + in_col*n_rows]);
} }
//! element accessor; no bounds check //! element accessor; no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
field<oT>::at(const u32 in_row, const u32 in_col) const field<oT>::at(const uword in_row, const uword in_col) const
{ {
return (*mem[in_row + in_col*n_rows]); return (*mem[in_row + in_col*n_rows]);
} }
template<typename oT> template<typename oT>
inline inline
field_injector< field<oT> > field_injector< field<oT> >
field<oT>::operator<<(const oT& val) field<oT>::operator<<(const oT& val)
{ {
return field_injector< field<oT> >(*this, val); return field_injector< field<oT> >(*this, val);
skipping to change at line 281 skipping to change at line 281
field_injector< field<oT> > field_injector< field<oT> >
field<oT>::operator<<(const injector_end_of_row& x) field<oT>::operator<<(const injector_end_of_row& x)
{ {
return field_injector< field<oT> >(*this, x); return field_injector< field<oT> >(*this, x);
} }
//! creation of subview_field (row of a field) //! creation of subview_field (row of a field)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::row(const u32 row_num) field<oT>::row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" ); arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" );
return subview_field<oT>(*this, row_num, 0, 1, n_cols); return subview_field<oT>(*this, row_num, 0, 1, n_cols);
} }
//! creation of subview_field (row of a field) //! creation of subview_field (row of a field)
template<typename oT> template<typename oT>
inline inline
const subview_field<oT> const subview_field<oT>
field<oT>::row(const u32 row_num) const field<oT>::row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" ); arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" );
return subview_field<oT>(*this, row_num, 0, 1, n_cols); return subview_field<oT>(*this, row_num, 0, 1, n_cols);
} }
//! creation of subview_field (column of a field) //! creation of subview_field (column of a field)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::col(const u32 col_num) field<oT>::col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds"); arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds");
return subview_field<oT>(*this, 0, col_num, n_rows, 1); return subview_field<oT>(*this, 0, col_num, n_rows, 1);
} }
//! creation of subview_field (column of a field) //! creation of subview_field (column of a field)
template<typename oT> template<typename oT>
inline inline
const subview_field<oT> const subview_field<oT>
field<oT>::col(const u32 col_num) const field<oT>::col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds"); arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds");
return subview_field<oT>(*this, 0, col_num, n_rows, 1); return subview_field<oT>(*this, 0, col_num, n_rows, 1);
} }
//! creation of subview_field (subfield comprised of specified rows) //! creation of subview_field (subfield comprised of specified rows)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::rows(const u32 in_row1, const u32 in_row2) field<oT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
( (in_row1 > in_row2) || (in_row2 >= n_rows) ), ( (in_row1 > in_row2) || (in_row2 >= n_rows) ),
"field::rows(): indicies out of bounds or incorrectly used" "field::rows(): indicies out of bounds or incorrectly used"
); );
const u32 sub_n_rows = in_row2 - in_row1 + 1; const uword sub_n_rows = in_row2 - in_row1 + 1;
return subview_field<oT>(*this, in_row1, 0, sub_n_rows, n_cols); return subview_field<oT>(*this, in_row1, 0, sub_n_rows, n_cols);
} }
//! creation of subview_field (subfield comprised of specified rows) //! creation of subview_field (subfield comprised of specified rows)
template<typename oT> template<typename oT>
inline inline
const subview_field<oT> const subview_field<oT>
field<oT>::rows(const u32 in_row1, const u32 in_row2) const field<oT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
( (in_row1 > in_row2) || (in_row2 >= n_rows) ), ( (in_row1 > in_row2) || (in_row2 >= n_rows) ),
"field::rows(): indicies out of bounds or incorrectly used" "field::rows(): indicies out of bounds or incorrectly used"
); );
const u32 sub_n_rows = in_row2 - in_row1 + 1; const uword sub_n_rows = in_row2 - in_row1 + 1;
return subview_field<oT>(*this, in_row1, 0, sub_n_rows, n_cols); return subview_field<oT>(*this, in_row1, 0, sub_n_rows, n_cols);
} }
//! creation of subview_field (subfield comprised of specified columns) //! creation of subview_field (subfield comprised of specified columns)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::cols(const u32 in_col1, const u32 in_col2) field<oT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
( (in_col1 > in_col2) || (in_col2 >= n_cols) ), ( (in_col1 > in_col2) || (in_col2 >= n_cols) ),
"field::cols(): indicies out of bounds or incorrectly used" "field::cols(): indicies out of bounds or incorrectly used"
); );
const u32 sub_n_cols = in_col2 - in_col1 + 1; const uword sub_n_cols = in_col2 - in_col1 + 1;
return subview_field<oT>(*this, 0, in_col1, n_rows, sub_n_cols); return subview_field<oT>(*this, 0, in_col1, n_rows, sub_n_cols);
} }
//! creation of subview_field (subfield comprised of specified columns) //! creation of subview_field (subfield comprised of specified columns)
template<typename oT> template<typename oT>
inline inline
const subview_field<oT> const subview_field<oT>
field<oT>::cols(const u32 in_col1, const u32 in_col2) const field<oT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
( (in_col1 > in_col2) || (in_col2 >= n_cols) ), ( (in_col1 > in_col2) || (in_col2 >= n_cols) ),
"field::cols(): indicies out of bounds or incorrectly used" "field::cols(): indicies out of bounds or incorrectly used"
); );
const u32 sub_n_cols = in_col2 - in_col1 + 1; const uword sub_n_cols = in_col2 - in_col1 + 1;
return subview_field<oT>(*this, 0, in_col1, n_rows, sub_n_cols); return subview_field<oT>(*this, 0, in_col1, n_rows, sub_n_cols);
} }
//! creation of subview_field (subfield with arbitrary dimensions) //! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::subfield(const u32 in_row1, const u32 in_col1, const u32 in_row2 , const u32 in_col2) field<oT>::subfield(const uword in_row1, const uword in_col1, const uword i n_row2, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (i n_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (i n_col2 >= n_cols),
"field::subfield(): indices out of bounds or incorrectly used" "field::subfield(): indices out of bounds or incorrectly used"
); );
const u32 sub_n_rows = in_row2 - in_row1 + 1; const uword sub_n_rows = in_row2 - in_row1 + 1;
const u32 sub_n_cols = in_col2 - in_col1 + 1; const uword sub_n_cols = in_col2 - in_col1 + 1;
return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols) ; return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols) ;
} }
//! creation of subview_field (subfield with arbitrary dimensions) //! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT> template<typename oT>
inline inline
const subview_field<oT> const subview_field<oT>
field<oT>::subfield(const u32 in_row1, const u32 in_col1, const u32 in_row2 , const u32 in_col2) const field<oT>::subfield(const uword in_row1, const uword in_col1, const uword i n_row2, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (i n_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (i n_col2 >= n_cols),
"field::subfield(): indices out of bounds or incorrectly used" "field::subfield(): indices out of bounds or incorrectly used"
); );
const u32 sub_n_rows = in_row2 - in_row1 + 1; const uword sub_n_rows = in_row2 - in_row1 + 1;
const u32 sub_n_cols = in_col2 - in_col1 + 1; const uword sub_n_cols = in_col2 - in_col1 + 1;
return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols) ; return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols) ;
} }
//! creation of subview_field (subfield with arbitrary dimensions) //! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::subfield(const span& row_span, const span& col_span) field<oT>::subfield(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"field::subfield(): indices out of bounds or incorrectly used" "field::subfield(): indices out of bounds or incorrectly used"
); );
skipping to change at line 490 skipping to change at line 490
template<typename oT> template<typename oT>
inline inline
const subview_field<oT> const subview_field<oT>
field<oT>::subfield(const span& row_span, const span& col_span) const field<oT>::subfield(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"field::subfield(): indices out of bounds or incorrectly used" "field::subfield(): indices out of bounds or incorrectly used"
); );
skipping to change at line 599 skipping to change at line 599
//! fill the field with an object //! fill the field with an object
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::fill(const oT& x) field<oT>::fill(const oT& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field<oT>& t = *this; field<oT>& t = *this;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
t[i] = x; t[i] = x;
} }
} }
//! reset the field to an empty state (i.e. the field will have no objects) //! reset the field to an empty state (i.e. the field will have no objects)
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::reset() field<oT>::reset()
skipping to change at line 641 skipping to change at line 641
field<oT>::is_empty() const field<oT>::is_empty() const
{ {
return (n_elem == 0); return (n_elem == 0);
} }
//! returns true if the given index is currently in range //! returns true if the given index is currently in range
template<typename oT> template<typename oT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
field<oT>::in_range(const u32 i) const field<oT>::in_range(const uword i) const
{ {
return (i < n_elem); return (i < n_elem);
} }
//! returns true if the given start and end indices are currently in range //! returns true if the given start and end indices are currently in range
template<typename oT> template<typename oT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
field<oT>::in_range(const span& x) const field<oT>::in_range(const span& x) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(x.whole == true) if(x.whole == true)
{ {
return true; return true;
} }
else else
{ {
const u32 a = x.a; const uword a = x.a;
const u32 b = x.b; const uword b = x.b;
return ( (a <= b) && (b < n_elem) ); return ( (a <= b) && (b < n_elem) );
} }
} }
//! returns true if the given location is currently in range //! returns true if the given location is currently in range
template<typename oT> template<typename oT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
field<oT>::in_range(const u32 in_row, const u32 in_col) const field<oT>::in_range(const uword in_row, const uword in_col) const
{ {
return ( (in_row < n_rows) && (in_col < n_cols) ); return ( (in_row < n_rows) && (in_col < n_cols) );
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
field<oT>::in_range(const span& row_span, const u32 in_col) const field<oT>::in_range(const span& row_span, const uword in_col) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(row_span.whole == true) if(row_span.whole == true)
{ {
return (in_col < n_cols); return (in_col < n_cols);
} }
else else
{ {
const u32 in_row1 = row_span.a; const uword in_row1 = row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
return ( (in_row1 <= in_row2) && (in_row2 < n_rows) && (in_col < n_cols ) ); return ( (in_row1 <= in_row2) && (in_row2 < n_rows) && (in_col < n_cols ) );
} }
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
field<oT>::in_range(const u32 in_row, const span& col_span) const field<oT>::in_range(const uword in_row, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(col_span.whole == true) if(col_span.whole == true)
{ {
return (in_row < n_rows); return (in_row < n_rows);
} }
else else
{ {
const u32 in_col1 = col_span.a; const uword in_col1 = col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
return ( (in_row < n_rows) && (in_col1 <= in_col2) && (in_col2 < n_cols ) ); return ( (in_row < n_rows) && (in_col1 <= in_col2) && (in_col2 < n_cols ) );
} }
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
field<oT>::in_range(const span& row_span, const span& col_span) const field<oT>::in_range(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a; const uword in_row1 = row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 in_col1 = col_span.a; const uword in_col1 = col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) );
return ( (rows_ok == true) && (cols_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) );
} }
template<typename oT> template<typename oT>
inline inline
bool bool
skipping to change at line 904 skipping to change at line 904
field<oT>::init(const field<oT>& x) field<oT>::init(const field<oT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
init(x.n_rows, x.n_cols); init(x.n_rows, x.n_cols);
field& t = *this; field& t = *this;
for(u32 col=0; col<x.n_cols; ++col) for(uword col=0; col<x.n_cols; ++col)
for(u32 row=0; row<x.n_rows; ++row) for(uword row=0; row<x.n_rows; ++row)
{ {
t.at(row,col) = x.at(row,col); t.at(row,col) = x.at(row,col);
} }
} }
} }
//! 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 u32 n_rows_in, const u32 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 );
const u32 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 975 skipping to change at line 975
} }
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::delete_objects() field<oT>::delete_objects()
{ {
arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem ); arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
if(mem[i] != 0) if(mem[i] != 0)
{ {
delete mem[i]; delete mem[i];
mem[i] = 0; mem[i] = 0;
} }
} }
} }
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::create_objects() field<oT>::create_objects()
{ {
arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem ); arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
mem[i] = new oT; mem[i] = new oT;
} }
} }
template<typename oT> template<typename oT>
inline inline
field<oT>::iterator::iterator(field<oT>& in_M, const bool at_end) field<oT>::iterator::iterator(field<oT>& in_M, const bool at_end)
: M(in_M) : M(in_M)
skipping to change at line 1215 skipping to change at line 1215
x.create_objects(); x.create_objects();
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::reset_objects(field< Mat<eT> >& x) field_aux::reset_objects(field< Mat<eT> >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).reset(); (*(x.mem[i])).reset();
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::reset_objects(field< Col<eT> >& x) field_aux::reset_objects(field< Col<eT> >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).reset(); (*(x.mem[i])).reset();
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::reset_objects(field< Row<eT> >& x) field_aux::reset_objects(field< Row<eT> >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).reset(); (*(x.mem[i])).reset();
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::reset_objects(field< Cube<eT> >& x) field_aux::reset_objects(field< Cube<eT> >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).reset(); (*(x.mem[i])).reset();
} }
} }
inline inline
void void
field_aux::reset_objects(field< std::string >& x) field_aux::reset_objects(field< std::string >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(uword i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).clear(); (*(x.mem[i])).clear();
} }
} }
// //
// //
// //
template<typename oT> template<typename oT>
 End of changes. 54 change blocks. 
76 lines changed or deleted 76 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
skipping to change at line 33 skipping to change at line 33
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
ea_type P = A.get_ea(); ea_type P = A.get_ea();
const u32 n_elem = A.get_n_elem(); const uword n_elem = A.get_n_elem();
eT val1 = eT(0); eT val1 = eT(0);
eT val2 = eT(0); eT val2 = eT(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val1 += P[i]; val1 += P[i];
val2 += P[j]; val2 += P[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
val1 += P[i]; val1 += P[i];
} }
return val1 + val2; return val1 + val2;
} }
else else
{ {
const u32 n_rows = A.get_n_rows(); const uword n_rows = A.get_n_rows();
const u32 n_cols = A.get_n_cols(); const uword n_cols = A.get_n_cols();
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
val += A.at(row,col); val += A.at(row,col);
} }
} }
return val; return val;
} }
} }
//! explicit handling of Hamming norm (also known as zero norm) //! explicit handling of Hamming norm (also known as zero norm)
template<typename T1> template<typename T1>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
u32 uword
accu(const mtOp<u32,T1,op_rel_noteq>& X) accu(const mtOp<uword,T1,op_rel_noteq>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
const u32 n_elem = A.get_n_elem(); const uword n_elem = A.get_n_elem();
const eT val = X.aux; const eT val = X.aux;
u32 n_nonzero = 0; uword n_nonzero = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
if(A[i] != val) if(A[i] != val)
{ {
++n_nonzero; ++n_nonzero;
} }
} }
return n_nonzero; return n_nonzero;
} }
skipping to change at line 119 skipping to change at line 119
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> A(X.get_ref()); const ProxyCube<T1> A(X.get_ref());
if(ProxyCube<T1>::prefer_at_accessor == false) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
ea_type P = A.get_ea(); ea_type P = A.get_ea();
const u32 n_elem = A.get_n_elem(); const uword n_elem = A.get_n_elem();
eT val1 = eT(0); eT val1 = eT(0);
eT val2 = eT(0); eT val2 = eT(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val1 += P[i]; val1 += P[i];
val2 += P[j]; val2 += P[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
val1 += P[i]; val1 += P[i];
} }
return val1 + val2; return val1 + val2;
} }
else else
{ {
const u32 n_rows = A.get_n_rows(); const uword n_rows = A.get_n_rows();
const u32 n_cols = A.get_n_cols(); const uword n_cols = A.get_n_cols();
const u32 n_slices = A.get_n_slices(); const uword n_slices = A.get_n_slices();
eT val = eT(0); eT val = eT(0);
for(u32 slice=0; slice<n_slices; ++slice) for(uword slice=0; slice<n_slices; ++slice)
{ {
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
val += A.at(row,col,slice); val += A.at(row,col,slice);
} }
} }
} }
return val; return val;
} }
} }
//! accumulate the elements of a diagview //! accumulate the elements of a diagview
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const diagview<eT>& X) accu(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const uword n_elem = X.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
return val; return val;
} }
//! accumulate the elements of a subview (submatrix) //! accumulate the elements of a subview (submatrix)
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview<eT>& S) accu(const subview<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 S_n_rows = S.n_rows; const uword S_n_rows = S.n_rows;
const u32 S_n_cols = S.n_cols; const uword S_n_cols = S.n_cols;
const u32 S_n_elem = S.n_elem; const uword S_n_elem = S.n_elem;
eT val = eT(0); eT val = eT(0);
if(S_n_elem > 0) if(S_n_elem > 0)
{ {
for(u32 col=0; col<S_n_cols; ++col) for(uword col=0; col<S_n_cols; ++col)
{ {
val += arrayops::accumulate( S.colptr(col), S_n_rows ); val += arrayops::accumulate( S.colptr(col), S_n_rows );
} }
} }
return val; return val;
} }
//! accumulate the elements of a subview_row //! accumulate the elements of a subview_row
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview_row<eT>& S) accu(const subview_row<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& X = S.m; const Mat<eT>& X = S.m;
const u32 n_elem = S.n_elem; const uword n_elem = S.n_elem;
const u32 row = S.aux_row1; const uword row = S.aux_row1;
const u32 start_col = S.aux_col1; const uword start_col = S.aux_col1;
const u32 end_col_p1 = start_col + S.n_cols; const uword end_col_p1 = start_col + S.n_cols;
eT val = eT(0); eT val = eT(0);
if(n_elem > 0) if(n_elem > 0)
{ {
u32 i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
{ {
val += X.at(row,i); val += X.at(row,i);
val += X.at(row,j); val += X.at(row,j);
} }
if(i < end_col_p1) if(i < end_col_p1)
{ {
val += X.at(row,i); val += X.at(row,i);
 End of changes. 20 change blocks. 
30 lines changed or deleted 30 lines changed or added


 fn_as_scalar.hpp   fn_as_scalar.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_as_scalar //! \addtogroup fn_as_scalar
//! @{ //! @{
template<u32 N> template<uword N>
struct as_scalar_redirect struct as_scalar_redirect
{ {
template<typename T1> template<typename T1>
inline static typename T1::elem_type apply(const T1& X); inline static typename T1::elem_type apply(const T1& X);
}; };
template<> template<>
struct as_scalar_redirect<2> struct as_scalar_redirect<2>
{ {
template<typename T1, typename T2> template<typename T1, typename T2>
inline static typename T1::elem_type apply(const Glue<T1,T2,glue_times>& X); inline static typename T1::elem_type apply(const Glue<T1,T2,glue_times>& X);
}; };
template<> template<>
struct as_scalar_redirect<3> struct as_scalar_redirect<3>
{ {
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
inline static typename T1::elem_type apply(const Glue< Glue<T1, T2, glue_ times>, T3, glue_times>& X); inline static typename T1::elem_type apply(const Glue< Glue<T1, T2, glue_ times>, T3, glue_times>& X);
}; };
template<u32 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 unwrap<T1> tmp(X);
skipping to change at line 73 skipping to change at line 73
// 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 partial_unwrap<T1> tmp1(X.A);
const partial_unwrap<T2> tmp2(X.B); const partial_unwrap<T2> tmp2(X.B);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const u32 A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols; const uword A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols;
const u32 A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows; const uword A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows;
const u32 B_n_rows = (tmp2.do_trans == false) ? B.n_rows : B.n_cols; const uword B_n_rows = (tmp2.do_trans == false) ? B.n_rows : B.n_cols;
const u32 B_n_cols = (tmp2.do_trans == false) ? B.n_cols : B.n_rows; const uword B_n_cols = (tmp2.do_trans == false) ? B.n_cols : B.n_rows;
const eT val = tmp1.get_val() * tmp2.get_val(); const eT val = tmp1.get_val() * tmp2.get_val();
arma_debug_check( (A_n_rows != 1) || (B_n_cols != 1) || (A_n_cols != B_n_ rows), "as_scalar(): incompatible dimensions" ); arma_debug_check( (A_n_rows != 1) || (B_n_cols != 1) || (A_n_cols != B_n_ rows), "as_scalar(): incompatible dimensions" );
return val * op_dot::direct_dot(A.n_elem, A.mem, B.mem); return val * op_dot::direct_dot(A.n_elem, A.mem, B.mem);
} }
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
inline inline
skipping to change at line 125 skipping to change at line 125
else else
{ {
const partial_unwrap<T1> tmp1(X.A.A); const partial_unwrap<T1> tmp1(X.A.A);
const partial_unwrap<T2_stripped_2> tmp2(strip2.M); const partial_unwrap<T2_stripped_2> tmp2(strip2.M);
const partial_unwrap<T3> tmp3(X.B); const partial_unwrap<T3> tmp3(X.B);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
const u32 A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols; const uword A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols;
const u32 A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows; const uword A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows;
const bool B_is_vec = B.is_vec(); const bool B_is_vec = B.is_vec();
const u32 B_n_rows = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans = const uword B_n_rows = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans
= false) ? B.n_rows : B.n_cols ); == false) ? B.n_rows : B.n_cols );
const u32 B_n_cols = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans = const uword B_n_cols = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans
= false) ? B.n_cols : B.n_rows ); == false) ? B.n_cols : B.n_rows );
const u32 C_n_rows = (tmp3.do_trans == false) ? C.n_rows : C.n_cols; const uword C_n_rows = (tmp3.do_trans == false) ? C.n_rows : C.n_cols;
const u32 C_n_cols = (tmp3.do_trans == false) ? C.n_cols : C.n_rows; const uword C_n_cols = (tmp3.do_trans == false) ? C.n_cols : C.n_rows;
const eT val = tmp1.get_val() * tmp2.get_val() * tmp3.get_val(); const eT val = tmp1.get_val() * tmp2.get_val() * tmp3.get_val();
arma_debug_check arma_debug_check
( (
(A_n_rows != 1) || (A_n_rows != 1) ||
(C_n_cols != 1) || (C_n_cols != 1) ||
(A_n_cols != B_n_rows) || (A_n_cols != B_n_rows) ||
(B_n_cols != C_n_rows) (B_n_cols != C_n_rows)
, ,
skipping to change at line 214 skipping to change at line 214
const strip_diagmat<T2> strip(X.A.B); const strip_diagmat<T2> strip(X.A.B);
const partial_unwrap<T1> tmp1(X.A.A); const partial_unwrap<T1> tmp1(X.A.A);
const partial_unwrap<T2_stripped> tmp2(strip.M); const partial_unwrap<T2_stripped> tmp2(strip.M);
const partial_unwrap<T3> tmp3(X.B); const partial_unwrap<T3> tmp3(X.B);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
const u32 A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols; const uword A_n_rows = (tmp1.do_trans == false) ? A.n_rows : A.n_cols;
const u32 A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows; const uword A_n_cols = (tmp1.do_trans == false) ? A.n_cols : A.n_rows;
const bool B_is_vec = B.is_vec(); const bool B_is_vec = B.is_vec();
const u32 B_n_rows = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans == const uword B_n_rows = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans =
false) ? B.n_rows : B.n_cols ); = false) ? B.n_rows : B.n_cols );
const u32 B_n_cols = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans == const uword B_n_cols = (B_is_vec == true) ? B.n_elem : ( (tmp2.do_trans =
false) ? B.n_cols : B.n_rows ); = false) ? B.n_cols : B.n_rows );
const u32 C_n_rows = (tmp3.do_trans == false) ? C.n_rows : C.n_cols; const uword C_n_rows = (tmp3.do_trans == false) ? C.n_rows : C.n_cols;
const u32 C_n_cols = (tmp3.do_trans == false) ? C.n_cols : C.n_rows; const uword C_n_cols = (tmp3.do_trans == false) ? C.n_cols : C.n_rows;
const eT val = tmp1.get_val() * tmp2.get_val() * tmp3.get_val(); const eT val = tmp1.get_val() * tmp2.get_val() * tmp3.get_val();
arma_debug_check arma_debug_check
( (
(A_n_rows != 1) || (A_n_rows != 1) ||
(C_n_cols != 1) || (C_n_cols != 1) ||
(A_n_cols != B_n_rows) || (A_n_cols != B_n_rows) ||
(B_n_cols != C_n_rows) (B_n_cols != C_n_rows)
, ,
skipping to change at line 258 skipping to change at line 258
arma_inline arma_inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
as_scalar(const Glue<T1, T2, glue_times>& X, const typename arma_not_cx<typ ename T1::elem_type>::result* junk = 0) as_scalar(const Glue<T1, T2, glue_times>& X, const typename arma_not_cx<typ ename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
if(is_glue_times_diag<T1>::value == false) if(is_glue_times_diag<T1>::value == false)
{ {
const s32 N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >:: num; const sword N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> > ::num;
arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat); arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat);
return as_scalar_redirect<N_mat>::apply(X); return as_scalar_redirect<N_mat>::apply(X);
} }
else else
{ {
return as_scalar_diag(X); return as_scalar_diag(X);
} }
} }
 End of changes. 11 change blocks. 
23 lines changed or deleted 23 lines changed or added


 fn_conv_to.hpp   fn_conv_to.hpp 
skipping to change at line 46 skipping to change at line 46
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_not_cx <in_eT>::result* junk) conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_not_cx <in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check(( is_supported_elem_type<out_eT>::value == false ));
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M; const Mat<in_eT>& X = tmp.M;
arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
return out_eT(X.mem[0]); return out_eT(X.mem[0]);
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_cx_onl y<in_eT>::result* junk) conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_cx_onl y<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check(( is_supported_elem_type<out_eT>::value == false ));
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M; const Mat<in_eT>& X = tmp.M;
arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
out_eT out; out_eT out;
arrayops::convert_cx_scalar(out, X.mem[0]); arrayops::convert_cx_scalar(out, X.mem[0]);
skipping to change at line 90 skipping to change at line 90
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_no t_cx<in_eT>::result* junk) conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_no t_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check(( is_supported_elem_type<out_eT>::value == false ));
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<in_eT>& X = tmp.M; const Cube<in_eT>& X = tmp.M;
arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
return out_eT(X.mem[0]); return out_eT(X.mem[0]);
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_cx _only<in_eT>::result* junk) conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_cx _only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check(( is_supported_elem_type<out_eT>::value == false ));
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<in_eT>& X = tmp.M; const Cube<in_eT>& X = tmp.M;
arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
out_eT out; out_eT out;
arrayops::convert_cx_scalar(out, X.mem[0]); arrayops::convert_cx_scalar(out, X.mem[0]);
skipping to change at line 493 skipping to change at line 493
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
Row<out_eT> Row<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm a_cx_only<in_eT>::result* junk) conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); //const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
Row<out_eT> out(in.rows() * in.cols()); Row<out_eT> out(in.rows() * in.cols());
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
skipping to change at line 704 skipping to change at line 704
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
Col<out_eT> Col<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm a_cx_only<in_eT>::result* junk) conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); //const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
Col<out_eT> out(in.rows() * in.cols()); Col<out_eT> out(in.rows() * in.cols());
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 fn_cor.hpp   fn_cor.hpp 
skipping to change at line 20 skipping to change at line 20
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_cor //! \addtogroup fn_cor
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_cor> const Op<T1, op_cor>
cor(const Base<typename T1::elem_type,T1>& X, const u32 norm_type = 0) cor(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (norm_type > 1), "cor(): norm_type must be 0 or 1"); arma_debug_check( (norm_type > 1), "cor(): norm_type must be 0 or 1");
return Op<T1, op_cor>(X.get_ref(), norm_type, 0); return Op<T1, op_cor>(X.get_ref(), norm_type, 0);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Glue<T1,T2,glue_cor> const Glue<T1,T2,glue_cor>
cor(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ type,T2>& B, const u32 norm_type = 0) cor(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ type,T2>& B, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (norm_type > 1), "cor(): norm_type must be 0 or 1"); arma_debug_check( (norm_type > 1), "cor(): norm_type must be 0 or 1");
return Glue<T1, T2, glue_cor>(A.get_ref(), B.get_ref(), norm_type); return Glue<T1, T2, glue_cor>(A.get_ref(), B.get_ref(), norm_type);
} }
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_cov.hpp   fn_cov.hpp 
skipping to change at line 20 skipping to change at line 20
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_cov //! \addtogroup fn_cov
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_cov> const Op<T1, op_cov>
cov(const Base<typename T1::elem_type,T1>& X, const u32 norm_type = 0) cov(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (norm_type > 1), "cov(): norm_type must be 0 or 1"); arma_debug_check( (norm_type > 1), "cov(): norm_type must be 0 or 1");
return Op<T1, op_cov>(X.get_ref(), norm_type, 0); return Op<T1, op_cov>(X.get_ref(), norm_type, 0);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Glue<T1,T2,glue_cov> const Glue<T1,T2,glue_cov>
cov(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ type,T2>& B, const u32 norm_type = 0) cov(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ type,T2>& B, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (norm_type > 1), "cov(): norm_type must be 0 or 1"); arma_debug_check( (norm_type > 1), "cov(): norm_type must be 0 or 1");
return Glue<T1, T2, glue_cov>(A.get_ref(), B.get_ref(), norm_type); return Glue<T1, T2, glue_cov>(A.get_ref(), B.get_ref(), norm_type);
} }
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_cumsum.hpp   fn_cumsum.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_cumsum //! \addtogroup fn_cumsum
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_cumsum_mat> const Op<T1, op_cumsum_mat>
cumsum(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) cumsum(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_cumsum_mat>(X.get_ref(), dim, 0); return Op<T1, op_cumsum_mat>(X.get_ref(), dim, 0);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Row<eT>, op_cumsum_vec> const Op<Row<eT>, op_cumsum_vec>
cumsum(const Row<eT>& A) cumsum(const Row<eT>& A)
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_det.hpp   fn_det.hpp 
skipping to change at line 53 skipping to change at line 53
const bool slow = false const bool slow = false
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(slow); arma_ignore(slow);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const diagmat_proxy<T1> A(X.m); const diagmat_proxy<T1> A(X.m);
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
eT val = eT(1); eT val = eT(1);
for(u32 i=0; i<A_n_elem; ++i) for(uword i=0; i<A_n_elem; ++i)
{ {
val *= A[i]; val *= A[i];
} }
return val; return val;
} }
//! determinant of inv(A), without doing the inverse operation //! determinant of inv(A), without doing the inverse operation
template<typename T1> template<typename T1>
inline inline
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_diagvec.hpp   fn_diagvec.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_diagvec //! \addtogroup fn_diagvec
//! @{ //! @{
//! extract a diagonal from a matrix //! extract a diagonal from a matrix
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_diagvec> const Op<T1, op_diagvec>
diagvec(const Base<typename T1::elem_type,T1>& X, const s32 diag_id = 0) diagvec(const Base<typename T1::elem_type,T1>& X, const sword diag_id = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_diagvec>(X.get_ref(), ((diag_id < 0) ? -diag_id : diag_i d), ((diag_id < 0) ? 1 : 0) ); return Op<T1, op_diagvec>(X.get_ref(), ((diag_id < 0) ? -diag_id : diag_i d), ((diag_id < 0) ? 1 : 0) );
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_eig.hpp   fn_eig.hpp 
skipping to change at line 203 skipping to change at line 203
} }
if(status == false) if(status == false)
{ {
eigval.reset(); eigval.reset();
eigvec.reset(); eigvec.reset();
arma_bad("eig_gen(): failed to converge", false); arma_bad("eig_gen(): failed to converge", false);
} }
else else
{ {
const u32 n = eigval.n_elem; const uword n = eigval.n_elem;
if(n > 0) if(n > 0)
{ {
eigvec.set_size(n,n); eigvec.set_size(n,n);
for(u32 j=0; j<n; ++j) for(uword j=0; j<n; ++j)
{ {
if( (j < n-1) && (eigval[j] == std::conj(eigval[j+1])) ) if( (j < n-1) && (eigval[j] == std::conj(eigval[j+1])) )
{ {
// eigvec.col(j) = Mat< std::complex<eT> >( tmp_eigvec.col(j), tmp_eigvec.col(j+1) ); // eigvec.col(j) = Mat< std::complex<eT> >( tmp_eigvec.col(j), tmp_eigvec.col(j+1) );
// eigvec.col(j+1) = Mat< std::complex<eT> >( tmp_eigvec.col(j), -tmp_eigvec.col(j+1) ); // eigvec.col(j+1) = Mat< std::complex<eT> >( tmp_eigvec.col(j), -tmp_eigvec.col(j+1) );
for(u32 i=0; i<n; ++i) for(uword i=0; i<n; ++i)
{ {
eigvec.at(i,j) = std::complex<eT>( tmp_eigvec.at(i,j), tmp_e igvec.at(i,j+1) ); eigvec.at(i,j) = std::complex<eT>( tmp_eigvec.at(i,j), tmp_e igvec.at(i,j+1) );
eigvec.at(i,j+1) = std::complex<eT>( tmp_eigvec.at(i,j), -tmp_e igvec.at(i,j+1) ); eigvec.at(i,j+1) = std::complex<eT>( tmp_eigvec.at(i,j), -tmp_e igvec.at(i,j+1) );
} }
++j; ++j;
} }
else else
{ {
// eigvec.col(i) = tmp_eigvec.col(i); // eigvec.col(i) = tmp_eigvec.col(i);
for(u32 i=0; i<n; ++i) for(uword i=0; i<n; ++i)
{ {
eigvec.at(i,j) = std::complex<eT>(tmp_eigvec.at(i,j), eT(0)); eigvec.at(i,j) = std::complex<eT>(tmp_eigvec.at(i,j), eT(0));
} }
} }
} }
} }
} }
return status; return status;
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 fn_elem.hpp   fn_elem.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_elem //! \addtogroup fn_elem
//! @{ //! @{
// //
// find // find
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
const mtOp<u32, T1, op_find> const mtOp<uword, T1, op_find>
find(const Base<eT,T1>& X, const u32 k = 0, const char* direction = "first" find(const Base<eT,T1>& X, const uword k = 0, const char* direction = "firs
) t")
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const char sig = direction[0]; const char sig = direction[0];
arma_debug_check arma_debug_check
( (
(sig != 'f' && sig != 'F' && sig != 'l' && sig != 'L'), (sig != 'f' && sig != 'F' && sig != 'l' && sig != 'L'),
"find(): 3rd input argument must be \"first\" or \"last\"" "find(): 3rd input argument must be \"first\" or \"last\""
); );
const u32 type = (sig == 'f' || sig == 'F') ? 0 : 1; const uword type = (sig == 'f' || sig == 'F') ? 0 : 1;
return mtOp<u32, T1, op_find>(X.get_ref(), k, type); return mtOp<uword, T1, op_find>(X.get_ref(), k, type);
} }
// //
// real // real
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
real(const Base<typename T1::pod_type, T1>& X) real(const Base<typename T1::pod_type, T1>& X)
{ {
skipping to change at line 87 skipping to change at line 87
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<typename T1::pod_type, T1, op_real>( X.get_ref() ); return mtOpCube<typename T1::pod_type, T1, op_real>( X.get_ref() );
} }
// //
// imag // imag
template<typename T1> template<typename T1>
inline inline
const eOp<Mat<typename T1::pod_type>, eop_zeros> const Gen<typename T1::pod_type, gen_zeros>
imag(const Base<typename T1::pod_type,T1>& X) imag(const Base<typename T1::pod_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
return eOp<Mat<typename T1::pod_type>, eop_zeros>(A.get_n_rows(), A.get_n _cols()); return Gen<typename T1::pod_type, gen_zeros>(A.get_n_rows(), A.get_n_cols ());
} }
template<typename T1> template<typename T1>
inline inline
const eOpCube<Cube<typename T1::pod_type>, eop_zeros> const GenCube<typename T1::pod_type, gen_zeros>
imag(const BaseCube<typename T1::pod_type,T1>& X) imag(const BaseCube<typename T1::pod_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const ProxyCube<T1> A(X.get_ref()); const ProxyCube<T1> A(X.get_ref());
return eOpCube<Cube<typename T1::pod_type>, eop_zeros>(A.get_n_rows(), A. get_n_cols(), A.get_n_slices()); return GenCube<typename T1::pod_type, gen_zeros>(A.get_n_rows(), A.get_n_ cols(), A.get_n_slices());
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<typename T1::pod_type, T1, op_imag> const mtOp<typename T1::pod_type, T1, op_imag>
imag(const Base<std::complex<typename T1::pod_type>, T1>& X) imag(const Base<std::complex<typename T1::pod_type>, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<typename T1::pod_type, T1, op_imag>( X.get_ref() ); return mtOp<typename T1::pod_type, T1, op_imag>( X.get_ref() );
 End of changes. 7 change blocks. 
9 lines changed or deleted 9 lines changed or added


 fn_eps.hpp   fn_eps.hpp 
skipping to change at line 54 skipping to change at line 54
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
Mat<T> out(A.n_rows, A.n_cols); Mat<T> out(A.n_rows, A.n_cols);
T* out_mem = out.memptr(); T* out_mem = out.memptr();
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
const u32 n_elem = A.n_elem; const uword n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = eop_aux::direct_eps( A_mem[i] ); out_mem[i] = eop_aux::direct_eps( A_mem[i] );
} }
return out; return out;
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_eye.hpp   fn_eye.hpp 
skipping to change at line 17 skipping to change at line 17
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_eye //! \addtogroup fn_eye
//! @{ //! @{
arma_inline arma_inline
const eOp<mat, eop_ones_diag> const Gen<mat::elem_type, gen_ones_diag>
eye(const u32 n_rows, const u32 n_cols) eye(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_diag>(n_rows, n_cols); return Gen<mat::elem_type, gen_ones_diag>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_ones_diag> const Gen<typename mat_type::elem_type, gen_ones_diag>
eye(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_onl eye(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row
y<mat_type>::result* junk = 0) _only<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_ones_diag>(n_rows, n_cols); return Gen<typename mat_type::elem_type, gen_ones_diag>(n_rows, n_cols);
} }
//! @} //! @}
 End of changes. 4 change blocks. 
7 lines changed or deleted 7 lines changed or added


 fn_inv.hpp   fn_inv.hpp 
skipping to change at line 60 skipping to change at line 60
( (
const Op<T1, op_trimat>& X, const Op<T1, op_trimat>& X,
const bool slow = false, const bool slow = false,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(slow); arma_ignore(slow);
arma_ignore(junk); arma_ignore(junk);
return Op<T1, op_inv_tr>(X.m, X.aux_u32_a, 0); return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
} }
//! delayed matrix inverse (symmetric positive definite matrices) //! delayed matrix inverse (symmetric positive definite matrices)
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_inv_sympd> const Op<T1, op_inv_sympd>
inv inv
( (
const Op<T1, op_sympd>& X, const Op<T1, op_sympd>& X,
const bool slow = false, const bool slow = false,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_log_det.hpp   fn_log_det.hpp 
skipping to change at line 53 skipping to change at line 53
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const diagmat_proxy<T1> A(X.m); const diagmat_proxy<T1> A(X.m);
const u32 N = A.n_elem; const uword N = A.n_elem;
if(N == 0) if(N == 0)
{ {
out_val = eT(0); out_val = eT(0);
out_sign = T(1); out_sign = T(1);
return; return;
} }
const eT x = A[0]; const eT x = A[0];
T sign = (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1; T sign = (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1;
eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x); eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x);
for(u32 i=1; i<N; ++i) for(uword i=1; i<N; ++i)
{ {
const eT x = A[i]; const eT x = A[i];
sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1; sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1;
val += (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x); val += (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x);
} }
out_val = val; out_val = val;
out_sign = sign; out_sign = sign;
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_max.hpp   fn_max.hpp 
skipping to change at line 26 skipping to change at line 26
//! \brief //! \brief
//! Delayed 'maximum values' operation. //! Delayed 'maximum values' operation.
//! The dimension, along which the maxima are found, is set via 'dim'. //! The dimension, along which the maxima are found, is set via 'dim'.
//! For dim = 0, the maximum value of each column is found (i.e. searches b y traversing across rows). //! For dim = 0, the maximum value of each column is found (i.e. searches b y traversing across rows).
//! For dim = 1, the maximum value of each row is found (i.e. searches by t raversing across columns). //! For dim = 1, the maximum value of each row is found (i.e. searches by t raversing across columns).
//! The default is dim = 0. //! The default is dim = 0.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_max> const Op<T1, op_max>
max(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) max(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_max>(X.get_ref(), dim, 0); return Op<T1, op_max>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the maximum value in a row vector' operation //! Immediate 'find the maximum value in a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const Row<eT>& A) max(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(A.mem, A_n_elem); return op_max::direct_max(A.mem, A_n_elem);
} }
//! Immediate 'find the maximum value in a column vector' operation //! Immediate 'find the maximum value in a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const Col<eT>& A) max(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(A.mem, A_n_elem); return op_max::direct_max(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find maximum value' operation, //! Immediate 'find maximum value' operation,
//! invoked, for example, by: max(max(A)) //! invoked, for example, by: max(max(A))
template<typename T1> template<typename T1>
skipping to change at line 82 skipping to change at line 82
max(const Op<T1, op_max>& in) max(const Op<T1, op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("max(): two consecutive max() calls detected"); arma_extra_debug_print("max(): two consecutive max() calls detected");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.m); const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M; const Mat<eT>& X = tmp1.M;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" ); arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(X.mem, X_n_elem); return op_max::direct_max(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op< Op<T1, op_max>, op_max> const Op< Op<T1, op_max>, op_max>
max(const Op<T1, op_max>& in, const u32 dim) max(const Op<T1, op_max>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_max>, op_max>(in, dim, 0); return Op< Op<T1, op_max>, op_max>(in, dim, 0);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
skipping to change at line 164 skipping to change at line 164
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const subview_elem1<eT,T1>& A) max(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> X(A); const Mat<eT> X(A);
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" ); arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(X.mem, X_n_elem); return op_max::direct_max(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 fn_mean.hpp   fn_mean.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_mean //! \addtogroup fn_mean
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_mean> const Op<T1, op_mean>
mean(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) mean(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_mean>(X.get_ref(), dim, 0); return Op<T1, op_mean>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the mean value of a row vector' operation //! Immediate 'find the mean value of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const Row<eT>& A) mean(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(A.mem, A_n_elem); return op_mean::direct_mean(A.mem, A_n_elem);
} }
//! Immediate 'find the mean value of a column vector' operation //! Immediate 'find the mean value of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const Col<eT>& A) mean(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(A.mem, A_n_elem); return op_mean::direct_mean(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find mean value' operation, //! Immediate 'find mean value' operation,
//! invoked, for example, by: mean(mean(A)) //! invoked, for example, by: mean(mean(A))
template<typename T1> template<typename T1>
skipping to change at line 75 skipping to change at line 75
mean(const Op<T1, op_mean>& in) mean(const Op<T1, op_mean>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("mean(): two consecutive mean() calls detected"); arma_extra_debug_print("mean(): two consecutive mean() calls detected");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.m); const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M; const Mat<eT>& X = tmp1.M;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements" ); arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(X.mem, X_n_elem); return op_mean::direct_mean(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op< Op<T1, op_mean>, op_mean> const Op< Op<T1, op_mean>, op_mean>
mean(const Op<T1, op_mean>& in, const u32 dim) mean(const Op<T1, op_mean>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_mean>, op_mean>(in, dim, 0); return Op< Op<T1, op_mean>, op_mean>(in, dim, 0);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
skipping to change at line 159 skipping to change at line 159
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const subview_elem1<eT,T1>& A) mean(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> X(A); const Mat<eT> X(A);
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements" ); arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(X.mem, X_n_elem); return op_mean::direct_mean(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 fn_median.hpp   fn_median.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_median //! \addtogroup fn_median
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_median> const Op<T1, op_median>
median(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) median(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_median>(X.get_ref(), dim, 0); return Op<T1, op_median>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the median value of a row vector' operation //! Immediate 'find the median value of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const Row<eT>& A) median(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" );
return op_median::direct_median(A.mem, A_n_elem); return op_median::direct_median(A.mem, A_n_elem);
} }
//! Immediate 'find the median value of a column vector' operation //! Immediate 'find the median value of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const Col<eT>& A) median(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" );
return op_median::direct_median(A.mem, A_n_elem); return op_median::direct_median(A.mem, A_n_elem);
} }
//! Immediate 'find the median value of a row vector' operation (complex nu mber version) //! Immediate 'find the median value of a row vector' operation (complex nu mber version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const Row< std::complex<T> >& A) median(const Row< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" );
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem); op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem);
return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem [index1], A.mem[index2] ); return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem [index1], A.mem[index2] );
} }
//! Immediate 'find the median value of a column vector' operation (complex number version) //! Immediate 'find the median value of a column vector' operation (complex number version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const Col< std::complex<T> >& A) median(const Col< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A_n_elem == 0), "median(): given object has no element s" );
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem); op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem);
return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem [index1], A.mem[index2] ); return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem [index1], A.mem[index2] );
} }
//! find the median value of a subview_row //! find the median value of a subview_row
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
skipping to change at line 137 skipping to change at line 137
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const subview_row< std::complex<T> >& A) median(const subview_row< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, A); op_median::direct_cx_median_index(index1, index2, A);
return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]); return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]);
} }
//! find the median value of a subview_col (complex number version) //! find the median value of a subview_col (complex number version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const subview_col< std::complex<T> >& A) median(const subview_col< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, A); op_median::direct_cx_median_index(index1, index2, A);
return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]); return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const diagview<eT>& A) median(const diagview<eT>& A)
skipping to change at line 185 skipping to change at line 185
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const diagview< std::complex<T> >& A) median(const diagview< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, A); op_median::direct_cx_median_index(index1, index2, A);
return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]); return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const subview_elem1<eT,T1>& A) median(const subview_elem1<eT,T1>& A)
 End of changes. 10 change blocks. 
15 lines changed or deleted 15 lines changed or added


 fn_min.hpp   fn_min.hpp 
skipping to change at line 26 skipping to change at line 26
//! \brief //! \brief
//! Delayed 'minimum values' operation. //! Delayed 'minimum values' operation.
//! The dimension, along which the minima are found, is set via 'dim'. //! The dimension, along which the minima are found, is set via 'dim'.
//! For dim = 0, the minimum value of each column is found (i.e. searches b y traversing across rows). //! For dim = 0, the minimum value of each column is found (i.e. searches b y traversing across rows).
//! For dim = 1, the minimum value of each row is found (i.e. searches by t raversing across columns). //! For dim = 1, the minimum value of each row is found (i.e. searches by t raversing across columns).
//! The default is dim = 0. //! The default is dim = 0.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_min> const Op<T1, op_min>
min(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) min(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_min>(X.get_ref(), dim, 0); return Op<T1, op_min>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the minimum value in a row vector' operation //! Immediate 'find the minimum value in a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const Row<eT>& A) min(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "min(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(A.mem, A_n_elem); return op_min::direct_min(A.mem, A_n_elem);
} }
//! Immediate 'find the minimum value in a column vector' //! Immediate 'find the minimum value in a column vector'
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const Col<eT>& A) min(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "min(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(A.mem, A_n_elem); return op_min::direct_min(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find minimum value' operation, //! Immediate 'find minimum value' operation,
//! invoked, for example, by: min(min(A)) //! invoked, for example, by: min(min(A))
template<typename T1> template<typename T1>
skipping to change at line 82 skipping to change at line 82
min(const Op<T1, op_min>& in) min(const Op<T1, op_min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("min(): two consecutive min() calls detected"); arma_extra_debug_print("min(): two consecutive min() calls detected");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.m); const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M; const Mat<eT>& X = tmp1.M;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "min(): given object has no elements" ); arma_debug_check( (X_n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(X.mem, X_n_elem); return op_min::direct_min(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
inline inline
const Op< Op<T1, op_min>, op_min> const Op< Op<T1, op_min>, op_min>
min(const Op<T1, op_min>& in, const u32 dim) min(const Op<T1, op_min>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_min>, op_min>(in, dim, 0); return Op< Op<T1, op_min>, op_min>(in, dim, 0);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
skipping to change at line 164 skipping to change at line 164
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const subview_elem1<eT,T1>& A) min(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> X(A); const Mat<eT> X(A);
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "min(): given object has no elements" ); arma_debug_check( (X_n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(X.mem, X_n_elem); return op_min::direct_min(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 27 skipping to change at line 27
//! Generate a vector with 'num' elements. //! Generate a vector with 'num' elements.
//! The values of the elements linearly increase from 'start' upto (and inc luding) 'end'. //! The values of the elements linearly increase from 'start' upto (and inc luding) 'end'.
template<typename vec_type> template<typename vec_type>
inline inline
vec_type vec_type
linspace linspace
( (
const typename vec_type::pod_type start, const typename vec_type::pod_type start,
const typename vec_type::pod_type end, const typename vec_type::pod_type end,
const u32 num = 100u, const uword num = 100u,
const typename arma_Mat_Col_Row_only<vec_type>::result* junk = 0 const typename arma_Mat_Col_Row_only<vec_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename vec_type::elem_type eT; typedef typename vec_type::elem_type eT;
typedef typename vec_type::pod_type T; typedef typename vec_type::pod_type T;
vec_type x; vec_type x;
if(num >= 2) if(num >= 2)
{ {
x.set_size(num); x.set_size(num);
eT* x_mem = x.memptr(); eT* x_mem = x.memptr();
const u32 num_m1 = num - 1; const uword num_m1 = num - 1;
if(is_non_integral<T>::value == true) if(is_non_integral<T>::value == true)
{ {
const T delta = (end-start)/T(num_m1); const T delta = (end-start)/T(num_m1);
for(u32 i=0; i<num_m1; ++i) for(uword i=0; i<num_m1; ++i)
{ {
x_mem[i] = eT(start + i*delta); x_mem[i] = eT(start + i*delta);
} }
x_mem[num_m1] = eT(end); x_mem[num_m1] = eT(end);
} }
else else
{ {
const double delta = (end >= start) ? double(end-start)/double(num_m1 ) : -double(start-end)/double(num_m1); const double delta = (end >= start) ? double(end-start)/double(num_m1 ) : -double(start-end)/double(num_m1);
for(u32 i=0; i<num_m1; ++i) for(uword i=0; i<num_m1; ++i)
{ {
x_mem[i] = eT(double(start) + i*delta); x_mem[i] = eT(double(start) + i*delta);
} }
x_mem[num_m1] = eT(end); x_mem[num_m1] = eT(end);
} }
return x; return x;
} }
else else
skipping to change at line 84 skipping to change at line 84
x.set_size(1); x.set_size(1);
x[0] = eT(end); x[0] = eT(end);
} }
return x; return x;
} }
inline inline
mat mat
linspace(const double start, const double end, const u32 num = 100u) linspace(const double start, const double end, const uword num = 100u)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return linspace<mat>(start, end, num); return linspace<mat>(start, end, num);
} }
// //
// log_add // log_add
template<typename eT> template<typename eT>
inline inline
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 fn_norm.hpp   fn_norm.hpp 
skipping to change at line 32 skipping to change at line 32
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type P = A.get_ea();
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
u32 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)
{ {
acc += std::abs(P[i]); acc += std::abs(P[i]);
acc += std::abs(P[j]); acc += std::abs(P[j]);
} }
if(i < N) if(i < N)
{ {
acc += std::abs(P[i]); acc += std::abs(P[i]);
} }
} }
else else
{ {
const u32 n_rows = A.get_n_rows(); const uword n_rows = A.get_n_rows();
const u32 n_cols = A.get_n_cols(); const uword n_cols = A.get_n_cols();
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_rows; i+=2, j+=2) for(i=0, j=1; j<n_rows; i+=2, j+=2)
{ {
acc += std::abs(A.at(i,col)); acc += std::abs(A.at(i,col));
acc += std::abs(A.at(j,col)); acc += std::abs(A.at(j,col));
} }
if(i < n_rows) if(i < n_rows)
{ {
acc += std::abs(A.at(i,col)); acc += std::abs(A.at(i,col));
skipping to change at line 89 skipping to change at line 89
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type P = A.get_ea();
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
u32 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 T tmp_i = P[i]; const T tmp_i = P[i];
const T tmp_j = P[j]; const T tmp_j = P[j];
acc += tmp_i * tmp_i; acc += tmp_i * tmp_i;
acc += tmp_j * tmp_j; acc += tmp_j * tmp_j;
} }
if(i < N) if(i < N)
{ {
const T tmp_i = P[i]; const T tmp_i = P[i];
acc += tmp_i * tmp_i; acc += tmp_i * tmp_i;
} }
} }
else else
{ {
const u32 n_rows = A.get_n_rows(); const uword n_rows = A.get_n_rows();
const u32 n_cols = A.get_n_cols(); const uword n_cols = A.get_n_cols();
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j<n_rows; i+=2, j+=2) for(i=0, j=1; j<n_rows; i+=2, j+=2)
{ {
const T tmp_i = A.at(i,col); const T tmp_i = A.at(i,col);
const T tmp_j = A.at(j,col); const T tmp_j = A.at(j,col);
acc += tmp_i * tmp_i; acc += tmp_i * tmp_i;
acc += tmp_j * tmp_j; acc += tmp_j * tmp_j;
} }
skipping to change at line 156 skipping to change at line 156
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type P = A.get_ea();
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const T tmp = std::abs(P[i]); const T tmp = std::abs(P[i]);
acc += tmp*tmp; acc += tmp*tmp;
} }
} }
else else
{ {
const u32 n_rows = A.get_n_rows(); const uword n_rows = A.get_n_rows();
const u32 n_cols = A.get_n_cols(); const uword n_cols = A.get_n_cols();
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
const T tmp = std::abs(A.at(row,col)); const T tmp = std::abs(A.at(row,col));
acc += tmp*tmp; acc += tmp*tmp;
} }
} }
return std::sqrt(acc); return std::sqrt(acc);
} }
template<typename T1> template<typename T1>
skipping to change at line 196 skipping to change at line 196
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type P = A.get_ea();
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
u32 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)
{ {
acc += std::pow(std::abs(P[i]), k); acc += std::pow(std::abs(P[i]), k);
acc += std::pow(std::abs(P[j]), k); acc += std::pow(std::abs(P[j]), k);
} }
if(i < N) if(i < N)
{ {
acc += std::pow(std::abs(P[i]), k); acc += std::pow(std::abs(P[i]), k);
} }
} }
else else
{ {
const u32 n_rows = A.get_n_rows(); const uword n_rows = A.get_n_rows();
const u32 n_cols = A.get_n_cols(); const uword n_cols = A.get_n_cols();
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
acc += std::pow(std::abs(A.at(row,col)), k); acc += std::pow(std::abs(A.at(row,col)), k);
} }
} }
return std::pow(acc, T(1)/T(k)); return std::pow(acc, T(1)/T(k));
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_max(const Proxy<T1>& A) arma_vec_norm_max(const Proxy<T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
ea_type P = A.get_ea(); ea_type P = A.get_ea();
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
T max_val = (N != 1) ? priv::most_neg<T>() : std::abs(P[0]); T max_val = (N != 1) ? priv::most_neg<T>() : std::abs(P[0]);
u32 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 T tmp_i = std::abs(P[i]); const T tmp_i = std::abs(P[i]);
const T tmp_j = std::abs(P[j]); const T tmp_j = std::abs(P[j]);
if(max_val < tmp_i) { max_val = tmp_i; } if(max_val < tmp_i) { max_val = tmp_i; }
if(max_val < tmp_j) { max_val = tmp_j; } if(max_val < tmp_j) { max_val = tmp_j; }
} }
skipping to change at line 275 skipping to change at line 275
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_min(const Proxy<T1>& A) arma_vec_norm_min(const Proxy<T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
ea_type P = A.get_ea(); ea_type P = A.get_ea();
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
T min_val = (N != 1) ? priv::most_pos<T>() : std::abs(P[0]); T min_val = (N != 1) ? priv::most_pos<T>() : std::abs(P[0]);
u32 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 T tmp_i = std::abs(P[i]); const T tmp_i = std::abs(P[i]);
const T tmp_j = std::abs(P[j]); const T tmp_j = std::abs(P[j]);
if(min_val > tmp_i) { min_val = tmp_i; } if(min_val > tmp_i) { min_val = tmp_i; }
if(min_val > tmp_j) { min_val = tmp_j; } if(min_val > tmp_j) { min_val = tmp_j; }
} }
skipping to change at line 360 skipping to change at line 360
return as_scalar( max( sum(abs(X),1) ) ); return as_scalar( max( sum(abs(X),1) ) );
} }
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::pod_type typename T1::pod_type
norm norm
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const u32 k, const uword k,
const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun k = 0 const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun k = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
 End of changes. 23 change blocks. 
29 lines changed or deleted 29 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
skipping to change at line 17 skipping to change at line 17
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_ones //! \addtogroup fn_ones
//! @{ //! @{
arma_inline arma_inline
const eOp<vec, eop_ones_full> const Gen<vec::elem_type, gen_ones_full>
ones(const u32 n_elem) ones(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<vec, eop_ones_full>(n_elem, 1); return Gen<vec::elem_type, gen_ones_full>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_ones_full> const Gen<typename vec_type::elem_type, gen_ones_full>
ones(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), c ones(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(),
onst typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_ones_full>(1, n_elem); return Gen<typename vec_type::elem_type, gen_ones_full>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_ones_full>(n_elem, 1); return Gen<typename vec_type::elem_type, gen_ones_full>(n_elem, 1);
} }
} }
arma_inline arma_inline
const eOp<mat, eop_ones_full> const Gen<mat::elem_type, gen_ones_full>
ones(const u32 n_rows, const u32 n_cols) ones(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_full>(n_rows, n_cols); return Gen<mat::elem_type, gen_ones_full>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_ones_full> const Gen<typename mat_type::elem_type, gen_ones_full>
ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_on ones(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Ro
ly<mat_type>::result* junk = 0) w_only<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_ones_full>(n_rows, n_cols); return Gen<typename mat_type::elem_type, gen_ones_full>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_ones_full> const GenCube<cube::elem_type, gen_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices) ones(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_ones_full>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_ones_full>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_ones_full> const GenCube<typename cube_type::elem_type, gen_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename ones(const uword n_rows, const uword n_cols, const uword n_slices, const ty
arma_Cube_only<cube_type>::result* junk = 0) pename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_ones_full>(n_rows, n_cols, n_slices); return GenCube<typename cube_type::elem_type, gen_ones_full>(n_rows, n_co ls, n_slices);
} }
//! @} //! @}
 End of changes. 13 change blocks. 
22 lines changed or deleted 22 lines changed or added


 fn_prod.hpp   fn_prod.hpp 
skipping to change at line 27 skipping to change at line 27
//! Delayed product of elements of a matrix along a specified dimension (ei ther rows or columns). //! Delayed product of elements of a matrix along a specified dimension (ei ther rows or columns).
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! For dim = 0, find the sum of each column (i.e. traverse across rows) //! For dim = 0, find the sum of each column (i.e. traverse across rows)
//! For dim = 1, find the sum of each row (i.e. traverse across columns) //! For dim = 1, find the sum of each row (i.e. traverse across columns)
//! The default is dim = 0. //! The default is dim = 0.
//! NOTE: this function works differently than in Matlab/Octave. //! NOTE: this function works differently than in Matlab/Octave.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_prod> const Op<T1, op_prod>
prod(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) prod(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_prod>(X.get_ref(), dim, 0); return Op<T1, op_prod>(X.get_ref(), dim, 0);
} }
//! \brief //! \brief
//! Immediate 'product of all values' operation for a row vector //! Immediate 'product of all values' operation for a row vector
template<typename eT> template<typename eT>
inline inline
skipping to change at line 83 skipping to change at line 83
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
return arrayops::product( X.memptr(), X.n_elem ); return arrayops::product( X.memptr(), X.n_elem );
} }
template<typename T1> template<typename T1>
inline inline
const Op<Op<T1, op_prod>, op_prod> const Op<Op<T1, op_prod>, op_prod>
prod(const Op<T1, op_prod>& in, const u32 dim) prod(const Op<T1, op_prod>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<Op<T1, op_prod>, op_prod>(in, dim, 0); return Op<Op<T1, op_prod>, op_prod>(in, dim, 0);
} }
//! product of all values of a subview_row //! product of all values of a subview_row
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
prod(const subview_row<eT>& S) prod(const subview_row<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& X = S.m; const Mat<eT>& X = S.m;
const u32 n_elem = S.n_elem; const uword n_elem = S.n_elem;
const u32 row = S.aux_row1; const uword row = S.aux_row1;
const u32 start_col = S.aux_col1; const uword start_col = S.aux_col1;
const u32 end_col_plus_1 = start_col + S.n_cols; const uword end_col_plus_1 = start_col + S.n_cols;
eT val = eT(1); eT val = eT(1);
if(n_elem > 0) if(n_elem > 0)
{ {
for(u32 col=start_col; col<end_col_plus_1; ++col) for(uword col=start_col; col<end_col_plus_1; ++col)
{ {
val *= X.at(row,col); val *= X.at(row,col);
} }
} }
return val; return val;
} }
//! product of all values of a subview_col //! product of all values of a subview_col
template<typename eT> template<typename eT>
skipping to change at line 140 skipping to change at line 140
//! product of all values of a diagview //! product of all values of a diagview
template<typename eT> template<typename eT>
arma_warn_unused arma_warn_unused
inline inline
eT eT
prod(const diagview<eT>& X) prod(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT val = eT(1); eT val = eT(1);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
val *= X[i]; val *= X[i];
} }
return val; return val;
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
 End of changes. 6 change blocks. 
9 lines changed or deleted 9 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
skipping to change at line 33 skipping to change at line 33
template<typename eT> template<typename eT>
inline inline
typename arma_scalar_only<eT>::result typename arma_scalar_only<eT>::result
randn() randn()
{ {
return eT(eop_aux_randn<eT>()); return eT(eop_aux_randn<eT>());
} }
//! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance) //! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<colvec, eop_randn> const Gen<vec::elem_type, gen_randn>
randn(const u32 n_elem) randn(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randn>(n_elem, 1); return Gen<vec::elem_type, gen_randn>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_randn> const Gen<typename vec_type::elem_type, gen_randn>
randn(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), randn(const uword n_elem, const arma_empty_class junk1 = arma_empty_class()
const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) , const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_randn>(1, n_elem); return Gen<typename vec_type::elem_type, gen_randn>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_randn>(n_elem, 1); return Gen<typename vec_type::elem_type, gen_randn>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance) //! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<mat, eop_randn> const Gen<mat::elem_type, gen_randn>
randn(const u32 n_rows, const u32 n_cols) randn(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_randn>(n_rows, n_cols); return Gen<mat::elem_type, gen_randn>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_randn> const Gen<typename mat_type::elem_type, gen_randn>
randn(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o randn(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R
nly<mat_type>::result* junk = 0) ow_only<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_randn>(n_rows, n_cols); return Gen<typename mat_type::elem_type, gen_randn>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_randn> const GenCube<cube::elem_type, gen_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices) randn(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_randn>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_randn>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_randn> const GenCube<typename cube_type::elem_type, gen_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam randn(const uword n_rows, const uword n_cols, const uword n_slices, const t
e arma_Cube_only<cube_type>::result* junk = 0) ypename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_randn>(n_rows, n_cols, n_slices); return GenCube<typename cube_type::elem_type, gen_randn>(n_rows, n_cols, n_slices);
} }
//! @} //! @}
 End of changes. 14 change blocks. 
23 lines changed or deleted 22 lines changed or added


 fn_randu.hpp   fn_randu.hpp 
skipping to change at line 33 skipping to change at line 33
template<typename eT> template<typename eT>
inline inline
typename arma_scalar_only<eT>::result typename arma_scalar_only<eT>::result
randu() randu()
{ {
return eT(eop_aux_randu<eT>()); return eT(eop_aux_randu<eT>());
} }
//! Generate a vector with all elements set to random values in the [0,1] i nterval (uniform distribution) //! Generate a vector with all elements set to random values in the [0,1] i nterval (uniform distribution)
arma_inline arma_inline
const eOp<colvec, eop_randu> const Gen<vec::elem_type, gen_randu>
randu(const u32 n_elem) randu(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randu>(n_elem, 1); return Gen<vec::elem_type, gen_randu>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_randu> const Gen<typename vec_type::elem_type, gen_randu>
randu(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), randu(const uword n_elem, const arma_empty_class junk1 = arma_empty_class()
const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) , const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_randu>(1, n_elem); return Gen<typename vec_type::elem_type, gen_randu>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_randu>(n_elem, 1); return Gen<typename vec_type::elem_type, gen_randu>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to random values in the [ 0,1] interval (uniform distribution) //! Generate a dense matrix with all elements set to random values in the [ 0,1] interval (uniform distribution)
arma_inline arma_inline
const eOp<mat, eop_randu> const Gen<mat::elem_type, gen_randu>
randu(const u32 n_rows, const u32 n_cols) randu(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_randu>(n_rows, n_cols); return Gen<mat::elem_type, gen_randu>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_randu> const Gen<typename mat_type::elem_type, gen_randu>
randu(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o randu(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R
nly<mat_type>::result* junk = 0) ow_only<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_randu>(n_rows, n_cols); return Gen<typename mat_type::elem_type, gen_randu>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_randu> const GenCube<cube::elem_type, gen_randu>
randu(const u32 n_rows, const u32 n_cols, const u32 n_slices) randu(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_randu>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_randu>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_randu> const GenCube<typename cube_type::elem_type, gen_randu>
randu(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam randu(const uword n_rows, const uword n_cols, const uword n_slices, const t
e arma_Cube_only<cube_type>::result* junk = 0) ypename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_randu>(n_rows, n_cols, n_slices); return GenCube<typename cube_type::elem_type, gen_randu>(n_rows, n_cols, n_slices);
} }
//! @} //! @}
 End of changes. 13 change blocks. 
22 lines changed or deleted 22 lines changed or added


 fn_rank.hpp   fn_rank.hpp 
skipping to change at line 21 skipping to change at line 21
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_rank //! \addtogroup fn_rank
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
u32 uword
rank rank
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
typename T1::pod_type tol = 0.0, typename T1::pod_type tol = 0.0,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
u32 X_n_rows; uword X_n_rows;
u32 X_n_cols; uword X_n_cols;
Col<T> s; Col<T> s;
const bool status = auxlib::svd(s, X, X_n_rows, X_n_cols); const bool status = auxlib::svd(s, X, X_n_rows, X_n_cols);
const u32 n_elem = s.n_elem; const uword n_elem = s.n_elem;
if(status == true) if(status == true)
{ {
if( (tol == T(0)) && (n_elem > 0) ) if( (tol == T(0)) && (n_elem > 0) )
{ {
tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s)); tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s));
} }
// count non zero valued elements in s // count non zero valued elements in s
const T* s_mem = s.memptr(); const T* s_mem = s.memptr();
u32 count = 0; uword count = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
if(s_mem[i] > tol) if(s_mem[i] > tol)
{ {
++count; ++count;
} }
} }
return count; return count;
} }
else else
{ {
arma_bad("rank(): failed to converge"); arma_bad("rank(): failed to converge");
return u32(0); return uword(0);
} }
} }
//! @} //! @}
 End of changes. 6 change blocks. 
7 lines changed or deleted 7 lines changed or added


 fn_repmat.hpp   fn_repmat.hpp 
skipping to change at line 22 skipping to change at line 22
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_repmat //! \addtogroup fn_repmat
//! @{ //! @{
//! \brief //! \brief
//! delayed 'repeat matrix' construction of a matrix //! delayed 'repeat matrix' construction of a matrix
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_repmat> const Op<T1, op_repmat>
repmat(const Base<typename T1::elem_type,T1>& A, const u32 r, const u32 c) repmat(const Base<typename T1::elem_type,T1>& A, const uword r, const uword c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_repmat>(A.get_ref(), r, c); return Op<T1, op_repmat>(A.get_ref(), r, c);
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_reshape.hpp   fn_reshape.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_reshape //! \addtogroup fn_reshape
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_reshape> const Op<T1, op_reshape>
reshape(const Base<typename T1::elem_type,T1>& X, const u32 in_n_rows, cons t u32 in_n_cols, const u32 dim = 0) reshape(const Base<typename T1::elem_type,T1>& X, const uword in_n_rows, co nst uword in_n_cols, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
return Op<T1, op_reshape>(X.get_ref(), eT(dim), in_n_rows, in_n_cols); return Op<T1, op_reshape>(X.get_ref(), in_n_rows, in_n_cols, dim, 'j');
} }
template<typename T1> template<typename T1>
inline inline
const OpCube<T1, op_reshape> const OpCube<T1, op_reshape>
reshape(const BaseCube<typename T1::elem_type,T1>& X, const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_slices, const u32 dim = 0) reshape(const BaseCube<typename T1::elem_type,T1>& X, const uword in_n_rows , const uword in_n_cols, const uword in_n_slices, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
return OpCube<T1, op_reshape>(X.get_ref(), eT(dim), in_n_rows, in_n_cols, in_n_slices); return OpCube<T1, op_reshape>(X.get_ref(), in_n_rows, in_n_cols, in_n_sli ces, dim, 'j');
} }
//! @} //! @}
 End of changes. 5 change blocks. 
6 lines changed or deleted 6 lines changed or added


 fn_shuffle.hpp   fn_shuffle.hpp 
skipping to change at line 25 skipping to change at line 25
//! @{ //! @{
//! \brief //! \brief
//! Shuffle the rows or the columns of a matrix or vector in random fashion . //! Shuffle the rows or the columns of a matrix or vector in random fashion .
//! If dim = 0, shuffle the columns (default operation). //! If dim = 0, shuffle the columns (default operation).
//! If dim = 1, shuffle the rows. //! If dim = 1, shuffle the rows.
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_shuffle> const Op<T1, op_shuffle>
shuffle(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) shuffle(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (dim > 1), "shuffle(): dim must be 0 or 1"); arma_debug_check( (dim > 1), "shuffle(): dim must be 0 or 1");
return Op<T1, op_shuffle>(X.get_ref(), dim, 0); return Op<T1, op_shuffle>(X.get_ref(), dim, 0);
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_solve.hpp   fn_solve.hpp 
skipping to change at line 56 skipping to change at line 56
const Op<T1, op_trimat>& A, const Op<T1, op_trimat>& A,
const Base<typename T1::elem_type,T2>& B, const Base<typename T1::elem_type,T2>& B,
const bool slow = false, const bool slow = false,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(slow); arma_ignore(slow);
arma_ignore(junk); arma_ignore(junk);
return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_u32_a); return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_uword_a);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
bool bool
solve solve
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B, const Base<typename T1::elem_type,T2>& B,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_sort.hpp   fn_sort.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_sort //! \addtogroup fn_sort
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_sort> const Op<T1, op_sort>
sort(const Base<typename T1::elem_type,T1>& X, const u32 sort_type = 0, con st u32 dim = 0) sort(const Base<typename T1::elem_type,T1>& X, const uword sort_type = 0, c onst uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_sort>(X.get_ref(), sort_type, dim); return Op<T1, op_sort>(X.get_ref(), sort_type, dim);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Col<eT>, op_sort> const Op<Col<eT>, op_sort>
sort(const Col<eT>& X, const u32 sort_type = 0) sort(const Col<eT>& X, const uword sort_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 dim = 0; const uword dim = 0;
return Op<Col<eT>, op_sort>(X, sort_type, dim); return Op<Col<eT>, op_sort>(X, sort_type, dim);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Row<eT>, op_sort> const Op<Row<eT>, op_sort>
sort(const Row<eT>& X, const u32 sort_type = 0) sort(const Row<eT>& X, const uword sort_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 dim = 1; const uword dim = 1;
return Op<Row<eT>, op_sort>(X, sort_type, dim); return Op<Row<eT>, op_sort>(X, sort_type, dim);
} }
//! @} //! @}
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 fn_sort_index.hpp   fn_sort_index.hpp 
skipping to change at line 53 skipping to change at line 53
return A.val > B.val; return A.val > B.val;
} }
template<typename umat_elem_type, typename packet_type, typename eT> template<typename umat_elem_type, typename packet_type, typename eT>
void void
inline inline
sort_index_helper(umat_elem_type* out_mem, std::vector<packet_type>& packet _vec, const eT* in_mem) sort_index_helper(umat_elem_type* out_mem, std::vector<packet_type>& packet _vec, const eT* in_mem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = packet_vec.size(); const uword n_elem = packet_vec.size();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
packet_vec[i].val = in_mem[i]; packet_vec[i].val = in_mem[i];
packet_vec[i].index = i; packet_vec[i].index = i;
} }
std::sort( packet_vec.begin(), packet_vec.end() ); std::sort( packet_vec.begin(), packet_vec.end() );
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = packet_vec[i].index; out_mem[i] = packet_vec[i].index;
} }
} }
template<typename T1> template<typename T1>
inline inline
umat umat
sort_index(const Base<typename T1::elem_type,T1>& X, const u32 sort_type = 0) sort_index(const Base<typename T1::elem_type,T1>& X, const uword sort_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_type_check< is_complex<eT>::value == true>::apply(); arma_type_check(( is_complex<eT>::value == true ));
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
if(A.is_empty() == true) if(A.is_empty() == true)
{ {
return umat(); return umat();
} }
arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha ndles vectors"); arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha ndles vectors");
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 fn_stddev.hpp   fn_stddev.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_stddev //! \addtogroup fn_stddev
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const mtOp<typename T1::pod_type, T1, op_stddev> const mtOp<typename T1::pod_type, T1, op_stddev>
stddev(const Base<typename T1::elem_type,T1>& X, const u32 norm_type = 0, c onst u32 dim = 0) stddev(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type, dim); return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type, dim);
} }
//! Immediate 'find the standard deviation of a row vector' operation //! Immediate 'find the standard deviation of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const Row<eT>& A, const u32 norm_type = 0) stddev(const Row<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element s" ); arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) );
} }
//! Immediate 'find the standard deviation of a column vector' operation //! Immediate 'find the standard deviation of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const Col<eT>& A, const u32 norm_type = 0) stddev(const Col<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element s" ); arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) );
} }
//! find the standard deviation of a subview_row //! find the standard deviation of a subview_row
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const subview_row<eT>& A, const u32 norm_type = 0) stddev(const subview_row<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" ); arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A, norm_type) ); return std::sqrt( op_var::direct_var(A, norm_type) );
} }
//! find the standard deviation of a subview_col //! find the standard deviation of a subview_col
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const subview_col<eT>& A, const u32 norm_type = 0) stddev(const subview_col<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" ); arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) ); return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) );
} }
//! find the standard deviation of a diagview //! find the standard deviation of a diagview
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const diagview<eT>& A, const u32 norm_type = 0) stddev(const diagview<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" ); arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A, norm_type) ); return std::sqrt( op_var::direct_var(A, norm_type) );
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const subview_elem1<eT,T1>& A, const u32 norm_type = 0) stddev(const subview_elem1<eT,T1>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Col<eT> X(A); const Col<eT> X(A);
return stddev(X, norm_type); return stddev(X, norm_type);
} }
//! @} //! @}
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added


 fn_sum.hpp   fn_sum.hpp 
skipping to change at line 27 skipping to change at line 27
//! Delayed sum of elements of a matrix along a specified dimension (either rows or columns). //! Delayed sum of elements of a matrix along a specified dimension (either rows or columns).
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! For dim = 0, find the sum of each column. //! For dim = 0, find the sum of each column.
//! For dim = 1, find the sum of each row. //! For dim = 1, find the sum of each row.
//! The default is dim = 0. //! The default is dim = 0.
//! NOTE: this function works differently than in Matlab/Octave. //! NOTE: this function works differently than in Matlab/Octave.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_sum> const Op<T1, op_sum>
sum(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) sum(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_sum>(X.get_ref(), dim, 0); return Op<T1, op_sum>(X.get_ref(), dim, 0);
} }
//! \brief //! \brief
//! Immediate 'sum all values' operation for a row vector //! Immediate 'sum all values' operation for a row vector
template<typename eT> template<typename eT>
inline inline
skipping to change at line 79 skipping to change at line 79
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("sum(): two consecutive sum() calls detected"); arma_extra_debug_print("sum(): two consecutive sum() calls detected");
return accu(in.m); return accu(in.m);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<Op<T1, op_sum>, op_sum> const Op<Op<T1, op_sum>, op_sum>
sum(const Op<T1, op_sum>& in, const u32 dim) sum(const Op<T1, op_sum>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<Op<T1, op_sum>, op_sum>(in, dim, 0); return Op<Op<T1, op_sum>, op_sum>(in, dim, 0);
} }
//! sum all values of a subview_row //! sum all values of a subview_row
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_svd.hpp   fn_svd.hpp 
skipping to change at line 134 skipping to change at line 134
( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ), ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ),
"svd_econ(): two or more output objects are the same object" "svd_econ(): two or more output objects are the same object"
); );
arma_debug_check arma_debug_check
( (
( (mode != 'l') && (mode != 'r') && (mode != 'b') ), ( (mode != 'l') && (mode != 'r') && (mode != 'b') ),
"svd_econ(): parameter 'mode' is incorrect" "svd_econ(): parameter 'mode' is incorrect"
); );
// auxlib::svd_thin() makes an internal copy of X // auxlib::svd_econ() makes an internal copy of X
const bool status = auxlib::svd_thin(U, S, V, X, mode); const bool status = auxlib::svd_econ(U, S, V, X, mode);
if(status == false) if(status == false)
{ {
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
arma_bad("svd_econ(): failed to converge", false); arma_bad("svd_econ(): failed to converge", false);
} }
return status; return status;
} }
template<typename T1> template<typename T1>
arma_deprecated
inline inline
bool bool
svd_thin svd_thin
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char mode = 'b', const char mode = 'b',
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
 End of changes. 2 change blocks. 
2 lines changed or deleted 3 lines changed or added


 fn_trace.hpp   fn_trace.hpp 
skipping to change at line 31 skipping to change at line 31
trace(const Base<typename T1::elem_type,T1>& X) trace(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 Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
arma_debug_check( (A.get_n_rows() != A.get_n_cols()), "trace(): matrix mu st be square sized" ); arma_debug_check( (A.get_n_rows() != A.get_n_cols()), "trace(): matrix mu st be square sized" );
const u32 N = A.get_n_rows(); const uword N = A.get_n_rows();
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
val += A.at(i,i); val += A.at(i,i);
} }
return val; return val;
} }
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
trace(const Op<T1, op_diagmat>& X) trace(const Op<T1, op_diagmat>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const diagmat_proxy<T1> A(X.m); const diagmat_proxy<T1> A(X.m);
const u32 N = A.n_elem; const uword N = A.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
val += A[i]; val += A[i];
} }
return val; return val;
} }
//! speedup for trace(A*B), where the result of A*B is a square sized matri x //! speedup for trace(A*B), where the result of A*B is a square sized matri x
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 87 skipping to change at line 87
const unwrap<T1> tmp1(X.A); const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B); const unwrap<T2> tmp2(X.B);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A, B, "matrix multiply"); arma_debug_assert_mul_size(A, B, "matrix multiply");
arma_debug_check( (A.n_rows != B.n_cols), "trace(): matrix must be square sized" ); arma_debug_check( (A.n_rows != B.n_cols), "trace(): matrix must be square sized" );
const u32 N1 = A.n_rows; const uword N1 = A.n_rows;
const u32 N2 = A.n_cols; const uword N2 = A.n_cols;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<N1; ++i) for(uword i=0; i<N1; ++i)
{ {
const eT* B_colmem = B.colptr(i); const eT* B_colmem = B.colptr(i);
eT acc = eT(0); eT acc = eT(0);
for(u32 j=0; j<N2; ++j) for(uword j=0; j<N2; ++j)
{ {
acc += A.at(i,j) * B_colmem[j]; acc += A.at(i,j) * B_colmem[j];
} }
val += acc; val += acc;
} }
return val; return val;
} }
 End of changes. 7 change blocks. 
8 lines changed or deleted 8 lines changed or added


 fn_var.hpp   fn_var.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_var //! \addtogroup fn_var
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const mtOp<typename T1::pod_type, T1, op_var> const mtOp<typename T1::pod_type, T1, op_var>
var(const Base<typename T1::elem_type,T1>& X, const u32 norm_type = 0, cons t u32 dim = 0) var(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, co nst uword dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<typename T1::pod_type, T1, op_var>(X.get_ref(), norm_type, di m); return mtOp<typename T1::pod_type, T1, op_var>(X.get_ref(), norm_type, di m);
} }
//! Immediate 'find the variance of a row vector' operation //! Immediate 'find the variance of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const Row<eT>& A, const u32 norm_type = 0) var(const Row<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "var(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A.mem, A_n_elem, norm_type); return op_var::direct_var(A.mem, A_n_elem, norm_type);
} }
//! Immediate 'find the variance of a column vector' operation //! Immediate 'find the variance of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const Col<eT>& A, const u32 norm_type = 0) var(const Col<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "var(): given object has no elements" ); arma_debug_check( (A_n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A.mem, A_n_elem, norm_type); return op_var::direct_var(A.mem, A_n_elem, norm_type);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const subview_row<eT>& A, const u32 norm_type = 0) var(const subview_row<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" ); arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A, norm_type); return op_var::direct_var(A, norm_type);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const subview_col<eT>& A, const u32 norm_type = 0) var(const subview_col<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" ); arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A.colptr(0), A.n_rows, norm_type); return op_var::direct_var(A.colptr(0), A.n_rows, norm_type);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const diagview<eT>& A, const u32 norm_type = 0) var(const diagview<eT>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" ); arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A, norm_type); return op_var::direct_var(A, norm_type);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const subview_elem1<eT,T1>& A, const u32 norm_type = 0) var(const subview_elem1<eT,T1>& A, const uword norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Col<eT> X(A); const Col<eT> X(A);
return var(X, norm_type); return var(X, norm_type);
} }
//! @} //! @}
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
skipping to change at line 18 skipping to change at line 18
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_zeros //! \addtogroup fn_zeros
//! @{ //! @{
//! Generate a vector with all elements set to zero //! Generate a vector with all elements set to zero
arma_inline arma_inline
const eOp<colvec, eop_zeros> const Gen<vec::elem_type, gen_zeros>
zeros(const u32 n_elem) zeros(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_zeros>(n_elem, 1); return Gen<vec::elem_type, gen_zeros>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_zeros> const Gen<typename vec_type::elem_type, gen_zeros>
zeros(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), zeros(const uword n_elem, const arma_empty_class junk1 = arma_empty_class()
const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) , const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_zeros>(1, n_elem); return Gen<typename vec_type::elem_type, gen_zeros>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_zeros>(n_elem, 1); return Gen<typename vec_type::elem_type, gen_zeros>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to zero //! Generate a dense matrix with all elements set to zero
arma_inline arma_inline
const eOp<mat, eop_zeros> const Gen<mat::elem_type, gen_zeros>
zeros(const u32 n_rows, const u32 n_cols) zeros(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_zeros>(n_rows, n_cols); return Gen<mat::elem_type, gen_zeros>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_zeros> const Gen<typename mat_type::elem_type, gen_zeros>
zeros(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o zeros(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R
nly<mat_type>::result* junk = 0) ow_only<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_zeros>(n_rows, n_cols); return Gen<typename mat_type::elem_type, gen_zeros>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_zeros> const GenCube<cube::elem_type, gen_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices) zeros(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_zeros>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_zeros> const GenCube<typename cube_type::elem_type, gen_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam zeros(const uword n_rows, const uword n_cols, const uword n_slices, const t
e arma_Cube_only<cube_type>::result* junk = 0) ypename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_zeros>(n_rows, n_cols, n_slices); return GenCube<typename cube_type::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
} }
//! @} //! @}
 End of changes. 13 change blocks. 
22 lines changed or deleted 22 lines changed or added


 format_wrap.hpp   format_wrap.hpp 
skipping to change at line 416 skipping to change at line 416
} }
} while( (required_size >= buffer_size) ); } while( (required_size >= buffer_size) );
return out; return out;
} }
template<typename T1> template<typename T1>
struct format_metaprog struct format_metaprog
{ {
static const u32 depth = 0; static const uword depth = 0;
inline inline
static static
const std::string& const std::string&
get_fmt(const T1& X) get_fmt(const T1& X)
{ {
return X.A; return X.A;
} }
}; };
//template<> //template<>
template<typename T1, typename T2> template<typename T1, typename T2>
struct format_metaprog< basic_format<T1,T2> > struct format_metaprog< basic_format<T1,T2> >
{ {
static const u32 depth = 1 + format_metaprog<T1>::depth; static const uword depth = 1 + format_metaprog<T1>::depth;
inline inline
static static
const std::string& const std::string&
get_fmt(const T1& X) get_fmt(const T1& X)
{ {
return format_metaprog<T1>::get_fmt(X.A); return format_metaprog<T1>::get_fmt(X.A);
} }
}; };
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 forward_bones.hpp   forward_bones.hpp 
skipping to change at line 73 skipping to change at line 73
class op_rel_lt_post; class op_rel_lt_post;
class op_rel_gt_pre; class op_rel_gt_pre;
class op_rel_gt_post; class op_rel_gt_post;
class op_rel_lteq_pre; class op_rel_lteq_pre;
class op_rel_lteq_post; class op_rel_lteq_post;
class op_rel_gteq_pre; class op_rel_gteq_pre;
class op_rel_gteq_post; class op_rel_gteq_post;
class op_rel_eq; class op_rel_eq;
class op_rel_noteq; class op_rel_noteq;
class gen_ones_diag;
class gen_ones_full;
class gen_zeros;
class gen_randu;
class gen_randn;
template<const bool, const bool, const bool, const bool> class gemm; template<const bool, const bool, const bool, const bool> class gemm;
template<const bool, const bool, const bool> class gemv; template<const bool, const bool, const bool> class gemv;
template< typename eT, typename gen_type> class Gen;
template< typename T1, typename op_type> class Op; template< typename T1, typename op_type> class Op;
template< typename T1, typename eop_type> class eOp; template< typename T1, typename eop_type> class eOp;
template<typename out_eT, typename T1, typename op_type> class mtOp; template<typename out_eT, typename T1, typename op_type> class mtOp;
template< typename T1, typename T2, typename glue_type> cl ass Glue; template< typename T1, typename T2, typename glue_type> cl ass Glue;
template< typename T1, typename T2, typename eglue_type> cl ass eGlue; template< typename T1, typename T2, typename eglue_type> cl ass eGlue;
template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlue; template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlue;
template< typename eT, typename gen_type> class GenCube;
template< typename T1, typename op_type> class OpCube; template< typename T1, typename op_type> class OpCube;
template< typename T1, typename eop_type> class eOpCube; template< typename T1, typename eop_type> class eOpCube;
template<typename out_eT, typename T1, typename op_type> class mtOpCube; template<typename out_eT, typename T1, typename op_type> class mtOpCube;
template< typename T1, typename T2, typename glue_type> cl ass GlueCube; template< typename T1, typename T2, typename glue_type> cl ass GlueCube;
template< typename T1, typename T2, typename eglue_type> cl ass eGlueCube; template< typename T1, typename T2, typename eglue_type> cl ass eGlueCube;
template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlueCube; template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlueCube;
template<typename T1> class Proxy; template<typename T1> class Proxy;
template<typename T1> class ProxyCube; template<typename T1> class ProxyCube;
 End of changes. 3 change blocks. 
0 lines changed or deleted 10 lines changed or added


 gemm.hpp   gemm.hpp 
skipping to change at line 80 skipping to change at line 80
( (
Mat<eT>& C, Mat<eT>& C,
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& 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 u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (do_trans_A == false) && (do_trans_B == false) )
{ {
arma_aligned podarray<eT> tmp(A_n_cols); arma_aligned podarray<eT> tmp(A_n_cols);
eT* A_rowdata = tmp.memptr(); eT* A_rowdata = tmp.memptr();
for(u32 row_A=0; row_A < A_n_rows; ++row_A) for(uword row_A=0; row_A < A_n_rows; ++row_A)
{ {
tmp.copy_row(A, row_A); tmp.copy_row(A, row_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(uword col_B=0; col_B < B_n_cols; ++col_B)
{ {
const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col ptr(col_B)); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col ptr(col_B));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,col_B) = acc; C.at(row_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
skipping to change at line 125 skipping to change at line 125
{ {
C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B); C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B);
} }
} }
} }
} }
else else
if( (do_trans_A == true) && (do_trans_B == false) ) if( (do_trans_A == true) && (do_trans_B == false) )
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
{ {
// col_A is interpreted as row_A when storing the results in matrix C // col_A is interpreted as row_A when storing the results in matrix C
const eT* A_coldata = A.colptr(col_A); const eT* A_coldata = A.colptr(col_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(uword col_B=0; col_B < B_n_cols; ++col_B)
{ {
const eT acc = op_dot::direct_dot_arma(B_n_rows, A_coldata, B.col ptr(col_B)); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_coldata, B.col ptr(col_B));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,col_B) = acc; C.at(col_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
skipping to change at line 178 skipping to change at line 178
{ {
// mat B_tmp = trans(B); // mat B_tmp = trans(B);
// dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta); // dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta);
// By using the trans(A)*trans(B) = trans(B*A) equivalency, // By using the trans(A)*trans(B) = trans(B*A) equivalency,
// transpose operations are not needed // transpose operations are not needed
arma_aligned podarray<eT> tmp(B.n_cols); arma_aligned podarray<eT> tmp(B.n_cols);
eT* B_rowdata = tmp.memptr(); eT* B_rowdata = tmp.memptr();
for(u32 row_B=0; row_B < B_n_rows; ++row_B) for(uword row_B=0; row_B < B_n_rows; ++row_B)
{ {
tmp.copy_row(B, row_B); tmp.copy_row(B, row_B);
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
{ {
const eT acc = op_dot::direct_dot_arma(A_n_rows, B_rowdata, A.col ptr(col_A)); const eT acc = op_dot::direct_dot_arma(A_n_rows, B_rowdata, A.col ptr(col_A));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,row_B) = acc; C.at(col_A,row_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
skipping to change at line 237 skipping to change at line 237
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& 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 u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) ) if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) )
{ {
if(do_trans_B == false) if(do_trans_B == false)
{ {
gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, B, a lpha, beta); gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, B, a lpha, beta);
} }
else else
{ {
Mat<eT> BB(A_n_rows, A_n_rows); Mat<eT> BB(A_n_rows, A_n_rows);
skipping to change at line 299 skipping to change at line 299
} }
if(do_trans_B) if(do_trans_B)
{ {
op_htrans::apply_noalias(tmp_B, B); op_htrans::apply_noalias(tmp_B, B);
} }
const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A; const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A;
const Mat<eT>& BB = (do_trans_B == false) ? B : tmp_B; const Mat<eT>& BB = (do_trans_B == false) ? B : tmp_B;
const u32 A_n_rows = AA.n_rows; const uword A_n_rows = AA.n_rows;
const u32 A_n_cols = AA.n_cols; const uword A_n_cols = AA.n_cols;
const u32 B_n_rows = BB.n_rows; const uword B_n_rows = BB.n_rows;
const u32 B_n_cols = BB.n_cols; const uword B_n_cols = BB.n_cols;
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) ) if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) )
{ {
gemm_emul_tinysq<false, use_alpha, use_beta>::apply(C, AA, BB, alpha, beta); gemm_emul_tinysq<false, use_alpha, use_beta>::apply(C, AA, BB, alpha, beta);
} }
else else
{ {
gemm_emul_large<false, false, use_alpha, use_beta>::apply(C, AA, BB, alpha, beta); gemm_emul_large<false, false, use_alpha, use_beta>::apply(C, AA, BB, alpha, beta);
} }
} }
 End of changes. 12 change blocks. 
18 lines changed or deleted 18 lines changed or added


 gemm_mixed.hpp   gemm_mixed.hpp 
skipping to change at line 42 skipping to change at line 42
( (
Mat<out_eT>& C, Mat<out_eT>& C,
const Mat<in_eT1>& A, const Mat<in_eT1>& A,
const Mat<in_eT2>& B, const Mat<in_eT2>& B,
const out_eT alpha = out_eT(1), const out_eT alpha = out_eT(1),
const out_eT beta = out_eT(0) const out_eT beta = out_eT(0)
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (do_trans_A == false) && (do_trans_B == false) )
{ {
podarray<in_eT1> tmp(A_n_cols); podarray<in_eT1> tmp(A_n_cols);
in_eT1* A_rowdata = tmp.memptr(); in_eT1* A_rowdata = tmp.memptr();
for(u32 row_A=0; row_A < A_n_rows; ++row_A) for(uword row_A=0; row_A < A_n_rows; ++row_A)
{ {
tmp.copy_row(A, row_A); tmp.copy_row(A, row_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(uword col_B=0; col_B < B_n_cols; ++col_B)
{ {
const in_eT2* B_coldata = B.colptr(col_B); const in_eT2* B_coldata = B.colptr(col_B);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < B_n_rows; ++i) for(uword i=0; i < B_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(A_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(A_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]);
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,col_B) = acc; C.at(row_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
skipping to change at line 93 skipping to change at line 93
{ {
C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B); C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B);
} }
} }
} }
} }
else else
if( (do_trans_A == true) && (do_trans_B == false) ) if( (do_trans_A == true) && (do_trans_B == false) )
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
{ {
// col_A is interpreted as row_A when storing the results in matrix C // col_A is interpreted as row_A when storing the results in matrix C
const in_eT1* A_coldata = A.colptr(col_A); const in_eT1* A_coldata = A.colptr(col_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(uword col_B=0; col_B < B_n_cols; ++col_B)
{ {
const in_eT2* B_coldata = B.colptr(col_B); const in_eT2* B_coldata = B.colptr(col_B);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < B_n_rows; ++i) for(uword i=0; i < B_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(A_coldata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(A_coldata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]);
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,col_B) = acc; C.at(col_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
skipping to change at line 153 skipping to change at line 153
{ {
// mat B_tmp = trans(B); // mat B_tmp = trans(B);
// dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta); // dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta);
// By using the trans(A)*trans(B) = trans(B*A) equivalency, // By using the trans(A)*trans(B) = trans(B*A) equivalency,
// transpose operations are not needed // transpose operations are not needed
podarray<in_eT2> tmp(B_n_cols); podarray<in_eT2> tmp(B_n_cols);
in_eT2* B_rowdata = tmp.memptr(); in_eT2* B_rowdata = tmp.memptr();
for(u32 row_B=0; row_B < B_n_rows; ++row_B) for(uword row_B=0; row_B < B_n_rows; ++row_B)
{ {
tmp.copy_row(B, row_B); tmp.copy_row(B, row_B);
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
{ {
const in_eT1* A_coldata = A.colptr(col_A); const in_eT1* A_coldata = A.colptr(col_A);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < A_n_rows; ++i) for(uword i=0; i < A_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(B_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(A_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(B_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(A_coldata[i]);
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,row_B) = acc; C.at(col_A,row_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
skipping to change at line 219 skipping to change at line 219
( (
Mat<out_eT>& C, Mat<out_eT>& C,
const Mat<in_eT1>& A, const Mat<in_eT1>& A,
const Mat<in_eT2>& B, const Mat<in_eT2>& B,
const out_eT alpha = out_eT(1), const out_eT alpha = out_eT(1),
const out_eT beta = out_eT(0) const out_eT beta = out_eT(0)
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (do_trans_A == false) && (do_trans_B == false) )
{ {
for(u32 row_A = 0; row_A < A_n_rows; ++row_A) for(uword row_A = 0; row_A < A_n_rows; ++row_A)
{ {
for(u32 col_B = 0; col_B < B_n_cols; ++col_B) for(uword col_B = 0; col_B < B_n_cols; ++col_B)
{ {
const in_eT2* B_coldata = B.colptr(col_B); const in_eT2* B_coldata = B.colptr(col_B);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i = 0; i < B_n_rows; ++i) for(uword i = 0; i < B_n_rows; ++i)
{ {
const out_eT val1 = upgrade_val<in_eT1,in_eT2>::apply(A.at(row_ A,i)); const out_eT val1 = upgrade_val<in_eT1,in_eT2>::apply(A.at(row_ A,i));
const out_eT val2 = upgrade_val<in_eT1,in_eT2>::apply(B_coldata [i]); const out_eT val2 = upgrade_val<in_eT1,in_eT2>::apply(B_coldata [i]);
acc += val1 * val2; acc += val1 * val2;
//acc += upgrade_val<in_eT1,in_eT2>::apply(A.at(row_A,i)) * upg rade_val<in_eT1,in_eT2>::apply(B_coldata[i]); //acc += upgrade_val<in_eT1,in_eT2>::apply(A.at(row_A,i)) * upg rade_val<in_eT1,in_eT2>::apply(B_coldata[i]);
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,col_B) = acc; C.at(row_A,col_B) = acc;
skipping to change at line 267 skipping to change at line 267
if( (use_alpha == true) && (use_beta == true) ) if( (use_alpha == true) && (use_beta == true) )
{ {
C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B); C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B);
} }
} }
} }
} }
else else
if( (do_trans_A == true) && (do_trans_B == false) ) if( (do_trans_A == true) && (do_trans_B == false) )
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
{ {
// col_A is interpreted as row_A when storing the results in matrix C // col_A is interpreted as row_A when storing the results in matrix C
const in_eT1* A_coldata = A.colptr(col_A); const in_eT1* A_coldata = A.colptr(col_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(uword col_B=0; col_B < B_n_cols; ++col_B)
{ {
const in_eT2* B_coldata = B.colptr(col_B); const in_eT2* B_coldata = B.colptr(col_B);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < B_n_rows; ++i) for(uword i=0; i < B_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(A_coldata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(A_coldata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]);
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,col_B) = acc; C.at(col_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
skipping to change at line 309 skipping to change at line 309
{ {
C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B);
} }
} }
} }
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) ) if( (do_trans_A == false) && (do_trans_B == true) )
{ {
for(u32 row_A = 0; row_A < A_n_rows; ++row_A) for(uword row_A = 0; row_A < A_n_rows; ++row_A)
{ {
for(u32 row_B = 0; row_B < B_n_rows; ++row_B) for(uword row_B = 0; row_B < B_n_rows; ++row_B)
{ {
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i = 0; i < B_n_cols; ++i) for(uword i = 0; i < B_n_cols; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(A.at(row_A,i)) * upgra de_val<in_eT1,in_eT2>::apply(B.at(row_B,i)); acc += upgrade_val<in_eT1,in_eT2>::apply(A.at(row_A,i)) * upgra de_val<in_eT1,in_eT2>::apply(B.at(row_B,i));
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,row_B) = acc; C.at(row_A,row_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
skipping to change at line 344 skipping to change at line 344
if( (use_alpha == true) && (use_beta == true) ) if( (use_alpha == true) && (use_beta == true) )
{ {
C.at(row_A,row_B) = alpha*acc + beta*C.at(row_A,row_B); C.at(row_A,row_B) = alpha*acc + beta*C.at(row_A,row_B);
} }
} }
} }
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) ) if( (do_trans_A == true) && (do_trans_B == true) )
{ {
for(u32 row_B=0; row_B < B_n_rows; ++row_B) for(uword row_B=0; row_B < B_n_rows; ++row_B)
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
{ {
const in_eT1* A_coldata = A.colptr(col_A); const in_eT1* A_coldata = A.colptr(col_A);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < A_n_rows; ++i) for(uword i=0; i < A_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(B.at(row_B,i)) * upgra de_val<in_eT1,in_eT2>::apply(A_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(B.at(row_B,i)) * upgra de_val<in_eT1,in_eT2>::apply(A_coldata[i]);
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,row_B) = acc; C.at(col_A,row_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
 End of changes. 25 change blocks. 
29 lines changed or deleted 29 lines changed or added


 gemv.hpp   gemv.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup gemv //! \addtogroup gemv
//! @{ //! @{
//! 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 gemv_emul_tinysq class gemv_emul_tinysq
{ {
public: public:
template<const u32 row, const u32 col> template<const uword row, const uword col>
struct pos struct pos
{ {
static const u32 n2 = (do_trans_A == false) ? (row + col*2) : (col + ro static const uword n2 = (do_trans_A == false) ? (row + col*2) : (col +
w*2); row*2);
static const u32 n3 = (do_trans_A == false) ? (row + col*3) : (col + ro static const uword n3 = (do_trans_A == false) ? (row + col*3) : (col +
w*3); row*3);
static const u32 n4 = (do_trans_A == false) ? (row + col*4) : (col + ro static const uword n4 = (do_trans_A == false) ? (row + col*4) : (col +
w*4); row*4);
}; };
template<typename eT, const u32 i> template<typename eT, const uword i>
arma_hot arma_hot
arma_inline arma_inline
static static
void void
assign(eT* y, const eT acc, const eT alpha, const eT beta) assign(eT* y, const eT acc, const eT alpha, const eT beta)
{ {
if(use_beta == false) if(use_beta == false)
{ {
y[i] = (use_alpha == false) ? acc : alpha*acc; y[i] = (use_alpha == false) ? acc : alpha*acc;
} }
skipping to change at line 143 skipping to change at line 143
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) ) apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 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.mem, x);
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
y[0] = acc; y[0] = acc;
skipping to change at line 173 skipping to change at line 173
{ {
y[0] = acc + beta*y[0]; y[0] = acc + beta*y[0];
} }
else else
if( (use_alpha == true) && (use_beta == true) ) if( (use_alpha == true) && (use_beta == true) )
{ {
y[0] = alpha*acc + beta*y[0]; y[0] = alpha*acc + beta*y[0];
} }
} }
else else
for(u32 row=0; row < A_n_rows; ++row) for(uword row=0; row < A_n_rows; ++row)
{ {
eT acc = eT(0); eT acc = eT(0);
for(u32 i=0; i < A_n_cols; ++i) for(uword i=0; i < A_n_cols; ++i)
{ {
acc += A.at(row,i) * x[i]; acc += A.at(row,i) * x[i];
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
y[row] = acc; y[row] = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
skipping to change at line 206 skipping to change at line 206
else else
if( (use_alpha == true) && (use_beta == true) ) if( (use_alpha == true) && (use_beta == true) )
{ {
y[row] = alpha*acc + beta*y[row]; y[row] = alpha*acc + beta*y[row];
} }
} }
} }
else else
if(do_trans_A == true) if(do_trans_A == true)
{ {
for(u32 col=0; col < A_n_cols; ++col) for(uword col=0; col < A_n_cols; ++col)
{ {
// col is interpreted as row when storing the results in 'y' // col is interpreted as row when storing the results in 'y'
// const eT* A_coldata = A.colptr(col); // const eT* A_coldata = A.colptr(col);
// //
// eT acc = eT(0); // eT acc = eT(0);
// for(u32 row=0; row < A_n_rows; ++row) // for(uword row=0; row < A_n_rows; ++row)
// { // {
// acc += A_coldata[row] * x[row]; // acc += A_coldata[row] * x[row];
// } // }
const eT acc = op_dot::direct_dot_arma(A_n_rows, A.colptr(col), x); const eT acc = op_dot::direct_dot_arma(A_n_rows, A.colptr(col), x);
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
y[col] = acc; y[col] = acc;
} }
skipping to change at line 261 skipping to change at line 261
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 ) apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 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);
} }
else else
{ {
gemv_emul_large<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alph a, beta); gemv_emul_large<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alph a, beta);
} }
} }
skipping to change at line 292 skipping to change at line 292
Mat<eT> tmp_A; Mat<eT> tmp_A;
if(do_trans_A) if(do_trans_A)
{ {
op_htrans::apply_noalias(tmp_A, A); op_htrans::apply_noalias(tmp_A, A);
} }
const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A; const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A;
const u32 AA_n_rows = AA.n_rows; const uword AA_n_rows = AA.n_rows;
const u32 AA_n_cols = AA.n_cols; const uword AA_n_cols = AA.n_cols;
if( (AA_n_rows <= 4) && (AA_n_rows == AA_n_cols) ) if( (AA_n_rows <= 4) && (AA_n_rows == AA_n_cols) )
{ {
gemv_emul_tinysq<false, use_alpha, use_beta>::apply(y, AA, x, alpha, beta); gemv_emul_tinysq<false, use_alpha, use_beta>::apply(y, AA, x, alpha, beta);
} }
else else
{ {
gemv_emul_large<false, use_alpha, use_beta>::apply(y, AA, x, alpha, b eta); gemv_emul_large<false, use_alpha, use_beta>::apply(y, AA, x, alpha, b eta);
} }
} }
 End of changes. 10 change blocks. 
18 lines changed or deleted 18 lines changed or added


 glue_conv_meat.hpp   glue_conv_meat.hpp 
skipping to change at line 38 skipping to change at line 38
const unwrap_check<T2> B_tmp(X.B, out); const unwrap_check<T2> B_tmp(X.B, out);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), "co nv(): inputs must be vectors" ); arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), "co nv(): inputs must be vectors" );
const Mat<eT>& h = (A.n_elem <= B.n_elem) ? A : B; const Mat<eT>& h = (A.n_elem <= B.n_elem) ? A : B;
const Mat<eT>& x = (A.n_elem <= B.n_elem) ? B : A; const Mat<eT>& x = (A.n_elem <= B.n_elem) ? B : A;
const u32 h_n_elem = h.n_elem; const uword h_n_elem = h.n_elem;
const u32 x_n_elem = x.n_elem; const uword x_n_elem = x.n_elem;
const u32 out_n_elem = h_n_elem + x_n_elem - 1; const uword out_n_elem = h_n_elem + x_n_elem - 1;
if( (h_n_elem == 0) || (x_n_elem == 0) ) if( (h_n_elem == 0) || (x_n_elem == 0) )
{ {
out.reset(); out.reset();
return; return;
} }
(A.n_cols == 1) ? out.set_size(out_n_elem, 1) : out.set_size(1, out_n_ele m); (A.n_cols == 1) ? out.set_size(out_n_elem, 1) : out.set_size(1, out_n_ele m);
const eT* h_mem = h.memptr(); const eT* h_mem = h.memptr();
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 out_i = 0; out_i < (h_n_elem-1); ++out_i) for(uword out_i = 0; out_i < (h_n_elem-1); ++out_i)
{ {
eT acc = eT(0); eT acc = eT(0);
u32 h_i = out_i; uword h_i = out_i;
for(u32 x_i = 0; x_i <= out_i; ++x_i, --h_i) for(uword x_i = 0; x_i <= out_i; ++x_i, --h_i)
{ {
acc += h_mem[h_i] * x_mem[x_i]; acc += h_mem[h_i] * x_mem[x_i];
} }
out_mem[out_i] = acc; out_mem[out_i] = acc;
} }
for(u32 out_i = h_n_elem-1; out_i < out_n_elem - (h_n_elem-1); ++out_i) for(uword out_i = h_n_elem-1; out_i < out_n_elem - (h_n_elem-1); ++out_i)
{ {
eT acc = eT(0); eT acc = eT(0);
u32 h_i = h_n_elem - 1; uword h_i = h_n_elem - 1;
for(u32 x_i = out_i - h_n_elem + 1; x_i <= out_i; ++x_i, --h_i) for(uword x_i = out_i - h_n_elem + 1; x_i <= out_i; ++x_i, --h_i)
{ {
acc += h_mem[h_i] * x_mem[x_i]; acc += h_mem[h_i] * x_mem[x_i];
} }
out_mem[out_i] = acc; out_mem[out_i] = acc;
} }
for(u32 out_i = out_n_elem - (h_n_elem-1); out_i < out_n_elem; ++out_i) for(uword out_i = out_n_elem - (h_n_elem-1); out_i < out_n_elem; ++out_i)
{ {
eT acc = eT(0); eT acc = eT(0);
u32 h_i = h_n_elem - 1; uword h_i = h_n_elem - 1;
for(u32 x_i = out_i - h_n_elem + 1; x_i < x_n_elem; ++x_i, --h_i) for(uword x_i = out_i - h_n_elem + 1; x_i < x_n_elem; ++x_i, --h_i)
{ {
acc += h_mem[h_i] * x_mem[x_i]; acc += h_mem[h_i] * x_mem[x_i];
} }
out_mem[out_i] = acc; out_mem[out_i] = acc;
} }
} }
//! @} //! @}
 End of changes. 10 change blocks. 
12 lines changed or deleted 12 lines changed or added


 glue_cor_bones.hpp   glue_cor_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_cor //! \addtogroup glue_cor
//! @{ //! @{
class glue_cor class glue_cor
{ {
public: public:
template<typename eT> inline static void direct_cor(Mat<eT>& template<typename eT> inline static void direct_cor(Mat<eT>&
out, const Mat<eT>& A, const Mat<eT>& B, c out, const Mat<eT>& A, const Mat<eT>& B, c
onst u32 norm_type); onst uword norm_type);
template<typename T> inline static void direct_cor(Mat< std::complex<T> template<typename T> inline static void direct_cor(Mat< std::complex<T>
>& out, const Mat< std::complex<T> >& A, const Mat< std::complex<T> >& B, c >& out, const Mat< std::complex<T> >& A, const Mat< std::complex<T> >& B, c
onst u32 norm_type); onst uword norm_type);
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_cor>& X); template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_cor>& X);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
6 lines changed or deleted 6 lines changed or added


 glue_cor_meat.hpp   glue_cor_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_cor //! \addtogroup glue_cor
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
glue_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, cons t u32 norm_type) glue_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, cons t uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty() ) if(A.is_empty() || B.is_empty() )
{ {
out.reset(); out.reset();
return; return;
} }
if(A.is_vec() && B.is_vec()) if(A.is_vec() && B.is_vec())
{ {
arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" ); arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" );
const eT* A_ptr = A.memptr(); const eT* A_ptr = A.memptr();
const eT* B_ptr = B.memptr(); const eT* B_ptr = B.memptr();
eT A_acc = eT(0); eT A_acc = eT(0);
eT B_acc = eT(0); eT B_acc = eT(0);
eT out_acc = eT(0); eT out_acc = eT(0);
const u32 N = A.n_elem; const uword N = A.n_elem;
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT A_tmp = A_ptr[i]; const eT A_tmp = A_ptr[i];
const eT B_tmp = B_ptr[i]; const eT B_tmp = B_ptr[i];
A_acc += A_tmp; A_acc += A_tmp;
B_acc += B_tmp; B_acc += B_tmp;
out_acc += A_tmp * B_tmp; out_acc += A_tmp * B_tmp;
} }
skipping to change at line 70 skipping to change at line 70
const Mat<eT> stddev_A = (A.n_rows == 1) ? Mat<eT>(stddev(trans(A))) : Mat<eT>(stddev(A)); const Mat<eT> stddev_A = (A.n_rows == 1) ? Mat<eT>(stddev(trans(A))) : Mat<eT>(stddev(A));
const Mat<eT> stddev_B = (B.n_rows == 1) ? Mat<eT>(stddev(trans(B))) : Mat<eT>(stddev(B)); const Mat<eT> stddev_B = (B.n_rows == 1) ? Mat<eT>(stddev(trans(B))) : Mat<eT>(stddev(B));
out /= stddev_A * stddev_B; out /= stddev_A * stddev_B;
} }
else else
{ {
arma_debug_assert_same_size(A, B, "cor()"); arma_debug_assert_same_size(A, B, "cor()");
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
out = trans(A) * B; out = trans(A) * B;
out -= (trans(sum(A)) * sum(B))/eT(N); out -= (trans(sum(A)) * sum(B))/eT(N);
out /= norm_val; out /= norm_val;
out /= trans(stddev(A)) * stddev(B); out /= trans(stddev(A)) * stddev(B);
} }
} }
template<typename T> template<typename T>
inline inline
void void
glue_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, const Mat< std::complex<T> >& B, const u32 norm_type) glue_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, const Mat< std::complex<T> >& B, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(A.is_empty() || B.is_empty() ) if(A.is_empty() || B.is_empty() )
{ {
out.reset(); out.reset();
return; return;
} }
skipping to change at line 106 skipping to change at line 106
{ {
arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" ); arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" );
const eT* A_ptr = A.memptr(); const eT* A_ptr = A.memptr();
const eT* B_ptr = B.memptr(); const eT* B_ptr = B.memptr();
eT A_acc = eT(0); eT A_acc = eT(0);
eT B_acc = eT(0); eT B_acc = eT(0);
eT out_acc = eT(0); eT out_acc = eT(0);
const u32 N = A.n_elem; const uword N = A.n_elem;
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT A_tmp = A_ptr[i]; const eT A_tmp = A_ptr[i];
const eT B_tmp = B_ptr[i]; const eT B_tmp = B_ptr[i];
A_acc += A_tmp; A_acc += A_tmp;
B_acc += B_tmp; B_acc += B_tmp;
out_acc += std::conj(A_tmp) * B_tmp; out_acc += std::conj(A_tmp) * B_tmp;
} }
skipping to change at line 135 skipping to change at line 135
const Mat<T> stddev_A = (A.n_rows == 1) ? Mat<T>(stddev(trans(A))) : Ma t<T>(stddev(A)); const Mat<T> stddev_A = (A.n_rows == 1) ? Mat<T>(stddev(trans(A))) : Ma t<T>(stddev(A));
const Mat<T> stddev_B = (B.n_rows == 1) ? Mat<T>(stddev(trans(B))) : Ma t<T>(stddev(B)); const Mat<T> stddev_B = (B.n_rows == 1) ? Mat<T>(stddev(trans(B))) : Ma t<T>(stddev(B));
out /= conv_to< Mat<eT> >::from( stddev_A * stddev_B ); out /= conv_to< Mat<eT> >::from( stddev_A * stddev_B );
} }
else else
{ {
arma_debug_assert_same_size(A, B, "cor()"); arma_debug_assert_same_size(A, B, "cor()");
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
out = trans(A) * B; // out = strans(conj(A)) * B; out = trans(A) * B; // out = strans(conj(A)) * B;
out -= (trans(sum(A)) * sum(B))/eT(N); // out -= (strans(conj(sum(A))) * sum(B))/eT(N); out -= (trans(sum(A)) * sum(B))/eT(N); // out -= (strans(conj(sum(A))) * sum(B))/eT(N);
out /= norm_val; out /= norm_val;
out /= conv_to< Mat<eT> >::from( trans(stddev(A)) * stddev(B) ); out /= conv_to< Mat<eT> >::from( trans(stddev(A)) * stddev(B) );
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
skipping to change at line 160 skipping to change at line 160
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> A_tmp(X.A, out); const unwrap_check<T1> A_tmp(X.A, out);
const unwrap_check<T2> B_tmp(X.B, out); const unwrap_check<T2> B_tmp(X.B, out);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
const u32 norm_type = X.aux_u32; const uword norm_type = X.aux_uword;
if(&A != &B) if(&A != &B)
{ {
glue_cor::direct_cor(out, A, B, norm_type); glue_cor::direct_cor(out, A, B, norm_type);
} }
else else
{ {
op_cor::direct_cor(out, A, norm_type); op_cor::direct_cor(out, A, norm_type);
} }
} }
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added


 glue_cov_bones.hpp   glue_cov_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_cov //! \addtogroup glue_cov
//! @{ //! @{
class glue_cov class glue_cov
{ {
public: public:
template<typename eT> inline static void direct_cov(Mat<eT>& template<typename eT> inline static void direct_cov(Mat<eT>&
out, const Mat<eT>& A, const Mat<eT>& B, c out, const Mat<eT>& A, const Mat<eT>& B, c
onst u32 norm_type); onst uword norm_type);
template<typename T> inline static void direct_cov(Mat< std::complex<T> template<typename T> inline static void direct_cov(Mat< std::complex<T>
>& out, const Mat< std::complex<T> >& A, const Mat< std::complex<T> >& B, c >& out, const Mat< std::complex<T> >& A, const Mat< std::complex<T> >& B, c
onst u32 norm_type); onst uword norm_type);
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_cov>& X); template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_cov>& X);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
6 lines changed or deleted 6 lines changed or added


 glue_cov_meat.hpp   glue_cov_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_cov //! \addtogroup glue_cov
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
glue_cov::direct_cov(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, cons t u32 norm_type) glue_cov::direct_cov(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, cons t uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_vec() && B.is_vec()) if(A.is_vec() && B.is_vec())
{ {
arma_debug_check( (A.n_elem != B.n_elem), "cov(): the number of element s in A and B must match" ); arma_debug_check( (A.n_elem != B.n_elem), "cov(): the number of element s in A and B must match" );
const eT* A_ptr = A.memptr(); const eT* A_ptr = A.memptr();
const eT* B_ptr = B.memptr(); const eT* B_ptr = B.memptr();
eT A_acc = eT(0); eT A_acc = eT(0);
eT B_acc = eT(0); eT B_acc = eT(0);
eT out_acc = eT(0); eT out_acc = eT(0);
const u32 N = A.n_elem; const uword N = A.n_elem;
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT A_tmp = A_ptr[i]; const eT A_tmp = A_ptr[i];
const eT B_tmp = B_ptr[i]; const eT B_tmp = B_ptr[i];
A_acc += A_tmp; A_acc += A_tmp;
B_acc += B_tmp; B_acc += B_tmp;
out_acc += A_tmp * B_tmp; out_acc += A_tmp * B_tmp;
} }
skipping to change at line 59 skipping to change at line 59
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
out.set_size(1,1); out.set_size(1,1);
out[0] = out_acc/norm_val; out[0] = out_acc/norm_val;
} }
else else
{ {
arma_debug_assert_same_size(A, B, "cov()"); arma_debug_assert_same_size(A, B, "cov()");
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
out = trans(A) * B; out = trans(A) * B;
out -= (trans(sum(A)) * sum(B))/eT(N); out -= (trans(sum(A)) * sum(B))/eT(N);
out /= norm_val; out /= norm_val;
} }
} }
template<typename T> template<typename T>
inline inline
void void
glue_cov::direct_cov(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, const Mat< std::complex<T> >& B, const u32 norm_type) glue_cov::direct_cov(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, const Mat< std::complex<T> >& B, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(A.is_vec() && B.is_vec()) if(A.is_vec() && B.is_vec())
{ {
arma_debug_check( (A.n_elem != B.n_elem), "cov(): the number of element s in A and B must match" ); arma_debug_check( (A.n_elem != B.n_elem), "cov(): the number of element s in A and B must match" );
const eT* A_ptr = A.memptr(); const eT* A_ptr = A.memptr();
const eT* B_ptr = B.memptr(); const eT* B_ptr = B.memptr();
eT A_acc = eT(0); eT A_acc = eT(0);
eT B_acc = eT(0); eT B_acc = eT(0);
eT out_acc = eT(0); eT out_acc = eT(0);
const u32 N = A.n_elem; const uword N = A.n_elem;
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT A_tmp = A_ptr[i]; const eT A_tmp = A_ptr[i];
const eT B_tmp = B_ptr[i]; const eT B_tmp = B_ptr[i];
A_acc += A_tmp; A_acc += A_tmp;
B_acc += B_tmp; B_acc += B_tmp;
out_acc += std::conj(A_tmp) * B_tmp; out_acc += std::conj(A_tmp) * B_tmp;
} }
skipping to change at line 112 skipping to change at line 112
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
out.set_size(1,1); out.set_size(1,1);
out[0] = out_acc/norm_val; out[0] = out_acc/norm_val;
} }
else else
{ {
arma_debug_assert_same_size(A, B, "cov()"); arma_debug_assert_same_size(A, B, "cov()");
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
out = trans(A) * B; // out = strans(conj(A)) * B; out = trans(A) * B; // out = strans(conj(A)) * B;
out -= (trans(sum(A)) * sum(B))/eT(N); // out -= (strans(conj(sum(A))) * sum(B))/eT(N); out -= (trans(sum(A)) * sum(B))/eT(N); // out -= (strans(conj(sum(A))) * sum(B))/eT(N);
out /= norm_val; out /= norm_val;
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 136 skipping to change at line 136
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> A_tmp(X.A, out); const unwrap_check<T1> A_tmp(X.A, out);
const unwrap_check<T2> B_tmp(X.B, out); const unwrap_check<T2> B_tmp(X.B, out);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
const u32 norm_type = X.aux_u32; const uword norm_type = X.aux_uword;
if(&A != &B) if(&A != &B)
{ {
glue_cov::direct_cov(out, A, B, norm_type); glue_cov::direct_cov(out, A, B, norm_type);
} }
else else
{ {
op_cov::direct_cov(out, A, norm_type); op_cov::direct_cov(out, A, norm_type);
} }
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added


 glue_join_meat.hpp   glue_join_meat.hpp 
skipping to change at line 31 skipping to change at line 31
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> A_tmp(X.A); const unwrap<T1> A_tmp(X.A);
const unwrap<T2> B_tmp(X.B); const unwrap<T2> B_tmp(X.B);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
const u32 join_type = X.aux_u32; const uword join_type = X.aux_uword;
if(join_type == 0) if(join_type == 0)
{ {
arma_debug_check arma_debug_check
( (
( (A_n_cols != B_n_cols) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && ( (B_n_rows > 0) || (B_n_cols > 0) ) ), ( (A_n_cols != B_n_cols) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && ( (B_n_rows > 0) || (B_n_cols > 0) ) ),
"join_cols(): number of columns must be the same" "join_cols(): number of columns must be the same"
); );
} }
else else
 End of changes. 3 change blocks. 
5 lines changed or deleted 5 lines changed or added


 glue_kron_meat.hpp   glue_kron_meat.hpp 
skipping to change at line 26 skipping to change at line 26
//! \brief //! \brief
//! both input matrices have the same element type //! both input matrices have the same element type
template<typename eT> template<typename eT>
inline inline
void void
glue_kron::direct_kron(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) glue_kron::direct_kron(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_rows = A.n_rows; const uword A_rows = A.n_rows;
const u32 A_cols = A.n_cols; const uword A_cols = A.n_cols;
const u32 B_rows = B.n_rows; const uword B_rows = B.n_rows;
const u32 B_cols = B.n_cols; const uword B_cols = B.n_cols;
out.set_size(A_rows*B_rows, A_cols*B_cols); out.set_size(A_rows*B_rows, A_cols*B_cols);
for(u32 i = 0; i < A_rows; i++) for(uword i = 0; i < A_rows; i++)
{ {
for(u32 j = 0; j < A_cols; j++) for(uword j = 0; j < A_cols; j++)
{ {
out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i, j) * B; out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i, j) * B;
} }
} }
} }
//! \brief //! \brief
//! different types of input matrices //! different types of input matrices
//! A -> complex, B -> basic element type //! A -> complex, B -> basic element type
template<typename T> template<typename T>
inline inline
void void
glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat< std::complex <T> >& A, const Mat<T>& B) glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat< std::complex <T> >& A, const Mat<T>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
const u32 A_rows = A.n_rows; const uword A_rows = A.n_rows;
const u32 A_cols = A.n_cols; const uword A_cols = A.n_cols;
const u32 B_rows = B.n_rows; const uword B_rows = B.n_rows;
const u32 B_cols = B.n_cols; const uword B_cols = B.n_cols;
out.set_size(A_rows*B_rows, A_cols*B_cols); out.set_size(A_rows*B_rows, A_cols*B_cols);
Mat<eT> tmp_B = conv_to< Mat<eT> >::from(B); Mat<eT> tmp_B = conv_to< Mat<eT> >::from(B);
for(u32 i = 0; i < A_rows; i++) for(uword i = 0; i < A_rows; i++)
{ {
for(u32 j = 0; j < A_cols; j++) for(uword j = 0; j < A_cols; j++)
{ {
out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i, j) * tmp_B; out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i, j) * tmp_B;
} }
} }
} }
//! \brief //! \brief
//! different types of input matrices //! different types of input matrices
//! A -> basic element type, B -> complex //! A -> basic element type, B -> complex
template<typename T> template<typename T>
inline inline
void void
glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat<T>& A, const Mat< std::complex<T> >& B) glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat<T>& A, const Mat< std::complex<T> >& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_rows = A.n_rows; const uword A_rows = A.n_rows;
const u32 A_cols = A.n_cols; const uword A_cols = A.n_cols;
const u32 B_rows = B.n_rows; const uword B_rows = B.n_rows;
const u32 B_cols = B.n_cols; const uword B_cols = B.n_cols;
out.set_size(A_rows*B_rows, A_cols*B_cols); out.set_size(A_rows*B_rows, A_cols*B_cols);
for(u32 i = 0; i < A_rows; i++) for(uword i = 0; i < A_rows; i++)
{ {
for(u32 j = 0; j < A_cols; j++) for(uword j = 0; j < A_cols; j++)
{ {
out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i, j) * B; out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i, j) * B;
} }
} }
} }
//! \brief //! \brief
//! apply Kronecker product for two objects with same element type //! apply Kronecker product for two objects with same element type
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
 End of changes. 9 change blocks. 
18 lines changed or deleted 18 lines changed or added


 glue_mixed_meat.hpp   glue_mixed_meat.hpp 
skipping to change at line 84 skipping to change at line 84
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "addition"); arma_debug_assert_same_size(A, B, "addition");
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! matrix subtraction with different element types //! matrix subtraction with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_minus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X) glue_mixed_minus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X)
skipping to change at line 115 skipping to change at line 115
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "subtraction"); arma_debug_assert_same_size(A, B, "subtraction");
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! element-wise matrix division with different element types //! element-wise matrix division with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_div::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtGl ue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X) glue_mixed_div::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtGl ue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X)
skipping to change at line 146 skipping to change at line 146
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise division"); arma_debug_assert_same_size(A, B, "element-wise division");
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! element-wise matrix multiplication with different element types //! element-wise matrix multiplication with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_schur::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X) glue_mixed_schur::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X)
skipping to change at line 177 skipping to change at line 177
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise multiplication"); arma_debug_assert_same_size(A, B, "element-wise multiplication");
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
// //
// //
// //
//! cube addition with different element types //! cube addition with different element types
skipping to change at line 212 skipping to change at line 212
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "addition"); arma_debug_assert_same_size(A, B, "addition");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! cube subtraction with different element types //! cube subtraction with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_minus::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X) glue_mixed_minus::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X)
skipping to change at line 243 skipping to change at line 243
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "subtraction"); arma_debug_assert_same_size(A, B, "subtraction");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! element-wise cube division with different element types //! element-wise cube division with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_div::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtG lueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X) glue_mixed_div::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtG lueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X)
skipping to change at line 274 skipping to change at line 274
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise division"); arma_debug_assert_same_size(A, B, "element-wise division");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! element-wise cube multiplication with different element types //! element-wise cube multiplication with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_schur::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X) glue_mixed_schur::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X)
skipping to change at line 305 skipping to change at line 305
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise multiplication"); arma_debug_assert_same_size(A, B, "element-wise multiplication");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! @} //! @}
 End of changes. 16 change blocks. 
16 lines changed or deleted 16 lines changed or added


 glue_relational_bones.hpp   glue_relational_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_relational //! \addtogroup glue_relational
//! @{ //! @{
class glue_rel_lt class glue_rel_lt
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat <u32>& out, const mtGlue<u32, T1, T2, glue_r el_lt>& X); inline static void apply(Mat <uword>& out, const mtGlue<uword, T1, T2, gl ue_rel_lt>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube <u32>& out, const mtGlueCube<u32, T1, T2, g lue_rel_lt>& X); inline static void apply(Cube <uword>& out, const mtGlueCube<uword, T1, T 2, glue_rel_lt>& X);
}; };
class glue_rel_gt class glue_rel_gt
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat <u32>& out, const mtGlue<u32, T1, T2, glue_r el_gt>& X); inline static void apply(Mat <uword>& out, const mtGlue<uword, T1, T2, gl ue_rel_gt>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube <u32>& out, const mtGlueCube<u32, T1, T2, g lue_rel_gt>& X); inline static void apply(Cube <uword>& out, const mtGlueCube<uword, T1, T 2, glue_rel_gt>& X);
}; };
class glue_rel_lteq class glue_rel_lteq
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat <u32>& out, const mtGlue<u32, T1, T2, glue_r el_lteq>& X); inline static void apply(Mat <uword>& out, const mtGlue<uword, T1, T2, gl ue_rel_lteq>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube <u32>& out, const mtGlueCube<u32, T1, T2, g lue_rel_lteq>& X); inline static void apply(Cube <uword>& out, const mtGlueCube<uword, T1, T 2, glue_rel_lteq>& X);
}; };
class glue_rel_gteq class glue_rel_gteq
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat <u32>& out, const mtGlue<u32, T1, T2, glue_r el_gteq>& X); inline static void apply(Mat <uword>& out, const mtGlue<uword, T1, T2, gl ue_rel_gteq>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube <u32>& out, const mtGlueCube<u32, T1, T2, g lue_rel_gteq>& X); inline static void apply(Cube <uword>& out, const mtGlueCube<uword, T1, T 2, glue_rel_gteq>& X);
}; };
class glue_rel_eq class glue_rel_eq
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat <u32>& out, const mtGlue<u32, T1, T2, glue_r el_eq>& X); inline static void apply(Mat <uword>& out, const mtGlue<uword, T1, T2, gl ue_rel_eq>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube <u32>& out, const mtGlueCube<u32, T1, T2, g lue_rel_eq>& X); inline static void apply(Cube <uword>& out, const mtGlueCube<uword, T1, T 2, glue_rel_eq>& X);
}; };
class glue_rel_noteq class glue_rel_noteq
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat <u32>& out, const mtGlue<u32, T1, T2, glue_r el_noteq>& X); inline static void apply(Mat <uword>& out, const mtGlue<uword, T1, T2, gl ue_rel_noteq>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube <u32>& out, const mtGlueCube<u32, T1, T2, g lue_rel_noteq>& X); inline static void apply(Cube <uword>& out, const mtGlueCube<uword, T1, T 2, glue_rel_noteq>& X);
}; };
//! @} //! @}
 End of changes. 12 change blocks. 
12 lines changed or deleted 12 lines changed or added


 glue_relational_meat.hpp   glue_relational_meat.hpp 
skipping to change at line 29 skipping to change at line 29
#undef arma_applier_mat #undef arma_applier_mat
#undef arma_applier_cube #undef arma_applier_cube
#define arma_applier_mat(operator_rel, operator_str) \ #define arma_applier_mat(operator_rel, operator_str) \
{\ {\
const Proxy<T1> P1(X.A);\ const Proxy<T1> P1(X.A);\
const Proxy<T2> P2(X.B);\ const Proxy<T2> P2(X.B);\
\ \
arma_debug_assert_same_size(P1, P2, operator_str);\ arma_debug_assert_same_size(P1, P2, operator_str);\
\ \
const u32 n_rows = P1.get_n_rows();\ const uword n_rows = P1.get_n_rows();\
const u32 n_cols = P1.get_n_cols();\ const uword n_cols = P1.get_n_cols();\
\ \
out.set_size(n_rows, n_cols);\ out.set_size(n_rows, n_cols);\
\ \
u32* out_mem = out.memptr();\ uword* 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)\
{\ {\
typename Proxy<T1>::ea_type A = P1.get_ea();\ typename Proxy<T1>::ea_type A = P1.get_ea();\
typename Proxy<T2>::ea_type B = P2.get_ea();\ typename Proxy<T2>::ea_type B = P2.get_ea();\
\ \
const u32 n_elem = out.n_elem;\ const uword n_elem = out.n_elem;\
\ \
for(u32 i=0; i<n_elem; ++i)\ for(uword i=0; i<n_elem; ++i)\
{\ {\
out_mem[i] = (A[i] operator_rel B[i]) ? u32(1) : u32(0);\ out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
}\ }\
}\ }\
else\ else\
{\ {\
u32 count = 0;\ uword count = 0;\
\ \
for(u32 col=0; col<n_cols; ++col)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
for(u32 row=0; row<n_rows; ++row, ++count)\ for(uword row=0; row<n_rows; ++row, ++count)\
{\ {\
out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? u32 (1) : u32(0);\ out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? uwo rd(1) : uword(0);\
}\ }\
}\ }\
}\ }\
} }
#define arma_applier_cube(operator_rel, operator_str) \ #define arma_applier_cube(operator_rel, operator_str) \
{\ {\
const ProxyCube<T1> P1(X.A);\ const ProxyCube<T1> P1(X.A);\
const ProxyCube<T2> P2(X.B);\ const ProxyCube<T2> P2(X.B);\
\ \
arma_debug_assert_same_size(P1, P2, operator_str);\ arma_debug_assert_same_size(P1, P2, operator_str);\
\ \
const u32 n_rows = P1.get_n_rows();\ const uword n_rows = P1.get_n_rows();\
const u32 n_cols = P1.get_n_cols();\ const uword n_cols = P1.get_n_cols();\
const u32 n_slices = P1.get_n_slices();\ const uword n_slices = P1.get_n_slices();\
\ \
out.set_size(n_rows, n_cols, n_slices);\ out.set_size(n_rows, n_cols, n_slices);\
\ \
u32* out_mem = out.memptr();\ uword* out_mem = out.memptr();\
\ \
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);\ const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);\
\ \
if(prefer_at_accessor == false)\ if(prefer_at_accessor == false)\
{\ {\
typename ProxyCube<T1>::ea_type A = P1.get_ea();\ typename ProxyCube<T1>::ea_type A = P1.get_ea();\
typename ProxyCube<T2>::ea_type B = P2.get_ea();\ typename ProxyCube<T2>::ea_type B = P2.get_ea();\
\ \
const u32 n_elem = out.n_elem;\ const uword n_elem = out.n_elem;\
\ \
for(u32 i=0; i<n_elem; ++i)\ for(uword i=0; i<n_elem; ++i)\
{\ {\
out_mem[i] = (A[i] operator_rel B[i]) ? u32(1) : u32(0);\ out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
}\ }\
}\ }\
else\ else\
{\ {\
u32 count = 0;\ uword count = 0;\
\ \
for(u32 slice = 0; slice < n_slices; ++slice)\ for(uword slice = 0; slice < n_slices; ++slice)\
for(u32 col = 0; col < n_cols; ++col)\ for(uword col = 0; col < n_cols; ++col)\
for(u32 row = 0; row < n_rows; ++row, ++count)\ for(uword row = 0; row < n_rows; ++row, ++count)\
{\ {\
out_mem[count] = (P1.at(row,col,slice) operator_rel P2.at(row,col,sli ce)) ? u32(1) : u32(0);\ out_mem[count] = (P1.at(row,col,slice) operator_rel P2.at(row,col,sli ce)) ? uword(1) : uword(0);\
}\ }\
}\ }\
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_lt::apply glue_rel_lt::apply
( (
Mat <u32>& out, Mat <uword>& out,
const mtGlue<u32, T1, T2, glue_rel_lt>& X const mtGlue<uword, T1, T2, glue_rel_lt>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_mat(<, "operator<"); arma_applier_mat(<, "operator<");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_gt::apply glue_rel_gt::apply
( (
Mat <u32>& out, Mat <uword>& out,
const mtGlue<u32, T1, T2, glue_rel_gt>& X const mtGlue<uword, T1, T2, glue_rel_gt>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_mat(>, "operator>"); arma_applier_mat(>, "operator>");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_lteq::apply glue_rel_lteq::apply
( (
Mat <u32>& out, Mat <uword>& out,
const mtGlue<u32, T1, T2, glue_rel_lteq>& X const mtGlue<uword, T1, T2, glue_rel_lteq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_mat(<=, "operator<="); arma_applier_mat(<=, "operator<=");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_gteq::apply glue_rel_gteq::apply
( (
Mat <u32>& out, Mat <uword>& out,
const mtGlue<u32, T1, T2, glue_rel_gteq>& X const mtGlue<uword, T1, T2, glue_rel_gteq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_mat(>=, "operator>="); arma_applier_mat(>=, "operator>=");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_eq::apply glue_rel_eq::apply
( (
Mat <u32>& out, Mat <uword>& out,
const mtGlue<u32, T1, T2, glue_rel_eq>& X const mtGlue<uword, T1, T2, glue_rel_eq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_mat(==, "operator=="); arma_applier_mat(==, "operator==");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_noteq::apply glue_rel_noteq::apply
( (
Mat <u32>& out, Mat <uword>& out,
const mtGlue<u32, T1, T2, glue_rel_noteq>& X const mtGlue<uword, T1, T2, glue_rel_noteq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_mat(!=, "operator!="); arma_applier_mat(!=, "operator!=");
} }
// //
// //
// //
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_lt::apply glue_rel_lt::apply
( (
Cube <u32>& out, Cube <uword>& out,
const mtGlueCube<u32, T1, T2, glue_rel_lt>& X const mtGlueCube<uword, T1, T2, glue_rel_lt>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_cube(<, "operator<"); arma_applier_cube(<, "operator<");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_gt::apply glue_rel_gt::apply
( (
Cube <u32>& out, Cube <uword>& out,
const mtGlueCube<u32, T1, T2, glue_rel_gt>& X const mtGlueCube<uword, T1, T2, glue_rel_gt>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_cube(>, "operator>"); arma_applier_cube(>, "operator>");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_lteq::apply glue_rel_lteq::apply
( (
Cube <u32>& out, Cube <uword>& out,
const mtGlueCube<u32, T1, T2, glue_rel_lteq>& X const mtGlueCube<uword, T1, T2, glue_rel_lteq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_cube(<=, "operator<="); arma_applier_cube(<=, "operator<=");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_gteq::apply glue_rel_gteq::apply
( (
Cube <u32>& out, Cube <uword>& out,
const mtGlueCube<u32, T1, T2, glue_rel_gteq>& X const mtGlueCube<uword, T1, T2, glue_rel_gteq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_cube(>=, "operator>="); arma_applier_cube(>=, "operator>=");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_eq::apply glue_rel_eq::apply
( (
Cube <u32>& out, Cube <uword>& out,
const mtGlueCube<u32, T1, T2, glue_rel_eq>& X const mtGlueCube<uword, T1, T2, glue_rel_eq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_cube(==, "operator=="); arma_applier_cube(==, "operator==");
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_rel_noteq::apply glue_rel_noteq::apply
( (
Cube <u32>& out, Cube <uword>& out,
const mtGlueCube<u32, T1, T2, glue_rel_noteq>& X const mtGlueCube<uword, T1, T2, glue_rel_noteq>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_applier_cube(!=, "operator!="); arma_applier_cube(!=, "operator!=");
} }
#undef arma_applier_mat #undef arma_applier_mat
#undef arma_applier_cube #undef arma_applier_cube
 End of changes. 29 change blocks. 
46 lines changed or deleted 46 lines changed or added


 glue_solve_meat.hpp   glue_solve_meat.hpp 
skipping to change at line 36 skipping to change at line 36
const unwrap_check<T2> B_tmp(X.B, out); const unwrap_check<T2> B_tmp(X.B, out);
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
arma_debug_check( (A.n_rows != B.n_rows), "solve(): number of rows in A a nd B must be the same" ); arma_debug_check( (A.n_rows != B.n_rows), "solve(): number of rows in A a nd B must be the same" );
bool status; bool status;
if(A.n_rows == A.n_cols) if(A.n_rows == A.n_cols)
{ {
const u32 mode = X.aux_u32; const uword mode = X.aux_uword;
status = (mode == 0) ? auxlib::solve(out, A, B) : auxlib::solve(out, A, B, true); status = (mode == 0) ? auxlib::solve(out, A, B) : auxlib::solve(out, A, B, true);
} }
else else
if(A.n_rows > A.n_cols) if(A.n_rows > A.n_cols)
{ {
arma_extra_debug_print("solve(): detected over-determined system"); arma_extra_debug_print("solve(): detected over-determined system");
status = auxlib::solve_od(out, A, B); status = auxlib::solve_od(out, A, B);
} }
else else
skipping to change at line 83 skipping to change at line 83
bool err_state = false; bool err_state = false;
char* err_msg = 0; char* err_msg = 0;
arma_debug_set_error( err_state, err_msg, ((&A) == (&B)), "solv e(): A is an alias of B" ); arma_debug_set_error( err_state, err_msg, ((&A) == (&B)), "solv e(): A is an alias of B" );
arma_debug_set_error( err_state, err_msg, (A.n_rows != B.n_rows), "solv e(): number of rows in A and B must be the same" ); arma_debug_set_error( err_state, err_msg, (A.n_rows != B.n_rows), "solv e(): number of rows in A and B must be the same" );
arma_debug_set_error( err_state, err_msg, (A.is_square() == false), "solv e(): A is not a square matrix" ); arma_debug_set_error( err_state, err_msg, (A.is_square() == false), "solv e(): A is not a square matrix" );
arma_debug_check(err_state, err_msg); arma_debug_check(err_state, err_msg);
const bool status = auxlib::solve_tr(out, A, B, X.aux_u32); const bool status = auxlib::solve_tr(out, A, B, X.aux_uword);
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("solve(): solution not found"); arma_bad("solve(): solution not found");
} }
} }
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 glue_times_bones.hpp   glue_times_bones.hpp 
skipping to change at line 24 skipping to change at line 24
//! @{ //! @{
//! \brief //! \brief
//! Template metaprogram depth_lhs //! Template metaprogram depth_lhs
//! calculates the number of Glue<Tx,Ty, glue_type> instances on the left h and side argument of Glue<Tx,Ty, glue_type> //! calculates the number of Glue<Tx,Ty, glue_type> instances on the left h and side argument of Glue<Tx,Ty, glue_type>
//! i.e. it recursively expands each Tx, until the type of Tx is not "Glue< ..,.., glue_type>" (i.e the "glue_type" changes) //! i.e. it recursively expands each Tx, until the type of Tx is not "Glue< ..,.., glue_type>" (i.e the "glue_type" changes)
template<typename glue_type, typename T1> template<typename glue_type, typename T1>
struct depth_lhs struct depth_lhs
{ {
static const u32 num = 0; static const uword num = 0;
}; };
template<typename glue_type, typename T1, typename T2> template<typename glue_type, typename T1, typename T2>
struct depth_lhs< glue_type, Glue<T1,T2,glue_type> > struct depth_lhs< glue_type, Glue<T1,T2,glue_type> >
{ {
static const u32 num = 1 + depth_lhs<glue_type, T1>::num; static const uword num = 1 + depth_lhs<glue_type, T1>::num;
}; };
template<u32 N> template<uword N>
struct glue_times_redirect struct glue_times_redirect
{ {
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,glue_times>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,glue_times>& X);
}; };
template<> template<>
struct glue_times_redirect<3> struct glue_times_redirect<3>
{ {
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
skipping to change at line 66 skipping to change at line 66
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,glue_times>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,glue_times>& X);
template<typename T1> template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const T1& X); inline static void apply_inplace(Mat<typename T1::elem_type>& out, 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 s32 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> template<typename eT>
arma_inline static u32 mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, 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, const bool do_trans_A, const bool do_trans_B);
template<typename eT> template<typename eT>
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M at<eT>& B, const eT val, const bool do_trans_A, const bool do_trans_B, cons t bool do_scalar_times); arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M at<eT>& B, const eT val, const bool do_trans_A, const bool do_trans_B, cons t bool do_scalar_times);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C, const eT val, const bool do_trans_A, const bool do_tran s_B, const bool do_trans_C, const bool do_scalar_times); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C, const eT val, const bool do_trans_A, const bool do_tran s_B, const bool do_trans_C, const bool do_scalar_times);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C, const Mat<eT>& D, const eT val, 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); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C, const Mat<eT>& D, const eT val, 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);
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 glue_times_meat.hpp   glue_times_meat.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_times //! \addtogroup glue_times
//! @{ //! @{
template<u32 N> template<uword N>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue< T1,T2,glue_times>& X) glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue< T1,T2,glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const partial_unwrap_check<T1> tmp1(X.A, out); const partial_unwrap_check<T1> tmp1(X.A, out);
skipping to change at line 113 skipping to change at line 113
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t imes>& X) glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t imes>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const s32 N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >::nu m; const sword N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >:: num;
arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat); arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat);
glue_times_redirect<N_mat>::apply(out, X); glue_times_redirect<N_mat>::apply(out, X);
} }
template<typename T1> template<typename T1>
inline inline
void void
glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X) glue_times::apply_inplace(Mat<typename T1::elem_type>& out, 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_check<T1> tmp(X, out); const unwrap_check<T1> tmp(X, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
arma_debug_assert_mul_size(out, B, "matrix multiplication"); arma_debug_assert_mul_size(out, B, "matrix multiplication");
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
if(out_n_cols == B.n_cols) if(out_n_cols == B.n_cols)
{ {
// size of resulting matrix is the same as 'out' // size of resulting matrix is the same as 'out'
podarray<eT> tmp(out_n_cols); podarray<eT> tmp(out_n_cols);
eT* tmp_rowdata = tmp.memptr(); eT* tmp_rowdata = tmp.memptr();
for(u32 row=0; row < out_n_rows; ++row) for(uword row=0; row < out_n_rows; ++row)
{ {
tmp.copy_row(out, row); tmp.copy_row(out, row);
for(u32 col=0; col < out_n_cols; ++col) for(uword col=0; col < out_n_cols; ++col)
{ {
out.at(row,col) = op_dot::direct_dot( out_n_cols, tmp_rowdata, B.co lptr(col) ); out.at(row,col) = op_dot::direct_dot( out_n_cols, tmp_rowdata, B.co lptr(col) );
} }
} }
} }
else else
{ {
const Mat<eT> tmp(out); const Mat<eT> tmp(out);
glue_times::apply(out, tmp, B, eT(1), false, false, false); glue_times::apply(out, tmp, B, eT(1), false, false, false);
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
glue_times::apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue <T1, T2, glue_times>& X, const s32 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; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const eT alpha = tmp1.get_val() * tmp2.get_val() * ( (sign > s32(0) ) ? eT(1) : eT(-1) ); const eT alpha = tmp1.get_val() * tmp2.get_val() * ( (sign > sword( 0)) ? eT(1) : eT(-1) );
const bool do_trans_A = tmp1.do_trans; const bool do_trans_A = tmp1.do_trans;
const bool do_trans_B = tmp2.do_trans; const bool do_trans_B = tmp2.do_trans;
const bool use_alpha = tmp1.do_times || tmp2.do_times || (sign < s32(0)) ; const bool use_alpha = tmp1.do_times || tmp2.do_times || (sign < sword(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 u32 result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const u32 result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const uword result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "addition"); arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "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) && (is_complex<eT>::value == false) )
{ {
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));
skipping to change at line 335 skipping to change at line 335
{ {
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> template<typename eT>
arma_inline arma_inline
u32 uword
glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, const bool do_trans_A, const bool do_trans_B) glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, const bool do_trans_A, const bool do_trans_B)
{ {
const u32 final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const u32 final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
return final_A_n_rows * final_B_n_cols; return final_A_n_rows * final_B_n_cols;
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
glue_times::apply glue_times::apply
( (
skipping to change at line 363 skipping to change at line 363
const eT alpha, const eT alpha,
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
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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 u32 final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const u32 final_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const uword final_n_cols = (do_trans_B == false) ? B.n_cols : 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) && (is_complex<eT>::value == false) )
{ {
gemv<true, false, false>::apply(out.memptr(), B, A.memptr() ); gemv<true, false, false>::apply(out.memptr(), B, A.memptr() );
skipping to change at line 614 skipping to change at line 614
{ {
const diagmat_proxy_check<T1_stripped> A(S1.M, out); const diagmat_proxy_check<T1_stripped> A(S1.M, out);
const unwrap_check<T2> tmp(X.B, out); const unwrap_check<T2> tmp(X.B, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_rows, B.n_cols, "mat rix multiplication"); arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_rows, B.n_cols, "mat rix multiplication");
out.set_size(A.n_elem, B.n_cols); out.set_size(A.n_elem, B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
const eT* B_coldata = B.colptr(col); const eT* B_coldata = B.colptr(col);
for(u32 row=0; row<B.n_rows; ++row) for(uword row=0; row<B.n_rows; ++row)
{ {
out_coldata[row] = A[row] * B_coldata[row]; out_coldata[row] = A[row] * B_coldata[row];
} }
} }
} }
else else
if( (S1.do_diagmat == false) && (S2.do_diagmat == true) ) if( (S1.do_diagmat == false) && (S2.do_diagmat == true) )
{ {
const unwrap_check<T1> tmp(X.A, out); const unwrap_check<T1> tmp(X.A, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const diagmat_proxy_check<T2_stripped> B(S2.M, out); const diagmat_proxy_check<T2_stripped> B(S2.M, out);
arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_elem, B.n_elem, "mat rix multiplication"); arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_elem, B.n_elem, "mat rix multiplication");
out.set_size(A.n_rows, B.n_elem); out.set_size(A.n_rows, B.n_elem);
for(u32 col=0; col<A.n_cols; ++col) for(uword col=0; col<A.n_cols; ++col)
{ {
const eT val = B[col]; const eT val = B[col];
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
const eT* A_coldata = A.colptr(col); const eT* A_coldata = A.colptr(col);
for(u32 row=0; row<A.n_rows; ++row) for(uword row=0; row<A.n_rows; ++row)
{ {
out_coldata[row] = A_coldata[row] * val; out_coldata[row] = A_coldata[row] * val;
} }
} }
} }
else else
if( (S1.do_diagmat == true) && (S2.do_diagmat == true) ) if( (S1.do_diagmat == true) && (S2.do_diagmat == true) )
{ {
const diagmat_proxy_check<T1_stripped> A(S1.M, out); const diagmat_proxy_check<T1_stripped> A(S1.M, out);
const diagmat_proxy_check<T2_stripped> B(S2.M, out); const diagmat_proxy_check<T2_stripped> B(S2.M, out);
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "mat rix multiplication"); arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "mat rix multiplication");
out.zeros(A.n_elem, A.n_elem); out.zeros(A.n_elem, A.n_elem);
for(u32 i=0; i<A.n_elem; ++i) for(uword i=0; i<A.n_elem; ++i)
{ {
out.at(i,i) = A[i] * B[i]; out.at(i,i) = A[i] * B[i];
} }
} }
} }
//! @} //! @}
 End of changes. 17 change blocks. 
21 lines changed or deleted 21 lines changed or added


 glue_toeplitz_meat.hpp   glue_toeplitz_meat.hpp 
skipping to change at line 36 skipping to change at line 36
if( ((void*)(&in.A)) == ((void*)(&in.B)) ) if( ((void*)(&in.A)) == ((void*)(&in.B)) )
{ {
arma_extra_debug_print("glue_toeplitz::apply(): one argument version"); arma_extra_debug_print("glue_toeplitz::apply(): one argument version");
const unwrap_check<T1> tmp(in.A, out); const unwrap_check<T1> tmp(in.A, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_vec() == false), "toeplitz(): input argument mu st be a vector" ); arma_debug_check( (A.is_vec() == false), "toeplitz(): input argument mu st be a vector" );
const u32 N = A.n_elem; const uword N = A.n_elem;
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
out.set_size(N,N); out.set_size(N,N);
for(u32 col=0; col<N; ++col) for(uword col=0; col<N; ++col)
{ {
eT* col_mem = out.colptr(col); eT* col_mem = out.colptr(col);
u32 i; uword i;
i = col; i = col;
for(u32 row=0; row<col; ++row, --i) for(uword row=0; row<col; ++row, --i)
{ {
col_mem[row] = A_mem[i]; col_mem[row] = A_mem[i];
} }
i = 0; i = 0;
for(u32 row=col; row<N; ++row, ++i) for(uword row=col; row<N; ++row, ++i)
{ {
col_mem[row] = A_mem[i]; col_mem[row] = A_mem[i];
} }
} }
} }
else else
{ {
arma_extra_debug_print("glue_toeplitz::apply(): two argument version"); arma_extra_debug_print("glue_toeplitz::apply(): two argument version");
const unwrap_check<T1> tmp1(in.A, out); const unwrap_check<T1> tmp1(in.A, out);
const unwrap_check<T2> tmp2(in.B, out); const unwrap_check<T2> tmp2(in.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), " toeplitz(): input arguments must be vectors" ); arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), " toeplitz(): input arguments must be vectors" );
const u32 A_N = A.n_elem; const uword A_N = A.n_elem;
const u32 B_N = B.n_elem; const uword B_N = B.n_elem;
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
const eT* B_mem = B.memptr(); const eT* B_mem = B.memptr();
out.set_size(A_N, B_N); out.set_size(A_N, B_N);
if( out.is_empty() ) if( out.is_empty() )
{ {
return; return;
} }
for(u32 col=0; col<B_N; ++col) for(uword col=0; col<B_N; ++col)
{ {
eT* col_mem = out.colptr(col); eT* col_mem = out.colptr(col);
u32 i = 0; uword i = 0;
for(u32 row=col; row<A_N; ++row, ++i) for(uword row=col; row<A_N; ++row, ++i)
{ {
col_mem[row] = A_mem[i]; col_mem[row] = A_mem[i];
} }
} }
for(u32 row=0; row<A_N; ++row) for(uword row=0; row<A_N; ++row)
{ {
u32 i = 1; uword i = 1;
for(u32 col=(row+1); col<B_N; ++col, ++i) for(uword col=(row+1); col<B_N; ++col, ++i)
{ {
out.at(row,col) = B_mem[i]; out.at(row,col) = B_mem[i];
} }
} }
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
skipping to change at line 127 skipping to change at line 127
if( ((void*)(&in.A)) == ((void*)(&in.B)) ) if( ((void*)(&in.A)) == ((void*)(&in.B)) )
{ {
arma_extra_debug_print("glue_toeplitz_circ::apply(): one argument versi on"); arma_extra_debug_print("glue_toeplitz_circ::apply(): one argument versi on");
const unwrap_check<T1> tmp(in.A, out); const unwrap_check<T1> tmp(in.A, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_vec() == false), "toeplitz(): input argument mu st be a vector" ); arma_debug_check( (A.is_vec() == false), "toeplitz(): input argument mu st be a vector" );
const u32 N = A.n_elem; const uword N = A.n_elem;
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
out.set_size(N,N); out.set_size(N,N);
if(A.is_colvec()) if(A.is_colvec())
{ {
// A is interpreted as colvec // A is interpreted as colvec
for(u32 col=0; col<N; ++col) for(uword col=0; col<N; ++col)
{ {
eT* col_mem = out.colptr(col); eT* col_mem = out.colptr(col);
u32 i = col; uword i = col;
for(u32 row=0; row<col; ++row, --i) for(uword row=0; row<col; ++row, --i)
{ {
col_mem[row] = A_mem[N-i]; col_mem[row] = A_mem[N-i];
} }
i = 0; i = 0;
for(u32 row=col; row<N; ++row, ++i) for(uword row=col; row<N; ++row, ++i)
{ {
col_mem[row] = A_mem[i]; col_mem[row] = A_mem[i];
} }
} }
} }
else else
{ {
// A is interpreted as rowvec - probably not the computationally most efficient way to do this ;-) // A is interpreted as rowvec - probably not the computationally most efficient way to do this ;-)
for(u32 row=0; row<N; ++row) for(uword row=0; row<N; ++row)
{ {
u32 i = row; uword i = row;
for(u32 col=0; col<row; ++col, --i) for(uword col=0; col<row; ++col, --i)
{ {
out.at(row,col) = A_mem[N-i]; out.at(row,col) = A_mem[N-i];
} }
i = 0; i = 0;
for(u32 col=row; col<N; ++col, ++i) for(uword col=row; col<N; ++col, ++i)
{ {
out.at(row,col) = A_mem[i]; out.at(row,col) = A_mem[i];
} }
} }
} }
} }
} }
//! @} //! @}
 End of changes. 19 change blocks. 
22 lines changed or deleted 22 lines changed or added


 injector_bones.hpp   injector_bones.hpp 
skipping to change at line 25 skipping to change at line 25
template<typename eT> template<typename eT>
class mat_injector_row class mat_injector_row
{ {
public: public:
inline mat_injector_row(); inline mat_injector_row();
inline void insert(const eT val) const; inline void insert(const eT val) const;
mutable u32 n_cols; mutable uword n_cols;
mutable podarray<eT> A; mutable podarray<eT> A;
mutable podarray<eT> B; mutable podarray<eT> B;
}; };
template<typename T1> template<typename T1>
class mat_injector class mat_injector
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
skipping to change at line 47 skipping to change at line 47
inline void insert(const elem_type val) const; inline void insert(const elem_type val) const;
inline void end_of_row() const; inline void end_of_row() const;
inline ~mat_injector(); inline ~mat_injector();
private: private:
inline mat_injector(T1& in_X, const elem_type val); inline mat_injector(T1& in_X, const elem_type val);
inline mat_injector(T1& in_X, const injector_end_of_row& x); inline mat_injector(T1& in_X, const injector_end_of_row& x);
T1& X; T1& X;
mutable u32 n_rows; mutable uword n_rows;
mutable podarray< mat_injector_row<elem_type>* >* AA; mutable podarray< mat_injector_row<elem_type>* >* AA;
mutable podarray< mat_injector_row<elem_type>* >* BB; mutable podarray< mat_injector_row<elem_type>* >* BB;
friend class Mat<elem_type>; friend class Mat<elem_type>;
friend class Row<elem_type>; friend class Row<elem_type>;
friend class Col<elem_type>; friend class Col<elem_type>;
}; };
// //
skipping to change at line 69 skipping to change at line 69
template<typename oT> template<typename oT>
class field_injector_row class field_injector_row
{ {
public: public:
inline field_injector_row(); inline field_injector_row();
inline ~field_injector_row(); inline ~field_injector_row();
inline void insert(const oT& val) const; inline void insert(const oT& val) const;
mutable u32 n_cols; mutable uword n_cols;
mutable field<oT>* AA; mutable field<oT>* AA;
mutable field<oT>* BB; mutable field<oT>* BB;
}; };
template<typename T1> template<typename T1>
class field_injector class field_injector
{ {
public: public:
typedef typename T1::object_type object_type; typedef typename T1::object_type object_type;
skipping to change at line 91 skipping to change at line 91
inline void insert(const object_type& val) const; inline void insert(const object_type& val) const;
inline void end_of_row() const; inline void end_of_row() const;
inline ~field_injector(); inline ~field_injector();
private: private:
inline field_injector(T1& in_X, const object_type& val); inline field_injector(T1& in_X, const object_type& val);
inline field_injector(T1& in_X, const injector_end_of_row& x); inline field_injector(T1& in_X, const injector_end_of_row& x);
T1& X; T1& X;
mutable u32 n_rows; mutable uword n_rows;
mutable podarray< field_injector_row<object_type>* >* AA; mutable podarray< field_injector_row<object_type>* >* AA;
mutable podarray< field_injector_row<object_type>* >* BB; mutable podarray< field_injector_row<object_type>* >* BB;
friend class field<object_type>; friend class field<object_type>;
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 injector_meat.hpp   injector_meat.hpp 
skipping to change at line 73 skipping to change at line 73
typedef typename mat_injector<T1>::elem_type eT; typedef typename mat_injector<T1>::elem_type eT;
AA = new podarray< mat_injector_row<eT>* >; AA = new podarray< mat_injector_row<eT>* >;
BB = new podarray< mat_injector_row<eT>* >; BB = new podarray< mat_injector_row<eT>* >;
podarray< mat_injector_row<eT>* >& A = *AA; podarray< mat_injector_row<eT>* >& A = *AA;
A.set_size(n_rows); A.set_size(n_rows);
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
A[row] = new mat_injector_row<eT>; A[row] = new mat_injector_row<eT>;
} }
(*(A[0])).insert(val); (*(A[0])).insert(val);
} }
template<typename T1> template<typename T1>
inline inline
mat_injector<T1>::mat_injector(T1& in_X, const injector_end_of_row& x) mat_injector<T1>::mat_injector(T1& in_X, const injector_end_of_row& x)
skipping to change at line 99 skipping to change at line 99
typedef typename mat_injector<T1>::elem_type eT; typedef typename mat_injector<T1>::elem_type eT;
AA = new podarray< mat_injector_row<eT>* >; AA = new podarray< mat_injector_row<eT>* >;
BB = new podarray< mat_injector_row<eT>* >; BB = new podarray< mat_injector_row<eT>* >;
podarray< mat_injector_row<eT>* >& A = *AA; podarray< mat_injector_row<eT>* >& A = *AA;
A.set_size(n_rows); A.set_size(n_rows);
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
A[row] = new mat_injector_row<eT>; A[row] = new mat_injector_row<eT>;
} }
(*this).end_of_row(); (*this).end_of_row();
} }
template<typename T1> template<typename T1>
inline inline
mat_injector<T1>::~mat_injector() mat_injector<T1>::~mat_injector()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename mat_injector<T1>::elem_type eT; typedef typename mat_injector<T1>::elem_type eT;
podarray< mat_injector_row<eT>* >& A = *AA; podarray< mat_injector_row<eT>* >& A = *AA;
if(n_rows > 0) if(n_rows > 0)
{ {
u32 max_n_cols = (*(A[0])).n_cols; uword max_n_cols = (*(A[0])).n_cols;
for(u32 row=1; row<n_rows; ++row) for(uword row=1; row<n_rows; ++row)
{ {
const u32 n_cols = (*(A[row])).n_cols; const uword n_cols = (*(A[row])).n_cols;
if(max_n_cols < n_cols) if(max_n_cols < n_cols)
{ {
max_n_cols = n_cols; max_n_cols = n_cols;
} }
} }
const u32 max_n_rows = ((*(A[n_rows-1])).n_cols == 0) ? n_rows-1 : n_ro ws; const uword max_n_rows = ((*(A[n_rows-1])).n_cols == 0) ? n_rows-1 : n_ rows;
if(is_Mat_only<T1>::value == true) if(is_Mat_only<T1>::value == true)
{ {
X.set_size(max_n_rows, max_n_cols); X.set_size(max_n_rows, max_n_cols);
for(u32 row=0; row<max_n_rows; ++row) for(uword row=0; row<max_n_rows; ++row)
{ {
const u32 n_cols = (*(A[row])).n_cols; const uword n_cols = (*(A[row])).n_cols;
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
X.at(row,col) = (*(A[row])).A[col]; X.at(row,col) = (*(A[row])).A[col];
} }
for(u32 col=n_cols; col<max_n_cols; ++col) for(uword col=n_cols; col<max_n_cols; ++col)
{ {
X.at(row,col) = eT(0); X.at(row,col) = eT(0);
} }
} }
} }
else else
if(is_Row<T1>::value == true) if(is_Row<T1>::value == true)
{ {
arma_debug_check( (max_n_rows > 1), "matrix initialisation: incompati ble dimensions" ); arma_debug_check( (max_n_rows > 1), "matrix initialisation: incompati ble dimensions" );
const u32 n_cols = (*(A[0])).n_cols; const uword n_cols = (*(A[0])).n_cols;
X.set_size(1, n_cols); X.set_size(1, n_cols);
arrayops::copy( X.memptr(), (*(A[0])).A.memptr(), n_cols ); arrayops::copy( X.memptr(), (*(A[0])).A.memptr(), n_cols );
} }
else else
if(is_Col<T1>::value == true) if(is_Col<T1>::value == true)
{ {
const bool is_vec = ( (max_n_rows == 1) || (max_n_cols == 1) ); const bool is_vec = ( (max_n_rows == 1) || (max_n_cols == 1) );
arma_debug_check( (is_vec == false), "matrix initialisation: incompat ible dimensions" ); arma_debug_check( (is_vec == false), "matrix initialisation: incompat ible dimensions" );
const u32 n_elem = (std::max)(max_n_rows, max_n_cols); const uword n_elem = (std::max)(max_n_rows, max_n_cols);
X.set_size(n_elem, 1); X.set_size(n_elem, 1);
u32 i = 0; uword i = 0;
for(u32 row=0; row<max_n_rows; ++row) for(uword row=0; row<max_n_rows; ++row)
{ {
const u32 n_cols = (*(A[0])).n_cols; const uword n_cols = (*(A[0])).n_cols;
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
X[i] = (*(A[row])).A[col]; X[i] = (*(A[row])).A[col];
++i; ++i;
} }
for(u32 col=n_cols; col<max_n_cols; ++col) for(uword col=n_cols; col<max_n_cols; ++col)
{ {
X[i] = eT(0); X[i] = eT(0);
++i; ++i;
} }
} }
} }
} }
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
delete A[row]; delete A[row];
} }
delete AA; delete AA;
delete BB; delete BB;
} }
template<typename T1> template<typename T1>
inline inline
skipping to change at line 233 skipping to change at line 233
typedef typename mat_injector<T1>::elem_type eT; typedef typename mat_injector<T1>::elem_type eT;
podarray< mat_injector_row<eT>* >& A = *AA; podarray< mat_injector_row<eT>* >& A = *AA;
podarray< mat_injector_row<eT>* >& B = *BB; podarray< mat_injector_row<eT>* >& B = *BB;
B.set_size( n_rows+1 ); B.set_size( n_rows+1 );
arrayops::copy(B.memptr(), A.memptr(), n_rows); arrayops::copy(B.memptr(), A.memptr(), n_rows);
for(u32 row=n_rows; row<(n_rows+1); ++row) for(uword row=n_rows; row<(n_rows+1); ++row)
{ {
B[row] = new mat_injector_row<eT>; B[row] = new mat_injector_row<eT>;
} }
std::swap(AA, BB); std::swap(AA, BB);
n_rows += 1; n_rows += 1;
} }
template<typename T1> template<typename T1>
skipping to change at line 346 skipping to change at line 346
if(n_cols < A.n_elem) if(n_cols < A.n_elem)
{ {
A[n_cols] = val; A[n_cols] = val;
++n_cols; ++n_cols;
} }
else else
{ {
B.set_size(2 * A.n_elem); B.set_size(2 * A.n_elem);
for(u32 i=0; i<n_cols; ++i) for(uword i=0; i<n_cols; ++i)
{ {
B[i] = A[i]; B[i] = A[i];
} }
B[n_cols] = val; B[n_cols] = val;
++n_cols; ++n_cols;
std::swap(AA, BB); std::swap(AA, BB);
} }
} }
skipping to change at line 379 skipping to change at line 379
typedef typename field_injector<T1>::object_type oT; typedef typename field_injector<T1>::object_type oT;
AA = new podarray< field_injector_row<oT>* >; AA = new podarray< field_injector_row<oT>* >;
BB = new podarray< field_injector_row<oT>* >; BB = new podarray< field_injector_row<oT>* >;
podarray< field_injector_row<oT>* >& A = *AA; podarray< field_injector_row<oT>* >& A = *AA;
A.set_size(n_rows); A.set_size(n_rows);
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
A[row] = new field_injector_row<oT>; A[row] = new field_injector_row<oT>;
} }
(*(A[0])).insert(val); (*(A[0])).insert(val);
} }
template<typename T1> template<typename T1>
inline inline
field_injector<T1>::field_injector(T1& in_X, const injector_end_of_row& x) field_injector<T1>::field_injector(T1& in_X, const injector_end_of_row& x)
skipping to change at line 405 skipping to change at line 405
typedef typename field_injector<T1>::object_type oT; typedef typename field_injector<T1>::object_type oT;
AA = new podarray< field_injector_row<oT>* >; AA = new podarray< field_injector_row<oT>* >;
BB = new podarray< field_injector_row<oT>* >; BB = new podarray< field_injector_row<oT>* >;
podarray< field_injector_row<oT>* >& A = *AA; podarray< field_injector_row<oT>* >& A = *AA;
A.set_size(n_rows); A.set_size(n_rows);
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
A[row] = new field_injector_row<oT>; A[row] = new field_injector_row<oT>;
} }
(*this).end_of_row(); (*this).end_of_row();
} }
template<typename T1> template<typename T1>
inline inline
field_injector<T1>::~field_injector() field_injector<T1>::~field_injector()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename field_injector<T1>::object_type oT; typedef typename field_injector<T1>::object_type oT;
podarray< field_injector_row<oT>* >& A = *AA; podarray< field_injector_row<oT>* >& A = *AA;
if(n_rows > 0) if(n_rows > 0)
{ {
u32 max_n_cols = (*(A[0])).n_cols; uword max_n_cols = (*(A[0])).n_cols;
for(u32 row=1; row<n_rows; ++row) for(uword row=1; row<n_rows; ++row)
{ {
const u32 n_cols = (*(A[row])).n_cols; const uword n_cols = (*(A[row])).n_cols;
if(max_n_cols < n_cols) if(max_n_cols < n_cols)
{ {
max_n_cols = n_cols; max_n_cols = n_cols;
} }
} }
const u32 max_n_rows = ((*(A[n_rows-1])).n_cols == 0) ? n_rows-1 : n_ro ws; const uword max_n_rows = ((*(A[n_rows-1])).n_cols == 0) ? n_rows-1 : n_ rows;
X.set_size(max_n_rows, max_n_cols); X.set_size(max_n_rows, max_n_cols);
for(u32 row=0; row<max_n_rows; ++row) for(uword row=0; row<max_n_rows; ++row)
{ {
const u32 n_cols = (*(A[row])).n_cols; const uword n_cols = (*(A[row])).n_cols;
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
const field<oT>& tmp = *((*(A[row])).AA); const field<oT>& tmp = *((*(A[row])).AA);
X.at(row,col) = tmp[col]; X.at(row,col) = tmp[col];
} }
for(u32 col=n_cols; col<max_n_cols; ++col) for(uword col=n_cols; col<max_n_cols; ++col)
{ {
X.at(row,col) = oT(); X.at(row,col) = oT();
} }
} }
} }
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
delete A[row]; delete A[row];
} }
delete AA; delete AA;
delete BB; delete BB;
} }
template<typename T1> template<typename T1>
inline inline
skipping to change at line 495 skipping to change at line 495
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename field_injector<T1>::object_type oT; typedef typename field_injector<T1>::object_type oT;
podarray< field_injector_row<oT>* >& A = *AA; podarray< field_injector_row<oT>* >& A = *AA;
podarray< field_injector_row<oT>* >& B = *BB; podarray< field_injector_row<oT>* >& B = *BB;
B.set_size( n_rows+1 ); B.set_size( n_rows+1 );
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
B[row] = A[row]; B[row] = A[row];
} }
for(u32 row=n_rows; row<(n_rows+1); ++row) for(uword row=n_rows; row<(n_rows+1); ++row)
{ {
B[row] = new field_injector_row<oT>; B[row] = new field_injector_row<oT>;
} }
std::swap(AA, BB); std::swap(AA, BB);
n_rows += 1; n_rows += 1;
} }
template<typename T1> template<typename T1>
 End of changes. 32 change blocks. 
33 lines changed or deleted 33 lines changed or added


 lapack_bones.hpp   lapack_bones.hpp 
skipping to change at line 329 skipping to change at line 329
// void arma_fortran(arma_dgeqp3)(blas_int* m, blas_int* n, double* a, blas_int* lda, blas_int* jpvt, double* tau, double* work, blas_int* lwork, blas_int* info); // void arma_fortran(arma_dgeqp3)(blas_int* m, blas_int* n, double* a, blas_int* lda, blas_int* jpvt, double* tau, double* work, blas_int* lwork, blas_int* info);
// void arma_fortran(arma_dormqr)(char* side, char* trans, blas_int* m, blas_int* n, blas_int* k, double* a, blas_int* lda, double* tau, double* c , blas_int* ldc, double* work, blas_int* lwork, blas_int* info); // void arma_fortran(arma_dormqr)(char* side, char* trans, blas_int* m, blas_int* n, blas_int* k, double* a, blas_int* lda, double* tau, double* c , blas_int* ldc, double* work, blas_int* lwork, blas_int* info);
// void arma_fortran(arma_dposv)(char* uplo, blas_int* n, blas_int* nr hs, double* a, blas_int* lda, double* b, blas_int* ldb, blas_int* info); // void arma_fortran(arma_dposv)(char* uplo, blas_int* n, blas_int* nr hs, double* a, blas_int* lda, double* b, blas_int* ldb, blas_int* info);
} }
template<typename eT> template<typename eT>
inline inline
void void
getrf(blas_int* m, blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, bla s_int* info) getrf(blas_int* m, blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, bla s_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgetrf)(m, n, (T*)a, lda, ipiv, info); arma_fortran(arma_sgetrf)(m, n, (T*)a, lda, ipiv, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 361 skipping to change at line 361
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_zgetrf)(m, n, (T*)a, lda, ipiv, info); arma_fortran(arma_zgetrf)(m, n, (T*)a, lda, ipiv, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
getri(blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, eT* work, blas_ int* lwork, blas_int* info) getri(blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, eT* work, blas_ int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgetri)(n, (T*)a, lda, ipiv, (T*)work, lwork, info) ; arma_fortran(arma_sgetri)(n, (T*)a, lda, ipiv, (T*)work, lwork, info) ;
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 393 skipping to change at line 393
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_zgetri)(n, (T*)a, lda, ipiv, (T*)work, lwork, info) ; arma_fortran(arma_zgetri)(n, (T*)a, lda, ipiv, (T*)work, lwork, info) ;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
trtri(char* uplo, char* diag, blas_int* n, eT* a, blas_int* lda, blas_int * info) trtri(char* uplo, char* diag, blas_int* n, eT* a, blas_int* lda, blas_int * info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_strtri)(uplo, diag, n, (T*)a, lda, info); arma_fortran(arma_strtri)(uplo, diag, n, (T*)a, lda, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 425 skipping to change at line 425
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_ztrtri)(uplo, diag, n, (T*)a, lda, info); arma_fortran(arma_ztrtri)(uplo, diag, n, (T*)a, lda, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
syev(char* jobz, char* uplo, blas_int* n, eT* a, blas_int* lda, eT* w, e T* work, blas_int* lwork, blas_int* info) syev(char* jobz, char* uplo, blas_int* n, eT* a, blas_int* lda, eT* w, e T* work, blas_int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_ssyev)(jobz, uplo, n, (T*)a, lda, (T*)w, (T*)work, lwork, info); arma_fortran(arma_ssyev)(jobz, uplo, n, (T*)a, lda, (T*)w, (T*)work, lwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 451 skipping to change at line 451
inline inline
void void
heev heev
( (
char* jobz, char* uplo, blas_int* n, char* jobz, char* uplo, blas_int* n,
eT* a, blas_int* lda, typename eT::value_type* w, eT* a, blas_int* lda, typename eT::value_type* w,
eT* work, blas_int* lwork, typename eT::value_type* rwork, eT* work, blas_int* lwork, typename eT::value_type* rwork,
blas_int* info blas_int* info
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_supported_complex_float<eT>::value == true) if(is_supported_complex_float<eT>::value == true)
{ {
typedef float T; typedef float T;
typedef typename std::complex<T> cx_T; typedef typename std::complex<T> cx_T;
arma_fortran(arma_cheev)(jobz, uplo, n, (cx_T*)a, lda, (T*)w, (cx_T*) work, lwork, (T*)rwork, info); arma_fortran(arma_cheev)(jobz, uplo, n, (cx_T*)a, lda, (T*)w, (cx_T*) work, lwork, (T*)rwork, info);
} }
else else
if(is_supported_complex_double<eT>::value == true) if(is_supported_complex_double<eT>::value == true)
{ {
skipping to change at line 480 skipping to change at line 480
void void
geev geev
( (
char* jobvl, char* jobvr, blas_int* n, char* jobvl, char* jobvr, blas_int* n,
eT* a, blas_int* lda, eT* wr, eT* wi, eT* vl, eT* a, blas_int* lda, eT* wr, eT* wi, eT* vl,
blas_int* ldvl, eT* vr, blas_int* ldvr, blas_int* ldvl, eT* vr, blas_int* ldvr,
eT* work, blas_int* lwork, eT* work, blas_int* lwork,
blas_int* info blas_int* info
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgeev)(jobvl, jobvr, n, (T*)a, lda, (T*)wr, (T*)wi , (T*)vl, ldvl, (T*)vr, ldvr, (T*)work, lwork, info); arma_fortran(arma_sgeev)(jobvl, jobvr, n, (T*)a, lda, (T*)wr, (T*)wi , (T*)vl, ldvl, (T*)vr, ldvr, (T*)work, lwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 508 skipping to change at line 508
cx_geev cx_geev
( (
char* jobvl, char* jobvr, blas_int* n, char* jobvl, char* jobvr, blas_int* n,
eT* a, blas_int* lda, eT* w, eT* a, blas_int* lda, eT* w,
eT* vl, blas_int* ldvl, eT* vl, blas_int* ldvl,
eT* vr, blas_int* ldvr, eT* vr, blas_int* ldvr,
eT* work, blas_int* lwork, typename eT::value_type* rwork, eT* work, blas_int* lwork, typename eT::value_type* rwork,
blas_int* info blas_int* info
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_supported_complex_float<eT>::value == true) if(is_supported_complex_float<eT>::value == true)
{ {
typedef float T; typedef float T;
typedef typename std::complex<T> cx_T; typedef typename std::complex<T> cx_T;
arma_fortran(arma_cgeev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)w, (c x_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work, lwork, (T*)rwork, info); arma_fortran(arma_cgeev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)w, (c x_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work, lwork, (T*)rwork, info);
} }
else else
if(is_supported_complex_double<eT>::value == true) if(is_supported_complex_double<eT>::value == true)
{ {
skipping to change at line 530 skipping to change at line 530
typedef typename std::complex<T> cx_T; typedef typename std::complex<T> cx_T;
arma_fortran(arma_zgeev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)w, (c x_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work, lwork, (T*)rwork, info); arma_fortran(arma_zgeev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)w, (c x_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work, lwork, (T*)rwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
potrf(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* info) potrf(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_spotrf)(uplo, n, (T*)a, lda, info); arma_fortran(arma_spotrf)(uplo, n, (T*)a, lda, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 563 skipping to change at line 563
arma_fortran(arma_zpotrf)(uplo, n, (T*)a, lda, info); arma_fortran(arma_zpotrf)(uplo, n, (T*)a, lda, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
potri(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* info) potri(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_spotri)(uplo, n, (T*)a, lda, info); arma_fortran(arma_spotri)(uplo, n, (T*)a, lda, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 596 skipping to change at line 596
arma_fortran(arma_zpotri)(uplo, n, (T*)a, lda, info); arma_fortran(arma_zpotri)(uplo, n, (T*)a, lda, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
geqrf(blas_int* m, blas_int* n, eT* a, blas_int* lda, eT* tau, eT* work, blas_int* lwork, blas_int* info) geqrf(blas_int* m, blas_int* n, eT* a, blas_int* lda, eT* tau, eT* work, blas_int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgeqrf)(m, n, (T*)a, lda, (T*)tau, (T*)work, lwork, info); arma_fortran(arma_sgeqrf)(m, n, (T*)a, lda, (T*)tau, (T*)work, lwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 629 skipping to change at line 629
arma_fortran(arma_zgeqrf)(m, n, (T*)a, lda, (T*)tau, (T*)work, lwork, info); arma_fortran(arma_zgeqrf)(m, n, (T*)a, lda, (T*)tau, (T*)work, lwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
orgqr(blas_int* m, blas_int* n, blas_int* k, eT* a, blas_int* lda, eT* ta u, eT* work, blas_int* lwork, blas_int* info) orgqr(blas_int* m, blas_int* n, blas_int* k, eT* a, blas_int* lda, eT* ta u, eT* work, blas_int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sorgqr)(m, n, k, (T*)a, lda, (T*)tau, (T*)work, lwo rk, info); arma_fortran(arma_sorgqr)(m, n, k, (T*)a, lda, (T*)tau, (T*)work, lwo rk, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
arma_fortran(arma_dorgqr)(m, n, k, (T*)a, lda, (T*)tau, (T*)work, lwo rk, info); arma_fortran(arma_dorgqr)(m, n, k, (T*)a, lda, (T*)tau, (T*)work, lwo rk, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
ungqr(blas_int* m, blas_int* n, blas_int* k, eT* a, blas_int* lda, eT* ta u, eT* work, blas_int* lwork, blas_int* info) ungqr(blas_int* m, blas_int* n, blas_int* k, eT* a, blas_int* lda, eT* ta u, eT* work, blas_int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_supported_complex_float<eT>::value == true) if(is_supported_complex_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_cungqr)(m, n, k, (T*)a, lda, (T*)tau, (T*)work, lwo rk, info); arma_fortran(arma_cungqr)(m, n, k, (T*)a, lda, (T*)tau, (T*)work, lwo rk, info);
} }
else else
if(is_supported_complex_double<eT>::value == true) if(is_supported_complex_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 674 skipping to change at line 674
template<typename eT> template<typename eT>
inline inline
void void
gesvd gesvd
( (
char* jobu, char* jobvt, blas_int* m, blas_int* n, eT* a, blas_int* lda , char* jobu, char* jobvt, blas_int* m, blas_int* n, eT* a, blas_int* lda ,
eT* s, eT* u, blas_int* ldu, eT* vt, blas_int* ldvt, eT* s, eT* u, blas_int* ldu, eT* vt, blas_int* ldvt,
eT* work, blas_int* lwork, blas_int* info eT* work, blas_int* lwork, blas_int* info
) )
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgesvd)(jobu, jobvt, m, n, (T*)a, lda, (T*)s, (T*)u , ldu, (T*)vt, ldvt, (T*)work, lwork, info); arma_fortran(arma_sgesvd)(jobu, jobvt, m, n, (T*)a, lda, (T*)s, (T*)u , ldu, (T*)vt, ldvt, (T*)work, lwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 699 skipping to change at line 699
template<typename T> template<typename T>
inline inline
void void
cx_gesvd cx_gesvd
( (
char* jobu, char* jobvt, blas_int* m, blas_int* n, std::complex<T>* a, blas_int* lda, char* jobu, char* jobvt, blas_int* m, blas_int* n, std::complex<T>* a, blas_int* lda,
T* s, std::complex<T>* u, blas_int* ldu, std::complex<T>* vt, blas_int* ldvt, T* s, std::complex<T>* u, blas_int* ldu, std::complex<T>* vt, blas_int* ldvt,
std::complex<T>* work, blas_int* lwork, T* rwork, blas_int* info std::complex<T>* work, blas_int* lwork, T* rwork, blas_int* info
) )
{ {
arma_type_check<is_supported_blas_type<T>::value == false>::apply(); arma_type_check(( is_supported_blas_type<T>::value == false ));
arma_type_check<is_supported_blas_type< std::complex<T> >::value == fal arma_type_check(( is_supported_blas_type< std::complex<T> >::value == f
se>::apply(); alse ));
if(is_float<T>::value == true) if(is_float<T>::value == true)
{ {
typedef float bT; typedef float bT;
arma_fortran(arma_cgesvd) arma_fortran(arma_cgesvd)
( (
jobu, jobvt, m, n, (std::complex<bT>*)a, lda, jobu, jobvt, m, n, (std::complex<bT>*)a, lda,
(bT*)s, (std::complex<bT>*)u, ldu, (std::complex<bT>*)vt, ldvt, (bT*)s, (std::complex<bT>*)u, ldu, (std::complex<bT>*)vt, ldvt,
(std::complex<bT>*)work, lwork, (bT*)rwork, info (std::complex<bT>*)work, lwork, (bT*)rwork, info
); );
skipping to change at line 730 skipping to change at line 730
(std::complex<bT>*)work, lwork, (bT*)rwork, info (std::complex<bT>*)work, lwork, (bT*)rwork, info
); );
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
gesv(blas_int* n, blas_int* nrhs, eT* a, blas_int* lda, blas_int* ipiv, e T* b, blas_int* ldb, blas_int* info) gesv(blas_int* n, blas_int* nrhs, eT* a, blas_int* lda, blas_int* ipiv, e T* b, blas_int* ldb, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgesv)(n, nrhs, (T*)a, lda, ipiv, (T*)b, ldb, info) ; arma_fortran(arma_sgesv)(n, nrhs, (T*)a, lda, ipiv, (T*)b, ldb, info) ;
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 762 skipping to change at line 762
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_zgesv)(n, nrhs, (T*)a, lda, ipiv, (T*)b, ldb, info) ; arma_fortran(arma_zgesv)(n, nrhs, (T*)a, lda, ipiv, (T*)b, ldb, info) ;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
gels(char* trans, blas_int* m, blas_int* n, blas_int* nrhs, eT* a, blas_i nt* lda, eT* b, blas_int* ldb, eT* work, blas_int* lwork, blas_int* info) gels(char* trans, blas_int* m, blas_int* n, blas_int* nrhs, eT* a, blas_i nt* lda, eT* b, blas_int* ldb, eT* work, blas_int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgels)(trans, m, n, nrhs, (T*)a, lda, (T*)b, ldb, ( T*)work, lwork, info); arma_fortran(arma_sgels)(trans, m, n, nrhs, (T*)a, lda, (T*)b, ldb, ( T*)work, lwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 794 skipping to change at line 794
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_zgels)(trans, m, n, nrhs, (T*)a, lda, (T*)b, ldb, ( T*)work, lwork, info); arma_fortran(arma_zgels)(trans, m, n, nrhs, (T*)a, lda, (T*)b, ldb, ( T*)work, lwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
trtrs(char* uplo, char* trans, char* diag, blas_int* n, blas_int* nrhs, c onst eT* a, blas_int* lda, eT* b, blas_int* ldb, blas_int* info) trtrs(char* uplo, char* trans, char* diag, blas_int* n, blas_int* nrhs, c onst eT* a, blas_int* lda, eT* b, blas_int* ldb, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_strtrs)(uplo, trans, diag, n, nrhs, (T*)a, lda, (T* )b, ldb, info); arma_fortran(arma_strtrs)(uplo, trans, diag, n, nrhs, (T*)a, lda, (T* )b, ldb, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 826 skipping to change at line 826
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_ztrtrs)(uplo, trans, diag, n, nrhs, (T*)a, lda, (T* )b, ldb, info); arma_fortran(arma_ztrtrs)(uplo, trans, diag, n, nrhs, (T*)a, lda, (T* )b, ldb, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
gees(char* jobvs, char* sort, blas_int* select, blas_int* n, eT* a, blas_ int* lda, blas_int* sdim, eT* wr, eT* wi, eT* vs, blas_int* ldvs, eT* work, blas_int* lwork, blas_int* bwork, blas_int* info) gees(char* jobvs, char* sort, blas_int* select, blas_int* n, eT* a, blas_ int* lda, blas_int* sdim, eT* wr, eT* wi, eT* vs, blas_int* ldvs, eT* work, blas_int* lwork, blas_int* bwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(sgees)(jobvs, sort, select, n, (T*)a, lda, sdim, (T*)wr, (T*)wi, (T*)vs, ldvs, (T*)work, lwork, bwork, info); arma_fortran(sgees)(jobvs, sort, select, n, (T*)a, lda, sdim, (T*)wr, (T*)wi, (T*)vs, ldvs, (T*)work, lwork, bwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
arma_fortran(dgees)(jobvs, sort, select, n, (T*)a, lda, sdim, (T*)wr, (T*)wi, (T*)vs, ldvs, (T*)work, lwork, bwork, info); arma_fortran(dgees)(jobvs, sort, select, n, (T*)a, lda, sdim, (T*)wr, (T*)wi, (T*)vs, ldvs, (T*)work, lwork, bwork, info);
} }
} }
template<typename T> template<typename T>
inline inline
void void
cx_gees(char* jobvs, char* sort, blas_int* select, blas_int* n, std::comp lex<T>* a, blas_int* lda, blas_int* sdim, std::complex<T>* w, std::complex< T>* vs, blas_int* ldvs, std::complex<T>* work, blas_int* lwork, T* rwork, b las_int* bwork, blas_int* info) cx_gees(char* jobvs, char* sort, blas_int* select, blas_int* n, std::comp lex<T>* a, blas_int* lda, blas_int* sdim, std::complex<T>* w, std::complex< T>* vs, blas_int* ldvs, std::complex<T>* work, blas_int* lwork, T* rwork, b las_int* bwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<T>::value == false>::apply(); arma_type_check(( is_supported_blas_type<T>::value == false ));
arma_type_check<is_supported_blas_type< std::complex<T> >::value == fal arma_type_check(( is_supported_blas_type< std::complex<T> >::value == f
se>::apply(); alse ));
if(is_float<T>::value == true) if(is_float<T>::value == true)
{ {
typedef float bT; typedef float bT;
typedef std::complex<bT> cT; typedef std::complex<bT> cT;
arma_fortran(cgees)(jobvs, sort, select, n, (cT*)a, lda, sdim, (cT*)w , (cT*)vs, ldvs, (cT*)work, lwork, (bT*)rwork, bwork, info); arma_fortran(cgees)(jobvs, sort, select, n, (cT*)a, lda, sdim, (cT*)w , (cT*)vs, ldvs, (cT*)work, lwork, (bT*)rwork, bwork, info);
} }
else else
if(is_double<T>::value == true) if(is_double<T>::value == true)
{ {
skipping to change at line 869 skipping to change at line 869
typedef std::complex<bT> cT; typedef std::complex<bT> cT;
arma_fortran(zgees)(jobvs, sort, select, n, (cT*)a, lda, sdim, (cT*)w , (cT*)vs, ldvs, (cT*)work, lwork, (bT*)rwork, bwork, info); arma_fortran(zgees)(jobvs, sort, select, n, (cT*)a, lda, sdim, (cT*)w , (cT*)vs, ldvs, (cT*)work, lwork, (bT*)rwork, bwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
trsyl(char* transa, char* transb, blas_int* isgn, blas_int* m, blas_int* n, const eT* a, blas_int* lda, const eT* b, blas_int* ldb, eT* c, blas_int* ldc, eT* scale, blas_int* info) trsyl(char* transa, char* transb, blas_int* isgn, blas_int* m, blas_int* n, const eT* a, blas_int* lda, const eT* b, blas_int* ldb, eT* c, blas_int* ldc, eT* scale, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(strsyl)(transa, transb, isgn, m, n, (T*)a, lda, (T*)b, l db, (T*)c, ldc, (T*)scale, info); arma_fortran(strsyl)(transa, transb, isgn, m, n, (T*)a, lda, (T*)b, l db, (T*)c, ldc, (T*)scale, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 901 skipping to change at line 901
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(ztrsyl)(transa, transb, isgn, m, n, (T*)a, lda, (T*)b, l db, (T*)c, ldc, (double*)scale, info); arma_fortran(ztrsyl)(transa, transb, isgn, m, n, (T*)a, lda, (T*)b, l db, (T*)c, ldc, (double*)scale, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
sytrf(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, eT* work, blas_int* lwork, blas_int* info) sytrf(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, eT* work, blas_int* lwork, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_ssytrf)(uplo, n, (T*)a, lda, ipiv, (T*)work, lwork, info); arma_fortran(arma_ssytrf)(uplo, n, (T*)a, lda, ipiv, (T*)work, lwork, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
skipping to change at line 933 skipping to change at line 933
typedef std::complex<double> T; typedef std::complex<double> T;
arma_fortran(arma_zsytrf)(uplo, n, (T*)a, lda, ipiv, (T*)work, lwork, info); arma_fortran(arma_zsytrf)(uplo, n, (T*)a, lda, ipiv, (T*)work, lwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
sytri(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, eT* work, blas_int* info) sytri(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* ipiv, eT* work, blas_int* info)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_ssytri)(uplo, n, (T*)a, lda, ipiv, (T*)work, info); arma_fortran(arma_ssytri)(uplo, n, (T*)a, lda, ipiv, (T*)work, info);
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
 End of changes. 22 change blocks. 
26 lines changed or deleted 26 lines changed or added


 mtGlueCube_bones.hpp   mtGlueCube_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 25 skipping to change at line 25
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class mtGlueCube : public BaseCube<out_eT, mtGlueCube<out_eT, T1, T2, glue_ type> > class mtGlueCube : public BaseCube<out_eT, mtGlueCube<out_eT, T1, T2, glue_ type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
arma_inline mtGlueCube(const T1& in_A, const T2& in_B); arma_inline mtGlueCube(const T1& in_A, const T2& in_B);
arma_inline mtGlueCube(const T1& in_A, const T2& in_B, const u32 in_aux_ u32); arma_inline mtGlueCube(const T1& in_A, const T2& in_B, const uword in_au x_uword);
arma_inline ~mtGlueCube(); arma_inline ~mtGlueCube();
arma_aligned const T1& A; //!< first operand arma_aligned const T1& A; //!< first operand
arma_aligned const T2& B; //!< second operand arma_aligned const T2& B; //!< second operand
arma_aligned const u32 aux_u32; //!< storage of auxiliary data, u32 forma arma_aligned uword aux_uword; //!< storage of auxiliary data, uword
t format
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
7 lines changed or deleted 7 lines changed or added


 mtGlueCube_meat.hpp   mtGlueCube_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup mtGlueCube //! \addtogroup mtGlueCube
//! @{ //! @{
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
inline inline
mtGlueCube<out_eT,T1,T2,glue_type>::mtGlueCube(const T1& in_A, const T2& in _B) mtGlueCube<out_eT,T1,T2,glue_type>::mtGlueCube(const T1& in_A, const T2& in _B)
: A(in_A) : A(in_A)
, B(in_B) , B(in_B)
, aux_u32(aux_u32)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
inline inline
mtGlueCube<out_eT,T1,T2,glue_type>::mtGlueCube(const T1& in_A, const T2& in _B, const u32 in_aux_u32) mtGlueCube<out_eT,T1,T2,glue_type>::mtGlueCube(const T1& in_A, const T2& in _B, const uword in_aux_uword)
: A(in_A) : A(in_A)
, B(in_B) , B(in_B)
, aux_u32(in_aux_u32) , aux_uword(in_aux_uword)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
inline inline
mtGlueCube<out_eT,T1,T2,glue_type>::~mtGlueCube() mtGlueCube<out_eT,T1,T2,glue_type>::~mtGlueCube()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
 End of changes. 4 change blocks. 
5 lines changed or deleted 4 lines changed or added


 mtGlue_bones.hpp   mtGlue_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 25 skipping to change at line 25
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class mtGlue : public Base<out_eT, mtGlue<out_eT, T1, T2, glue_type> > class mtGlue : public Base<out_eT, mtGlue<out_eT, T1, T2, glue_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
arma_inline mtGlue(const T1& in_A, const T2& in_B); arma_inline mtGlue(const T1& in_A, const T2& in_B);
arma_inline mtGlue(const T1& in_A, const T2& in_B, const u32 in_aux_u32) ; arma_inline mtGlue(const T1& in_A, const T2& in_B, const uword in_aux_uw ord);
arma_inline ~mtGlue(); arma_inline ~mtGlue();
arma_aligned const T1& A; //!< first operand arma_aligned const T1& A; //!< first operand
arma_aligned const T2& B; //!< second operand arma_aligned const T2& B; //!< second operand
arma_aligned const u32 aux_u32; //!< storage of auxiliary data, u32 forma arma_aligned uword aux_uword; //!< storage of auxiliary data, uword
t format
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
7 lines changed or deleted 7 lines changed or added


 mtGlue_meat.hpp   mtGlue_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup mtGlue //! \addtogroup mtGlue
//! @{ //! @{
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
inline inline
mtGlue<out_eT,T1,T2,glue_type>::mtGlue(const T1& in_A, const T2& in_B) mtGlue<out_eT,T1,T2,glue_type>::mtGlue(const T1& in_A, const T2& in_B)
: A(in_A) : A(in_A)
, B(in_B) , B(in_B)
, aux_u32(aux_u32)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
inline inline
mtGlue<out_eT,T1,T2,glue_type>::mtGlue(const T1& in_A, const T2& in_B, cons t u32 in_aux_u32) mtGlue<out_eT,T1,T2,glue_type>::mtGlue(const T1& in_A, const T2& in_B, cons t uword in_aux_uword)
: A(in_A) : A(in_A)
, B(in_B) , B(in_B)
, aux_u32(in_aux_u32) , aux_uword(in_aux_uword)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
inline inline
mtGlue<out_eT,T1,T2,glue_type>::~mtGlue() mtGlue<out_eT,T1,T2,glue_type>::~mtGlue()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
 End of changes. 4 change blocks. 
5 lines changed or deleted 4 lines changed or added


 mtOpCube_bones.hpp   mtOpCube_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
inline explicit mtOpCube(const T1& in_m); inline explicit mtOpCube(const T1& in_m);
inline mtOpCube(const T1& in_m, const in_eT in_aux); inline mtOpCube(const T1& in_m, const in_eT in_aux);
inline mtOpCube(const T1& in_m, const u32 in_aux_u32_a, const inline mtOpCube(const T1& in_m, const uword in_aux_uword_a, cons
u32 in_aux_u32_b, const u32 in_aux_u32_c); t uword in_aux_uword_b, const uword in_aux_uword_c);
inline mtOpCube(const T1& in_m, const in_eT in_aux, const inline mtOpCube(const T1& in_m, const in_eT in_aux, cons
u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c); t uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uwor
d_c);
inline mtOpCube(const char junk, const T1& in_m, const out_eT in _aux); inline mtOpCube(const char junk, const T1& in_m, const out_eT in _aux);
inline ~mtOpCube(); inline ~mtOpCube();
arma_aligned const T1& m; //!< storage of reference to the o arma_aligned const T1& m; //!< storage of reference to the
perand (e.g. a matrix) operand (eg. a matrix)
arma_aligned const in_eT aux; //!< storage of auxiliary data, us arma_aligned in_eT aux; //!< storage of auxiliary data, u
ing the element type as used by T1 sing the element type as used by T1
arma_aligned const out_eT aux_out_eT; //!< storage of auxiliary data, us arma_aligned out_eT aux_out_eT; //!< storage of auxiliary data, u
ing the element type as specified by the out_eT template parameter sing the element type as specified by the out_eT template parameter
arma_aligned const u32 aux_u32_a; //!< storage of auxiliary data, u3 arma_aligned uword aux_uword_a; //!< storage of auxiliary data, u
2 format word format
arma_aligned const u32 aux_u32_b; //!< storage of auxiliary data, u3 arma_aligned uword aux_uword_b; //!< storage of auxiliary data, u
2 format word format
arma_aligned const u32 aux_u32_c; //!< storage of auxiliary data, u3 arma_aligned uword aux_uword_c; //!< storage of auxiliary data, u
2 format word format
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
18 lines changed or deleted 19 lines changed or added


 mtOpCube_meat.hpp   mtOpCube_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup mtOpCube //! \addtogroup mtOpCube
//! @{ //! @{
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m) mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m)
: m(in_m) : m(in_m)
, aux(aux)
, aux_out_eT(aux_out_eT)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
, aux_u32_c(aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m, const typename T1:: elem_type in_aux) mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m, const typename T1:: elem_type in_aux)
: m(in_m) : m(in_m)
, aux(in_aux) , aux(in_aux)
, aux_out_eT(aux_out_eT)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
, aux_u32_c(aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m, const u32 in_aux_u3 2_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c) mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m, const uword in_aux_ uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c)
: m(in_m) : m(in_m)
, aux(aux) , aux_uword_a(in_aux_uword_a)
, aux_out_eT(aux_out_eT) , aux_uword_b(in_aux_uword_b)
, aux_u32_a(in_aux_u32_a) , aux_uword_c(in_aux_uword_c)
, aux_u32_b(in_aux_u32_b)
, aux_u32_c(in_aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m, const typename T1:: elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c) mtOpCube<out_eT, T1, op_type>::mtOpCube(const T1& in_m, const typename T1:: elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b, c onst uword in_aux_uword_c)
: m(in_m) : m(in_m)
, aux(in_aux) , aux(in_aux)
, aux_out_eT(aux_out_eT) , aux_uword_a(in_aux_uword_a)
, aux_u32_a(in_aux_u32_a) , aux_uword_b(in_aux_uword_b)
, aux_u32_b(in_aux_u32_b) , aux_uword_c(in_aux_uword_c)
, aux_u32_c(in_aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOpCube<out_eT, T1, op_type>::mtOpCube(const char junk, const T1& in_m, co nst out_eT in_aux) mtOpCube<out_eT, T1, op_type>::mtOpCube(const char junk, const T1& in_m, co nst out_eT in_aux)
: m(in_m) : m(in_m)
, aux(aux)
, aux_out_eT(in_aux) , aux_out_eT(in_aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
, aux_u32_c(aux_u32_c)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOpCube<out_eT, T1, op_type>::~mtOpCube() mtOpCube<out_eT, T1, op_type>::~mtOpCube()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 9 change blocks. 
26 lines changed or deleted 10 lines changed or added


 mtOp_bones.hpp   mtOp_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
inline explicit mtOp(const T1& in_m); inline explicit mtOp(const T1& in_m);
inline mtOp(const T1& in_m, const in_eT in_aux); inline mtOp(const T1& in_m, const in_eT in_aux);
inline mtOp(const T1& in_m, const u32 in_aux_u32_a, const u32 inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uw
in_aux_u32_b); ord in_aux_uword_b);
inline mtOp(const T1& in_m, const in_eT in_aux, const u32 inline mtOp(const T1& in_m, const in_eT in_aux, const uw
in_aux_u32_a, const u32 in_aux_u32_b); ord in_aux_uword_a, const uword in_aux_uword_b);
inline mtOp(const char junk, const T1& in_m, const out_eT in_aux ); inline mtOp(const char junk, const T1& in_m, const out_eT in_aux );
inline ~mtOp(); inline ~mtOp();
arma_aligned const T1& m; //!< storage of reference to the o arma_aligned const T1& m; //!< storage of reference to the
perand (e.g. a matrix) operand (eg. a matrix)
arma_aligned const in_eT aux; //!< storage of auxiliary data, us arma_aligned in_eT aux; //!< storage of auxiliary data, u
ing the element type as used by T1 sing the element type as used by T1
arma_aligned const out_eT aux_out_eT; //!< storage of auxiliary data, us arma_aligned out_eT aux_out_eT; //!< storage of auxiliary data, u
ing the element type as specified by the out_eT template parameter sing the element type as specified by the out_eT template parameter
arma_aligned const u32 aux_u32_a; //!< storage of auxiliary data, u3 arma_aligned uword aux_uword_a; //!< storage of auxiliary data, u
2 format word format
arma_aligned const u32 aux_u32_b; //!< storage of auxiliary data, u3 arma_aligned uword aux_uword_b; //!< storage of auxiliary data, u
2 format word format
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
16 lines changed or deleted 16 lines changed or added


 mtOp_meat.hpp   mtOp_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup mtOp //! \addtogroup mtOp
//! @{ //! @{
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m) mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m)
: m(in_m) : m(in_m)
, aux(aux)
, aux_out_eT(aux_out_eT)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m, const typename T1::elem_typ e in_aux) mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m, const typename T1::elem_typ e in_aux)
: m(in_m) : m(in_m)
, aux(in_aux) , aux(in_aux)
, aux_out_eT(aux_out_eT)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m, const u32 in_aux_u32_a, con st u32 in_aux_u32_b) mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b)
: m(in_m) : m(in_m)
, aux(aux) , aux_uword_a(in_aux_uword_a)
, aux_out_eT(aux_out_eT) , aux_uword_b(in_aux_uword_b)
, aux_u32_a(in_aux_u32_a)
, aux_u32_b(in_aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m, const typename T1::elem_typ e in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32_b) mtOp<out_eT, T1, op_type>::mtOp(const T1& in_m, const typename T1::elem_typ e in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b)
: m(in_m) : m(in_m)
, aux(in_aux) , aux(in_aux)
, aux_out_eT(aux_out_eT) , aux_uword_a(in_aux_uword_a)
, aux_u32_a(in_aux_u32_a) , aux_uword_b(in_aux_uword_b)
, aux_u32_b(in_aux_u32_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOp<out_eT, T1, op_type>::mtOp(const char junk, const T1& in_m, const out_ eT in_aux) mtOp<out_eT, T1, op_type>::mtOp(const char junk, const T1& in_m, const out_ eT in_aux)
: m(in_m) : m(in_m)
, aux(aux)
, aux_out_eT(in_aux) , aux_out_eT(in_aux)
, aux_u32_a(aux_u32_a)
, aux_u32_b(aux_u32_b)
{ {
arma_ignore(junk); arma_ignore(junk);
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
inline inline
mtOp<out_eT, T1, op_type>::~mtOp() mtOp<out_eT, T1, op_type>::~mtOp()
{ {
 End of changes. 9 change blocks. 
21 lines changed or deleted 8 lines changed or added


 op_cor_bones.hpp   op_cor_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_cor //! \addtogroup op_cor
//! @{ //! @{
class op_cor class op_cor
{ {
public: public:
template<typename eT> inline static void direct_cor(Mat<eT>& template<typename eT> inline static void direct_cor(Mat<eT>&
out, const Mat<eT>& X, const u32 norm_type); out, const Mat<eT>& X, const uword norm_type);
template<typename T> inline static void direct_cor(Mat< std::complex<T> template<typename T> inline static void direct_cor(Mat< std::complex<T>
>& out, const Mat< std::complex<T> >& X, const u32 norm_type); >& out, const Mat< std::complex<T> >& X, const uword norm_type);
template<typename T1> inline static void apply(Mat<typename T1::elem_type >& out, const Op<T1,op_cor>& in); template<typename T1> inline static void apply(Mat<typename T1::elem_type >& out, const Op<T1,op_cor>& in);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_cor_meat.hpp   op_cor_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_cor //! \addtogroup op_cor
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
op_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const u32 norm_type) op_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty()) if(A.is_empty())
{ {
out.reset(); out.reset();
return; return;
} }
if(A.is_vec()) if(A.is_vec())
{ {
out.set_size(1,1); out.set_size(1,1);
out[0] = eT(1); out[0] = eT(1);
} }
else else
{ {
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
const Row<eT> acc = sum(A); const Row<eT> acc = sum(A);
const Row<eT> sd = stddev(A); const Row<eT> sd = stddev(A);
out = (trans(A) * A); out = (trans(A) * A);
out -= (trans(acc) * acc)/eT(N); out -= (trans(acc) * acc)/eT(N);
out /= norm_val; out /= norm_val;
out /= trans(sd) * sd; out /= trans(sd) * sd;
} }
} }
template<typename T> template<typename T>
inline inline
void void
op_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const u32 norm_type) op_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(A.is_empty()) if(A.is_empty())
{ {
out.reset(); out.reset();
return; return;
} }
if(A.is_vec()) if(A.is_vec())
{ {
out.set_size(1,1); out.set_size(1,1);
out[0] = eT(1); out[0] = eT(1);
} }
else else
{ {
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
const Row<eT> acc = sum(A); const Row<eT> acc = sum(A);
const Row<T> sd = stddev(A); const Row<T> sd = stddev(A);
out = trans(A) * A; // out = strans(conj(A)) * A; out = trans(A) * A; // out = strans(conj(A)) * A;
out -= (trans(acc) * acc)/eT(N); // out -= (strans(conj(acc)) * acc)/e T(N); out -= (trans(acc) * acc)/eT(N); // out -= (strans(conj(acc)) * acc)/e T(N);
out /= norm_val; out /= norm_val;
//out = out / (trans(sd) * sd); //out = out / (trans(sd) * sd);
skipping to change at line 99 skipping to change at line 99
void void
op_cor::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cor>& in) op_cor::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cor>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a; const uword norm_type = in.aux_uword_a;
op_cor::direct_cor(out, A, norm_type); op_cor::direct_cor(out, A, norm_type);
} }
//! @} //! @}
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 op_cov_bones.hpp   op_cov_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_cov //! \addtogroup op_cov
//! @{ //! @{
class op_cov class op_cov
{ {
public: public:
template<typename eT> inline static void direct_cov(Mat<eT>& template<typename eT> inline static void direct_cov(Mat<eT>&
out, const Mat<eT>& X, const u32 norm_type); out, const Mat<eT>& X, const uword norm_type);
template<typename T> inline static void direct_cov(Mat< std::complex<T> template<typename T> inline static void direct_cov(Mat< std::complex<T>
>& out, const Mat< std::complex<T> >& X, const u32 norm_type); >& out, const Mat< std::complex<T> >& X, const uword norm_type);
template<typename T1> inline static void apply(Mat<typename T1::elem_type >& out, const Op<T1,op_cov>& in); template<typename T1> inline static void apply(Mat<typename T1::elem_type >& out, const Op<T1,op_cov>& in);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_cov_meat.hpp   op_cov_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_cov //! \addtogroup op_cov
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
op_cov::direct_cov(Mat<eT>& out, const Mat<eT>& A, const u32 norm_type) op_cov::direct_cov(Mat<eT>& out, const Mat<eT>& A, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_vec()) if(A.is_vec())
{ {
if(A.n_rows == 1) if(A.n_rows == 1)
{ {
out = var(trans(A), norm_type); out = var(trans(A), norm_type);
} }
else else
{ {
out = var(A, norm_type); out = var(A, norm_type);
} }
} }
else else
{ {
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
const Row<eT> acc = sum(A); const Row<eT> acc = sum(A);
out = trans(A) * A; out = trans(A) * A;
out -= (trans(acc) * acc)/eT(N); out -= (trans(acc) * acc)/eT(N);
out /= norm_val; out /= norm_val;
} }
} }
template<typename T> template<typename T>
inline inline
void void
op_cov::direct_cov(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const u32 norm_type) op_cov::direct_cov(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(A.is_vec()) if(A.is_vec())
{ {
if(A.n_rows == 1) if(A.n_rows == 1)
{ {
const Mat<T> tmp_mat = var(trans(A), norm_type); const Mat<T> tmp_mat = var(trans(A), norm_type);
skipping to change at line 74 skipping to change at line 74
} }
else else
{ {
const Mat<T> tmp_mat = var(A, norm_type); const Mat<T> tmp_mat = var(A, norm_type);
out.set_size(1,1); out.set_size(1,1);
out[0] = tmp_mat[0]; out[0] = tmp_mat[0];
} }
} }
else else
{ {
const u32 N = A.n_rows; const uword N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
const Row<eT> acc = sum(A); const Row<eT> acc = sum(A);
out = trans(A) * A; // out = strans(conj(A)) * A; out = trans(A) * A; // out = strans(conj(A)) * A;
out -= (trans(acc) * acc)/eT(N); // out -= (strans(conj(acc)) * acc)/e T(N); out -= (trans(acc) * acc)/eT(N); // out -= (strans(conj(acc)) * acc)/e T(N);
out /= norm_val; out /= norm_val;
} }
} }
skipping to change at line 97 skipping to change at line 97
void void
op_cov::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cov>& in) op_cov::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cov>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a; const uword norm_type = in.aux_uword_a;
op_cov::direct_cov(out, A, norm_type); op_cov::direct_cov(out, A, norm_type);
} }
//! @} //! @}
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 op_cumsum_meat.hpp   op_cumsum_meat.hpp 
skipping to change at line 28 skipping to change at line 28
void void
op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_mat>& in) op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_mat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or 1");
out.copy_size(X); out.copy_size(X);
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_cumsum::apply(), dim = 0"); arma_extra_debug_print("op_cumsum::apply(), dim = 0");
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
eT* out_colmem = out.colptr(col); eT* out_colmem = out.colptr(col);
const eT* X_colmem = X.colptr(col); const eT* X_colmem = X.colptr(col);
eT acc = eT(0); eT acc = eT(0);
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
acc += X_colmem[row]; acc += X_colmem[row];
out_colmem[row] = acc; out_colmem[row] = acc;
} }
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_cumsum::apply(), dim = 1"); arma_extra_debug_print("op_cumsum::apply(), dim = 1");
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
eT acc = eT(0); eT acc = eT(0);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
acc += X.at(row,col); acc += X.at(row,col);
out.at(row,col) = acc; out.at(row,col) = acc;
} }
} }
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 86 skipping to change at line 86
void void
op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_vec>& in) op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_vec>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 n_elem = X.n_elem; const uword n_elem = X.n_elem;
out.copy_size(X); out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.memptr(); const eT* X_mem = X.memptr();
eT acc = eT(0); eT acc = eT(0);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
acc += X_mem[i]; acc += X_mem[i];
out_mem[i] = acc; out_mem[i] = acc;
} }
} }
//! @} //! @}
 End of changes. 8 change blocks. 
9 lines changed or deleted 9 lines changed or added


 op_cx_scalar_meat.hpp   op_cx_scalar_meat.hpp 
skipping to change at line 35 skipping to change at line 35
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] * k; out_mem[i] = A[i] * k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_plus::apply op_cx_scalar_plus::apply
( (
skipping to change at line 63 skipping to change at line 63
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] + k; out_mem[i] = A[i] + k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_minus_pre::apply op_cx_scalar_minus_pre::apply
( (
skipping to change at line 91 skipping to change at line 91
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = k - A[i]; out_mem[i] = k - A[i];
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_minus_post::apply op_cx_scalar_minus_post::apply
( (
skipping to change at line 119 skipping to change at line 119
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] - k; out_mem[i] = A[i] - k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_div_pre::apply op_cx_scalar_div_pre::apply
( (
skipping to change at line 147 skipping to change at line 147
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = k / A[i]; out_mem[i] = k / A[i];
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_div_post::apply op_cx_scalar_div_post::apply
( (
skipping to change at line 175 skipping to change at line 175
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] / k; out_mem[i] = A[i] / k;
} }
} }
// //
// //
// //
template<typename T1> template<typename T1>
skipping to change at line 207 skipping to change at line 207
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] * k; out_mem[i] = A[i] * k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_plus::apply op_cx_scalar_plus::apply
( (
skipping to change at line 235 skipping to change at line 235
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] + k; out_mem[i] = A[i] + k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_minus_pre::apply op_cx_scalar_minus_pre::apply
( (
skipping to change at line 263 skipping to change at line 263
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = k - A[i]; out_mem[i] = k - A[i];
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_minus_post::apply op_cx_scalar_minus_post::apply
( (
skipping to change at line 291 skipping to change at line 291
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] - k; out_mem[i] = A[i] - k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_div_pre::apply op_cx_scalar_div_pre::apply
( (
skipping to change at line 319 skipping to change at line 319
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = k / A[i]; out_mem[i] = k / A[i];
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_div_post::apply op_cx_scalar_div_post::apply
( (
skipping to change at line 347 skipping to change at line 347
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = A[i] / k; out_mem[i] = A[i] / k;
} }
} }
//! @} //! @}
 End of changes. 24 change blocks. 
24 lines changed or deleted 24 lines changed or added


 op_diagmat_meat.hpp   op_diagmat_meat.hpp 
skipping to change at line 32 skipping to change at line 32
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.m); const unwrap<T1> tmp(X.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
if(A.is_vec() == true) if(A.is_vec() == true)
{ {
// generate a diagonal matrix out of a vector // generate a diagonal matrix out of a vector
const u32 N = A.n_elem; const uword N = A.n_elem;
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
if(&out != &A) if(&out != &A)
{ {
// no aliasing // no aliasing
out.zeros(N,N); out.zeros(N,N);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.at(i,i) = A_mem[i]; out.at(i,i) = A_mem[i];
} }
} }
else else
{ {
// aliasing // aliasing
const podarray<eT> tmp(A_mem, N); const podarray<eT> tmp(A_mem, N);
const eT* tmp_mem = tmp.memptr(); const eT* tmp_mem = tmp.memptr();
out.zeros(N,N); out.zeros(N,N);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.at(i,i) = tmp_mem[i]; out.at(i,i) = tmp_mem[i];
} }
} }
} }
else else
{ {
// generate a diagonal matrix out of a matrix // generate a diagonal matrix out of a matrix
arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is not square" );
const u32 N = A.n_rows; const uword N = A.n_rows;
if(&out != &A) if(&out != &A)
{ {
// no aliasing // no aliasing
out.zeros(N,N); out.zeros(N,N);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.at(i,i) = A.at(i,i); out.at(i,i) = A.at(i,i);
} }
} }
else else
{ {
// aliasing // aliasing
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
eT* colptr = out.colptr(i); eT* colptr = out.colptr(i);
// clear above the diagonal // clear above the diagonal
arrayops::inplace_set(colptr, eT(0), i); arrayops::inplace_set(colptr, eT(0), i);
// clear below the diagonal // clear below the diagonal
arrayops::inplace_set(colptr+(i+1), eT(0), N-1-i); arrayops::inplace_set(colptr+(i+1), eT(0), N-1-i);
} }
} }
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_diagvec_meat.hpp   op_diagvec_meat.hpp 
skipping to change at line 25 skipping to change at line 25
template<typename T1> template<typename T1>
inline inline
void void
op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec >& X) op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const s32 id = (X.aux_u32_b > 0) ? -s32(X.aux_u32_a) : s32(X.aux_u32_a); const sword id = (X.aux_uword_b > 0) ? -sword(X.aux_uword_a) : sword(X.au x_uword_a);
const unwrap_check<T1> tmp(X.m, out); const unwrap_check<T1> tmp(X.m, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
out = A.diag(id); out = A.diag(id);
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 op_dot_bones.hpp   op_dot_bones.hpp 
skipping to change at line 24 skipping to change at line 24
//! @{ //! @{
//! \brief //! \brief
//! dot product operation //! dot product operation
class op_dot class op_dot
{ {
public: public:
template<typename eT> template<typename eT>
arma_hot arma_pure inline static eT direct_dot_arma(const u32 n_elem, con st eT* const A, const eT* const B); arma_hot arma_pure inline static eT direct_dot_arma(const uword n_elem, c onst eT* const A, const eT* const B);
template<typename eT> template<typename eT>
arma_hot arma_pure inline static typename arma_float_only<eT>::result arma_hot arma_pure inline static typename arma_float_only<eT>::result
direct_dot(const u32 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 typename arma_cx_only<eT>::result arma_hot arma_pure inline static typename arma_cx_only<eT>::result
direct_dot(const u32 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 typename arma_integral_only<eT>::result arma_hot arma_pure inline static typename arma_integral_only<eT>::result
direct_dot(const u32 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 u32 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 arma_inline static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot arma_inline static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
}; };
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 op_dot_meat.hpp   op_dot_meat.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup op_dot //! \addtogroup op_dot
//! @{ //! @{
//! for two arrays, generic version //! for two arrays, generic version
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
eT eT
op_dot::direct_dot_arma(const u32 n_elem, const eT* const A, const eT* cons t B) op_dot::direct_dot_arma(const uword n_elem, const eT* const A, const eT* co nst B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val1 = eT(0); eT val1 = eT(0);
eT val2 = eT(0); eT val2 = eT(0);
u32 i, j; uword i, j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val1 += A[i] * B[i]; val1 += A[i] * B[i];
val2 += A[j] * B[j]; val2 += A[j] * B[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
val1 += A[i] * B[i]; val1 += A[i] * B[i];
skipping to change at line 51 skipping to change at line 51
return val1 + val2; return val1 + val2;
} }
//! for two arrays, float and double version //! for two arrays, float and double version
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
typename arma_float_only<eT>::result typename arma_float_only<eT>::result
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B) op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if( n_elem <= (128/sizeof(eT)) ) if( n_elem <= (128/sizeof(eT)) )
{ {
return op_dot::direct_dot_arma(n_elem, A, B); return op_dot::direct_dot_arma(n_elem, A, B);
} }
else else
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
skipping to change at line 87 skipping to change at line 87
#endif #endif
} }
} }
//! for two arrays, complex version //! for two arrays, complex version
template<typename eT> template<typename eT>
inline inline
arma_hot arma_hot
arma_pure arma_pure
typename arma_cx_only<eT>::result typename arma_cx_only<eT>::result
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B) op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B )
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
arma_extra_debug_print("atlas::cx_cblas_dot()"); arma_extra_debug_print("atlas::cx_cblas_dot()");
return atlas::cx_cblas_dot(n_elem, A, B); return atlas::cx_cblas_dot(n_elem, A, B);
} }
#elif defined(ARMA_USE_BLAS) #elif defined(ARMA_USE_BLAS)
{ {
// TODO: work out the mess with zdotu() and zdotu_sub() in BLAS // TODO: work out the mess with zdotu() and zdotu_sub() in BLAS
skipping to change at line 113 skipping to change at line 113
} }
#endif #endif
} }
//! for two arrays, integral version //! for two arrays, integral version
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
typename arma_integral_only<eT>::result typename arma_integral_only<eT>::result
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B) op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B )
{ {
return op_dot::direct_dot_arma(n_elem, A, B); return op_dot::direct_dot_arma(n_elem, A, B);
} }
//! for three arrays //! for three arrays
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
inline inline
eT eT
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B, const eT* C) op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B , const eT* C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
val += A[i] * B[i] * C[i]; val += A[i] * B[i] * C[i];
} }
return val; return val;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
arma_inline arma_inline
skipping to change at line 198 skipping to change at line 198
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
const Proxy<T2> B(Y.get_ref()); const Proxy<T2> B(Y.get_ref());
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);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "dot(): objects m ust have the same number of elements" ); arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "dot(): objects m ust have the same number of elements" );
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
ea_type1 PA = A.get_ea(); ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea(); ea_type2 PB = B.get_ea();
eT val1 = eT(0); eT val1 = eT(0);
eT val2 = eT(0); eT val2 = eT(0);
u32 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)
{ {
val1 += PA[i] * PB[i]; val1 += PA[i] * PB[i];
val2 += PA[j] * PB[j]; val2 += PA[j] * PB[j];
} }
if(i < N) if(i < N)
{ {
val1 += PA[i] * PB[i]; val1 += PA[i] * PB[i];
skipping to change at line 250 skipping to change at line 250
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);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
const Proxy<T2> B(Y.get_ref()); const Proxy<T2> B(Y.get_ref());
arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "norm_dot(): obje cts must have the same number of elements" ); arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "norm_dot(): obje cts must have the same number of elements" );
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
ea_type1 PA = A.get_ea(); ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea(); ea_type2 PB = B.get_ea();
eT acc1 = eT(0); eT acc1 = eT(0);
eT acc2 = eT(0); eT acc2 = eT(0);
eT acc3 = eT(0); eT acc3 = eT(0);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT tmpA = PA[i]; const eT tmpA = PA[i];
const eT tmpB = PB[i]; const eT tmpB = PB[i];
acc1 += tmpA * tmpA; acc1 += tmpA * tmpA;
acc2 += tmpB * tmpB; acc2 += tmpB * tmpB;
acc3 += tmpA * tmpB; acc3 += tmpA * tmpB;
} }
return acc3 / ( std::sqrt(acc1 * acc2) ); return acc3 / ( std::sqrt(acc1 * acc2) );
skipping to change at line 294 skipping to change at line 294
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X.get_ref()); const unwrap<T1> tmp1(X.get_ref());
const unwrap<T2> tmp2(Y.get_ref()); const unwrap<T2> tmp2(Y.get_ref());
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_check( (A.n_elem != B.n_elem), "norm_dot(): objects must have the same number of elements" ); arma_debug_check( (A.n_elem != B.n_elem), "norm_dot(): objects must have the same number of elements" );
const u32 N = A.n_elem; const uword N = A.n_elem;
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
const eT* B_mem = B.memptr(); const eT* B_mem = B.memptr();
eT acc1 = eT(0); eT acc1 = eT(0);
eT acc2 = eT(0); eT acc2 = eT(0);
eT acc3 = eT(0); eT acc3 = eT(0);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT tmpA = A_mem[i]; const eT tmpA = A_mem[i];
const eT tmpB = B_mem[i]; const eT tmpB = B_mem[i];
acc1 += tmpA * tmpA; acc1 += tmpA * tmpA;
acc2 += tmpB * tmpB; acc2 += tmpB * tmpB;
acc3 += tmpA * tmpB; acc3 += tmpA * tmpB;
} }
return acc3 / ( std::sqrt(acc1 * acc2) ); return acc3 / ( std::sqrt(acc1 * acc2) );
skipping to change at line 336 skipping to change at line 336
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 Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
const Proxy<T2> B(Y.get_ref()); const Proxy<T2> B(Y.get_ref());
arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "cdot(): objects mu st have the same number of elements" ); arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "cdot(): objects mu st have the same number of elements" );
const u32 N = A.get_n_elem(); const uword N = A.get_n_elem();
ea_type1 PA = A.get_ea(); ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea(); ea_type2 PB = B.get_ea();
eT val1 = eT(0); eT val1 = eT(0);
eT val2 = eT(0); eT val2 = eT(0);
u32 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)
{ {
val1 += std::conj(PA[i]) * PB[i]; val1 += std::conj(PA[i]) * PB[i];
val2 += std::conj(PA[j]) * PB[j]; val2 += std::conj(PA[j]) * PB[j];
} }
if(i < N) if(i < N)
{ {
val1 += std::conj(PA[i]) * PB[i]; val1 += std::conj(PA[i]) * PB[i];
} }
 End of changes. 15 change blocks. 
15 lines changed or deleted 15 lines changed or added


 op_dotext_meat.hpp   op_dotext_meat.hpp 
skipping to change at line 28 skipping to change at line 28
eT eT
op_dotext::direct_rowvec_mat_colvec op_dotext::direct_rowvec_mat_colvec
( (
const eT* A_mem, const eT* A_mem,
const Mat<eT>& B, const Mat<eT>& B,
const eT* C_mem const eT* C_mem
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 cost_AB = B.n_cols; const uword cost_AB = B.n_cols;
const u32 cost_BC = B.n_rows; const uword cost_BC = B.n_rows;
if(cost_AB <= cost_BC) if(cost_AB <= cost_BC)
{ {
podarray<eT> tmp(B.n_cols); podarray<eT> tmp(B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
const eT* B_coldata = B.colptr(col); const eT* B_coldata = B.colptr(col);
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i) for(uword i=0; i<B.n_rows; ++i)
{ {
val += A_mem[i] * B_coldata[i]; val += A_mem[i] * B_coldata[i];
} }
tmp[col] = val; tmp[col] = val;
} }
return op_dot::direct_dot(B.n_cols, tmp.mem, C_mem); return op_dot::direct_dot(B.n_cols, tmp.mem, C_mem);
} }
else else
{ {
podarray<eT> tmp(B.n_rows); podarray<eT> tmp(B.n_rows);
for(u32 row=0; row<B.n_rows; ++row) for(uword row=0; row<B.n_rows; ++row)
{ {
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
val += B.at(row,col) * C_mem[col]; val += B.at(row,col) * C_mem[col];
} }
tmp[row] = val; tmp[row] = val;
} }
return op_dot::direct_dot(B.n_rows, A_mem, tmp.mem); return op_dot::direct_dot(B.n_rows, A_mem, tmp.mem);
} }
skipping to change at line 82 skipping to change at line 82
eT eT
op_dotext::direct_rowvec_transmat_colvec op_dotext::direct_rowvec_transmat_colvec
( (
const eT* A_mem, const eT* A_mem,
const Mat<eT>& B, const Mat<eT>& B,
const eT* C_mem const eT* C_mem
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 cost_AB = B.n_rows; const uword cost_AB = B.n_rows;
const u32 cost_BC = B.n_cols; const uword cost_BC = B.n_cols;
if(cost_AB <= cost_BC) if(cost_AB <= cost_BC)
{ {
podarray<eT> tmp(B.n_rows); podarray<eT> tmp(B.n_rows);
for(u32 row=0; row<B.n_rows; ++row) for(uword row=0; row<B.n_rows; ++row)
{ {
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<B.n_cols; ++i) for(uword i=0; i<B.n_cols; ++i)
{ {
val += A_mem[i] * B.at(row,i); val += A_mem[i] * B.at(row,i);
} }
tmp[row] = val; tmp[row] = val;
} }
return op_dot::direct_dot(B.n_rows, tmp.mem, C_mem); return op_dot::direct_dot(B.n_rows, tmp.mem, C_mem);
} }
else else
{ {
podarray<eT> tmp(B.n_cols); podarray<eT> tmp(B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(uword col=0; col<B.n_cols; ++col)
{ {
const eT* B_coldata = B.colptr(col); const eT* B_coldata = B.colptr(col);
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i) for(uword i=0; i<B.n_rows; ++i)
{ {
val += B_coldata[i] * C_mem[i]; val += B_coldata[i] * C_mem[i];
} }
tmp[col] = val; tmp[col] = val;
} }
return op_dot::direct_dot(B.n_cols, A_mem, tmp.mem); return op_dot::direct_dot(B.n_cols, A_mem, tmp.mem);
} }
skipping to change at line 140 skipping to change at line 140
( (
const eT* A_mem, const eT* A_mem,
const Mat<eT>& B, const Mat<eT>& B,
const eT* C_mem const eT* C_mem
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i) for(uword i=0; i<B.n_rows; ++i)
{ {
val += A_mem[i] * B.at(i,i) * C_mem[i]; val += A_mem[i] * B.at(i,i) * C_mem[i];
} }
return val; return val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
skipping to change at line 162 skipping to change at line 162
( (
const eT* A_mem, const eT* A_mem,
const Mat<eT>& B, const Mat<eT>& B,
const eT* C_mem const eT* C_mem
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i) for(uword i=0; i<B.n_rows; ++i)
{ {
val += (A_mem[i] * C_mem[i]) / B.at(i,i); val += (A_mem[i] * C_mem[i]) / B.at(i,i);
} }
return val; return val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
skipping to change at line 186 skipping to change at line 186
const Mat<eT>& B, const Mat<eT>& B,
const eT* C_mem const eT* C_mem
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<B.n_elem; ++i) for(uword i=0; i<B.n_elem; ++i)
{ {
val += (A_mem[i] * C_mem[i]) / B_mem[i]; val += (A_mem[i] * C_mem[i]) / B_mem[i];
} }
return val; return val;
} }
//! @} //! @}
 End of changes. 13 change blocks. 
15 lines changed or deleted 15 lines changed or added


 op_find_bones.hpp   op_find_bones.hpp 
skipping to change at line 22 skipping to change at line 22
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_find //! \addtogroup op_find
//! @{ //! @{
class op_find class op_find
{ {
public: public:
template<typename T1> template<typename T1>
inline static u32 inline static uword
helper helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const Base<typename T1::elem_type, T1>& X const Base<typename T1::elem_type, T1>& X
); );
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline static u32 inline static uword
helper helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtOp<u32, T1, op_type>& X, const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result junk1 = 0, const typename arma_op_rel_only<op_type>::result junk1 = 0,
const typename arma_not_cx<typename T1::elem_type>::result junk2 = 0 const typename arma_not_cx<typename T1::elem_type>::result junk2 = 0
); );
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline static u32 inline static uword
helper helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtOp<u32, T1, op_type>& X, const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result junk1 = 0, const typename arma_op_rel_only<op_type>::result junk1 = 0,
const typename arma_cx_only<typename T1::elem_type>::result junk2 = 0 const typename arma_cx_only<typename T1::elem_type>::result junk2 = 0
); );
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline static u32 inline static uword
helper helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtGlue<u32, T1, T2, glue_type>& X, const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result junk1 = 0, const typename arma_glue_rel_only<glue_type>::result junk1 = 0,
const typename arma_not_cx<typename T1::elem_type>::result junk2 = 0, const typename arma_not_cx<typename T1::elem_type>::result junk2 = 0,
const typename arma_not_cx<typename T2::elem_type>::result junk3 = 0 const typename arma_not_cx<typename T2::elem_type>::result junk3 = 0
); );
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline static u32 inline static uword
helper helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtGlue<u32, T1, T2, glue_type>& X, const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result junk1 = 0, const typename arma_glue_rel_only<glue_type>::result junk1 = 0,
const typename arma_cx_only<typename T1::elem_type>::result junk2 = 0, const typename arma_cx_only<typename T1::elem_type>::result junk2 = 0,
const typename arma_cx_only<typename T2::elem_type>::result junk3 = 0 const typename arma_cx_only<typename T2::elem_type>::result junk3 = 0
); );
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_find>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_find>& X);
}; };
//! @} //! @}
 End of changes. 11 change blocks. 
15 lines changed or deleted 15 lines changed or added


 op_find_meat.hpp   op_find_meat.hpp 
skipping to change at line 19 skipping to change at line 19
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_find //! \addtogroup op_find
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
u32 uword
op_find::helper op_find::helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const Base<typename T1::elem_type, T1>& X 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;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
const u32 n_elem = A.get_n_elem(); const uword n_elem = A.get_n_elem();
indices.set_size(n_elem, 1); indices.set_size(n_elem, 1);
u32* indices_mem = indices.memptr(); uword* indices_mem = indices.memptr();
u32 n_nz = 0; uword n_nz = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
if(PA[i] != eT(0)) if(PA[i] != eT(0))
{ {
indices_mem[n_nz] = i; indices_mem[n_nz] = i;
++n_nz; ++n_nz;
} }
} }
return n_nz; return n_nz;
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
u32 uword
op_find::helper op_find::helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtOp<u32, T1, op_type>& X, const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result junk1, const typename arma_op_rel_only<op_type>::result junk1,
const typename arma_not_cx<typename T1::elem_type>::result junk2 const typename arma_not_cx<typename T1::elem_type>::result junk2
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
const eT val = X.aux; const eT val = X.aux;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
const u32 n_elem = A.get_n_elem(); const uword n_elem = A.get_n_elem();
indices.set_size(n_elem, 1); indices.set_size(n_elem, 1);
u32* indices_mem = indices.memptr(); uword* indices_mem = indices.memptr();
u32 n_nz = 0; uword n_nz = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT tmp = PA[i]; const eT tmp = PA[i];
bool not_zero; bool not_zero;
if(is_same_type<op_type, op_rel_lt_pre >::value == true) { not_ zero = (val < tmp); } if(is_same_type<op_type, op_rel_lt_pre >::value == true) { not_ zero = (val < tmp); }
else if(is_same_type<op_type, op_rel_lt_post >::value == true) { not_ zero = (tmp < val); } else if(is_same_type<op_type, op_rel_lt_post >::value == true) { not_ zero = (tmp < val); }
else if(is_same_type<op_type, op_rel_gt_pre >::value == true) { not_ zero = (val > tmp); } else if(is_same_type<op_type, op_rel_gt_pre >::value == true) { not_ zero = (val > tmp); }
else if(is_same_type<op_type, op_rel_gt_post >::value == true) { not_ zero = (tmp > val); } else if(is_same_type<op_type, op_rel_gt_post >::value == true) { not_ zero = (tmp > val); }
else if(is_same_type<op_type, op_rel_lteq_pre >::value == true) { not_ zero = (val <= tmp); } else if(is_same_type<op_type, op_rel_lteq_pre >::value == true) { not_ zero = (val <= tmp); }
skipping to change at line 113 skipping to change at line 113
indices_mem[n_nz] = i; indices_mem[n_nz] = i;
++n_nz; ++n_nz;
} }
} }
return n_nz; return n_nz;
} }
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
u32 uword
op_find::helper op_find::helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtOp<u32, T1, op_type>& X, const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result junk1, const typename arma_op_rel_only<op_type>::result junk1,
const typename arma_cx_only<typename T1::elem_type>::result junk2 const typename arma_cx_only<typename T1::elem_type>::result junk2
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
const eT val = X.aux; const eT val = X.aux;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
const u32 n_elem = A.get_n_elem(); const uword n_elem = A.get_n_elem();
indices.set_size(n_elem, 1); indices.set_size(n_elem, 1);
u32* indices_mem = indices.memptr(); uword* indices_mem = indices.memptr();
u32 n_nz = 0; uword n_nz = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT tmp = PA[i]; const eT tmp = PA[i];
bool not_zero; bool not_zero;
if(is_same_type<op_type, op_rel_eq >::value == true) { not_zero = (tmp == val); } if(is_same_type<op_type, op_rel_eq >::value == true) { not_zero = (tmp == val); }
else if(is_same_type<op_type, op_rel_noteq>::value == true) { not_zero = (tmp != val); } else if(is_same_type<op_type, op_rel_noteq>::value == true) { not_zero = (tmp != val); }
else not_zero = false; else not_zero = false;
if(not_zero == true) if(not_zero == true)
skipping to change at line 163 skipping to change at line 163
indices_mem[n_nz] = i; indices_mem[n_nz] = i;
++n_nz; ++n_nz;
} }
} }
return n_nz; return n_nz;
} }
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
u32 uword
op_find::helper op_find::helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtGlue<u32, T1, T2, glue_type>& X, const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result junk1, const typename arma_glue_rel_only<glue_type>::result junk1,
const typename arma_not_cx<typename T1::elem_type>::result junk2, const typename arma_not_cx<typename T1::elem_type>::result junk2,
const typename arma_not_cx<typename T2::elem_type>::result junk3 const typename arma_not_cx<typename T2::elem_type>::result junk3
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
arma_ignore(junk3); arma_ignore(junk3);
skipping to change at line 191 skipping to change at line 191
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 Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "relational operator"); arma_debug_assert_same_size(A, B, "relational operator");
ea_type1 PA = A.get_ea(); ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea(); ea_type2 PB = B.get_ea();
const u32 n_elem = B.get_n_elem(); const uword n_elem = B.get_n_elem();
indices.set_size(n_elem, 1); indices.set_size(n_elem, 1);
u32* indices_mem = indices.memptr(); uword* indices_mem = indices.memptr();
u32 n_nz = 0; uword n_nz = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT1 tmp1 = PA[i]; const eT1 tmp1 = PA[i];
const eT2 tmp2 = PB[i]; const eT2 tmp2 = PB[i];
bool not_zero; bool not_zero;
if(is_same_type<glue_type, glue_rel_lt >::value == true) { not _zero = (tmp1 < tmp2); } if(is_same_type<glue_type, glue_rel_lt >::value == true) { not _zero = (tmp1 < tmp2); }
else if(is_same_type<glue_type, glue_rel_gt >::value == true) { not _zero = (tmp1 > tmp2); } else if(is_same_type<glue_type, glue_rel_gt >::value == true) { not _zero = (tmp1 > tmp2); }
else if(is_same_type<glue_type, glue_rel_lteq >::value == true) { not _zero = (tmp1 <= tmp2); } else if(is_same_type<glue_type, glue_rel_lteq >::value == true) { not _zero = (tmp1 <= tmp2); }
else if(is_same_type<glue_type, glue_rel_gteq >::value == true) { not _zero = (tmp1 >= tmp2); } else if(is_same_type<glue_type, glue_rel_gteq >::value == true) { not _zero = (tmp1 >= tmp2); }
skipping to change at line 225 skipping to change at line 225
indices_mem[n_nz] = i; indices_mem[n_nz] = i;
++n_nz; ++n_nz;
} }
} }
return n_nz; return n_nz;
} }
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
u32 uword
op_find::helper op_find::helper
( (
Mat<u32>& indices, Mat<uword>& indices,
const mtGlue<u32, T1, T2, glue_type>& X, const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result junk1, const typename arma_glue_rel_only<glue_type>::result junk1,
const typename arma_cx_only<typename T1::elem_type>::result junk2, const typename arma_cx_only<typename T1::elem_type>::result junk2,
const typename arma_cx_only<typename T2::elem_type>::result junk3 const typename arma_cx_only<typename T2::elem_type>::result junk3
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
arma_ignore(junk3); arma_ignore(junk3);
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 Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "relational operator"); arma_debug_assert_same_size(A, B, "relational operator");
ea_type1 PA = A.get_ea(); ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea(); ea_type2 PB = B.get_ea();
const u32 n_elem = B.get_n_elem(); const uword n_elem = B.get_n_elem();
indices.set_size(n_elem, 1); indices.set_size(n_elem, 1);
u32* indices_mem = indices.memptr(); uword* indices_mem = indices.memptr();
u32 n_nz = 0; uword n_nz = 0;
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
bool not_zero; bool not_zero;
if(is_same_type<glue_type, glue_rel_eq >::value == true) { not _zero = (PA[i] == PB[i]); } if(is_same_type<glue_type, glue_rel_eq >::value == true) { not _zero = (PA[i] == PB[i]); }
else if(is_same_type<glue_type, glue_rel_noteq >::value == true) { not _zero = (PA[i] != PB[i]); } else if(is_same_type<glue_type, glue_rel_noteq >::value == true) { not _zero = (PA[i] != PB[i]); }
else not_zero = false; else not_zero = false;
if(not_zero == true) if(not_zero == true)
{ {
indices_mem[n_nz] = i; indices_mem[n_nz] = i;
++n_nz; ++n_nz;
} }
} }
return n_nz; return n_nz;
} }
template<typename T1> template<typename T1>
inline inline
void void
op_find::apply(Mat<u32>& out, const mtOp<u32, T1, op_find>& X) op_find::apply(Mat<uword>& out, const mtOp<uword, T1, op_find>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 k = X.aux_u32_a; const uword k = X.aux_uword_a;
const u32 type = X.aux_u32_b; const uword type = X.aux_uword_b;
Mat<u32> indices; Mat<uword> indices;
const u32 n_nz = op_find::helper(indices, X.m); const uword n_nz = op_find::helper(indices, X.m);
if(n_nz > 0) if(n_nz > 0)
{ {
if(type == 0) // "first" if(type == 0) // "first"
{ {
out = (k > 0 && k <= n_nz) ? indices.rows(0, k-1 ) : indices.r ows(0, n_nz-1); out = (k > 0 && k <= n_nz) ? indices.rows(0, k-1 ) : indices.r ows(0, n_nz-1);
} }
else // "last" else // "last"
{ {
out = (k > 0 && k <= n_nz) ? indices.rows(n_nz-k, n_nz-1) : indices.r ows(0, n_nz-1); out = (k > 0 && k <= n_nz) ? indices.rows(n_nz-k, n_nz-1) : indices.r ows(0, n_nz-1);
 End of changes. 28 change blocks. 
39 lines changed or deleted 39 lines changed or added


 op_flip_meat.hpp   op_flip_meat.hpp 
skipping to change at line 32 skipping to change at line 32
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT> X = tmp.M; const Mat<eT> X = tmp.M;
if(&out != &X) if(&out != &X)
{ {
out.copy_size(X); out.copy_size(X);
for(u32 i=0; i<X.n_rows; ++i) for(uword i=0; i<X.n_rows; ++i)
{ {
out.row(i) = X.row(X.n_rows-1 - i); out.row(i) = X.row(X.n_rows-1 - i);
} }
} }
else else
{ {
const u32 N = X.n_rows / 2; const uword N = X.n_rows / 2;
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.swap_rows(i, X.n_rows-1 - i); out.swap_rows(i, X.n_rows-1 - i);
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_fliplr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_fliplr>& in) op_fliplr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_fliplr>& in)
skipping to change at line 64 skipping to change at line 64
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT> X = tmp.M; const Mat<eT> X = tmp.M;
if(&out != &X) if(&out != &X)
{ {
out.copy_size(X); out.copy_size(X);
for(u32 i=0; i<X.n_cols; ++i) for(uword i=0; i<X.n_cols; ++i)
{ {
out.col(i) = X.col(X.n_cols-1 - i); out.col(i) = X.col(X.n_cols-1 - i);
} }
} }
else else
{ {
const u32 N = X.n_cols / 2; const uword N = X.n_cols / 2;
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.swap_cols(i, X.n_cols-1 - i); out.swap_cols(i, X.n_cols-1 - i);
} }
} }
} }
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_htrans_meat.hpp   op_htrans_meat.hpp 
skipping to change at line 35 skipping to change at line 35
} }
template<typename eT> template<typename eT>
inline inline
void void
op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_cx_only<eT>::result* junk) op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_cx_only<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
out.set_size(A_n_cols, A_n_rows); out.set_size(A_n_cols, A_n_rows);
for(u32 in_row = 0; in_row < A_n_rows; ++in_row) for(uword in_row = 0; in_row < A_n_rows; ++in_row)
{ {
const u32 out_col = in_row; const uword out_col = in_row;
for(u32 in_col = 0; in_col < A_n_cols; ++in_col) for(uword in_col = 0; in_col < A_n_cols; ++in_col)
{ {
const u32 out_row = in_col; const uword out_row = in_col;
out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) ); out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) );
} }
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx <eT>::result* junk) op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx <eT>::result* junk)
skipping to change at line 82 skipping to change at line 82
if(&out != &A) if(&out != &A)
{ {
op_htrans::apply_noalias(out, A); op_htrans::apply_noalias(out, A);
} }
else else
{ {
if(out.n_rows == out.n_cols) if(out.n_rows == out.n_cols)
{ {
arma_extra_debug_print("doing in-place hermitian transpose of a squar e matrix"); arma_extra_debug_print("doing in-place hermitian transpose of a squar e matrix");
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
eT* coldata = out.colptr(col); eT* coldata = out.colptr(col);
out.at(col,col) = std::conj( out.at(col,col) ); out.at(col,col) = std::conj( out.at(col,col) );
for(u32 row=(col+1); row<n_rows; ++row) for(uword row=(col+1); row<n_rows; ++row)
{ {
const eT val1 = std::conj(coldata[row]); const eT val1 = std::conj(coldata[row]);
const eT val2 = std::conj(out.at(col,row)); const eT val2 = std::conj(out.at(col,row));
out.at(col,row) = val1; out.at(col,row) = val1;
coldata[row] = val2; coldata[row] = val2;
} }
} }
} }
else else
{ {
const Mat<eT> A_copy = A; Mat<eT> tmp;
op_htrans::apply_noalias(out, A_copy); op_strans::apply_noalias(tmp, A);
out.steal_mem(tmp);
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in) op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in)
{ {
skipping to change at line 137 skipping to change at line 139
void void
op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trim at>, op_htrans>& in) op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trim at>, op_htrans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m.m); const unwrap<T1> tmp(in.m.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const bool upper = in.m.aux_u32_a; const bool upper = in.m.aux_uword_a;
op_trimat::apply_htrans(out, A, upper); op_trimat::apply_htrans(out, A, upper);
} }
template<typename T1> template<typename T1>
inline inline
void void
op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2> & in) op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2> & in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 10 change blocks. 
13 lines changed or deleted 15 lines changed or added


 op_inv_meat.hpp   op_inv_meat.hpp 
skipping to change at line 55 skipping to change at line 55
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const strip_diagmat<T1> strip(X.m); const strip_diagmat<T1> strip(X.m);
if(strip.do_diagmat == true) if(strip.do_diagmat == true)
{ {
op_inv::apply_diag(out, strip.M); op_inv::apply_diag(out, strip.M);
} }
else else
{ {
const u32 mode = X.aux_u32_a; const uword mode = X.aux_uword_a;
const bool status = (mode == 0) ? auxlib::inv(out, X.m) : auxlib::inv(o ut, X.m, true); const bool status = (mode == 0) ? auxlib::inv(out, X.m) : auxlib::inv(o ut, X.m, true);
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("inv(): matrix appears to be singular"); arma_bad("inv(): matrix appears to be singular");
} }
} }
} }
skipping to change at line 78 skipping to change at line 78
inline inline
void void
op_inv::apply_diag(Mat<typename T1::elem_type>& out, const Base<typename T1 ::elem_type, T1>& X) op_inv::apply_diag(Mat<typename T1::elem_type>& out, 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 diagmat_proxy_check<T1> A(X.get_ref(), out); const diagmat_proxy_check<T1> A(X.get_ref(), out);
const u32 N = A.n_elem; const uword N = A.n_elem;
out.set_size(N,N); out.set_size(N,N);
for(u32 col=0; col<N; ++col) for(uword col=0; col<N; ++col)
{ {
for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); } for(uword row=0; row<col; ++row) { out.at(row,col) = eT(0); }
out.at(col,col) = eT(1) / A[col]; out.at(col,col) = eT(1) / A[col];
for(u32 row=col+1; row<N; ++row) { out.at(row,col) = eT(0); } for(uword row=col+1; row<N; ++row) { out.at(row,col) = eT(0); }
} }
} }
//! inverse of T1 (triangular matrices) //! inverse of T1 (triangular matrices)
template<typename T1> template<typename T1>
inline inline
void void
op_inv_tr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_tr>& X) op_inv_tr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_tr>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool status = auxlib::inv_tr(out, X.m, X.aux_u32_a); const bool status = auxlib::inv_tr(out, X.m, X.aux_uword_a);
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("inv(): matrix appears to be singular"); arma_bad("inv(): matrix appears to be singular");
} }
} }
//! inverse of T1 (symmetric positive definite matrices) //! inverse of T1 (symmetric positive definite matrices)
template<typename T1> template<typename T1>
inline inline
void void
op_inv_sympd::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_sy mpd>& X) op_inv_sympd::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_sy mpd>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool status = auxlib::inv_sympd(out, X.m, X.aux_u32_a); const bool status = auxlib::inv_sympd(out, X.m, X.aux_uword_a);
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("inv(): matrix appears to be singular"); arma_bad("inv(): matrix appears to be singular");
} }
} }
//! @} //! @}
 End of changes. 7 change blocks. 
7 lines changed or deleted 7 lines changed or added


 op_max_bones.hpp   op_max_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup op_max //! \addtogroup op_max
//! @{ //! @{
//! Class for finding maximum values in a matrix //! Class for finding maximum values in a matrix
class op_max class op_max
{ {
public: public:
template<typename eT> template<typename eT>
inline static eT direct_max(const eT* const X, const u32 N); inline static eT direct_max(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_max(const eT* const X, const u32 N, u32& index_of _max_val); inline static eT direct_max(const eT* const X, const uword N, uword& inde x_of_max_val);
template<typename eT> template<typename eT>
inline static eT direct_max(const Mat<eT>& X, const u32 row); inline static eT direct_max(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_max(const subview<eT>& X); inline static eT direct_max(const subview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_max(const diagview<eT>& X); inline static eT direct_max(const diagview<eT>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _max>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _max>& in);
// //
// for complex numbers // for complex numbers
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const std::complex<T>* const X, const u32 n_elem); inline static std::complex<T> direct_max(const std::complex<T>* const X, const uword n_elem);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const std::complex<T>* const X, const u32 n_elem, u32& index_of_max_val); inline static std::complex<T> direct_max(const std::complex<T>* const X, const uword n_elem, uword& index_of_max_val);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const Mat< std::complex<T> >& X, const u32 row); inline static std::complex<T> direct_max(const Mat< std::complex<T> >& X, const uword row);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const subview< std::complex<T> > & X); inline static std::complex<T> direct_max(const subview< std::complex<T> > & X);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const diagview< std::complex<T> >& X); inline static std::complex<T> direct_max(const diagview< std::complex<T> >& X);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_max_meat.hpp   op_max_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_max //! \addtogroup op_max
//! @{ //! @{
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_max::direct_max(const eT* const X, const u32 n_elem) op_max::direct_max(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i > max_val) if(X_i > max_val)
{ {
max_val = X_i; max_val = X_i;
} }
skipping to change at line 60 skipping to change at line 60
max_val = X_i; max_val = X_i;
} }
} }
return max_val; return max_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const eT* const X, const u32 n_elem, u32& index_of_max_v al) op_max::direct_max(const eT* const X, const uword n_elem, uword& index_of_m ax_val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
u32 best_index = 0; uword best_index = 0;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i > max_val) if(X_i > max_val)
{ {
max_val = X_i; max_val = X_i;
best_index = i; best_index = i;
skipping to change at line 107 skipping to change at line 107
} }
index_of_max_val = best_index; index_of_max_val = best_index;
return max_val; return max_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const Mat<eT>& X, const u32 row) op_max::direct_max(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
const eT tmp_val = X.at(row,col); const eT tmp_val = X.at(row,col);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const subview<eT>& X) op_max::direct_max(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const diagview<eT>& X) op_max::direct_max(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
skipping to change at line 192 skipping to change at line 192
void void
op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in) op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_max::apply(), dim = 0"); arma_extra_debug_print("op_max::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "max(): given object has zero rows" ); arma_debug_check( (X_n_rows == 0), "max(): given object has zero rows" );
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = op_max::direct_max( X.colptr(col), X_n_rows ); out_mem[col] = op_max::direct_max( X.colptr(col), X_n_rows );
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_max::apply(), dim = 1"); arma_extra_debug_print("op_max::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "max(): given object has zero column s" ); arma_debug_check( (X_n_cols == 0), "max(): given object has zero column s" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
out_mem[row] = op_max::direct_max( X, row ); out_mem[row] = op_max::direct_max( X, row );
} }
} }
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const std::complex<T>* const X, const u32 n_elem) op_max::direct_max(const std::complex<T>* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; uword index = 0;
T max_val = priv::most_neg<T>(); T max_val = priv::most_neg<T>();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
return X[index]; return X[index];
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const std::complex<T>* const X, const u32 n_elem, u32& i ndex_of_max_val) op_max::direct_max(const std::complex<T>* const X, const uword n_elem, uwor d& index_of_max_val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; uword index = 0;
T max_val = priv::most_neg<T>(); T max_val = priv::most_neg<T>();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
index_of_max_val = index; index_of_max_val = index;
return X[index]; return X[index];
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const Mat< std::complex<T> >& X, const u32 row) op_max::direct_max(const Mat< std::complex<T> >& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
u32 index = 0; uword index = 0;
T max_val = priv::most_neg<T>(); T max_val = priv::most_neg<T>();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
const T tmp_val = std::abs(X.at(row,col)); const T tmp_val = std::abs(X.at(row,col));
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = col; index = col;
} }
} }
return X.at(row,index); return X.at(row,index);
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const subview< std::complex<T> >& X) op_max::direct_max(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
u32 index = 0; uword index = 0;
T max_val = priv::most_neg<T>(); T max_val = priv::most_neg<T>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
return X[index]; return X[index];
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const diagview< std::complex<T> >& X) op_max::direct_max(const diagview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
u32 index = 0; uword index = 0;
T max_val = priv::most_neg<T>(); T max_val = priv::most_neg<T>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
 End of changes. 32 change blocks. 
33 lines changed or deleted 33 lines changed or added


 op_mean_bones.hpp   op_mean_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup op_mean //! \addtogroup op_mean
//! @{ //! @{
//! Class for finding mean values of a matrix //! Class for finding mean values of a matrix
class op_mean class op_mean
{ {
public: public:
template<typename eT> template<typename eT>
inline static eT direct_mean(const eT* const X, const u32 N); inline static eT direct_mean(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_mean(const Mat<eT>& X, const u32 row); inline static eT direct_mean(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_mean(const subview<eT>& X); inline static eT direct_mean(const subview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_mean(const diagview<eT>& X); inline static eT direct_mean(const diagview<eT>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _mean>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _mean>& in);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const eT* const X, const u32 N); inline static eT direct_mean_robust(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const Mat<eT>& X, const u32 row); inline static eT direct_mean_robust(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const subview<eT>& X); inline static eT direct_mean_robust(const subview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const diagview<eT>& X); inline static eT direct_mean_robust(const diagview<eT>& X);
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_mean_meat.hpp   op_mean_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_mean //! \addtogroup op_mean
//! @{ //! @{
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_mean::direct_mean(const eT* const X, const u32 n_elem) op_mean::direct_mean(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const eT result = arrayops::accumulate(X, n_elem) / T(n_elem); const eT result = arrayops::accumulate(X, n_elem) / T(n_elem);
return arma_isfinite(result) ? result : op_mean::direct_mean_robust(X, n_ elem); return arma_isfinite(result) ? result : op_mean::direct_mean_robust(X, n_ elem);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const Mat<eT>& X, const u32 row) op_mean::direct_mean(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
val += X.at(row,col); val += X.at(row,col);
} }
const eT result = val / T(X_n_cols); const eT result = val / T(X_n_cols);
return arma_isfinite(result) ? result : direct_mean_robust(X, row); return arma_isfinite(result) ? result : direct_mean_robust(X, row);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const subview<eT>& X) op_mean::direct_mean(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
const eT result = val / T(X_n_elem); const eT result = val / T(X_n_elem);
return arma_isfinite(result) ? result : direct_mean_robust(X); return arma_isfinite(result) ? result : direct_mean_robust(X);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const diagview<eT>& X) op_mean::direct_mean(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
const eT result = val / T(X_n_elem); const eT result = val / T(X_n_elem);
return arma_isfinite(result) ? result : direct_mean_robust(X); return arma_isfinite(result) ? result : direct_mean_robust(X);
} }
//! \brief //! \brief
skipping to change at line 117 skipping to change at line 117
op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in) op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in)
{ {
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;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1 "); arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1 ");
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 0"); arma_extra_debug_print("op_mean::apply(), dim = 0");
out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols ); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
if(X_n_rows > 0) if(X_n_rows > 0)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = op_mean::direct_mean( X.colptr(col), X_n_rows ); out_mem[col] = op_mean::direct_mean( X.colptr(col), X_n_rows );
} }
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 1"); arma_extra_debug_print("op_mean::apply(), dim = 1");
out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0); out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
if(X_n_cols > 0) if(X_n_cols > 0)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
out_mem[row] = op_mean::direct_mean( X, row ); out_mem[row] = op_mean::direct_mean( X, row );
} }
} }
} }
} }
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_mean::direct_mean_robust(const eT* const X, const u32 n_elem) op_mean::direct_mean_robust(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// use an adapted form of the mean finding algorithm from the running_sta t class // use an adapted form of the mean finding algorithm from the running_sta t class
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
u32 i,j; uword i,j;
eT r_mean = eT(0); eT r_mean = eT(0);
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT Xi = X[i]; const eT Xi = X[i];
const eT Xj = X[j]; const eT Xj = X[j];
r_mean = r_mean + (Xi - r_mean)/T(j); // we need i+1, and j is equiv alent to i+1 here r_mean = r_mean + (Xi - r_mean)/T(j); // we need i+1, and j is equiv alent to i+1 here
r_mean = r_mean + (Xj - r_mean)/T(j+1); r_mean = r_mean + (Xj - r_mean)/T(j+1);
skipping to change at line 196 skipping to change at line 196
r_mean = r_mean + (Xi - r_mean)/T(i+1); r_mean = r_mean + (Xi - r_mean)/T(i+1);
} }
return r_mean; return r_mean;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean_robust(const Mat<eT>& X, const u32 row) op_mean::direct_mean_robust(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
eT r_mean = eT(0); eT r_mean = eT(0);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
r_mean = r_mean + (X.at(row,col) - r_mean)/T(col+1); r_mean = r_mean + (X.at(row,col) - r_mean)/T(col+1);
} }
return r_mean; return r_mean;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean_robust(const subview<eT>& X) op_mean::direct_mean_robust(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT r_mean = eT(0); eT r_mean = eT(0);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
r_mean = r_mean + (X[i] - r_mean)/T(i+1); r_mean = r_mean + (X[i] - r_mean)/T(i+1);
} }
return r_mean; return r_mean;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean_robust(const diagview<eT>& X) op_mean::direct_mean_robust(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT r_mean = eT(0); eT r_mean = eT(0);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
r_mean = r_mean + (X[i] - r_mean)/T(i+1); r_mean = r_mean + (X[i] - r_mean)/T(i+1);
} }
return r_mean; return r_mean;
} }
//! @} //! @}
 End of changes. 21 change blocks. 
22 lines changed or deleted 22 lines changed or added


 op_median_bones.hpp   op_median_bones.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_median //! \addtogroup op_median
//! @{ //! @{
template<typename T> template<typename T>
struct arma_cx_median_packet struct arma_cx_median_packet
{ {
T val; T val;
u32 index; uword index;
}; };
template<typename T> template<typename T>
inline inline
bool bool
operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T >& B) operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T >& B)
{ {
return A.val < B.val; return A.val < B.val;
} }
skipping to change at line 43 skipping to change at line 43
{ {
public: public:
template<typename eT> template<typename eT>
arma_inline static eT robust_mean(const eT A, const eT B); arma_inline static eT robust_mean(const eT A, const eT B);
template<typename eT> template<typename eT>
inline static eT direct_median(std::vector<eT>& X); inline static eT direct_median(std::vector<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_median(const eT* X, const u32 n_elem); inline static eT direct_median(const eT* X, const uword n_elem);
template<typename eT> template<typename eT>
inline static eT direct_median(const subview<eT>& X); inline static eT direct_median(const subview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_median(const diagview<eT>& X); inline static eT direct_median(const diagview<eT>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _median>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _median>& in);
// //
// for complex numbers // for complex numbers
template<typename T> template<typename T>
arma_inline static std::complex<T> robust_mean(const std::complex<T>& A, const std::complex<T>& B); arma_inline static std::complex<T> robust_mean(const std::complex<T>& A, const std::complex<T>& B);
template<typename T> template<typename T>
inline static void direct_cx_median_index(u32& out_index1, u32& out_index 2, std::vector< arma_cx_median_packet<T> >& X); inline static void direct_cx_median_index(uword& out_index1, uword& out_i ndex2, std::vector< arma_cx_median_packet<T> >& X);
template<typename T> template<typename T>
inline static void direct_cx_median_index(u32& out_index1, u32& out_index 2, const std::complex<T>* X, const u32 n_elem); inline static void direct_cx_median_index(uword& out_index1, uword& out_i ndex2, const std::complex<T>* X, const uword n_elem);
template<typename T> template<typename T>
inline static void direct_cx_median_index(u32& out_index1, u32& out_index 2, const subview< std::complex<T> >& X); inline static void direct_cx_median_index(uword& out_index1, uword& out_i ndex2, const subview< std::complex<T> >& X);
template<typename T> template<typename T>
inline static void direct_cx_median_index(u32& out_index1, u32& out_index 2, const diagview< std::complex<T> >& X); inline static void direct_cx_median_index(uword& out_index1, uword& out_i ndex2, const diagview< std::complex<T> >& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_medi an>& in); inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_medi an>& in);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_median_meat.hpp   op_median_meat.hpp 
skipping to change at line 32 skipping to change at line 32
} }
//! find the median value of a std::vector (contents is modified) //! find the median value of a std::vector (contents is modified)
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(std::vector<eT>& X) op_median::direct_median(std::vector<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.size(); const uword n_elem = X.size();
const u32 half = n_elem/2; const uword half = n_elem/2;
std::sort(X.begin(), X.end()); std::sort(X.begin(), X.end());
if((n_elem % 2) == 0) if((n_elem % 2) == 0)
{ {
return op_median::robust_mean(X[half-1], X[half]); return op_median::robust_mean(X[half-1], X[half]);
} }
else else
{ {
return X[half]; return X[half];
} }
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(const eT* X, const u32 n_elem) op_median::direct_median(const eT* X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector<eT> tmp(X, X+n_elem); std::vector<eT> tmp(X, X+n_elem);
return op_median::direct_median(tmp); return op_median::direct_median(tmp);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(const subview<eT>& X) op_median::direct_median(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
std::vector<eT> tmp(X_n_elem); std::vector<eT> tmp(X_n_elem);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
tmp[i] = X[i]; tmp[i] = X[i];
} }
return op_median::direct_median(tmp); return op_median::direct_median(tmp);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(const diagview<eT>& X) op_median::direct_median(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
std::vector<eT> tmp(X_n_elem); std::vector<eT> tmp(X_n_elem);
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
tmp[i] = X[i]; tmp[i] = X[i];
} }
return op_median::direct_median(tmp); return op_median::direct_median(tmp);
} }
//! \brief //! \brief
//! For each row or for each column, find the median value. //! For each row or for each column, find the median value.
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
skipping to change at line 113 skipping to change at line 113
void void
op_median::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in) op_median::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // in each column if(dim == 0) // in each column
{ {
arma_extra_debug_print("op_median::apply(), dim = 0"); arma_extra_debug_print("op_median::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "median(): given object has zero row s" ); arma_debug_check( (X_n_rows == 0), "median(): given object has zero row s" );
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
std::vector<eT> tmp_vec(X_n_rows); std::vector<eT> tmp_vec(X_n_rows);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
const eT* colmem = X.colptr(col); const eT* colmem = X.colptr(col);
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp_vec[row] = colmem[row]; tmp_vec[row] = colmem[row];
} }
out[col] = op_median::direct_median(tmp_vec); out[col] = op_median::direct_median(tmp_vec);
} }
} }
else else
if(dim == 1) // in each row if(dim == 1) // in each row
{ {
arma_extra_debug_print("op_median::apply(), dim = 1"); arma_extra_debug_print("op_median::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "median(): given object has zero col umns" ); arma_debug_check( (X_n_cols == 0), "median(): given object has zero col umns" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
std::vector<eT> tmp_vec(X_n_cols); std::vector<eT> tmp_vec(X_n_cols);
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
tmp_vec[col] = X.at(row,col); tmp_vec[col] = X.at(row,col);
} }
out[row] = op_median::direct_median(tmp_vec); out[row] = op_median::direct_median(tmp_vec);
} }
} }
} }
template<typename T> template<typename T>
skipping to change at line 177 skipping to change at line 177
op_median::robust_mean(const std::complex<T>& A, const std::complex<T>& B) op_median::robust_mean(const std::complex<T>& A, const std::complex<T>& B)
{ {
return A + (B - A)/T(2); return A + (B - A)/T(2);
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index op_median::direct_cx_median_index
( (
u32& out_index1, uword& out_index1,
u32& out_index2, uword& out_index2,
std::vector< arma_cx_median_packet<T> >& X std::vector< arma_cx_median_packet<T> >& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.size(); const uword n_elem = X.size();
const u32 half = n_elem/2; const uword half = n_elem/2;
std::sort(X.begin(), X.end()); std::sort(X.begin(), X.end());
if((n_elem % 2) == 0) if((n_elem % 2) == 0)
{ {
out_index1 = X[half-1].index; out_index1 = X[half-1].index;
out_index2 = X[half ].index; out_index2 = X[half ].index;
} }
else else
{ {
out_index1 = X[half].index; out_index1 = X[half].index;
out_index2 = out_index1; out_index2 = out_index1;
} }
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index op_median::direct_cx_median_index
( (
u32& out_index1, uword& out_index1,
u32& out_index2, uword& out_index2,
const std::complex<T>* X, const std::complex<T>* X,
const u32 n_elem const uword n_elem
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector< arma_cx_median_packet<T> > tmp(n_elem); std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
tmp[i].val = std::abs(X[i]); tmp[i].val = std::abs(X[i]);
tmp[i].index = i; tmp[i].index = i;
} }
op_median::direct_cx_median_index(out_index1, out_index2, tmp); op_median::direct_cx_median_index(out_index1, out_index2, tmp);
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index op_median::direct_cx_median_index
( (
u32& out_index1, uword& out_index1,
u32& out_index2, uword& out_index2,
const subview< std::complex<T> >&X const subview< std::complex<T> >&X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const uword n_elem = X.n_elem;
std::vector< arma_cx_median_packet<T> > tmp(n_elem); std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
tmp[i].val = std::abs(X[i]); tmp[i].val = std::abs(X[i]);
tmp[i].index = i; tmp[i].index = i;
} }
op_median::direct_cx_median_index(out_index1, out_index2, tmp); op_median::direct_cx_median_index(out_index1, out_index2, tmp);
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index op_median::direct_cx_median_index
( (
u32& out_index1, uword& out_index1,
u32& out_index2, uword& out_index2,
const diagview< std::complex<T> >&X const diagview< std::complex<T> >&X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const uword n_elem = X.n_elem;
std::vector< arma_cx_median_packet<T> > tmp(n_elem); std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
tmp[i].val = std::abs(X[i]); tmp[i].val = std::abs(X[i]);
tmp[i].index = i; tmp[i].index = i;
} }
op_median::direct_cx_median_index(out_index1, out_index2, tmp); op_median::direct_cx_median_index(out_index1, out_index2, tmp);
} }
//! Implementation for complex numbers //! Implementation for complex numbers
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_median::apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in) op_median::apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
arma_type_check< is_same_type<eT, typename T1::elem_type>::value == false >::apply(); arma_type_check(( is_same_type<eT, typename T1::elem_type>::value == fals e ));
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // in each column if(dim == 0) // in each column
{ {
arma_extra_debug_print("op_median::apply(), dim = 0"); arma_extra_debug_print("op_median::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "median(): given object has zero row s" ); arma_debug_check( (X_n_rows == 0), "median(): given object has zero row s" );
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_rows); std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_rows);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
const eT* colmem = X.colptr(col); const eT* colmem = X.colptr(col);
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp_vec[row].val = std::abs(colmem[row]); tmp_vec[row].val = std::abs(colmem[row]);
tmp_vec[row].index = row; tmp_vec[row].index = row;
} }
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec); op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[col] = op_median::robust_mean(colmem[index1], colmem[index2]); out[col] = op_median::robust_mean(colmem[index1], colmem[index2]);
} }
} }
else else
if(dim == 1) // in each row if(dim == 1) // in each row
{ {
arma_extra_debug_print("op_median::apply(), dim = 1"); arma_extra_debug_print("op_median::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "median(): given object has zero col umns" ); arma_debug_check( (X_n_cols == 0), "median(): given object has zero col umns" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_cols); std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_cols);
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
tmp_vec[col].val = std::abs(X.at(row,col)); tmp_vec[col].val = std::abs(X.at(row,col));
tmp_vec[row].index = col; tmp_vec[row].index = col;
} }
u32 index1; uword index1;
u32 index2; uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec); op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[row] = op_median::robust_mean( X.at(row,index1), X.at(row,index2) ); out[row] = op_median::robust_mean( X.at(row,index1), X.at(row,index2) );
} }
} }
} }
//! @} //! @}
 End of changes. 32 change blocks. 
42 lines changed or deleted 42 lines changed or added


 op_min_bones.hpp   op_min_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup op_min //! \addtogroup op_min
//! @{ //! @{
//! Class for finding minimum values in a matrix //! Class for finding minimum values in a matrix
class op_min class op_min
{ {
public: public:
template<typename eT> template<typename eT>
inline static eT direct_min(const eT* const X, const u32 N); inline static eT direct_min(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_min(const eT* const X, const u32 N, u32& index_of _min_val); inline static eT direct_min(const eT* const X, const uword N, uword& inde x_of_min_val);
template<typename eT> template<typename eT>
inline static eT direct_min(const Mat<eT>& X, const u32 row); inline static eT direct_min(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_min(const subview<eT>& X); inline static eT direct_min(const subview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_min(const diagview<eT>& X); inline static eT direct_min(const diagview<eT>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _min>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _min>& in);
// //
// for complex numbers // for complex numbers
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const std::complex<T>* const X, const u32 n_elem); inline static std::complex<T> direct_min(const std::complex<T>* const X, const uword n_elem);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const std::complex<T>* const X, const u32 n_elem, u32& index_of_min_val); inline static std::complex<T> direct_min(const std::complex<T>* const X, const uword n_elem, uword& index_of_min_val);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const Mat< std::complex<T> >& X, const u32 row); inline static std::complex<T> direct_min(const Mat< std::complex<T> >& X, const uword row);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const subview< std::complex<T> > &X); inline static std::complex<T> direct_min(const subview< std::complex<T> > &X);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const diagview< std::complex<T> >&X); inline static std::complex<T> direct_min(const diagview< std::complex<T> >&X);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_min_meat.hpp   op_min_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_min //! \addtogroup op_min
//! @{ //! @{
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_min::direct_min(const eT* const X, const u32 n_elem) op_min::direct_min(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i < min_val) if(X_i < min_val)
{ {
min_val = X_i; min_val = X_i;
} }
skipping to change at line 60 skipping to change at line 60
min_val = X_i; min_val = X_i;
} }
} }
return min_val; return min_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const eT* const X, const u32 n_elem, u32& index_of_min_v al) op_min::direct_min(const eT* const X, const uword n_elem, uword& index_of_m in_val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
u32 best_index = 0; uword best_index = 0;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i < min_val) if(X_i < min_val)
{ {
min_val = X_i; min_val = X_i;
best_index = i; best_index = i;
skipping to change at line 107 skipping to change at line 107
} }
index_of_min_val = best_index; index_of_min_val = best_index;
return min_val; return min_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const Mat<eT>& X, const u32 row) op_min::direct_min(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
const eT tmp_val = X.at(row,col); const eT tmp_val = X.at(row,col);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const subview<eT>& X) op_min::direct_min(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const diagview<eT>& X) op_min::direct_min(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT min_val = priv::most_pos<eT>();; eT min_val = priv::most_pos<eT>();;
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
skipping to change at line 190 skipping to change at line 190
template<typename T1> template<typename T1>
inline void op_min::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ min>& in) inline void op_min::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) // min in each column if(dim == 0) // min in each column
{ {
arma_extra_debug_print("op_min::apply(), dim = 0"); arma_extra_debug_print("op_min::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "min(): given object has zero rows" ); arma_debug_check( (X_n_rows == 0), "min(): given object has zero rows" );
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = op_min::direct_min( X.colptr(col), X_n_rows ); out_mem[col] = op_min::direct_min( X.colptr(col), X_n_rows );
} }
} }
else else
if(dim == 1) // min in each row if(dim == 1) // min in each row
{ {
arma_extra_debug_print("op_min::apply(), dim = 1"); arma_extra_debug_print("op_min::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "min(): given object has zero column s" ); arma_debug_check( (X_n_cols == 0), "min(): given object has zero column s" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
out_mem[row] = op_min::direct_min( X, row ); out_mem[row] = op_min::direct_min( X, row );
} }
} }
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const std::complex<T>* const X, const u32 n_elem) op_min::direct_min(const std::complex<T>* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
return X[index]; return X[index];
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const std::complex<T>* const X, const u32 n_elem, u32& i ndex_of_min_val) op_min::direct_min(const std::complex<T>* const X, const uword n_elem, uwor d& index_of_min_val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
index_of_min_val = index; index_of_min_val = index;
return X[index]; return X[index];
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const Mat< std::complex<T> >& X, const u32 row) op_min::direct_min(const Mat< std::complex<T> >& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
u32 index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
const T tmp_val = std::abs(X.at(row,col)); const T tmp_val = std::abs(X.at(row,col));
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = col; index = col;
} }
} }
return X.at(row,index); return X.at(row,index);
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const subview< std::complex<T> >& X) op_min::direct_min(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
u32 index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
return X[index]; return X[index];
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const diagview< std::complex<T> >& X) op_min::direct_min(const diagview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
u32 index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(u32 i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
 End of changes. 30 change blocks. 
33 lines changed or deleted 33 lines changed or added


 op_misc_meat.hpp   op_misc_meat.hpp 
skipping to change at line 29 skipping to change at line 29
op_real::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_real>& X ) op_real::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_real>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = std::real(A[i]); out_mem[i] = std::real(A[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_real::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_real>& X ) op_real::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_real>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = std::real(A[i]); out_mem[i] = std::real(A[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_imag::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_imag>& X ) op_imag::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_imag>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = std::imag(A[i]); out_mem[i] = std::imag(A[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_imag::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_imag>& X ) op_imag::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_imag>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = std::imag(A[i]); out_mem[i] = std::imag(A[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_abs::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod _type, T1, op_abs>& X ) op_abs::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod _type, T1, op_abs>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); out.set_size(A.get_n_rows(), A.get_n_cols());
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = std::abs(A[i]); out_mem[i] = std::abs(A[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_abs::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1 ::pod_type, T1, op_abs>& X ) op_abs::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1 ::pod_type, T1, op_abs>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = std::abs(A[i]); out_mem[i] = std::abs(A[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_sympd::apply( Mat<typename T1::elem_type>& out, const Op<T1, op_sympd>& X ) op_sympd::apply( Mat<typename T1::elem_type>& out, const Op<T1, op_sympd>& X )
{ {
 End of changes. 12 change blocks. 
12 lines changed or deleted 12 lines changed or added


 op_pinv_meat.hpp   op_pinv_meat.hpp 
skipping to change at line 25 skipping to change at line 25
//! \addtogroup op_pinv //! \addtogroup op_pinv
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
op_pinv::direct_pinv(Mat<eT>& out, const Mat<eT>& A, eT tol) op_pinv::direct_pinv(Mat<eT>& out, const Mat<eT>& A, eT tol)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = A.n_rows; const uword n_rows = A.n_rows;
const u32 n_cols = A.n_cols; const uword n_cols = A.n_cols;
// SVD decomposition // economical SVD decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
Mat<eT> V; Mat<eT> V;
const bool status = (n_cols > n_rows) ? auxlib::svd(U,s,V,trans(A)) : a const bool status = (n_cols > n_rows) ? auxlib::svd_econ(U,s,V,trans(A
uxlib::svd(U,s,V,A); ),'b') : auxlib::svd_econ(U,s,V,A,'b');
const u32 s_n_elem = s.n_elem; const uword s_n_elem = s.n_elem;
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("pinv(): svd failed"); arma_bad("pinv(): svd failed");
return; return;
} }
// set tolerance to default if it hasn't been specified as an argument // set tolerance to default if it hasn't been specified as an argument
if( (tol == eT(0)) && (s_n_elem > 0) ) if( (tol == eT(0)) && (s_n_elem > 0) )
{ {
tol = (std::max)(n_rows,n_cols) * eop_aux::direct_eps(max(s)); tol = (std::max)(n_rows,n_cols) * eop_aux::direct_eps(max(s));
} }
// count non zero valued elements in s // count non zero valued elements in s
u32 count = 0; const eT* s_mem = s.memptr();
for(u32 i=0; i < s_n_elem; ++i) uword count = 0;
for(uword i=0; i < s_n_elem; ++i)
{ {
if(s[i] > tol) if(s_mem[i] > tol)
{ {
++count; ++count;
} }
} }
if(count != 0) if(count != 0)
{ {
// reduce the length of s in order to contain only the values above tol Col<eT> s2(count);
erance
if(count < s_n_elem) eT* s2_mem = s2.memptr();
uword count2 = 0;
for(uword i=0; i < s_n_elem; ++i)
{ {
//s = s.rows(0,count-1); const eT val = s_mem[i];
s.shed_rows(count, s_n_elem-1);
}
// set the elements of s equal to their reciprocals if(val > tol)
s = eT(1) / s; {
s2_mem[count2] = eT(1) / val;
++count2;
}
}
if(A.n_cols <= A.n_rows) if(A.n_cols <= A.n_rows)
{ {
out = ( V.n_cols > count ? V.cols(0,count-1) : V ) * diagmat(s) * tra ns( U.n_cols > count ? U.cols(0,count-1) : U ); out = ( V.n_cols > count ? V.cols(0,count-1) : V ) * diagmat(s2) * tr ans( U.n_cols > count ? U.cols(0,count-1) : U );
} }
else else
{ {
out = ( U.n_cols > count ? U.cols(0,count-1) : U ) * diagmat(s) * tra ns( V.n_cols > count ? V.cols(0,count-1) : V ); out = ( U.n_cols > count ? U.cols(0,count-1) : U ) * diagmat(s2) * tr ans( V.n_cols > count ? V.cols(0,count-1) : V );
} }
} }
else else
{ {
out.zeros(n_cols, n_rows); out.zeros(n_cols, n_rows);
} }
} }
template<typename T> template<typename T>
inline inline
void void
op_pinv::direct_pinv(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, T tol) op_pinv::direct_pinv(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, T tol)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = A.n_rows; const uword n_rows = A.n_rows;
const u32 n_cols = A.n_cols; const uword n_cols = A.n_cols;
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
// SVD decomposition // economical SVD decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
Mat<eT> V; Mat<eT> V;
const bool status = (n_cols > n_rows) ? auxlib::svd(U,s,V,trans(A)) : au const bool status = (n_cols > n_rows) ? auxlib::svd_econ(U,s,V,trans(A),
xlib::svd(U,s,V,A); 'b') : auxlib::svd_econ(U,s,V,A,'b');
const u32 s_n_elem = s.n_elem; const uword s_n_elem = s.n_elem;
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("pinv(): svd failed"); arma_bad("pinv(): svd failed");
return; return;
} }
// set tolerance to default if it hasn't been specified as an argument // set tolerance to default if it hasn't been specified as an argument
if( (tol == T(0)) && (s_n_elem > 0) ) if( (tol == T(0)) && (s_n_elem > 0) )
{ {
tol = (std::max)(n_rows,n_cols) * eop_aux::direct_eps(max(s)); tol = (std::max)(n_rows,n_cols) * eop_aux::direct_eps(max(s));
} }
// count non zero valued elements in s // count non zero valued elements in s
u32 count = 0; uword count = 0;
for(u32 i = 0; i < s_n_elem; ++i) for(uword i = 0; i < s_n_elem; ++i)
{ {
if(s[i] > tol) if(s[i] > tol)
{ {
++count; ++count;
} }
} }
if(count != 0) if(count != 0)
{ {
// reduce the length of s in order to contain only the values above tol erance // reduce the length of s in order to contain only the values above tol erance
 End of changes. 16 change blocks. 
27 lines changed or deleted 35 lines changed or added


 op_princomp_meat.hpp   op_princomp_meat.hpp 
skipping to change at line 39 skipping to change at line 39
( (
Mat<eT>& coeff_out, Mat<eT>& coeff_out,
Mat<eT>& score_out, Mat<eT>& score_out,
Col<eT>& latent_out, Col<eT>& latent_out,
Col<eT>& tsquared_out, Col<eT>& tsquared_out,
const Mat<eT>& in const Mat<eT>& in
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
skipping to change at line 129 skipping to change at line 129
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat<eT>& coeff_out, Mat<eT>& coeff_out,
Mat<eT>& score_out, Mat<eT>& score_out,
Col<eT>& latent_out, Col<eT>& latent_out,
const Mat<eT>& in const Mat<eT>& in
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
skipping to change at line 200 skipping to change at line 200
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat<eT>& coeff_out, Mat<eT>& coeff_out,
Mat<eT>& score_out, Mat<eT>& score_out,
const Mat<eT>& in const Mat<eT>& in
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
skipping to change at line 307 skipping to change at line 307
Mat< std::complex<T> >& score_out, Mat< std::complex<T> >& score_out,
Col<T>& latent_out, Col<T>& latent_out,
Col< std::complex<T> >& tsquared_out, Col< std::complex<T> >& tsquared_out,
const Mat< std::complex<T> >& in const Mat< std::complex<T> >& in
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<T> s; Col<T> s;
skipping to change at line 396 skipping to change at line 396
Mat< std::complex<T> >& coeff_out, Mat< std::complex<T> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<T> >& score_out,
Col<T>& latent_out, Col<T>& latent_out,
const Mat< std::complex<T> >& in const Mat< std::complex<T> >& in
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
skipping to change at line 469 skipping to change at line 469
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<T> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<T> >& score_out,
const Mat< std::complex<T> >& in const Mat< std::complex<T> >& in
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
 End of changes. 6 change blocks. 
12 lines changed or deleted 12 lines changed or added


 op_prod_meat.hpp   op_prod_meat.hpp 
skipping to change at line 29 skipping to change at line 29
//! See the prod() function for more details. //! See the prod() function for more details.
template<typename T1> template<typename T1>
inline inline
void void
op_prod::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_prod>& in) op_prod::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_prod>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "prod(): incorrect usage. dim must be 0 or 1 "); arma_debug_check( (dim > 1), "prod(): incorrect usage. dim must be 0 or 1 ");
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the product in each colu mn) if(dim == 0) // traverse across rows (i.e. find the product in each colu mn)
{ {
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = arrayops::product(X.colptr(col), X_n_rows); out_mem[col] = arrayops::product(X.colptr(col), X_n_rows);
} }
} }
else // traverse across columns (i.e. find the product in each row) else // traverse across columns (i.e. find the product in each row)
{ {
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
eT val = eT(1); eT val = eT(1);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
val *= X.at(row,col); val *= X.at(row,col);
} }
out_mem[row] = val; out_mem[row] = val;
} }
} }
} }
//! @} //! @}
 End of changes. 5 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_relational_bones.hpp   op_relational_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_relational //! \addtogroup op_relational
//! @{ //! @{
class op_rel_lt_pre class op_rel_lt_pre
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lt_pre >& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt _pre>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_l t_pre>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_lt_pre>& X);
}; };
class op_rel_lt_post class op_rel_lt_post
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lt_pos t>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt _post>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_l t_post>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_lt_post>& X);
}; };
class op_rel_gt_pre class op_rel_gt_pre
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gt_pre >& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt _pre>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_g t_pre>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_gt_pre>& X);
}; };
class op_rel_gt_post class op_rel_gt_post
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gt_pos t>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt _post>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_g t_post>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_gt_post>& X);
}; };
class op_rel_lteq_pre class op_rel_lteq_pre
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lteq_p re>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt eq_pre>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_l teq_pre>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_lteq_pre>& X);
}; };
class op_rel_lteq_post class op_rel_lteq_post
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lteq_p ost>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt eq_post>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_l teq_post>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_lteq_post>& X);
}; };
class op_rel_gteq_pre class op_rel_gteq_pre
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gteq_p re>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt eq_pre>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_g teq_pre>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_gteq_pre>& X);
}; };
class op_rel_gteq_post class op_rel_gteq_post
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gteq_p ost>& X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt eq_post>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_g teq_post>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_gteq_post>& X);
}; };
class op_rel_eq class op_rel_eq
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_eq>& X ); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_eq >& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_e q>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_eq>& X);
}; };
class op_rel_noteq class op_rel_noteq
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_noteq> & X); inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_no teq>& X);
template<typename T1> template<typename T1>
inline static void apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_n oteq>& X); inline static void apply(Cube<uword>& out, const mtOpCube<uword, T1, op_r el_noteq>& X);
}; };
//! @} //! @}
 End of changes. 20 change blocks. 
20 lines changed or deleted 20 lines changed or added


 op_relational_meat.hpp   op_relational_meat.hpp 
skipping to change at line 19 skipping to change at line 19
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_relational //! \addtogroup op_relational
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lt_pre::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lt_pre>& X) op_rel_lt_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt_pre>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val < A[i]) ? u32(1) : u32(0); out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
out_mem[j] = (val < A[j]) ? u32(1) : u32(0); out_mem[j] = (val < A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val < A[i]) ? u32(1) : u32(0); out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lt_post::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lt_post>& X ) op_rel_lt_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt_post >& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] < val) ? u32(1) : u32(0); out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
out_mem[j] = (A[j] < val) ? u32(1) : u32(0); out_mem[j] = (A[j] < val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] < val) ? u32(1) : u32(0); out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gt_pre::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gt_pre>& X) op_rel_gt_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt_pre>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val > A[i]) ? u32(1) : u32(0); out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
out_mem[j] = (val > A[j]) ? u32(1) : u32(0); out_mem[j] = (val > A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val > A[i]) ? u32(1) : u32(0); out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gt_post::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gt_post>& X ) op_rel_gt_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt_post >& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] > val) ? u32(1) : u32(0); out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
out_mem[j] = (A[j] > val) ? u32(1) : u32(0); out_mem[j] = (A[j] > val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] > val) ? u32(1) : u32(0); out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lteq_pre::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lteq_pre>& X) op_rel_lteq_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lteq_p re>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val <= A[i]) ? u32(1) : u32(0); out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
out_mem[j] = (val <= A[j]) ? u32(1) : u32(0); out_mem[j] = (val <= A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val <= A[i]) ? u32(1) : u32(0); out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lteq_post::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_lteq_post >& X) op_rel_lteq_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lteq_ post>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] <= val) ? u32(1) : u32(0); out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
out_mem[j] = (A[j] <= val) ? u32(1) : u32(0); out_mem[j] = (A[j] <= val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] <= val) ? u32(1) : u32(0); out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gteq_pre::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gteq_pre>& X) op_rel_gteq_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gteq_p re>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val >= A[i]) ? u32(1) : u32(0); out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
out_mem[j] = (val >= A[j]) ? u32(1) : u32(0); out_mem[j] = (val >= A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val >= A[i]) ? u32(1) : u32(0); out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gteq_post::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_gteq_post >& X) op_rel_gteq_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gteq_ post>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] >= val) ? u32(1) : u32(0); out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
out_mem[j] = (A[j] >= val) ? u32(1) : u32(0); out_mem[j] = (A[j] >= val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] >= val) ? u32(1) : u32(0); out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_eq::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_eq>& X) op_rel_eq::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_eq>& X)
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] == val) ? u32(1) : u32(0); out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
out_mem[j] = (A[j] == val) ? u32(1) : u32(0); out_mem[j] = (A[j] == val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] == val) ? u32(1) : u32(0); out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_noteq::apply(Mat<u32>& out, const mtOp<u32, T1, op_rel_noteq>& X) op_rel_noteq::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_noteq>& X )
{ {
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_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> Y(X.m); const Proxy<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols()); out.set_size(Y.get_n_rows(), Y.get_n_cols());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] != val) ? u32(1) : u32(0); out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
out_mem[j] = (A[j] != val) ? u32(1) : u32(0); out_mem[j] = (A[j] != val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] != val) ? u32(1) : u32(0); out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
} }
} }
// //
// //
// //
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lt_pre::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_lt_pre> & X) op_rel_lt_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_lt_ pre>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val < A[i]) ? u32(1) : u32(0); out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
out_mem[j] = (val < A[j]) ? u32(1) : u32(0); out_mem[j] = (val < A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val < A[i]) ? u32(1) : u32(0); out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lt_post::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_lt_pos t>& X) op_rel_lt_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_lt _post>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] < val) ? u32(1) : u32(0); out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
out_mem[j] = (A[j] < val) ? u32(1) : u32(0); out_mem[j] = (A[j] < val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] < val) ? u32(1) : u32(0); out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gt_pre::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_gt_pre> & X) op_rel_gt_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_gt_ pre>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val > A[i]) ? u32(1) : u32(0); out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
out_mem[j] = (val > A[j]) ? u32(1) : u32(0); out_mem[j] = (val > A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val > A[i]) ? u32(1) : u32(0); out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gt_post::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_gt_pos t>& X) op_rel_gt_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_gt _post>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] > val) ? u32(1) : u32(0); out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
out_mem[j] = (A[j] > val) ? u32(1) : u32(0); out_mem[j] = (A[j] > val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] > val) ? u32(1) : u32(0); out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lteq_pre::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_lteq_ pre>& X) op_rel_lteq_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_l teq_pre>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val <= A[i]) ? u32(1) : u32(0); out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
out_mem[j] = (val <= A[j]) ? u32(1) : u32(0); out_mem[j] = (val <= A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val <= A[i]) ? u32(1) : u32(0); out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_lteq_post::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_lteq _post>& X) op_rel_lteq_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_ lteq_post>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] <= val) ? u32(1) : u32(0); out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
out_mem[j] = (A[j] <= val) ? u32(1) : u32(0); out_mem[j] = (A[j] <= val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] <= val) ? u32(1) : u32(0); out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gteq_pre::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_gteq_ pre>& X) op_rel_gteq_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_g teq_pre>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (val >= A[i]) ? u32(1) : u32(0); out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
out_mem[j] = (val >= A[j]) ? u32(1) : u32(0); out_mem[j] = (val >= A[j]) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (val >= A[i]) ? u32(1) : u32(0); out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_gteq_post::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_gteq _post>& X) op_rel_gteq_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_ gteq_post>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] >= val) ? u32(1) : u32(0); out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
out_mem[j] = (A[j] >= val) ? u32(1) : u32(0); out_mem[j] = (A[j] >= val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] >= val) ? u32(1) : u32(0); out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_eq::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_eq>& X) op_rel_eq::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_eq>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] == val) ? u32(1) : u32(0); out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
out_mem[j] = (A[j] == val) ? u32(1) : u32(0); out_mem[j] = (A[j] == val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] == val) ? u32(1) : u32(0); out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_rel_noteq::apply(Cube<u32>& out, const mtOpCube<u32, T1, op_rel_noteq>& X) op_rel_noteq::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_note q>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type; typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> Y(X.m); const ProxyCube<T1> Y(X.m);
out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices()); out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
const eT val = X.aux; const eT val = X.aux;
ea_type A = Y.get_ea(); ea_type A = Y.get_ea();
u32* out_mem = out.memptr(); uword* out_mem = out.memptr();
const u32 n_elem = out.n_elem; const uword n_elem = out.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = (A[i] != val) ? u32(1) : u32(0); out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
out_mem[j] = (A[j] != val) ? u32(1) : u32(0); out_mem[j] = (A[j] != val) ? uword(1) : uword(0);
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] = (A[i] != val) ? u32(1) : u32(0); out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
} }
} }
//! @} //! @}
 End of changes. 100 change blocks. 
140 lines changed or deleted 140 lines changed or added


 op_repmat_meat.hpp   op_repmat_meat.hpp 
skipping to change at line 31 skipping to change at line 31
void void
op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>& in) op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 copies_per_row = in.aux_u32_a; const uword copies_per_row = in.aux_uword_a;
const u32 copies_per_col = in.aux_u32_b; const uword copies_per_col = in.aux_uword_b;
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
out.set_size(X_n_rows * copies_per_row, X_n_cols * copies_per_col); out.set_size(X_n_rows * copies_per_row, X_n_cols * copies_per_col);
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
if( (out_n_rows > 0) && (out_n_cols > 0) ) if( (out_n_rows > 0) && (out_n_cols > 0) )
{ {
for(u32 col = 0; col < out_n_cols; col += X_n_cols) for(uword col = 0; col < out_n_cols; col += X_n_cols)
{ {
for(u32 row = 0; row < out_n_rows; row += X_n_rows) for(uword row = 0; row < out_n_rows; row += X_n_rows)
{ {
out.submat(row, col, row+X_n_rows-1, col+X_n_cols-1) = X; out.submat(row, col, row+X_n_rows-1, col+X_n_cols-1) = X;
} }
} }
} }
} }
//! @} //! @}
 End of changes. 5 change blocks. 
8 lines changed or deleted 8 lines changed or added


 op_reshape_meat.hpp   op_reshape_meat.hpp 
skipping to change at line 28 skipping to change at line 28
void void
op_reshape::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reshape> & in) op_reshape::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reshape> & in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 in_n_rows = in.aux_u32_a; const uword in_n_rows = in.aux_uword_a;
const u32 in_n_cols = in.aux_u32_b; const uword in_n_cols = in.aux_uword_b;
const uword in_dim = in.aux_uword_c;
const u32 in_n_elem = in_n_rows * in_n_cols; const uword in_n_elem = in_n_rows * in_n_cols;
if(A.n_elem == in_n_elem) if(A.n_elem == in_n_elem)
{ {
if(in.aux == eT(0)) if(in_dim == 0)
{ {
if(&out != &A) if(&out != &A)
{ {
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
arrayops::copy( out.memptr(), A.memptr(), out.n_elem ); arrayops::copy( out.memptr(), A.memptr(), out.n_elem );
} }
else // &out == &A, i.e. inplace resize else // &out == &A, i.e. inplace resize
{ {
const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols = = in_n_cols) ); const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols = = in_n_cols) );
skipping to change at line 67 skipping to change at line 68
} }
} }
else else
{ {
unwrap_check< Mat<eT> > tmp(A, out); unwrap_check< Mat<eT> > tmp(A, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i = 0; uword i = 0;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
for(u32 row=0; row<B_n_rows; ++row) for(uword row=0; row<B_n_rows; ++row)
{ {
for(u32 col=0; col<B_n_cols; ++col) for(uword col=0; col<B_n_cols; ++col)
{ {
out_mem[i] = B.at(row,col); out_mem[i] = B.at(row,col);
++i; ++i;
} }
} }
} }
} }
else else
{ {
const unwrap_check< Mat<eT> > tmp(A, out); const unwrap_check< Mat<eT> > tmp(A, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
const u32 n_elem_to_copy = (std::min)(B.n_elem, in_n_elem); const uword n_elem_to_copy = (std::min)(B.n_elem, in_n_elem);
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(in.aux == eT(0)) if(in_dim == 0)
{ {
arrayops::copy( out_mem, B.memptr(), n_elem_to_copy ); arrayops::copy( out_mem, B.memptr(), n_elem_to_copy );
} }
else else
{ {
u32 row = 0; uword row = 0;
u32 col = 0; uword col = 0;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
for(u32 i=0; i<n_elem_to_copy; ++i) for(uword i=0; i<n_elem_to_copy; ++i)
{ {
out_mem[i] = B.at(row,col); out_mem[i] = B.at(row,col);
++col; ++col;
if(col >= B_n_cols) if(col >= B_n_cols)
{ {
col = 0; col = 0;
++row; ++row;
} }
} }
} }
for(u32 i=n_elem_to_copy; i<in_n_elem; ++i) for(uword i=n_elem_to_copy; i<in_n_elem; ++i)
{ {
out_mem[i] = eT(0); out_mem[i] = eT(0);
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_reshape::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_res hape>& in) op_reshape::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_res hape>& in)
{ {
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(in.m); const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M; const Cube<eT>& A = tmp.M;
const u32 in_n_rows = in.aux_u32_a; const uword in_n_rows = in.aux_uword_a;
const u32 in_n_cols = in.aux_u32_b; const uword in_n_cols = in.aux_uword_b;
const u32 in_n_slices = in.aux_u32_c; const uword in_n_slices = in.aux_uword_c;
const uword in_dim = in.aux_uword_d;
const u32 in_n_elem = in_n_rows * in_n_cols * in_n_slices; const uword in_n_elem = in_n_rows * in_n_cols * in_n_slices;
if(A.n_elem == in_n_elem) if(A.n_elem == in_n_elem)
{ {
if(in.aux == eT(0)) if(in_dim == 0)
{ {
if(&out != &A) if(&out != &A)
{ {
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
arrayops::copy( out.memptr(), A.memptr(), out.n_elem ); arrayops::copy( out.memptr(), A.memptr(), out.n_elem );
} }
else // &out == &A, i.e. inplace resize else // &out == &A, i.e. inplace resize
{ {
const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols = = in_n_cols) && (out.n_slices == in_n_slices) ); const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols = = in_n_cols) && (out.n_slices == in_n_slices) );
skipping to change at line 185 skipping to change at line 187
} }
} }
else else
{ {
unwrap_cube_check< Cube<eT> > tmp(A, out); unwrap_cube_check< Cube<eT> > tmp(A, out);
const Cube<eT>& B = tmp.M; const Cube<eT>& B = tmp.M;
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i = 0; uword i = 0;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
const u32 B_n_slices = B.n_slices; const uword B_n_slices = B.n_slices;
for(u32 slice=0; slice<B_n_slices; ++slice) for(uword slice=0; slice<B_n_slices; ++slice)
{ {
for(u32 row=0; row<B_n_rows; ++row) for(uword row=0; row<B_n_rows; ++row)
{ {
for(u32 col=0; col<B_n_cols; ++col) for(uword col=0; col<B_n_cols; ++col)
{ {
out_mem[i] = B.at(row,col,slice); out_mem[i] = B.at(row,col,slice);
++i; ++i;
} }
} }
} }
} }
} }
else else
{ {
const unwrap_cube_check< Cube<eT> > tmp(A, out); const unwrap_cube_check< Cube<eT> > tmp(A, out);
const Cube<eT>& B = tmp.M; const Cube<eT>& B = tmp.M;
const u32 n_elem_to_copy = (std::min)(B.n_elem, in_n_elem); const uword n_elem_to_copy = (std::min)(B.n_elem, in_n_elem);
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(in.aux == eT(0)) if(in_dim == 0)
{ {
arrayops::copy( out_mem, B.memptr(), n_elem_to_copy ); arrayops::copy( out_mem, B.memptr(), n_elem_to_copy );
} }
else else
{ {
u32 row = 0; uword row = 0;
u32 col = 0; uword col = 0;
u32 slice = 0; uword slice = 0;
const u32 B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
for(u32 i=0; i<n_elem_to_copy; ++i) for(uword i=0; i<n_elem_to_copy; ++i)
{ {
out_mem[i] = B.at(row,col,slice); out_mem[i] = B.at(row,col,slice);
++col; ++col;
if(col >= B_n_cols) if(col >= B_n_cols)
{ {
col = 0; col = 0;
++row; ++row;
if(row >= B_n_rows) if(row >= B_n_rows)
{ {
row = 0; row = 0;
++slice; ++slice;
} }
} }
} }
} }
for(u32 i=n_elem_to_copy; i<in_n_elem; ++i) for(uword i=n_elem_to_copy; i<in_n_elem; ++i)
{ {
out_mem[i] = eT(0); out_mem[i] = eT(0);
} }
} }
} }
//! @} //! @}
 End of changes. 27 change blocks. 
37 lines changed or deleted 39 lines changed or added


 op_shuffle_meat.hpp   op_shuffle_meat.hpp 
skipping to change at line 35 skipping to change at line 35
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
if(X.is_empty()) if(X.is_empty())
{ {
out.copy_size(X); out.copy_size(X);
return; return;
} }
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
const u32 N = (dim == 0) ? X.n_rows : X.n_cols; const uword N = (dim == 0) ? X.n_rows : X.n_cols;
// see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet_ ascend" // see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet_ ascend"
// and the associated "operator<" // and the associated "operator<"
std::vector< arma_sort_index_packet_ascend<int,u32> > packet_vec(N); std::vector< arma_sort_index_packet_ascend<int,uword> > packet_vec(N);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
packet_vec[i].val = std::rand(); packet_vec[i].val = std::rand();
packet_vec[i].index = i; packet_vec[i].index = i;
} }
std::sort( packet_vec.begin(), packet_vec.end() ); std::sort( packet_vec.begin(), packet_vec.end() );
if(X.is_vec() == false) if(X.is_vec() == false)
{ {
if(&out != &X) if(&out != &X)
{ {
arma_extra_debug_print("op_shuffle::apply(): matrix"); arma_extra_debug_print("op_shuffle::apply(): matrix");
out.copy_size(X); out.copy_size(X);
if(dim == 0) if(dim == 0)
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.row(i) = X.row(packet_vec[i].index); out.row(i) = X.row(packet_vec[i].index);
} }
} }
else else
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.col(i) = X.col(packet_vec[i].index); out.col(i) = X.col(packet_vec[i].index);
} }
} }
} }
else // in-place shuffle else // in-place shuffle
{ {
arma_extra_debug_print("op_shuffle::apply(): in-place matrix"); arma_extra_debug_print("op_shuffle::apply(): in-place matrix");
// reuse the val member variable of packet_vec // reuse the val member variable of packet_vec
// to indicate whether a particular row or column // to indicate whether a particular row or column
// has already been shuffled // has already been shuffled
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
packet_vec[i].val = 0; packet_vec[i].val = 0;
} }
if(dim == 0) if(dim == 0)
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
if(packet_vec[i].val == 0) if(packet_vec[i].val == 0)
{ {
const u32 j = packet_vec[i].index; const uword j = packet_vec[i].index;
out.swap_rows(i, j); out.swap_rows(i, j);
packet_vec[j].val = 1; packet_vec[j].val = 1;
} }
} }
} }
else else
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
if(packet_vec[i].val == 0) if(packet_vec[i].val == 0)
{ {
const u32 j = packet_vec[i].index; const uword j = packet_vec[i].index;
out.swap_cols(i, j); out.swap_cols(i, j);
packet_vec[j].val = 1; packet_vec[j].val = 1;
} }
} }
} }
} }
} }
else // we're dealing with a vector else // we're dealing with a vector
skipping to change at line 128 skipping to change at line 128
if(&out != &X) if(&out != &X)
{ {
arma_extra_debug_print("op_shuffle::apply(): vector"); arma_extra_debug_print("op_shuffle::apply(): vector");
out.copy_size(X); out.copy_size(X);
if(dim == 0) if(dim == 0)
{ {
if(X.n_rows > 1) // i.e. column vector if(X.n_rows > 1) // i.e. column vector
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out[i] = X[ packet_vec[i].index ]; out[i] = X[ packet_vec[i].index ];
} }
} }
else else
{ {
out = X; out = X;
} }
} }
else else
{ {
if(X.n_cols > 1) // i.e. row vector if(X.n_cols > 1) // i.e. row vector
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out[i] = X[ packet_vec[i].index ]; out[i] = X[ packet_vec[i].index ];
} }
} }
else else
{ {
out = X; out = X;
} }
} }
} }
else // in-place shuffle else // in-place shuffle
{ {
arma_extra_debug_print("op_shuffle::apply(): in-place vector"); arma_extra_debug_print("op_shuffle::apply(): in-place vector");
// reuse the val member variable of packet_vec // reuse the val member variable of packet_vec
// to indicate whether a particular row or column // to indicate whether a particular row or column
// has already been shuffled // has already been shuffled
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
packet_vec[i].val = 0; packet_vec[i].val = 0;
} }
if(dim == 0) if(dim == 0)
{ {
if(X.n_rows > 1) // i.e. column vector if(X.n_rows > 1) // i.e. column vector
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
if(packet_vec[i].val == 0) if(packet_vec[i].val == 0)
{ {
const u32 j = packet_vec[i].index; const uword j = packet_vec[i].index;
std::swap(out[i], out[j]); std::swap(out[i], out[j]);
packet_vec[j].val = 1; packet_vec[j].val = 1;
} }
} }
} }
} }
else else
{ {
if(X.n_cols > 1) // i.e. row vector if(X.n_cols > 1) // i.e. row vector
{ {
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
if(packet_vec[i].val == 0) if(packet_vec[i].val == 0)
{ {
const u32 j = packet_vec[i].index; const uword j = packet_vec[i].index;
std::swap(out[i], out[j]); std::swap(out[i], out[j]);
packet_vec[j].val = 1; packet_vec[j].val = 1;
} }
} }
} }
} }
} }
} }
 End of changes. 17 change blocks. 
18 lines changed or deleted 18 lines changed or added


 op_sort_bones.hpp   op_sort_bones.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_sort //! \addtogroup op_sort
//! @{ //! @{
class op_sort class op_sort
{ {
public: public:
template<typename eT> template<typename eT>
inline static void copy_row(eT* X, const Mat<eT>& A, const u32 row); inline static void copy_row(eT* X, const Mat<eT>& A, const uword row);
template<typename eT> template<typename eT>
inline static void copy_row(Mat<eT>& A, const eT* X, const u32 row); inline static void copy_row(Mat<eT>& A, const eT* X, const uword row);
template<typename eT> template<typename eT>
inline static void direct_sort(eT* X, const u32 N, const u32 sort_type = 0); inline static void direct_sort(eT* X, const uword N, const uword sort_typ e = 0);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _sort>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _sort>& in);
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 op_sort_meat.hpp   op_sort_meat.hpp 
skipping to change at line 75 skipping to change at line 75
bool bool
operator() (const eT& a, const eT& b) const operator() (const eT& a, const eT& b) const
{ {
return (std::abs(a) > std::abs(b)); return (std::abs(a) > std::abs(b));
} }
}; };
template<typename eT> template<typename eT>
inline inline
void void
op_sort::direct_sort(eT* X, const u32 n_elem, const u32 sort_type) op_sort::direct_sort(eT* X, const uword n_elem, const uword sort_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(sort_type == 0) if(sort_type == 0)
{ {
arma_ascend_sort_helper<eT> comparator; arma_ascend_sort_helper<eT> comparator;
std::sort(&X[0], &X[n_elem], comparator); std::sort(&X[0], &X[n_elem], comparator);
} }
else else
{ {
arma_descend_sort_helper<eT> comparator; arma_descend_sort_helper<eT> comparator;
std::sort(&X[0], &X[n_elem], comparator); std::sort(&X[0], &X[n_elem], comparator);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
op_sort::copy_row(eT* X, const Mat<eT>& A, const u32 row) op_sort::copy_row(eT* X, const Mat<eT>& A, const uword row)
{ {
const u32 N = A.n_cols; const uword N = A.n_cols;
u32 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)
{ {
X[i] = A.at(row,i); X[i] = A.at(row,i);
X[j] = A.at(row,j); X[j] = A.at(row,j);
} }
if(i < N) if(i < N)
{ {
X[i] = A.at(row,i); X[i] = A.at(row,i);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
op_sort::copy_row(Mat<eT>& A, const eT* X, const u32 row) op_sort::copy_row(Mat<eT>& A, const eT* X, const uword row)
{ {
const u32 N = A.n_cols; const uword N = A.n_cols;
u32 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)
{ {
A.at(row,i) = X[i]; A.at(row,i) = X[i];
A.at(row,j) = X[j]; A.at(row,j) = X[j];
} }
if(i < N) if(i < N)
{ {
A.at(row,i) = X[i]; A.at(row,i) = X[i];
skipping to change at line 147 skipping to change at line 147
void void
op_sort::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort>& in) op_sort::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 sort_type = in.aux_u32_a; const uword sort_type = in.aux_uword_a;
const u32 dim = in.aux_u32_b; const uword dim = in.aux_uword_b;
arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor t_type must be 0 or 1"); arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor t_type must be 0 or 1");
arma_debug_check( (dim > 1), "sort(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sort(): incorrect usage. dim must be 0 or 1" );
arma_debug_check( (X.is_finite() == false), "sort(): given object has non -finite elements" ); arma_debug_check( (X.is_finite() == false), "sort(): given object has non -finite elements" );
if( (X.n_rows * X.n_cols) <= 1 ) if( (X.n_rows * X.n_cols) <= 1 )
{ {
out = X; out = X;
return; return;
} }
if(dim == 0) // sort the contents of each column if(dim == 0) // sort the contents of each column
{ {
arma_extra_debug_print("op_sort::apply(), dim = 0"); arma_extra_debug_print("op_sort::apply(), dim = 0");
out = X; out = X;
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
for(u32 col=0; col < n_cols; ++col) for(uword col=0; col < n_cols; ++col)
{ {
op_sort::direct_sort( out.colptr(col), n_rows, sort_type ); op_sort::direct_sort( out.colptr(col), n_rows, sort_type );
} }
} }
else else
if(dim == 1) // sort the contents of each row if(dim == 1) // sort the contents of each row
{ {
if(X.n_rows == 1) // a row vector if(X.n_rows == 1) // a row vector
{ {
arma_extra_debug_print("op_sort::apply(), dim = 1, vector specific"); arma_extra_debug_print("op_sort::apply(), dim = 1, vector specific");
out = X; out = X;
op_sort::direct_sort(out.memptr(), out.n_elem, sort_type); op_sort::direct_sort(out.memptr(), out.n_elem, sort_type);
} }
else // not a row vector else // not a row vector
{ {
arma_extra_debug_print("op_sort::apply(), dim = 1, generic"); arma_extra_debug_print("op_sort::apply(), dim = 1, generic");
out.copy_size(X); out.copy_size(X);
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
podarray<eT> tmp_array(n_cols); podarray<eT> tmp_array(n_cols);
for(u32 row=0; row < n_rows; ++row) for(uword row=0; row < n_rows; ++row)
{ {
op_sort::copy_row(tmp_array.memptr(), X, row); op_sort::copy_row(tmp_array.memptr(), X, row);
op_sort::direct_sort( tmp_array.memptr(), n_cols, sort_type ); op_sort::direct_sort( tmp_array.memptr(), n_cols, sort_type );
op_sort::copy_row(out, tmp_array.memptr(), row); op_sort::copy_row(out, tmp_array.memptr(), row);
} }
} }
} }
 End of changes. 12 change blocks. 
15 lines changed or deleted 15 lines changed or added


 op_stddev_meat.hpp   op_stddev_meat.hpp 
skipping to change at line 33 skipping to change at line 33
op_stddev::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::p od_type, T1, op_stddev>& in) op_stddev::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::p od_type, T1, op_stddev>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
typedef typename T1::pod_type out_eT; typedef typename T1::pod_type out_eT;
const unwrap_check_mixed<T1> tmp(in.m, out); const unwrap_check_mixed<T1> tmp(in.m, out);
const Mat<in_eT>& X = tmp.M; const Mat<in_eT>& X = tmp.M;
const u32 norm_type = in.aux_u32_a; const uword norm_type = in.aux_uword_a;
const u32 dim = in.aux_u32_b; const uword dim = in.aux_uword_b;
arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type must be 0 or 1"); arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type must be 0 or 1");
arma_debug_check( (dim > 1), "stddev(): incorrect usage. dim must b e 0 or 1" ); arma_debug_check( (dim > 1), "stddev(): incorrect usage. dim must b e 0 or 1" );
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 0"); arma_extra_debug_print("op_stddev::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "stddev(): given object has zero row s" ); arma_debug_check( (X_n_rows == 0), "stddev(): given object has zero row s" );
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = std::sqrt( op_var::direct_var( X.colptr(col), X_n_rows , norm_type ) ); out_mem[col] = std::sqrt( op_var::direct_var( X.colptr(col), X_n_rows , norm_type ) );
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 1"); arma_extra_debug_print("op_stddev::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "stddev(): given object has zero col umns" ); arma_debug_check( (X_n_cols == 0), "stddev(): given object has zero col umns" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
podarray<in_eT> tmp(X_n_cols); podarray<in_eT> tmp(X_n_cols);
in_eT* tmp_mem = tmp.memptr(); in_eT* tmp_mem = tmp.memptr();
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp.copy_row(X, row); tmp.copy_row(X, row);
out_mem[row] = std::sqrt( op_var::direct_var( tmp_mem, X_n_cols, norm _type) ); out_mem[row] = std::sqrt( op_var::direct_var( tmp_mem, X_n_cols, norm _type) );
} }
} }
} }
//! @} //! @}
 End of changes. 4 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_strans_bones.hpp   op_strans_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup op_strans //! \addtogroup op_strans
//! @{ //! @{
//! 'matrix transpose' operation //! 'matrix transpose' operation
class op_strans class op_strans
{ {
public: public:
template<const bool do_flip, const u32 row, const u32 col> template<const bool do_flip, const uword row, const uword col>
struct pos struct pos
{ {
static const u32 n2 = (do_flip == false) ? (row + col*2) : (col + row*2 static const uword n2 = (do_flip == false) ? (row + col*2) : (col + row
); *2);
static const u32 n3 = (do_flip == false) ? (row + col*3) : (col + row*3 static const uword n3 = (do_flip == false) ? (row + col*3) : (col + row
); *3);
static const u32 n4 = (do_flip == false) ? (row + col*4) : (col + row*4 static const uword n4 = (do_flip == false) ? (row + col*4) : (col + row
); *4);
}; };
template<typename eT> template<typename eT>
inline static void apply_noalias_tinysq(Mat<eT>& out, const Mat<eT>& A); inline static void apply_noalias_tinysq(Mat<eT>& out, const Mat<eT>& A);
template<typename eT> template<typename eT>
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A); inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A); inline static void apply(Mat<eT>& out, const Mat<eT>& A);
 End of changes. 2 change blocks. 
7 lines changed or deleted 7 lines changed or added


 op_strans_meat.hpp   op_strans_meat.hpp 
skipping to change at line 97 skipping to change at line 97
} }
//! Immediate transpose of a dense matrix //! Immediate transpose of a dense matrix
template<typename eT> template<typename eT>
inline inline
void void
op_strans::apply_noalias(Mat<eT>& out, const Mat<eT>& A) op_strans::apply_noalias(Mat<eT>& out, const Mat<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const u32 A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
out.set_size(A_n_cols, A_n_rows); out.set_size(A_n_cols, A_n_rows);
if( (A_n_cols == 1) || (A_n_rows == 1) ) if( (A_n_cols == 1) || (A_n_rows == 1) )
{ {
arrayops::copy( out.memptr(), A.mem, A.n_elem ); arrayops::copy( out.memptr(), A.mem, A.n_elem );
} }
else else
{ {
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) )
{ {
op_strans::apply_noalias_tinysq(out, A); op_strans::apply_noalias_tinysq(out, A);
} }
else else
{ {
for(u32 k=0; k < A_n_cols; ++k) for(uword k=0; k < A_n_cols; ++k)
{ {
u32 i, j; uword i, j;
const eT* colptr = A.colptr(k); const eT* colptr = A.colptr(k);
for(i=0, j=1; j < A_n_rows; i+=2, j+=2) for(i=0, j=1; j < A_n_rows; i+=2, j+=2)
{ {
const eT tmp_i = colptr[i]; const eT tmp_i = colptr[i];
const eT tmp_j = colptr[j]; const eT tmp_j = colptr[j];
out.at(k, i) = tmp_i; out.at(k, i) = tmp_i;
out.at(k, j) = tmp_j; out.at(k, j) = tmp_j;
skipping to change at line 151 skipping to change at line 151
op_strans::apply(Mat<eT>& out, const Mat<eT>& A) op_strans::apply(Mat<eT>& out, const Mat<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(&out != &A) if(&out != &A)
{ {
op_strans::apply_noalias(out, A); op_strans::apply_noalias(out, A);
} }
else else
{ {
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
if(n_rows == n_cols) if(n_rows == n_cols)
{ {
arma_extra_debug_print("op_strans::apply(): doing in-place transpose of a square matrix"); arma_extra_debug_print("op_strans::apply(): doing in-place transpose of a square matrix");
const u32 N = n_rows; const uword N = n_rows;
for(u32 k=0; k < N; ++k) for(uword k=0; k < N; ++k)
{ {
eT* colptr = out.colptr(k); eT* colptr = out.colptr(k);
u32 i,j; uword i,j;
for(i=(k+1), j=(k+2); j < N; i+=2, j+=2) for(i=(k+1), j=(k+2); j < N; i+=2, j+=2)
{ {
std::swap(out.at(k,i), colptr[i]); std::swap(out.at(k,i), colptr[i]);
std::swap(out.at(k,j), colptr[j]); std::swap(out.at(k,j), colptr[j]);
} }
if(i < N) if(i < N)
{ {
std::swap(out.at(k,i), colptr[i]); std::swap(out.at(k,i), colptr[i]);
} }
} }
} }
else else
{ {
const Mat<eT> AA = A; Mat<eT> tmp;
op_strans::apply_noalias(out, AA); op_strans::apply_noalias(tmp, A);
out.steal_mem(tmp);
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_strans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_strans>& in) op_strans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_strans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 207 skipping to change at line 209
op_strans::apply(out, A); op_strans::apply(out, A);
} }
// inline void op_strans::apply_inplace(mat &X) // inline void op_strans::apply_inplace(mat &X)
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// if((X.n_rows == 1) || (X.n_cols == 1)) // if((X.n_rows == 1) || (X.n_cols == 1))
// { // {
// const u32 old_n_rows = X.n_rows; // const uword old_n_rows = X.n_rows;
// access::rw(X.n_rows) = X.n_cols; // access::rw(X.n_rows) = X.n_cols;
// access::rw(X.n_cols) = old_n_rows; // access::rw(X.n_cols) = old_n_rows;
// } // }
// else // else
// if(X.n_rows == X.n_cols) // if(X.n_rows == X.n_cols)
// { // {
// for(u32 col=0; col < X.n_cols; ++col) // for(uword col=0; col < X.n_cols; ++col)
// { // {
// double* X_coldata = X.colptr(col); // double* X_coldata = X.colptr(col);
// //
// for(u32 row=(col+1); row < X.n_rows; ++row) // for(uword row=(col+1); row < X.n_rows; ++row)
// { // {
// std::swap( A.at(col,row), A_coldata[row] ); // std::swap( A.at(col,row), A_coldata[row] );
// } // }
// } // }
// } // }
// else // else
// { // {
// mat tmp = trans(X); // mat tmp = trans(X);
// //
// if(X.mem != X.mem_local) // if(X.mem != X.mem_local)
 End of changes. 11 change blocks. 
14 lines changed or deleted 16 lines changed or added


 op_sum_meat.hpp   op_sum_meat.hpp 
skipping to change at line 27 skipping to change at line 27
//! Immediate sum of elements of a matrix along a specified dimension (eith er rows or columns). //! Immediate sum of elements of a matrix along a specified dimension (eith er rows or columns).
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! See the sum() function for more details. //! See the sum() function for more details.
template<typename T1> template<typename T1>
inline inline
void void
op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in) op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 dim = in.aux_u32_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" );
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the sum in each column) if(dim == 0) // traverse across rows (i.e. find the sum in each column)
{ {
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = arrayops::accumulate(X.colptr(col), X_n_rows); out_mem[col] = arrayops::accumulate(X.colptr(col), X_n_rows);
} }
} }
else // traverse across columns (i.e. find the sum in each row) else // traverse across columns (i.e. find the sum in each row)
{ {
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
val += X.at(row,col); val += X.at(row,col);
} }
out_mem[row] = val; out_mem[row] = val;
} }
} }
} }
//! @} //! @}
 End of changes. 5 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_symmat_meat.hpp   op_symmat_meat.hpp 
skipping to change at line 36 skipping to change at line 36
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" );
const u32 N = A.n_rows; const uword N = A.n_rows;
const bool upper = (in.aux_u32_a == 0); const bool upper = (in.aux_uword_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(upper) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( out_data, A_data, i+1 ); arrayops::copy( out_data, A_data, i+1 );
} }
} }
else else
{ {
// lower triangular: copy the diagonal and the elements below the dia gonal // lower triangular: copy the diagonal and the elements below the dia gonal
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( &out_data[i], &A_data[i], N-i ); arrayops::copy( &out_data[i], &A_data[i], N-i );
} }
} }
} }
if(upper) if(upper)
{ {
// reflect elements across the diagonal from upper triangle to lower tr iangle // reflect elements across the diagonal from upper triangle to lower tr iangle
for(u32 col=1; col < N; ++col) for(uword col=1; col < N; ++col)
{ {
const eT* coldata = out.colptr(col); const eT* coldata = out.colptr(col);
for(u32 row=0; row < col; ++row) for(uword row=0; row < col; ++row)
{ {
out.at(col,row) = coldata[row]; out.at(col,row) = coldata[row];
} }
} }
} }
else else
{ {
// reflect elements across the diagonal from lower triangle to upper tr iangle // reflect elements across the diagonal from lower triangle to upper tr iangle
for(u32 col=0; col < N; ++col) for(uword col=0; col < N; ++col)
{ {
const eT* coldata = out.colptr(col); const eT* coldata = out.colptr(col);
for(u32 row=(col+1); row < N; ++row) for(uword row=(col+1); row < N; ++row)
{ {
out.at(col,row) = coldata[row]; out.at(col,row) = coldata[row];
} }
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 119 skipping to change at line 119
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" );
const u32 N = A.n_rows; const uword N = A.n_rows;
const bool upper = (in.aux_u32_a == 0); const bool upper = (in.aux_uword_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(upper) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( out_data, A_data, i+1 ); arrayops::copy( out_data, A_data, i+1 );
} }
} }
else else
{ {
// lower triangular: copy the diagonal and the elements below the dia gonal // lower triangular: copy the diagonal and the elements below the dia gonal
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( &out_data[i], &A_data[i], N-i ); arrayops::copy( &out_data[i], &A_data[i], N-i );
} }
} }
} }
if(upper) if(upper)
{ {
// reflect elements across the diagonal from upper triangle to lower tr iangle // reflect elements across the diagonal from upper triangle to lower tr iangle
for(u32 col=1; col < N; ++col) for(uword col=1; col < N; ++col)
{ {
const eT* coldata = out.colptr(col); const eT* coldata = out.colptr(col);
for(u32 row=0; row < col; ++row) for(uword row=0; row < col; ++row)
{ {
out.at(col,row) = std::conj(coldata[row]); out.at(col,row) = std::conj(coldata[row]);
} }
} }
} }
else else
{ {
// reflect elements across the diagonal from lower triangle to upper tr iangle // reflect elements across the diagonal from lower triangle to upper tr iangle
for(u32 col=0; col < N; ++col) for(uword col=0; col < N; ++col)
{ {
const eT* coldata = out.colptr(col); const eT* coldata = out.colptr(col);
for(u32 row=(col+1); row < N; ++row) for(uword row=(col+1); row < N; ++row)
{ {
out.at(col,row) = std::conj(coldata[row]); out.at(col,row) = std::conj(coldata[row]);
} }
} }
} }
} }
//! @} //! @}
 End of changes. 14 change blocks. 
16 lines changed or deleted 16 lines changed or added


 op_trimat_meat.hpp   op_trimat_meat.hpp 
skipping to change at line 24 skipping to change at line 24
//! \addtogroup op_trimat //! \addtogroup op_trimat
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
op_trimat::fill_zeros(Mat<eT>& out, const bool upper) op_trimat::fill_zeros(Mat<eT>& out, const bool upper)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 N = out.n_rows; const uword N = out.n_rows;
if(upper) if(upper)
{ {
// upper triangular: set all elements below the diagonal to zero // upper triangular: set all elements below the diagonal to zero
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
eT* data = out.colptr(i); eT* data = out.colptr(i);
arrayops::inplace_set( &data[i+1], eT(0), (N-(i+1)) ); arrayops::inplace_set( &data[i+1], eT(0), (N-(i+1)) );
} }
} }
else else
{ {
// lower triangular: set all elements above the diagonal to zero // lower triangular: set all elements above the diagonal to zero
for(u32 i=1; i<N; ++i) for(uword i=1; i<N; ++i)
{ {
eT* data = out.colptr(i); eT* data = out.colptr(i);
arrayops::inplace_set( data, eT(0), i ); arrayops::inplace_set( data, eT(0), i );
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
skipping to change at line 64 skipping to change at line 64
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" );
const u32 N = A.n_rows; const uword N = A.n_rows;
const bool upper = (in.aux_u32_a == 0); const bool upper = (in.aux_uword_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(upper) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( out_data, A_data, i+1 ); arrayops::copy( out_data, A_data, i+1 );
} }
} }
else else
{ {
// lower triangular: copy the diagonal and the elements below the dia gonal // lower triangular: copy the diagonal and the elements below the dia gonal
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( &out_data[i], &A_data[i], N-i ); arrayops::copy( &out_data[i], &A_data[i], N-i );
} }
} }
} }
op_trimat::fill_zeros(out, upper); op_trimat::fill_zeros(out, upper);
skipping to change at line 110 skipping to change at line 110
void void
op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<Op<T1, op_htran s>, op_trimat>& in) op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<Op<T1, op_htran s>, op_trimat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m.m); const unwrap<T1> tmp(in.m.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const bool upper = (in.aux_u32_a == 0); const bool upper = (in.aux_uword_a == 0);
op_trimat::apply_htrans(out, A, upper); op_trimat::apply_htrans(out, A, upper);
} }
template<typename eT> template<typename eT>
inline inline
void void
op_trimat::apply_htrans op_trimat::apply_htrans
( (
Mat<eT>& out, Mat<eT>& out,
skipping to change at line 140 skipping to change at line 140
// trimatu(trans(X)) = trans(trimatl(X)). We want to avoid the creation of an // trimatu(trans(X)) = trans(trimatl(X)). We want to avoid the creation of an
// extra temporary. // extra temporary.
// It doesn't matter if the input and output matrices are the same; we wi ll // It doesn't matter if the input and output matrices are the same; we wi ll
// pull data from the upper or lower triangular to the lower or upper // pull data from the upper or lower triangular to the lower or upper
// triangular (respectively) and then set the rest to 0, so overwriting i ssues // triangular (respectively) and then set the rest to 0, so overwriting i ssues
// aren't present. // aren't present.
arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" );
const u32 N = A.n_rows; const uword N = A.n_rows;
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
} }
// We can't really get away with any array copy operations here, // We can't really get away with any array copy operations here,
// unfortunately... // unfortunately...
if(upper) if(upper)
{ {
// Upper triangular: but since we're transposing, we're taking the lowe r // Upper triangular: but since we're transposing, we're taking the lowe r
// triangular and putting it in the upper half. // triangular and putting it in the upper half.
for(u32 row = 0; row < N; ++row) for(uword row = 0; row < N; ++row)
{ {
eT* out_colptr = out.colptr(row); eT* out_colptr = out.colptr(row);
for(u32 col = 0; col <= row; ++col) for(uword col = 0; col <= row; ++col)
{ {
//out.at(col, row) = A.at(row, col); //out.at(col, row) = A.at(row, col);
out_colptr[col] = A.at(row, col); out_colptr[col] = A.at(row, col);
} }
} }
} }
else else
{ {
// Lower triangular: but since we're transposing, we're taking the uppe r // Lower triangular: but since we're transposing, we're taking the uppe r
// triangular and putting it in the lower half. // triangular and putting it in the lower half.
for(u32 row = 0; row < N; ++row) for(uword row = 0; row < N; ++row)
{ {
for(u32 col = row; col < N; ++col) for(uword col = row; col < N; ++col)
{ {
out.at(col, row) = A.at(row, col); out.at(col, row) = A.at(row, col);
} }
} }
} }
op_trimat::fill_zeros(out, upper); op_trimat::fill_zeros(out, upper);
} }
template<typename eT> template<typename eT>
skipping to change at line 197 skipping to change at line 197
const Mat<eT>& A, const Mat<eT>& A,
const bool upper, const bool upper,
const typename arma_cx_only<eT>::result* junk const typename arma_cx_only<eT>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" );
const u32 N = A.n_rows; const uword N = A.n_rows;
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
} }
if(upper) if(upper)
{ {
// Upper triangular: but since we're transposing, we're taking the lowe r // Upper triangular: but since we're transposing, we're taking the lowe r
// triangular and putting it in the upper half. // triangular and putting it in the upper half.
for(u32 row = 0; row < N; ++row) for(uword row = 0; row < N; ++row)
{ {
eT* out_colptr = out.colptr(row); eT* out_colptr = out.colptr(row);
for(u32 col = 0; col <= row; ++col) for(uword col = 0; col <= row; ++col)
{ {
//out.at(col, row) = std::conj( A.at(row, col) ); //out.at(col, row) = std::conj( A.at(row, col) );
out_colptr[col] = std::conj( A.at(row, col) ); out_colptr[col] = std::conj( A.at(row, col) );
} }
} }
} }
else else
{ {
// Lower triangular: but since we're transposing, we're taking the uppe r // Lower triangular: but since we're transposing, we're taking the uppe r
// triangular and putting it in the lower half. // triangular and putting it in the lower half.
for(u32 row = 0; row < N; ++row) for(uword row = 0; row < N; ++row)
{ {
for(u32 col = row; col < N; ++col) for(uword col = row; col < N; ++col)
{ {
out.at(col, row) = std::conj( A.at(row, col) ); out.at(col, row) = std::conj( A.at(row, col) );
} }
} }
} }
op_trimat::fill_zeros(out, upper); op_trimat::fill_zeros(out, upper);
} }
//! @} //! @}
 End of changes. 17 change blocks. 
18 lines changed or deleted 18 lines changed or added


 op_var_bones.hpp   op_var_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup op_var //! \addtogroup op_var
//! @{ //! @{
//! Class for finding variance values of a matrix //! Class for finding variance values of a matrix
class op_var class op_var
{ {
public: public:
template<typename eT> template<typename eT>
inline static eT direct_var(const eT* const X, const u32 N, const u32 nor m_type = 0); inline static eT direct_var(const eT* const X, const uword N, const uword norm_type = 0);
template<typename T> template<typename T>
inline static T direct_var(const std::complex<T>* const X, const u32 N, const u32 norm_type = 0); inline static T direct_var(const std::complex<T>* const X, const uword N , const uword norm_type = 0);
template<typename eT> template<typename eT>
inline static typename get_pod_type<eT>::result direct_var(const subview_ row<eT>& X, const u32 norm_type = 0); inline static typename get_pod_type<eT>::result direct_var(const subview_ row<eT>& X, const uword norm_type = 0);
template<typename eT> template<typename eT>
inline static typename get_pod_type<eT>::result direct_var(const subview_ col<eT>& X, const u32 norm_type = 0); inline static typename get_pod_type<eT>::result direct_var(const subview_ col<eT>& X, const uword norm_type = 0);
template<typename eT> template<typename eT>
inline static typename get_pod_type<eT>::result direct_var(const diagview <eT>& X, const u32 norm_type = 0); inline static typename get_pod_type<eT>::result direct_var(const diagview <eT>& X, const uword norm_type = 0);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::pod_type>& out, const mtOp<type name T1::pod_type, T1, op_var>& in); inline static void apply(Mat<typename T1::pod_type>& out, const mtOp<type name T1::pod_type, T1, op_var>& in);
template<typename eT> template<typename eT>
inline static eT direct_var_robust(const eT* const X, const u32 N, const u32 norm_type = 0); inline static eT direct_var_robust(const eT* const X, const uword N, cons t uword norm_type = 0);
template<typename T> template<typename T>
inline static T direct_var_robust(const std::complex<T>* const X, const u32 N, const u32 norm_type = 0); inline static T direct_var_robust(const std::complex<T>* const X, const uword N, const uword norm_type = 0);
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
7 lines changed or deleted 7 lines changed or added


 op_var_meat.hpp   op_var_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_var //! \addtogroup op_var
//! @{ //! @{
//! find the variance of an array //! find the variance of an array
template<typename eT> template<typename eT>
inline inline
eT eT
op_var::direct_var(const eT* const X, const u32 n_elem, const u32 norm_type ) op_var::direct_var(const eT* const X, const uword n_elem, const uword norm_ type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(n_elem >= 2) if(n_elem >= 2)
{ {
const eT acc1 = op_mean::direct_mean(X, n_elem); const eT acc1 = op_mean::direct_mean(X, n_elem);
eT acc2 = eT(0); eT acc2 = eT(0);
eT acc3 = eT(0); eT acc3 = eT(0);
u32 i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT Xi = X[i]; const eT Xi = X[i];
const eT Xj = X[j]; const eT Xj = X[j];
const eT tmpi = acc1 - Xi; const eT tmpi = acc1 - Xi;
const eT tmpj = acc1 - Xj; const eT tmpj = acc1 - Xj;
acc2 += tmpi*tmpi + tmpj*tmpj; acc2 += tmpi*tmpi + tmpj*tmpj;
skipping to change at line 70 skipping to change at line 70
else else
{ {
return eT(0); return eT(0);
} }
} }
//! find the variance of an array (version for complex numbers) //! find the variance of an array (version for complex numbers)
template<typename T> template<typename T>
inline inline
T T
op_var::direct_var(const std::complex<T>* const X, const u32 n_elem, const u32 norm_type) op_var::direct_var(const std::complex<T>* const X, const uword n_elem, cons t uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(n_elem >= 2) if(n_elem >= 2)
{ {
const eT acc1 = op_mean::direct_mean(X, n_elem); const eT acc1 = op_mean::direct_mean(X, n_elem);
T acc2 = T(0); T acc2 = T(0);
eT acc3 = eT(0); eT acc3 = eT(0);
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT tmp = acc1 - X[i]; const eT tmp = acc1 - X[i];
acc2 += std::norm(tmp); acc2 += std::norm(tmp);
acc3 += tmp; acc3 += tmp;
} }
const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem); const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem);
const T var_val = (acc2 - std::norm(acc3)/T(n_elem)) / norm_val; const T var_val = (acc2 - std::norm(acc3)/T(n_elem)) / norm_val;
skipping to change at line 106 skipping to change at line 106
else else
{ {
return T(0); return T(0);
} }
} }
//! find the variance of a subview_row //! find the variance of a subview_row
template<typename eT> template<typename eT>
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
op_var::direct_var(const subview_row<eT>& X, const u32 norm_type) op_var::direct_var(const subview_row<eT>& X, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const uword n_elem = X.n_elem;
podarray<eT> tmp(n_elem); podarray<eT> tmp(n_elem);
eT* tmp_mem = tmp.memptr(); eT* tmp_mem = tmp.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
tmp_mem[i] = X[i]; tmp_mem[i] = X[i];
} }
return op_var::direct_var(tmp_mem, n_elem, norm_type); return op_var::direct_var(tmp_mem, n_elem, norm_type);
} }
//! find the variance of a subview_col //! find the variance of a subview_col
template<typename eT> template<typename eT>
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
op_var::direct_var(const subview_col<eT>& X, const u32 norm_type) op_var::direct_var(const subview_col<eT>& X, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return op_var::direct_var(X.colptr(0), X.n_elem, norm_type); return op_var::direct_var(X.colptr(0), X.n_elem, norm_type);
} }
//! find the variance of a diagview //! find the variance of a diagview
template<typename eT> template<typename eT>
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
op_var::direct_var(const diagview<eT>& X, const u32 norm_type) op_var::direct_var(const diagview<eT>& X, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const uword n_elem = X.n_elem;
podarray<eT> tmp(n_elem); podarray<eT> tmp(n_elem);
eT* tmp_mem = tmp.memptr(); eT* tmp_mem = tmp.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
tmp_mem[i] = X[i]; tmp_mem[i] = X[i];
} }
return op_var::direct_var(tmp_mem, n_elem, norm_type); return op_var::direct_var(tmp_mem, n_elem, norm_type);
} }
//! \brief //! \brief
//! For each row or for each column, find the variance. //! For each row or for each column, find the variance.
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
skipping to change at line 174 skipping to change at line 174
op_var::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_ type, T1, op_var>& in) op_var::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_ type, T1, op_var>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
typedef typename T1::pod_type out_eT; typedef typename T1::pod_type out_eT;
const unwrap_check_mixed<T1> tmp(in.m, out); const unwrap_check_mixed<T1> tmp(in.m, out);
const Mat<in_eT>& X = tmp.M; const Mat<in_eT>& X = tmp.M;
const u32 norm_type = in.aux_u32_a; const uword norm_type = in.aux_uword_a;
const u32 dim = in.aux_u32_b; const uword dim = in.aux_uword_b;
arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus t be 0 or 1"); arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus t be 0 or 1");
arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_var::apply(), dim = 0"); arma_extra_debug_print("op_var::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "var(): given object has zero rows" ); arma_debug_check( (X_n_rows == 0), "var(): given object has zero rows" );
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
out_mem[col] = op_var::direct_var( X.colptr(col), X_n_rows, norm_type ); out_mem[col] = op_var::direct_var( X.colptr(col), X_n_rows, norm_type );
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_var::apply(), dim = 1"); arma_extra_debug_print("op_var::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "var(): given object has zero column s" ); arma_debug_check( (X_n_cols == 0), "var(): given object has zero column s" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
podarray<in_eT> tmp(X_n_cols); podarray<in_eT> tmp(X_n_cols);
in_eT* tmp_mem = tmp.memptr(); in_eT* tmp_mem = tmp.memptr();
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp.copy_row(X, row); tmp.copy_row(X, row);
out_mem[row] = op_var::direct_var( tmp_mem, X_n_cols, norm_type ); out_mem[row] = op_var::direct_var( tmp_mem, X_n_cols, norm_type );
} }
} }
} }
//! find the variance of an array (robust but slow) //! find the variance of an array (robust but slow)
template<typename eT> template<typename eT>
inline inline
eT eT
op_var::direct_var_robust(const eT* const X, const u32 n_elem, const u32 no rm_type) op_var::direct_var_robust(const eT* const X, const uword n_elem, const uwor d norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(n_elem > 1) if(n_elem > 1)
{ {
eT r_mean = X[0]; eT r_mean = X[0];
eT r_var = eT(0); eT r_var = eT(0);
for(u32 i=1; i<n_elem; ++i) for(uword i=1; i<n_elem; ++i)
{ {
const eT tmp = X[i] - r_mean; const eT tmp = X[i] - r_mean;
const eT i_plus_1 = eT(i+1); const eT i_plus_1 = eT(i+1);
r_var = eT(i-1)/eT(i) * r_var + (tmp*tmp)/i_plus_1; r_var = eT(i-1)/eT(i) * r_var + (tmp*tmp)/i_plus_1;
r_mean = r_mean + tmp/i_plus_1; r_mean = r_mean + tmp/i_plus_1;
} }
return (norm_type == 0) ? r_var : (eT(n_elem-1)/eT(n_elem)) * r_var; return (norm_type == 0) ? r_var : (eT(n_elem-1)/eT(n_elem)) * r_var;
skipping to change at line 256 skipping to change at line 256
else else
{ {
return eT(0); return eT(0);
} }
} }
//! find the variance of an array (version for complex numbers) (robust but slow) //! find the variance of an array (version for complex numbers) (robust but slow)
template<typename T> template<typename T>
inline inline
T T
op_var::direct_var_robust(const std::complex<T>* const X, const u32 n_elem, const u32 norm_type) op_var::direct_var_robust(const std::complex<T>* const X, const uword n_ele m, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(n_elem > 1) if(n_elem > 1)
{ {
eT r_mean = X[0]; eT r_mean = X[0];
T r_var = T(0); T r_var = T(0);
for(u32 i=1; i<n_elem; ++i) for(uword i=1; i<n_elem; ++i)
{ {
const eT tmp = X[i] - r_mean; const eT tmp = X[i] - r_mean;
const T i_plus_1 = T(i+1); const T i_plus_1 = T(i+1);
r_var = T(i-1)/T(i) * r_var + std::norm(tmp)/i_plus_1; r_var = T(i-1)/T(i) * r_var + std::norm(tmp)/i_plus_1;
r_mean = r_mean + tmp/i_plus_1; r_mean = r_mean + tmp/i_plus_1;
} }
return (norm_type == 0) ? r_var : (T(n_elem-1)/T(n_elem)) * r_var; return (norm_type == 0) ? r_var : (T(n_elem-1)/T(n_elem)) * r_var;
 End of changes. 19 change blocks. 
21 lines changed or deleted 21 lines changed or added


 operator_cube_relational.hpp   operator_cube_relational.hpp 
skipping to change at line 25 skipping to change at line 25
// < : lt // < : lt
// > : gt // > : gt
// <= : lteq // <= : lteq
// >= : gteq // >= : gteq
// == : eq // == : eq
// != : noteq // != : noteq
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlueCube<u32, T1, T2, glue_rel_lt> const mtGlueCube<uword, T1, T2, glue_rel_lt>
operator< operator<
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlueCube<u32, T1, T2, glue_rel_lt>( X.get_ref(), Y.get_ref() ); return mtGlueCube<uword, T1, T2, glue_rel_lt>( X.get_ref(), Y.get_ref() ) ;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlueCube<u32, T1, T2, glue_rel_gt> const mtGlueCube<uword, T1, T2, glue_rel_gt>
operator> operator>
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlueCube<u32, T1, T2, glue_rel_gt>( X.get_ref(), Y.get_ref() ); return mtGlueCube<uword, T1, T2, glue_rel_gt>( X.get_ref(), Y.get_ref() ) ;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlueCube<u32, T1, T2, glue_rel_lteq> const mtGlueCube<uword, T1, T2, glue_rel_lteq>
operator<= operator<=
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlueCube<u32, T1, T2, glue_rel_lteq>( X.get_ref(), Y.get_ref() ) ; return mtGlueCube<uword, T1, T2, glue_rel_lteq>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlueCube<u32, T1, T2, glue_rel_gteq> const mtGlueCube<uword, T1, T2, glue_rel_gteq>
operator>= operator>=
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlueCube<u32, T1, T2, glue_rel_gteq>( X.get_ref(), Y.get_ref() ) ; return mtGlueCube<uword, T1, T2, glue_rel_gteq>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlueCube<u32, T1, T2, glue_rel_eq> const mtGlueCube<uword, T1, T2, glue_rel_eq>
operator== operator==
(const BaseCube<typename T1::elem_type,T1>& X, const BaseCube<typename T1:: elem_type,T2>& Y) (const BaseCube<typename T1::elem_type,T1>& X, const BaseCube<typename T1:: elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlueCube<u32, T1, T2, glue_rel_eq>( X.get_ref(), Y.get_ref() ); return mtGlueCube<uword, T1, T2, glue_rel_eq>( X.get_ref(), Y.get_ref() ) ;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlueCube<u32, T1, T2, glue_rel_noteq> const mtGlueCube<uword, T1, T2, glue_rel_noteq>
operator!= operator!=
(const BaseCube<typename T1::elem_type,T1>& X, const BaseCube<typename T1:: elem_type,T2>& Y) (const BaseCube<typename T1::elem_type,T1>& X, const BaseCube<typename T1:: elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlueCube<u32, T1, T2, glue_rel_noteq>( X.get_ref(), Y.get_ref() ); return mtGlueCube<uword, T1, T2, glue_rel_noteq>( X.get_ref(), Y.get_ref( ) );
} }
// //
// //
// //
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_lt_pre> const mtOpCube<uword, T1, op_rel_lt_pre>
operator< operator<
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_lt_pre>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_lt_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_lt_post> const mtOpCube<uword, T1, op_rel_lt_post>
operator< operator<
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_lt_post>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_lt_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_gt_pre> const mtOpCube<uword, T1, op_rel_gt_pre>
operator> operator>
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_gt_pre>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_gt_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_gt_post> const mtOpCube<uword, T1, op_rel_gt_post>
operator> operator>
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_gt_post>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_gt_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_lteq_pre> const mtOpCube<uword, T1, op_rel_lteq_pre>
operator<= operator<=
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_lteq_pre>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_lteq_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_lteq_post> const mtOpCube<uword, T1, op_rel_lteq_post>
operator<= operator<=
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_lteq_post>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_lteq_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_gteq_pre> const mtOpCube<uword, T1, op_rel_gteq_pre>
operator>= operator>=
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base Cube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_gteq_pre>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_gteq_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_gteq_post> const mtOpCube<uword, T1, op_rel_gteq_post>
operator>= operator>=
(const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val) (const BaseCube<typename arma_not_cx<typename T1::elem_type>::result,T1>& X , const typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_gteq_post>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_gteq_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_eq> const mtOpCube<uword, T1, op_rel_eq>
operator== operator==
(const typename T1::elem_type val, const BaseCube<typename T1::elem_type,T1 >& X) (const typename T1::elem_type val, const BaseCube<typename T1::elem_type,T1 >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_eq>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_eq>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_eq> const mtOpCube<uword, T1, op_rel_eq>
operator== operator==
(const BaseCube<typename T1::elem_type,T1>& X, const typename T1::elem_type val) (const BaseCube<typename T1::elem_type,T1>& X, const typename T1::elem_type val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_eq>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_eq>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_noteq> const mtOpCube<uword, T1, op_rel_noteq>
operator!= operator!=
(const typename T1::elem_type val, const BaseCube<typename T1::elem_type,T1 >& X) (const typename T1::elem_type val, const BaseCube<typename T1::elem_type,T1 >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_noteq>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_noteq>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOpCube<u32, T1, op_rel_noteq> const mtOpCube<uword, T1, op_rel_noteq>
operator!= operator!=
(const BaseCube<typename T1::elem_type,T1>& X, const typename T1::elem_type val) (const BaseCube<typename T1::elem_type,T1>& X, const typename T1::elem_type val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOpCube<u32, T1, op_rel_noteq>(X.get_ref(), val); return mtOpCube<uword, T1, op_rel_noteq>(X.get_ref(), val);
} }
//! @} //! @}
 End of changes. 36 change blocks. 
36 lines changed or deleted 36 lines changed or added


 operator_relational.hpp   operator_relational.hpp 
skipping to change at line 25 skipping to change at line 25
// < : lt // < : lt
// > : gt // > : gt
// <= : lteq // <= : lteq
// >= : gteq // >= : gteq
// == : eq // == : eq
// != : noteq // != : noteq
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlue<u32, T1, T2, glue_rel_lt> const mtGlue<uword, T1, T2, glue_rel_lt>
operator< operator<
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlue<u32, T1, T2, glue_rel_lt>( X.get_ref(), Y.get_ref() ); return mtGlue<uword, T1, T2, glue_rel_lt>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlue<u32, T1, T2, glue_rel_gt> const mtGlue<uword, T1, T2, glue_rel_gt>
operator> operator>
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlue<u32, T1, T2, glue_rel_gt>( X.get_ref(), Y.get_ref() ); return mtGlue<uword, T1, T2, glue_rel_gt>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlue<u32, T1, T2, glue_rel_lteq> const mtGlue<uword, T1, T2, glue_rel_lteq>
operator<= operator<=
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlue<u32, T1, T2, glue_rel_lteq>( X.get_ref(), Y.get_ref() ); return mtGlue<uword, T1, T2, glue_rel_lteq>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlue<u32, T1, T2, glue_rel_gteq> const mtGlue<uword, T1, T2, glue_rel_gteq>
operator>= operator>=
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst Base<typename arma_not_cx<typename T1::elem_type>::result,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlue<u32, T1, T2, glue_rel_gteq>( X.get_ref(), Y.get_ref() ); return mtGlue<uword, T1, T2, glue_rel_gteq>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlue<u32, T1, T2, glue_rel_eq> const mtGlue<uword, T1, T2, glue_rel_eq>
operator== operator==
(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_typ e,T2>& Y) (const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_typ e,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlue<u32, T1, T2, glue_rel_eq>( X.get_ref(), Y.get_ref() ); return mtGlue<uword, T1, T2, glue_rel_eq>( X.get_ref(), Y.get_ref() );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const mtGlue<u32, T1, T2, glue_rel_noteq> const mtGlue<uword, T1, T2, glue_rel_noteq>
operator!= operator!=
(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_typ e,T2>& Y) (const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_typ e,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtGlue<u32, T1, T2, glue_rel_noteq>( X.get_ref(), Y.get_ref() ); return mtGlue<uword, T1, T2, glue_rel_noteq>( X.get_ref(), Y.get_ref() );
} }
// //
// //
// //
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_lt_pre> const mtOp<uword, T1, op_rel_lt_pre>
operator< operator<
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_lt_pre>(X.get_ref(), val); return mtOp<uword, T1, op_rel_lt_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_lt_post> const mtOp<uword, T1, op_rel_lt_post>
operator< operator<
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_lt_post>(X.get_ref(), val); return mtOp<uword, T1, op_rel_lt_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_gt_pre> const mtOp<uword, T1, op_rel_gt_pre>
operator> operator>
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_gt_pre>(X.get_ref(), val); return mtOp<uword, T1, op_rel_gt_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_gt_post> const mtOp<uword, T1, op_rel_gt_post>
operator> operator>
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_gt_post>(X.get_ref(), val); return mtOp<uword, T1, op_rel_gt_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_lteq_pre> const mtOp<uword, T1, op_rel_lteq_pre>
operator<= operator<=
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_lteq_pre>(X.get_ref(), val); return mtOp<uword, T1, op_rel_lteq_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_lteq_post> const mtOp<uword, T1, op_rel_lteq_post>
operator<= operator<=
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_lteq_post>(X.get_ref(), val); return mtOp<uword, T1, op_rel_lteq_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_gteq_pre> const mtOp<uword, T1, op_rel_gteq_pre>
operator>= operator>=
(const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X) (const typename arma_not_cx<typename T1::elem_type>::result val, const Base <typename arma_not_cx<typename T1::elem_type>::result,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_gteq_pre>(X.get_ref(), val); return mtOp<uword, T1, op_rel_gteq_pre>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_gteq_post> const mtOp<uword, T1, op_rel_gteq_post>
operator>= operator>=
(const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val) (const Base<typename arma_not_cx<typename T1::elem_type>::result,T1>& X, co nst typename arma_not_cx<typename T1::elem_type>::result val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_gteq_post>(X.get_ref(), val); return mtOp<uword, T1, op_rel_gteq_post>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_eq> const mtOp<uword, T1, op_rel_eq>
operator== operator==
(const typename T1::elem_type val, const Base<typename T1::elem_type,T1>& X ) (const typename T1::elem_type val, const Base<typename T1::elem_type,T1>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_eq>(X.get_ref(), val); return mtOp<uword, T1, op_rel_eq>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_eq> const mtOp<uword, T1, op_rel_eq>
operator== operator==
(const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type val ) (const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type val )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_eq>(X.get_ref(), val); return mtOp<uword, T1, op_rel_eq>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_noteq> const mtOp<uword, T1, op_rel_noteq>
operator!= operator!=
(const typename T1::elem_type val, const Base<typename T1::elem_type,T1>& X ) (const typename T1::elem_type val, const Base<typename T1::elem_type,T1>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_noteq>(X.get_ref(), val); return mtOp<uword, T1, op_rel_noteq>(X.get_ref(), val);
} }
template<typename T1> template<typename T1>
inline inline
const mtOp<u32, T1, op_rel_noteq> const mtOp<uword, T1, op_rel_noteq>
operator!= operator!=
(const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type val ) (const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type val )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<u32, T1, op_rel_noteq>(X.get_ref(), val); return mtOp<uword, T1, op_rel_noteq>(X.get_ref(), val);
} }
//! @} //! @}
 End of changes. 36 change blocks. 
36 lines changed or deleted 36 lines changed or added


 operator_times.hpp   operator_times.hpp 
skipping to change at line 139 skipping to change at line 139
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 multiply");
const u32 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(u32 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] );
} }
return out; return out;
} }
//! multiplication of Base objects with same element type //! multiplication of Base objects with same element type
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_inline
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 podarray_bones.hpp   podarray_bones.hpp 
skipping to change at line 18 skipping to change at line 18
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup podarray //! \addtogroup podarray
//! @{ //! @{
struct podarray_prealloc_n_elem struct podarray_prealloc_n_elem
{ {
static const u32 val = 16; static const uword val = 16;
}; };
//! A lightweight array for POD types. If the amount of memory requested is small, the stack is used. //! A lightweight array for POD types. If the amount of memory requested is small, the stack is used.
template<typename eT> template<typename eT>
class podarray class podarray
{ {
public: public:
arma_aligned const u32 n_elem; //!< number of elements held arma_aligned const uword n_elem; //!< number of elements held
arma_aligned const eT* const mem; //!< pointer to memory used by the o bject arma_aligned const eT* const mem; //!< pointer to memory used by the o bject
protected: protected:
//! Internal memory, to avoid calling the 'new' operator for small amount s of memory. //! Internal memory, to avoid calling the 'new' operator for small amount s of memory.
arma_aligned eT mem_local[ podarray_prealloc_n_elem::val ]; arma_aligned eT mem_local[ podarray_prealloc_n_elem::val ];
public: public:
inline ~podarray(); inline ~podarray();
inline podarray(); inline podarray();
inline podarray (const podarray& x); inline podarray (const podarray& x);
inline const podarray& operator=(const podarray& x); inline const podarray& operator=(const podarray& x);
arma_inline explicit podarray(const u32 new_N); arma_inline explicit podarray(const uword new_N);
arma_inline explicit podarray(const eT* X, const u32 new_N); arma_inline explicit podarray(const eT* X, const uword new_N);
arma_inline eT& operator[] (const u32 i); arma_inline eT& operator[] (const uword i);
arma_inline eT operator[] (const u32 i) const; arma_inline eT operator[] (const uword i) const;
arma_inline eT& operator() (const u32 i); arma_inline eT& operator() (const uword i);
arma_inline eT operator() (const u32 i) const; arma_inline eT operator() (const uword i) const;
inline void set_size(const u32 new_n_elem); inline void set_size(const uword new_n_elem);
inline void reset(); inline void reset();
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const u32 new_n_elem); inline void zeros(const uword new_n_elem);
arma_inline eT* memptr(); arma_inline eT* memptr();
arma_inline const eT* memptr() const; arma_inline const eT* memptr() const;
arma_hot inline void copy_row(const Mat<eT>& A, const u32 row); arma_hot inline void copy_row(const Mat<eT>& A, const uword row);
protected: protected:
inline void init(const u32 new_n_elem); inline void init(const uword new_n_elem);
}; };
//! @} //! @}
 End of changes. 10 change blocks. 
12 lines changed or deleted 12 lines changed or added


 podarray_meat.hpp   podarray_meat.hpp 
skipping to change at line 73 skipping to change at line 73
init(x.n_elem); init(x.n_elem);
arrayops::copy( memptr(), x.memptr(), n_elem ); arrayops::copy( memptr(), x.memptr(), n_elem );
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
podarray<eT>::podarray(const u32 new_n_elem) podarray<eT>::podarray(const uword new_n_elem)
: n_elem(0) : n_elem(0)
, mem (0) , mem (0)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(new_n_elem); init(new_n_elem);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
podarray<eT>::podarray(const eT* X, const u32 new_n_elem) podarray<eT>::podarray(const eT* X, const uword new_n_elem)
: n_elem(0) : n_elem(0)
, mem (0) , mem (0)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(new_n_elem); init(new_n_elem);
arrayops::copy( memptr(), X, new_n_elem ); arrayops::copy( memptr(), X, new_n_elem );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
podarray<eT>::operator[] (const u32 i) const podarray<eT>::operator[] (const uword i) const
{ {
return mem[i]; return mem[i];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
podarray<eT>::operator[] (const u32 i) podarray<eT>::operator[] (const uword i)
{ {
return access::rw(mem[i]); return access::rw(mem[i]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
podarray<eT>::operator() (const u32 i) const podarray<eT>::operator() (const uword i) const
{ {
arma_debug_check( (i >= n_elem), "podarray::operator(): index out of boun ds"); arma_debug_check( (i >= n_elem), "podarray::operator(): index out of boun ds");
return mem[i]; return mem[i];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
podarray<eT>::operator() (const u32 i) podarray<eT>::operator() (const uword i)
{ {
arma_debug_check( (i >= n_elem), "podarray::operator(): index out of boun ds"); arma_debug_check( (i >= n_elem), "podarray::operator(): index out of boun ds");
return access::rw(mem[i]); return access::rw(mem[i]);
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::set_size(const u32 new_n_elem) podarray<eT>::set_size(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(new_n_elem); init(new_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::reset() podarray<eT>::reset()
skipping to change at line 172 skipping to change at line 172
podarray<eT>::zeros() podarray<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::zeros(const u32 new_n_elem) podarray<eT>::zeros(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(new_n_elem); init(new_n_elem);
fill(eT(0)); fill(eT(0));
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
skipping to change at line 200 skipping to change at line 200
const eT* const eT*
podarray<eT>::memptr() const podarray<eT>::memptr() const
{ {
return mem; return mem;
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
podarray<eT>::copy_row(const Mat<eT>& A, const u32 row) podarray<eT>::copy_row(const Mat<eT>& A, const uword row)
{ {
const u32 cols = A.n_cols; const uword cols = A.n_cols;
// note: this function assumes that the podarray has been set to the corr ect size beforehand // note: this function assumes that the podarray has been set to the corr ect size beforehand
eT* out = memptr(); eT* out = memptr();
switch(cols) switch(cols)
{ {
default: default:
{ {
u32 i,j; uword i,j;
for(i=0, j=1; j < cols; i+=2, j+=2) for(i=0, j=1; j < cols; i+=2, j+=2)
{ {
out[i] = A.at(row, i); out[i] = A.at(row, i);
out[j] = A.at(row, j); out[j] = A.at(row, j);
} }
if(i < cols) if(i < cols)
{ {
out[i] = A.at(row, i); out[i] = A.at(row, i);
} }
skipping to change at line 254 skipping to change at line 254
out[1] = A.at(row, 1); out[1] = A.at(row, 1);
case 1: case 1:
out[0] = A.at(row, 0); out[0] = A.at(row, 0);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::init(const u32 new_n_elem) podarray<eT>::init(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(n_elem == new_n_elem) if(n_elem == new_n_elem)
{ {
return; return;
} }
if(n_elem > sizeof(mem_local)/sizeof(eT) ) if(n_elem > sizeof(mem_local)/sizeof(eT) )
{ {
 End of changes. 12 change blocks. 
12 lines changed or deleted 12 lines changed or added


 promote_type.hpp   promote_type.hpp 
skipping to change at line 35 skipping to change at line 35
static const bool value = true; static const bool value = true;
}; };
template<typename T> struct is_promotable<T, T> : public is_p romotable_ok { typedef T result; }; template<typename T> struct is_promotable<T, T> : public is_p romotable_ok { typedef T result; };
template<typename T> struct is_promotable<std::complex<T>, T> : public is_p romotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, T> : public is_p romotable_ok { typedef std::complex<T> result; };
template<> struct is_promotable<std::complex<double>, std::complex<float> > : public is_promotable_ok { typedef std::complex<double> result; }; template<> struct is_promotable<std::complex<double>, std::complex<float> > : public is_promotable_ok { typedef std::complex<double> result; };
template<> struct is_promotable<std::complex<double>, float> : public is_promotable_ok { typedef std::complex<double> result; }; template<> struct is_promotable<std::complex<double>, float> : public is_promotable_ok { typedef std::complex<double> result; };
template<> struct is_promotable<std::complex<float>, double> : public is_promotable_ok { typedef std::complex<double> result; }; template<> struct is_promotable<std::complex<float>, double> : public is_promotable_ok { typedef std::complex<double> result; };
// template<typename T> struct is_promotable<std::complex<T>, u64> : public #if defined(ARMA_64BIT_WORD)
is_promotable_ok { typedef std::complex<T> result; }; template<typename t> struct is_promotable<std::complex<t>, u64> : public is
_promotable_ok { typedef std::complex<t> result; };
template<typename t> struct is_promotable<std::complex<t>, s64> : public is
_promotable_ok { typedef std::complex<t> result; };
#endif
template<typename T> struct is_promotable<std::complex<T>, s32> : public is _promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, s32> : public is _promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<std::complex<T>, u32> : public is _promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, u32> : public is _promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<std::complex<T>, s16> : public is _promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, s16> : public is _promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<std::complex<T>, u16> : public is _promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, u16> : public is _promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<std::complex<T>, s8> : public is _promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, s8> : public is _promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<std::complex<T>, u8> : public is _promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<std::complex<T>, u8> : public is _promotable_ok { typedef std::complex<T> result; };
template<> struct is_promotable<double, float> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, float> : public is_promotable_ok { typedef double result; };
// template<> struct is_promotable<double, u64 > : public is_promotable_ok #if defined(ARMA_64BIT_WORD)
{ typedef double result; }; template<> struct is_promotable<double, s64 > : public is_promotable_ok {
typedef double result; };
template<> struct is_promotable<double, u64 > : public is_promotable_ok {
typedef double result; };
#endif
template<> struct is_promotable<double, s32 > : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, s32 > : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<double, u32 > : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, u32 > : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<double, s16 > : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, s16 > : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<double, u16 > : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, u16 > : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<double, s8 > : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, s8 > : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<double, u8 > : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<double, u8 > : public is_promotable_ok { typedef double result; };
// template<> struct is_promotable<float, u64> : public is_promotable_ok { #if defined(ARMA_64BIT_WORD)
typedef float result; }; template<> struct is_promotable<float, s64> : public is_promotable_ok { typ
edef float result; };
template<> struct is_promotable<float, u64> : public is_promotable_ok { typ
edef float result; };
#endif
template<> struct is_promotable<float, s32> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<float, s32> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<float, u32> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<float, u32> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<float, s16> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<float, s16> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<float, u16> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<float, u16> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<float, s8 > : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<float, s8 > : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<float, u8 > : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<float, u8 > : public is_promotable_ok { typ edef float result; };
// template<> struct is_promotable<u64, u32> : public is_promotable_ok { ty #if defined(ARMA_64BIT_WORD)
pedef u64 result; }; template<> struct is_promotable<u64, u32> : public is_promotable_ok { typed
// template<> struct is_promotable<u64, u16> : public is_promotable_ok { ty ef u64 result; };
pedef u64 result; }; template<> struct is_promotable<u64, u16> : public is_promotable_ok { typed
// template<> struct is_promotable<u64, u8 > : public is_promotable_ok { ty ef u64 result; };
pedef u64 result; }; template<> struct is_promotable<u64, u8 > : public is_promotable_ok { typed
ef u64 result; };
#endif
#if defined(ARMA_64BIT_WORD)
template<> struct is_promotable<s64, u64> : public is_promotable_ok { typed
ef s64 result; }; // float ?
template<> struct is_promotable<s64, u32> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s64, s32> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s64, s16> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s64, u16> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s64, s8 > : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s64, u8 > : public is_promotable_ok { typed
ef s64 result; };
#endif
template<> struct is_promotable<s32, u32> : public is_promotable_ok { typed ef s32 result; }; // float ? template<> struct is_promotable<s32, u32> : public is_promotable_ok { typed ef s32 result; }; // float ?
template<> struct is_promotable<s32, s16> : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<s32, s16> : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<s32, u16> : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<s32, u16> : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<s32, s8 > : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<s32, s8 > : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<s32, u8 > : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<s32, u8 > : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<u32, s16> : public is_promotable_ok { typed ef s32 result; }; // float ? template<> struct is_promotable<u32, s16> : public is_promotable_ok { typed ef s32 result; }; // float ?
template<> struct is_promotable<u32, u16> : public is_promotable_ok { typed ef u32 result; }; template<> struct is_promotable<u32, u16> : public is_promotable_ok { typed ef u32 result; };
template<> struct is_promotable<u32, s8 > : public is_promotable_ok { typed ef s32 result; }; // float ? template<> struct is_promotable<u32, s8 > : public is_promotable_ok { typed ef s32 result; }; // float ?
skipping to change at line 93 skipping to change at line 114
// //
// mirrored versions // mirrored versions
template<typename T> struct is_promotable<T, std::complex<T> > : public is_ promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<T, std::complex<T> > : public is_ promotable_ok { typedef std::complex<T> result; };
template<> struct is_promotable<std::complex<float>, std::complex<double> > : public is_promotable_ok { typedef std::complex<double> result; }; template<> struct is_promotable<std::complex<float>, std::complex<double> > : public is_promotable_ok { typedef std::complex<double> result; };
template<> struct is_promotable<float, std::complex<double> > : public is_promotable_ok { typedef std::complex<double> result; }; template<> struct is_promotable<float, std::complex<double> > : public is_promotable_ok { typedef std::complex<double> result; };
template<> struct is_promotable<double, std::complex<float> > : public is_promotable_ok { typedef std::complex<double> result; }; template<> struct is_promotable<double, std::complex<float> > : public is_promotable_ok { typedef std::complex<double> result; };
// template<typename T> struct is_promotable<u64, std::complex<T> > : publi #if defined(ARMA_64BIT_WORD)
c is_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<s64, std::complex<T> > : public i
s_promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<u64, std::complex<T> > : public i
s_promotable_ok { typedef std::complex<T> result; };
#endif
template<typename T> struct is_promotable<s32, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<s32, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<u32, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<u32, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<s16, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<s16, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<u16, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<u16, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<s8, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<s8, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; };
template<typename T> struct is_promotable<u8, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; }; template<typename T> struct is_promotable<u8, std::complex<T> > : public i s_promotable_ok { typedef std::complex<T> result; };
template<> struct is_promotable<float, double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<float, double> : public is_promotable_ok { typedef double result; };
// template<> struct is_promotable<u64 , double> : public is_promotable_ok #if defined(ARMA_64BIT_WORD)
{ typedef double result; }; template<> struct is_promotable<s64 , double> : public is_promotable_ok {
typedef double result; };
template<> struct is_promotable<u64 , double> : public is_promotable_ok {
typedef double result; };
#endif
template<> struct is_promotable<s32 , double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<s32 , double> : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<u32 , double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<u32 , double> : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<s16 , double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<s16 , double> : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<u16 , double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<u16 , double> : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<s8 , double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<s8 , double> : public is_promotable_ok { typedef double result; };
template<> struct is_promotable<u8 , double> : public is_promotable_ok { typedef double result; }; template<> struct is_promotable<u8 , double> : public is_promotable_ok { typedef double result; };
// template<> struct is_promotable<u64, float> : public is_promotable_ok { #if defined(ARMA_64BIT_WORD)
typedef float result; }; template<> struct is_promotable<s64, float> : public is_promotable_ok { typ
edef float result; };
template<> struct is_promotable<u64, float> : public is_promotable_ok { typ
edef float result; };
#endif
template<> struct is_promotable<s32, float> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<s32, float> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<u32, float> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<u32, float> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<s16, float> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<s16, float> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<u16, float> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<u16, float> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<s8 , float> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<s8 , float> : public is_promotable_ok { typ edef float result; };
template<> struct is_promotable<u8 , float> : public is_promotable_ok { typ edef float result; }; template<> struct is_promotable<u8 , float> : public is_promotable_ok { typ edef float result; };
// template<> struct is_promotable<u32, u64> : public is_promotable_ok { ty #if defined(ARMA_64BIT_WORD)
pedef u64 result; }; template<> struct is_promotable<u32, u64> : public is_promotable_ok { typed
// template<> struct is_promotable<u16, u64> : public is_promotable_ok { ty ef u64 result; };
pedef u64 result; }; template<> struct is_promotable<u16, u64> : public is_promotable_ok { typed
// template<> struct is_promotable<u8, u64> : public is_promotable_ok { ty ef u64 result; };
pedef u64 result; }; template<> struct is_promotable<u8, u64> : public is_promotable_ok { typed
ef u64 result; };
#endif
#if defined(ARMA_64BIT_WORD)
template<> struct is_promotable<u64, s64> : public is_promotable_ok { typed
ef s64 result; }; // float ?
template<> struct is_promotable<u32, s64> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s16, s64> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<u16, s64> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<s8 , s64> : public is_promotable_ok { typed
ef s64 result; };
template<> struct is_promotable<u8 , s64> : public is_promotable_ok { typed
ef s64 result; };
#endif
template<> struct is_promotable<u32, s32> : public is_promotable_ok { typed ef s32 result; }; // float ? template<> struct is_promotable<u32, s32> : public is_promotable_ok { typed ef s32 result; }; // float ?
template<> struct is_promotable<s16, s32> : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<s16, s32> : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<u16, s32> : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<u16, s32> : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<s8 , s32> : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<s8 , s32> : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<u8 , s32> : public is_promotable_ok { typed ef s32 result; }; template<> struct is_promotable<u8 , s32> : public is_promotable_ok { typed ef s32 result; };
template<> struct is_promotable<s16, u32> : public is_promotable_ok { typed ef s32 result; }; // float ? template<> struct is_promotable<s16, u32> : public is_promotable_ok { typed ef s32 result; }; // float ?
template<> struct is_promotable<u16, u32> : public is_promotable_ok { typed ef u32 result; }; template<> struct is_promotable<u16, u32> : public is_promotable_ok { typed ef u32 result; };
template<> struct is_promotable<s8 , u32> : public is_promotable_ok { typed ef s32 result; }; // float ? template<> struct is_promotable<s8 , u32> : public is_promotable_ok { typed ef s32 result; }; // float ?
skipping to change at line 147 skipping to change at line 188
template<> struct is_promotable<s8, u16> : public is_promotable_ok { typede f s16 result; }; // s32 ? template<> struct is_promotable<s8, u16> : public is_promotable_ok { typede f s16 result; }; // s32 ?
template<> struct is_promotable<u8, u16> : public is_promotable_ok { typede f u16 result; }; template<> struct is_promotable<u8, u16> : public is_promotable_ok { typede f u16 result; };
template<> struct is_promotable<u8, s8> : public is_promotable_ok { typedef s8 result; }; // s16 ? template<> struct is_promotable<u8, s8> : public is_promotable_ok { typedef s8 result; }; // s16 ?
template<typename T1, typename T2> template<typename T1, typename T2>
struct promote_type struct promote_type
{ {
inline static void check() inline static void check()
{ {
arma_static_assert< is_promotable<T1,T2>::value > ERROR___UNSUPPORTED_M arma_type_check(( is_promotable<T1,T2>::value == false ));
IXTURE_OF_TYPES;
ERROR___UNSUPPORTED_MIXTURE_OF_TYPES = ERROR___UNSUPPORTED_MIXTURE_OF_T
YPES;
} }
typedef typename is_promotable<T1,T2>::result result; typedef typename is_promotable<T1,T2>::result result;
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct eT_promoter struct eT_promoter
{ {
typedef typename promote_type<typename T1::elem_type, typename T2::elem_t ype>::result eT; typedef typename promote_type<typename T1::elem_type, typename T2::elem_t ype>::result eT;
}; };
 End of changes. 9 change blocks. 
28 lines changed or deleted 85 lines changed or added


 restrictors.hpp   restrictors.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup restrictors //! \addtogroup restrictors
//! @{ //! @{
// structures for template based restrictions of input/output arguments // structures for template based restrictions of input/output arguments
// (part of the SFINAE approach) // (part of the SFINAE approach)
// http://en.wikipedia.org/wiki/SFINAE // http://en.wikipedia.org/wiki/SFINAE
template<typename T> struct arma_scalar_only { }; template<typename T> struct arma_scalar_only { };
template<> struct arma_scalar_only<char> { typedef char result; }; template<> struct arma_scalar_only<u8> { typedef u8 result; };
template<> struct arma_scalar_only<short> { typedef short result; }; template<> struct arma_scalar_only<s8> { typedef s8 result; };
template<> struct arma_scalar_only<int> { typedef int result; }; template<> struct arma_scalar_only<u16> { typedef u16 result; };
template<> struct arma_scalar_only<long> { typedef long result; }; template<> struct arma_scalar_only<s16> { typedef s16 result; };
template<> struct arma_scalar_only<u32> { typedef u32 result; };
template<> struct arma_scalar_only<s32> { typedef s32 result; };
#if defined(ARMA_64BIT_WORD)
template<> struct arma_scalar_only<u64> { typedef u64 result; };
template<> struct arma_scalar_only<s64> { typedef s64 result; };
#endif
template<> struct arma_scalar_only<float> { typedef float result; }; template<> struct arma_scalar_only<float> { typedef float result; };
template<> struct arma_scalar_only<double> { typedef double result; }; template<> struct arma_scalar_only<double> { typedef double result; };
template<> struct arma_scalar_only<unsigned char> { typedef unsigned char template<typename T>
result; }; struct arma_scalar_only< std::complex<T> > { typedef std::complex<T> result
template<> struct arma_scalar_only<unsigned short> { typedef unsigned short ; };
result; };
template<> struct arma_scalar_only<unsigned int> { typedef unsigned int
result; };
template<> struct arma_scalar_only<unsigned long> { typedef unsigned long
result; };
template<typename T> struct arma_scalar_only< std::complex<T> > { typedef s
td::complex<T> result; };
template<typename T> struct arma_integral_only { }; template<typename T> struct arma_integral_only { };
template<> struct arma_integral_only<char> { typedef char result; }; template<> struct arma_integral_only<u8> { typedef u8 result; };
template<> struct arma_integral_only<short> { typedef short result; }; template<> struct arma_integral_only<s8> { typedef s8 result; };
template<> struct arma_integral_only<int> { typedef int result; }; template<> struct arma_integral_only<u16> { typedef u16 result; };
template<> struct arma_integral_only<long> { typedef long result; }; template<> struct arma_integral_only<s16> { typedef s16 result; };
template<> struct arma_integral_only<u32> { typedef u32 result; };
template<> struct arma_integral_only<unsigned char> { typedef unsigned cha template<> struct arma_integral_only<s32> { typedef s32 result; };
r result; }; #if defined(ARMA_64BIT_WORD)
template<> struct arma_integral_only<unsigned short> { typedef unsigned sho template<> struct arma_integral_only<u64> { typedef u64 result; };
rt result; }; template<> struct arma_integral_only<s64> { typedef s64 result; };
template<> struct arma_integral_only<unsigned int> { typedef unsigned int #endif
result; };
template<> struct arma_integral_only<unsigned long> { typedef unsigned lon
g result; };
template<typename T> struct arma_unsigned_integral_only { }; template<typename T> struct arma_unsigned_integral_only { };
template<> struct arma_unsigned_integral_only<unsigned char> { typedef uns template<> struct arma_unsigned_integral_only<u8> { typedef u8 result; };
igned char result; }; template<> struct arma_unsigned_integral_only<u16> { typedef u16 result; };
template<> struct arma_unsigned_integral_only<unsigned short> { typedef uns template<> struct arma_unsigned_integral_only<u32> { typedef u32 result; };
igned short result; }; #if defined(ARMA_64BIT_WORD)
template<> struct arma_unsigned_integral_only<unsigned int> { typedef uns template<> struct arma_unsigned_integral_only<u64> { typedef u64 result; };
igned int result; }; #endif
template<> struct arma_unsigned_integral_only<unsigned long> { typedef uns
igned long result; };
template<typename T> struct arma_signed_integral_only { }; template<typename T> struct arma_signed_integral_only { };
template<> struct arma_signed_integral_only<char> { typedef char result template<> struct arma_signed_integral_only<s8> { typedef s8 result; };
; }; template<> struct arma_signed_integral_only<s16> { typedef s16 result; };
template<> struct arma_signed_integral_only<short> { typedef short result template<> struct arma_signed_integral_only<s32> { typedef s32 result; };
; }; #if defined(ARMA_64BIT_WORD)
template<> struct arma_signed_integral_only<int> { typedef int result template<> struct arma_signed_integral_only<s64> { typedef s64 result; };
; }; #endif
template<> struct arma_signed_integral_only<long> { typedef long result
; };
template<typename T> struct arma_signed_only { }; template<typename T> struct arma_signed_only { };
template<> struct arma_signed_only<char> { typedef char result; }; template<> struct arma_signed_only<s8> { typedef s8 result; };
template<> struct arma_signed_only<short> { typedef short result; }; template<> struct arma_signed_only<s16> { typedef s16 result; };
template<> struct arma_signed_only<int> { typedef int result; }; template<> struct arma_signed_only<s32> { typedef s32 result; };
template<> struct arma_signed_only<long> { typedef long result; }; #if defined(ARMA_64BIT_WORD)
template<> struct arma_signed_only<s64> { typedef s64 result; };
#endif
template<> struct arma_signed_only<float> { typedef float result; }; template<> struct arma_signed_only<float> { typedef float result; };
template<> struct arma_signed_only<double> { typedef double result; }; template<> struct arma_signed_only<double> { typedef double result; };
template<typename T> struct arma_signed_only< std::complex<T> > { typedef s td::complex<T> result; }; template<typename T> struct arma_signed_only< std::complex<T> > { typedef s td::complex<T> result; };
template<typename T> struct arma_float_only { }; template<typename T> struct arma_float_only { };
template<> struct arma_float_only<float> { typedef float result; }; template<> struct arma_float_only<float> { typedef float result; };
template<> struct arma_float_only<double> { typedef double result; }; template<> struct arma_float_only<double> { typedef double result; };
 End of changes. 6 change blocks. 
48 lines changed or deleted 41 lines changed or added


 running_stat_bones.hpp   running_stat_bones.hpp 
skipping to change at line 34 skipping to change at line 34
inline const arma_counter& operator++(); inline const arma_counter& operator++();
inline void operator++(int); inline void operator++(int);
inline void reset(); inline void reset();
inline eT value() const; inline eT value() const;
inline eT value_plus_1() const; inline eT value_plus_1() const;
inline eT value_minus_1() const; inline eT value_minus_1() const;
private: private:
arma_aligned eT d_count; arma_aligned eT d_count;
arma_aligned u32 i_count; arma_aligned uword i_count;
}; };
//! Class for keeping statistics of a continuously sampled process / signal . //! Class for keeping statistics of a continuously sampled process / signal .
//! Useful if the storage of individual samples is not necessary or desired . //! Useful if the storage of individual samples is not necessary or desired .
//! Also useful if the number of samples is not known beforehand or exceeds //! Also useful if the number of samples is not known beforehand or exceeds
//! available memory. //! available memory.
template<typename eT> template<typename eT>
class running_stat class running_stat
{ {
public: public:
skipping to change at line 59 skipping to change at line 59
inline ~running_stat(); inline ~running_stat();
inline running_stat(); inline running_stat();
inline void operator() (const T sample); inline void operator() (const T sample);
inline void operator() (const std::complex<T>& sample); inline void operator() (const std::complex<T>& sample);
inline void reset(); inline void reset();
inline eT mean() const; inline eT mean() const;
inline T var (const u32 norm_type = 0) const; inline T var (const uword norm_type = 0) const;
inline T stddev(const u32 norm_type = 0) const; inline T stddev(const uword norm_type = 0) const;
inline eT min() const; inline eT min() const;
inline eT max() const; inline eT max() const;
inline T count() const; inline T count() const;
// //
// //
private: private:
 End of changes. 2 change blocks. 
4 lines changed or deleted 4 lines changed or added


 running_stat_meat.hpp   running_stat_meat.hpp 
skipping to change at line 27 skipping to change at line 27
inline inline
arma_counter<eT>::~arma_counter() arma_counter<eT>::~arma_counter()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT> template<typename eT>
inline inline
arma_counter<eT>::arma_counter() arma_counter<eT>::arma_counter()
: d_count( eT(0)) : d_count( eT(0))
, i_count(u32(0)) , i_count(uword(0))
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT> template<typename eT>
inline inline
const arma_counter<eT>& const arma_counter<eT>&
arma_counter<eT>::operator++() arma_counter<eT>::operator++()
{ {
const u32 max_val = 0xffffffff; if(i_count < ARMA_MAX_UWORD)
if(i_count < max_val)
{ {
i_count++; i_count++;
} }
else else
{ {
d_count += eT(max_val); d_count += eT(ARMA_MAX_UWORD);
i_count = 0; i_count = 0;
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
void void
arma_counter<eT>::operator++(int) arma_counter<eT>::operator++(int)
{ {
operator++(); operator++();
} }
template<typename eT> template<typename eT>
inline inline
void void
arma_counter<eT>::reset() arma_counter<eT>::reset()
{ {
d_count = eT(0); d_count = eT(0);
i_count = u32(0); i_count = uword(0);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
arma_counter<eT>::value() const arma_counter<eT>::value() const
{ {
return d_count + eT(i_count); return d_count + eT(i_count);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
arma_counter<eT>::value_plus_1() const arma_counter<eT>::value_plus_1() const
{ {
const u32 max_val = 0xffffffff; if(i_count < ARMA_MAX_UWORD)
if(i_count < max_val)
{ {
return d_count + eT(i_count + 1); return d_count + eT(i_count + 1);
} }
else else
{ {
return d_count + eT(max_val) + eT(1); return d_count + eT(ARMA_MAX_UWORD) + eT(1);
} }
} }
template<typename eT> template<typename eT>
inline inline
eT eT
arma_counter<eT>::value_minus_1() const arma_counter<eT>::value_minus_1() const
{ {
if(i_count > 0) if(i_count > 0)
{ {
skipping to change at line 154 skipping to change at line 150
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for complex numbers)
template<typename eT> template<typename eT>
inline inline
void void
running_stat<eT>::operator() (const std::complex< typename running_stat<eT> ::T >& sample) running_stat<eT>::operator() (const std::complex< typename running_stat<eT> ::T >& sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_same_type<eT, std::complex< typename running_stat<eT> ::T > >::value == false >::apply(); arma_type_check(( is_same_type<eT, std::complex< typename running_stat<eT >::T > >::value == false ));
if( arma_isfinite(sample) == false ) if( arma_isfinite(sample) == false )
{ {
arma_warn(true, "running_stat: sample ignored as it is non-finite" ); arma_warn(true, "running_stat: sample ignored as it is non-finite" );
return; return;
} }
running_stat_aux::update_stats(*this, sample); running_stat_aux::update_stats(*this, sample);
} }
skipping to change at line 202 skipping to change at line 198
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return r_mean; return r_mean;
} }
//! variance //! variance
template<typename eT> template<typename eT>
inline inline
typename running_stat<eT>::T typename running_stat<eT>::T
running_stat<eT>::var(const u32 norm_type) const running_stat<eT>::var(const uword norm_type) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return r_var; return r_var;
skipping to change at line 230 skipping to change at line 226
else else
{ {
return T(0); return T(0);
} }
} }
//! standard deviation //! standard deviation
template<typename eT> template<typename eT>
inline inline
typename running_stat<eT>::T typename running_stat<eT>::T
running_stat<eT>::stddev(const u32 norm_type) const running_stat<eT>::stddev(const uword norm_type) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return std::sqrt( (*this).var(norm_type) ); return std::sqrt( (*this).var(norm_type) );
} }
//! minimum value //! minimum value
template<typename eT> template<typename eT>
inline inline
eT eT
 End of changes. 9 change blocks. 
13 lines changed or deleted 9 lines changed or added


 running_stat_vec_bones.hpp   running_stat_vec_bones.hpp 
skipping to change at line 41 skipping to change at line 41
inline const running_stat_vec& operator=(const running_stat_vec& in_rsv); inline const running_stat_vec& operator=(const running_stat_vec& in_rsv);
template<typename T1> arma_hot inline void operator() (const Base< T, T1>& X); template<typename T1> arma_hot inline void operator() (const Base< T, T1>& X);
template<typename T1> arma_hot inline void operator() (const Base< std::c omplex<T>, T1>& X); template<typename T1> arma_hot inline void operator() (const Base< std::c omplex<T>, T1>& X);
inline void reset(); inline void reset();
inline const Mat<eT>& mean() const; inline const Mat<eT>& mean() const;
inline const Mat< T>& var (const u32 norm_type = 0); inline const Mat< T>& var (const uword norm_type = 0);
inline Mat< T> stddev(const u32 norm_type = 0) const; inline Mat< T> stddev(const uword norm_type = 0) const;
inline const Mat<eT>& cov (const u32 norm_type = 0); inline const Mat<eT>& cov (const uword norm_type = 0);
inline const Mat<eT>& min() const; inline const Mat<eT>& min() const;
inline const Mat<eT>& max() const; inline const Mat<eT>& max() const;
inline T count() const; inline T count() const;
// //
// //
private: private:
skipping to change at line 94 skipping to change at line 94
template<typename T> template<typename T>
inline static void update_stats(running_stat_vec< std::complex<T> >& x, c onst Mat< T>& sample); inline static void update_stats(running_stat_vec< std::complex<T> >& x, c onst Mat< T>& sample);
template<typename T> template<typename T>
inline static void update_stats(running_stat_vec< std::complex<T> >& x, c onst Mat< std::complex<T> >& sample); inline static void update_stats(running_stat_vec< std::complex<T> >& x, c onst Mat< std::complex<T> >& sample);
// //
template<typename eT> template<typename eT>
inline static Mat<eT> var(const running_stat_vec< eT >& x, c onst u32 norm_type = 0); inline static Mat<eT> var(const running_stat_vec< eT >& x, c onst uword norm_type = 0);
template<typename T> template<typename T>
inline static Mat< T> var(const running_stat_vec< std::complex<T> >& x, c onst u32 norm_type = 0); inline static Mat< T> var(const running_stat_vec< std::complex<T> >& x, c onst uword norm_type = 0);
// //
template<typename eT> template<typename eT>
inline static Mat< eT > cov(const running_stat_vec< eT >& x, const u32 norm_type = 0); inline static Mat< eT > cov(const running_stat_vec< eT >& x, const uword norm_type = 0);
template<typename T> template<typename T>
inline static Mat< std::complex<T> > cov(const running_stat_vec< std::com plex<T> >& x, const u32 norm_type = 0); inline static Mat< std::complex<T> > cov(const running_stat_vec< std::com plex<T> >& x, const uword norm_type = 0);
}; };
//! @} //! @}
 End of changes. 5 change blocks. 
7 lines changed or deleted 7 lines changed or added


 running_stat_vec_meat.hpp   running_stat_vec_meat.hpp 
skipping to change at line 164 skipping to change at line 164
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return r_mean; return r_mean;
} }
//! variance //! variance
template<typename eT> template<typename eT>
inline inline
const Mat<typename get_pod_type<eT>::result>& const Mat<typename get_pod_type<eT>::result>&
running_stat_vec<eT>::var(const u32 norm_type) running_stat_vec<eT>::var(const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return r_var; return r_var;
skipping to change at line 198 skipping to change at line 198
return r_var_dummy; return r_var_dummy;
} }
} }
//! standard deviation //! standard deviation
template<typename eT> template<typename eT>
inline inline
Mat<typename get_pod_type<eT>::result> Mat<typename get_pod_type<eT>::result>
running_stat_vec<eT>::stddev(const u32 norm_type) const running_stat_vec<eT>::stddev(const uword norm_type) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return sqrt(r_var); return sqrt(r_var);
skipping to change at line 227 skipping to change at line 227
else else
{ {
return Mat<T>(); return Mat<T>();
} }
} }
//! covariance //! covariance
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
running_stat_vec<eT>::cov(const u32 norm_type) running_stat_vec<eT>::cov(const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(calc_cov == true) if(calc_cov == true)
{ {
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
skipping to change at line 317 skipping to change at line 317
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename running_stat_vec<eT>::T T; typedef typename running_stat_vec<eT>::T T;
const T N = x.counter.value(); const T N = x.counter.value();
if(N > T(0)) if(N > T(0))
{ {
arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch"); arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch");
const u32 n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
T* r_var_mem = x.r_var.memptr(); T* r_var_mem = x.r_var.memptr();
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
const T N_plus_1 = x.counter.value_plus_1(); const T N_plus_1 = x.counter.value_plus_1();
const T N_minus_1 = x.counter.value_minus_1(); const T N_minus_1 = x.counter.value_minus_1();
if(x.calc_cov == true) if(x.calc_cov == true)
skipping to change at line 347 skipping to change at line 347
} }
else else
{ {
tmp2 = trans(tmp1)*tmp1; tmp2 = trans(tmp1)*tmp1;
} }
x.r_cov *= (N_minus_1/N); x.r_cov *= (N_minus_1/N);
x.r_cov += tmp2 / N_plus_1; x.r_cov += tmp2 / N_plus_1;
} }
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT val = sample_mem[i]; const eT val = sample_mem[i];
if(val < min_val_mem[i]) if(val < min_val_mem[i])
{ {
min_val_mem[i] = val; min_val_mem[i] = val;
} }
if(val > max_val_mem[i]) if(val > max_val_mem[i])
{ {
skipping to change at line 385 skipping to change at line 385
x.r_var.zeros(sample.n_rows, sample.n_cols); x.r_var.zeros(sample.n_rows, sample.n_cols);
if(x.calc_cov == true) if(x.calc_cov == true)
{ {
x.r_cov.zeros(sample.n_elem, sample.n_elem); x.r_cov.zeros(sample.n_elem, sample.n_elem);
} }
x.min_val.set_size(sample.n_rows, sample.n_cols); x.min_val.set_size(sample.n_rows, sample.n_cols);
x.max_val.set_size(sample.n_rows, sample.n_cols); x.max_val.set_size(sample.n_rows, sample.n_cols);
const u32 n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT val = sample_mem[i]; const eT val = sample_mem[i];
r_mean_mem[i] = val; r_mean_mem[i] = val;
min_val_mem[i] = val; min_val_mem[i] = val;
max_val_mem[i] = val; max_val_mem[i] = val;
} }
} }
x.counter++; x.counter++;
skipping to change at line 433 skipping to change at line 433
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
const T N = x.counter.value(); const T N = x.counter.value();
if(N > T(0)) if(N > T(0))
{ {
arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch"); arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch");
const u32 n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
T* r_var_mem = x.r_var.memptr(); T* r_var_mem = x.r_var.memptr();
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
T* min_val_norm_mem = x.min_val_norm.memptr(); T* min_val_norm_mem = x.min_val_norm.memptr();
T* max_val_norm_mem = x.max_val_norm.memptr(); T* max_val_norm_mem = x.max_val_norm.memptr();
const T N_plus_1 = x.counter.value_plus_1(); const T N_plus_1 = x.counter.value_plus_1();
const T N_minus_1 = x.counter.value_minus_1(); const T N_minus_1 = x.counter.value_minus_1();
if(x.calc_cov == true) if(x.calc_cov == true)
{ {
Mat<eT>& tmp1 = x.tmp1; Mat<eT>& tmp1 = x.tmp1;
Mat<eT>& tmp2 = x.tmp2; Mat<eT>& tmp2 = x.tmp2;
tmp1 = sample - x.r_mean; tmp1 = sample - x.r_mean;
if(sample.n_cols == 1) if(sample.n_cols == 1)
{ {
tmp2 = conj(tmp1)*strans(tmp1); tmp2 = arma::conj(tmp1)*strans(tmp1);
} }
else else
{ {
tmp2 = trans(tmp1)*tmp1; //tmp2 = strans(conj(tmp1))*tmp1; tmp2 = trans(tmp1)*tmp1; //tmp2 = strans(conj(tmp1))*tmp1;
} }
x.r_cov *= (N_minus_1/N); x.r_cov *= (N_minus_1/N);
x.r_cov += tmp2 / N_plus_1; x.r_cov += tmp2 / N_plus_1;
} }
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT& val = sample_mem[i]; const eT& val = sample_mem[i];
const T val_norm = std::norm(val); const T val_norm = std::norm(val);
if(val_norm < min_val_norm_mem[i]) if(val_norm < min_val_norm_mem[i])
{ {
min_val_norm_mem[i] = val_norm; min_val_norm_mem[i] = val_norm;
min_val_mem[i] = val; min_val_mem[i] = val;
} }
skipping to change at line 509 skipping to change at line 509
{ {
x.r_cov.zeros(sample.n_elem, sample.n_elem); x.r_cov.zeros(sample.n_elem, sample.n_elem);
} }
x.min_val.set_size(sample.n_rows, sample.n_cols); x.min_val.set_size(sample.n_rows, sample.n_cols);
x.max_val.set_size(sample.n_rows, sample.n_cols); x.max_val.set_size(sample.n_rows, sample.n_cols);
x.min_val_norm.set_size(sample.n_rows, sample.n_cols); x.min_val_norm.set_size(sample.n_rows, sample.n_cols);
x.max_val_norm.set_size(sample.n_rows, sample.n_cols); x.max_val_norm.set_size(sample.n_rows, sample.n_cols);
const u32 n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
T* min_val_norm_mem = x.min_val_norm.memptr(); T* min_val_norm_mem = x.min_val_norm.memptr();
T* max_val_norm_mem = x.max_val_norm.memptr(); T* max_val_norm_mem = x.max_val_norm.memptr();
for(u32 i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT& val = sample_mem[i]; const eT& val = sample_mem[i];
const T val_norm = std::norm(val); const T val_norm = std::norm(val);
r_mean_mem[i] = val; r_mean_mem[i] = val;
min_val_mem[i] = val; min_val_mem[i] = val;
max_val_mem[i] = val; max_val_mem[i] = val;
min_val_norm_mem[i] = val_norm; min_val_norm_mem[i] = val_norm;
max_val_norm_mem[i] = val_norm; max_val_norm_mem[i] = val_norm;
 End of changes. 12 change blocks. 
12 lines changed or deleted 12 lines changed or added


 span.hpp   span.hpp 
skipping to change at line 33 skipping to change at line 33
static const span_alt all; static const span_alt all;
}; };
template<typename Dummy> template<typename Dummy>
const span_alt span_base<Dummy>::all = span_alt(); const span_alt span_base<Dummy>::all = span_alt();
class span : public span_base<> class span : public span_base<>
{ {
public: public:
u32 a; uword a;
u32 b; uword b;
bool whole; bool whole;
inline inline
span() span()
: a(a) : whole(true)
, b(b)
, whole(true)
{ {
} }
inline inline
span(const span_alt&) span(const span_alt&)
: a(a) : whole(true)
, b(b)
, whole(true)
{ {
} }
// TODO: // TODO:
// if the "explicit" keyword is removed or commented out, // if the "explicit" keyword is removed or commented out,
// the compiler will be able to automatically convert integers to an inst ance of the span class. // the compiler will be able to automatically convert integers to an inst ance of the span class.
// this is useful for Cube::operator()(span&, span&, span&), // this is useful for Cube::operator()(span&, span&, span&),
// but it might have unintended consequences or interactions elsewhere. // but it might have unintended consequences or interactions elsewhere.
// as such, removal of "explicit" needs thorough testing. // as such, removal of "explicit" needs thorough testing.
inline inline
explicit explicit
span(const u32 in_a) span(const uword in_a)
: a(in_a) : a(in_a)
, b(in_a) , b(in_a)
, whole(false) , whole(false)
{ {
} }
inline inline
span(const u32 in_a, const u32 in_b) span(const uword in_a, const uword in_b)
: a(in_a) : a(in_a)
, b(in_b) , b(in_b)
, whole(false) , whole(false)
{ {
} }
}; };
//! @} //! @}
 End of changes. 5 change blocks. 
11 lines changed or deleted 7 lines changed or added


 subview_bones.hpp   subview_bones.hpp 
skipping to change at line 30 skipping to change at line 30
class subview : public Base<eT, subview<eT> > class subview : public Base<eT, subview<eT> >
{ {
public: arma_aligned const Mat<eT>& m; public: arma_aligned const Mat<eT>& m;
protected: arma_aligned Mat<eT>* m_ptr; protected: arma_aligned Mat<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
const u32 aux_row1; const uword aux_row1;
const u32 aux_col1; const uword aux_col1;
const u32 n_rows; const uword n_rows;
const u32 n_cols; const uword n_cols;
const u32 n_elem; const uword n_elem;
protected: protected:
arma_inline subview(const Mat<eT>& in_m, const u32 in_row1, const u32 in_ arma_inline subview(const Mat<eT>& in_m, const uword in_row1, const uword
col1, const u32 in_n_rows, const u32 in_n_cols); in_col1, const uword in_n_rows, const uword in_n_cols);
arma_inline subview( Mat<eT>& in_m, const u32 in_row1, const u32 in_ arma_inline subview( Mat<eT>& in_m, const uword in_row1, const uword
col1, const u32 in_n_rows, const u32 in_n_cols); in_col1, const uword in_n_rows, const uword in_n_cols);
public: public:
inline ~subview(); inline ~subview();
inline void operator+= (const eT val); inline void operator+= (const eT val);
inline void operator-= (const eT val); inline void operator-= (const eT val);
inline void operator*= (const eT val); inline void operator*= (const eT val);
inline void operator/= (const eT val); inline void operator/= (const eT val);
skipping to change at line 76 skipping to change at line 76
inline static void plus_inplace(Mat<eT>& out, const subview& in); inline static void plus_inplace(Mat<eT>& out, const subview& in);
inline static void minus_inplace(Mat<eT>& out, const subview& in); inline static void minus_inplace(Mat<eT>& out, const subview& in);
inline static void schur_inplace(Mat<eT>& out, const subview& in); inline static void schur_inplace(Mat<eT>& out, const subview& in);
inline static void div_inplace(Mat<eT>& out, const subview& in); inline static void div_inplace(Mat<eT>& out, const subview& in);
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void ones(); inline void ones();
inline void eye(); inline void eye();
inline eT& operator[](const u32 i); inline eT& operator[](const uword i);
inline eT operator[](const u32 i) const; inline eT operator[](const uword i) const;
inline eT& operator()(const u32 i); inline eT& operator()(const uword i);
inline eT operator()(const u32 i) const; inline eT operator()(const uword i) const;
inline eT& operator()(const u32 in_row, const u32 in_col); inline eT& operator()(const uword in_row, const uword in_col);
inline eT operator()(const u32 in_row, const u32 in_col) const; inline eT operator()(const uword in_row, const uword in_col) const;
inline eT& at(const u32 in_row, const u32 in_col); inline eT& at(const uword in_row, const uword in_col);
inline eT at(const u32 in_row, const u32 in_col) const; inline eT at(const uword in_row, const uword in_col) const;
arma_inline eT* colptr(const u32 in_col); arma_inline eT* colptr(const uword in_col);
arma_inline const eT* colptr(const u32 in_col) const; arma_inline const eT* colptr(const uword in_col) const;
inline bool check_overlap(const subview& x) const; inline bool check_overlap(const subview& x) const;
inline bool is_vec() const; inline bool is_vec() const;
inline subview_row<eT> row(const u32 row_num); inline subview_row<eT> row(const uword row_num);
inline const subview_row<eT> row(const u32 row_num) const; inline const subview_row<eT> row(const uword row_num) const;
inline subview_row<eT> operator()(const u32 row_num, const spa inline subview_row<eT> operator()(const uword row_num, const s
n& col_span); pan& col_span);
inline const subview_row<eT> operator()(const u32 row_num, const spa inline const subview_row<eT> operator()(const uword row_num, const s
n& col_span) const; pan& col_span) const;
inline subview_col<eT> col(const u32 col_num); inline subview_col<eT> col(const uword col_num);
inline const subview_col<eT> col(const u32 col_num) const; inline const subview_col<eT> col(const uword col_num) const;
inline subview_col<eT> operator()(const span& row_span, const inline subview_col<eT> operator()(const span& row_span, const
u32 col_num); uword col_num);
inline const subview_col<eT> operator()(const span& row_span, const inline const subview_col<eT> operator()(const span& row_span, const
u32 col_num) const; uword col_num) const;
inline Col<eT> unsafe_col(const u32 col_num); inline Col<eT> unsafe_col(const uword col_num);
inline const Col<eT> unsafe_col(const u32 col_num) const; inline const Col<eT> unsafe_col(const uword col_num) const;
inline subview<eT> rows(const u32 in_row1, const u32 in_row2); inline subview<eT> rows(const uword in_row1, const uword in_row2);
inline const subview<eT> rows(const u32 in_row1, const u32 in_row2) const inline const subview<eT> rows(const uword in_row1, const uword in_row2) c
; onst;
inline subview<eT> cols(const u32 in_col1, const u32 in_col2); inline subview<eT> cols(const uword in_col1, const uword in_col2);
inline const subview<eT> cols(const u32 in_col1, const u32 in_col2) const inline const subview<eT> cols(const uword in_col1, const uword in_col2) c
; onst;
inline subview<eT> submat(const u32 in_row1, const u32 in_col1, con inline subview<eT> submat(const uword in_row1, const uword in_col1,
st u32 in_row2, const u32 in_col2); const uword in_row2, const uword in_col2);
inline const subview<eT> submat(const u32 in_row1, const u32 in_col1, con inline const subview<eT> submat(const uword in_row1, const uword in_col1,
st u32 in_row2, const u32 in_col2) const; const uword in_row2, const uword in_col2) const;
inline subview<eT> submat (const span& row_span, const span & col_span); inline subview<eT> submat (const span& row_span, const span & col_span);
inline const subview<eT> submat (const span& row_span, const span & col_span) const; inline const subview<eT> submat (const span& row_span, const span & col_span) const;
inline subview<eT> operator()(const span& row_span, const span & col_span); inline subview<eT> operator()(const span& row_span, const span & col_span);
inline const subview<eT> operator()(const span& row_span, const span & col_span) const; inline const subview<eT> operator()(const span& row_span, const span & col_span) const;
inline diagview<eT> diag(const s32 in_id = 0); inline diagview<eT> diag(const sword in_id = 0);
inline const diagview<eT> diag(const s32 in_id = 0) const; inline const diagview<eT> diag(const sword in_id = 0) const;
inline void swap_rows(const u32 in_row1, const u32 in_row2); inline void swap_rows(const uword in_row1, const uword in_row2);
inline void swap_cols(const u32 in_col1, const u32 in_col2); inline void swap_cols(const uword in_col1, const uword in_col2);
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_trans(const std::string extra_text = "") const;
inline void print_trans(std::ostream& user_stream, const std::string extr
a_text = "") const;
inline void raw_print(const std::string extra_text = "") const;
inline void raw_print(std::ostream& user_stream, const std::string extra_
text = "") const;
inline void raw_print_trans(const std::string extra_text = "") const;
inline void raw_print_trans(std::ostream& user_stream, const std::string
extra_text = "") const;
// // primitive forward iterator // // primitive forward iterator
// class iter // class iter
// { // {
// public: // public:
// //
// inline iter(const subview<eT>& in_M); // inline iter(const subview<eT>& in_M);
// //
// arma_inline eT operator* () const; // arma_inline eT operator* () const;
// //
// inline void operator++(); // inline void operator++();
// inline void operator++(int); // inline void operator++(int);
// //
// //
// private: // private:
// //
// arma_aligned const eT* mem; // arma_aligned const eT* mem;
// //
// arma_aligned u32 n_rows; // arma_aligned uword n_rows;
// //
// arma_aligned u32 row_start; // arma_aligned uword row_start;
// arma_aligned u32 row_end_p1; // arma_aligned uword row_end_p1;
// //
// arma_aligned u32 row; // arma_aligned uword row;
// arma_aligned u32 col; // arma_aligned uword col;
// arma_aligned u32 i; // arma_aligned uword i;
// }; // };
private: private:
friend class Mat<eT>; friend class Mat<eT>;
subview(); subview();
}; };
template<typename eT> template<typename eT>
class subview_col : public subview<eT> class subview_col : public subview<eT>
skipping to change at line 190 skipping to change at line 178
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline void operator= (const subview<eT>& x); inline void operator= (const subview<eT>& x);
inline void operator= (const subview_col& x); inline void operator= (const subview_col& x);
template<typename T1> template<typename T1>
inline void operator= (const Base<eT,T1>& x); inline void operator= (const Base<eT,T1>& x);
inline subview_col<eT> rows(const u32 in_row1, const u32 in_row2); inline subview_col<eT> rows(const uword in_row1, const uword in_row
inline const subview_col<eT> rows(const u32 in_row1, const u32 in_row2) c 2);
onst; inline const subview_col<eT> rows(const uword in_row1, const uword in_row
2) const;
inline subview_col<eT> subvec(const u32 in_row1, const u32 in_row2) inline subview_col<eT> subvec(const uword in_row1, const uword in_r
; ow2);
inline const subview_col<eT> subvec(const u32 in_row1, const u32 in_row2) inline const subview_col<eT> subvec(const uword in_row1, const uword in_r
const; ow2) const;
protected: protected:
inline subview_col(const Mat<eT>& in_m, const u32 in_col); inline subview_col(const Mat<eT>& in_m, const uword in_col);
inline subview_col( Mat<eT>& in_m, const u32 in_col); inline subview_col( Mat<eT>& in_m, const uword in_col);
inline subview_col(const Mat<eT>& in_m, const u32 in_col, const u32 in_ro inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword i
w1, const u32 in_n_rows); n_row1, const uword in_n_rows);
inline subview_col( Mat<eT>& in_m, const u32 in_col, const u32 in_ro inline subview_col( Mat<eT>& in_m, const uword in_col, const uword i
w1, const u32 in_n_rows); n_row1, const uword in_n_rows);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Col<eT>; friend class Col<eT>;
friend class subview<eT>; friend class subview<eT>;
subview_col(); subview_col();
}; };
skipping to change at line 227 skipping to change at line 215
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline void operator= (const subview<eT>& x); inline void operator= (const subview<eT>& x);
inline void operator= (const subview_row& x); inline void operator= (const subview_row& x);
template<typename T1> template<typename T1>
inline void operator= (const Base<eT,T1>& x); inline void operator= (const Base<eT,T1>& x);
inline subview_row<eT> cols(const u32 in_col1, const u32 in_col2); inline subview_row<eT> cols(const uword in_col1, const uword in_col
inline const subview_row<eT> cols(const u32 in_col1, const u32 in_col2) c 2);
onst; inline const subview_row<eT> cols(const uword in_col1, const uword in_col
2) const;
inline subview_row<eT> subvec(const u32 in_col1, const u32 in_col2) inline subview_row<eT> subvec(const uword in_col1, const uword in_c
; ol2);
inline const subview_row<eT> subvec(const u32 in_col1, const u32 in_col2) inline const subview_row<eT> subvec(const uword in_col1, const uword in_c
const; ol2) const;
protected: protected:
inline subview_row(const Mat<eT>& in_m, const u32 in_row); inline subview_row(const Mat<eT>& in_m, const uword in_row);
inline subview_row( Mat<eT>& in_m, const u32 in_row); inline subview_row( Mat<eT>& in_m, const uword in_row);
inline subview_row(const Mat<eT>& in_m, const u32 in_row, const u32 in_co inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword i
l1, const u32 in_n_cols); n_col1, const uword in_n_cols);
inline subview_row( Mat<eT>& in_m, const u32 in_row, const u32 in_co inline subview_row( Mat<eT>& in_m, const uword in_row, const uword i
l1, const u32 in_n_cols); n_col1, const uword in_n_cols);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Row<eT>; friend class Row<eT>;
friend class subview<eT>; friend class subview<eT>;
subview_row(); subview_row();
}; };
 End of changes. 29 change blocks. 
95 lines changed or deleted 81 lines changed or added


 subview_cube_bones.hpp   subview_cube_bones.hpp 
skipping to change at line 29 skipping to change at line 29
class subview_cube : public BaseCube<eT, subview_cube<eT> > class subview_cube : public BaseCube<eT, subview_cube<eT> >
{ {
public: arma_aligned const Cube<eT>& m; public: arma_aligned const Cube<eT>& m;
protected: arma_aligned Cube<eT>* m_ptr; protected: arma_aligned Cube<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
const u32 aux_row1; const uword aux_row1;
const u32 aux_col1; const uword aux_col1;
const u32 aux_slice1; const uword aux_slice1;
const u32 n_rows; const uword n_rows;
const u32 n_cols; const uword n_cols;
const u32 n_elem_slice; const uword n_elem_slice;
const u32 n_slices; const uword n_slices;
const u32 n_elem; const uword n_elem;
protected: protected:
arma_inline subview_cube(const Cube<eT>& in_m, const u32 in_row1, const u arma_inline subview_cube(const Cube<eT>& in_m, const uword in_row1, const
32 in_col1, const u32 in_slice1, const u32 in_n_rows, const u32 in_n_cols, uword in_col1, const uword in_slice1, const uword in_n_rows, const uword i
const u32 in_n_slices); n_n_cols, const uword in_n_slices);
arma_inline subview_cube( Cube<eT>& in_m, const u32 in_row1, const u arma_inline subview_cube( Cube<eT>& in_m, const uword in_row1, const
32 in_col1, const u32 in_slice1, const u32 in_n_rows, const u32 in_n_cols, uword in_col1, const uword in_slice1, const uword in_n_rows, const uword i
const u32 in_n_slices); n_n_cols, const uword in_n_slices);
public: public:
inline ~subview_cube(); inline ~subview_cube();
inline void operator+= (const eT val); inline void operator+= (const eT val);
inline void operator-= (const eT val); inline void operator-= (const eT val);
inline void operator*= (const eT val); inline void operator*= (const eT val);
inline void operator/= (const eT val); inline void operator/= (const eT val);
skipping to change at line 88 skipping to change at line 88
inline static void extract(Mat<eT>& out, const subview_cube& in); inline static void extract(Mat<eT>& out, const subview_cube& in);
inline static void plus_inplace(Mat<eT>& out, const subview_cube& in); inline static void plus_inplace(Mat<eT>& out, const subview_cube& in);
inline static void minus_inplace(Mat<eT>& out, const subview_cube& in); inline static void minus_inplace(Mat<eT>& out, const subview_cube& in);
inline static void schur_inplace(Mat<eT>& out, const subview_cube& in); inline static void schur_inplace(Mat<eT>& out, const subview_cube& in);
inline static void div_inplace(Mat<eT>& out, const subview_cube& in); inline static void div_inplace(Mat<eT>& out, const subview_cube& in);
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void ones(); inline void ones();
inline eT& operator[](const u32 i); inline eT& operator[](const uword i);
inline eT operator[](const u32 i) const; inline eT operator[](const uword i) const;
inline eT& operator()(const u32 i); inline eT& operator()(const uword i);
inline eT operator()(const u32 i) const; inline eT operator()(const uword i) const;
arma_inline eT& operator()(const u32 in_row, const u32 in_col, const u32 arma_inline eT& operator()(const uword in_row, const uword in_col, const
in_slice); uword in_slice);
arma_inline eT operator()(const u32 in_row, const u32 in_col, const u32 arma_inline eT operator()(const uword in_row, const uword in_col, const
in_slice) const; uword in_slice) const;
arma_inline eT& at(const u32 in_row, const u32 in_col, const u32 arma_inline eT& at(const uword in_row, const uword in_col, const
in_slice); uword in_slice);
arma_inline eT at(const u32 in_row, const u32 in_col, const u32 arma_inline eT at(const uword in_row, const uword in_col, const
in_slice) const; uword in_slice) const;
arma_inline eT* slice_colptr(const u32 in_slice, const u32 in_col); arma_inline eT* slice_colptr(const uword in_slice, const uword in_c
arma_inline const eT* slice_colptr(const u32 in_slice, const u32 in_col) ol);
const; arma_inline const eT* slice_colptr(const uword in_slice, const uword in_c
ol) const;
inline bool check_overlap(const subview_cube& x) const; inline bool check_overlap(const subview_cube& x) const;
inline bool check_overlap(const Mat<eT>& x) const; inline bool check_overlap(const Mat<eT>& x) const;
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Cube<eT>; friend class Cube<eT>;
subview_cube(); subview_cube();
 End of changes. 7 change blocks. 
30 lines changed or deleted 31 lines changed or added


 subview_cube_meat.hpp   subview_cube_meat.hpp 
skipping to change at line 28 skipping to change at line 28
subview_cube<eT>::~subview_cube() subview_cube<eT>::~subview_cube()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_cube<eT>::subview_cube subview_cube<eT>::subview_cube
( (
const Cube<eT>& in_m, const Cube<eT>& in_m,
const u32 in_row1, const uword in_row1,
const u32 in_col1, const uword in_col1,
const u32 in_slice1, const uword in_slice1,
const u32 in_n_rows, const uword in_n_rows,
const u32 in_n_cols, const uword in_n_cols,
const u32 in_n_slices const uword in_n_slices
) )
: m (in_m) : m (in_m)
, m_ptr (0) , m_ptr (0)
, aux_row1 (in_row1) , aux_row1 (in_row1)
, aux_col1 (in_col1) , aux_col1 (in_col1)
, aux_slice1 (in_slice1) , aux_slice1 (in_slice1)
, n_rows (in_n_rows) , n_rows (in_n_rows)
, n_cols (in_n_cols) , n_cols (in_n_cols)
, n_elem_slice(in_n_rows * in_n_cols) , n_elem_slice(in_n_rows * in_n_cols)
, n_slices (in_n_slices) , n_slices (in_n_slices)
, n_elem (n_elem_slice * in_n_slices) , n_elem (n_elem_slice * in_n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_cube<eT>::subview_cube subview_cube<eT>::subview_cube
( (
Cube<eT>& in_m, Cube<eT>& in_m,
const u32 in_row1, const uword in_row1,
const u32 in_col1, const uword in_col1,
const u32 in_slice1, const uword in_slice1,
const u32 in_n_rows, const uword in_n_rows,
const u32 in_n_cols, const uword in_n_cols,
const u32 in_n_slices const uword in_n_slices
) )
: m (in_m) : m (in_m)
, m_ptr (&in_m) , m_ptr (&in_m)
, aux_row1 (in_row1) , aux_row1 (in_row1)
, aux_col1 (in_col1) , aux_col1 (in_col1)
, aux_slice1 (in_slice1) , aux_slice1 (in_slice1)
, n_rows (in_n_rows) , n_rows (in_n_rows)
, n_cols (in_n_cols) , n_cols (in_n_cols)
, n_elem_slice(in_n_rows * in_n_cols) , n_elem_slice(in_n_rows * in_n_cols)
, n_slices (in_n_slices) , n_slices (in_n_slices)
skipping to change at line 82 skipping to change at line 82
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator+= (const eT val) subview_cube<eT>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice) for(uword slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < local_n_cols; ++col) for(uword col = 0; col < local_n_cols; ++col)
{ {
arrayops::inplace_plus( slice_colptr(slice,col), val, local_n_rows ); arrayops::inplace_plus( slice_colptr(slice,col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator-= (const eT val) subview_cube<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice) for(uword slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < local_n_cols; ++col) for(uword col = 0; col < local_n_cols; ++col)
{ {
arrayops::inplace_minus( slice_colptr(slice,col), val, local_n_rows ) ; arrayops::inplace_minus( slice_colptr(slice,col), val, local_n_rows ) ;
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator*= (const eT val) subview_cube<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice) for(uword slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < local_n_cols; ++col) for(uword col = 0; col < local_n_cols; ++col)
{ {
arrayops::inplace_mul( slice_colptr(slice,col), val, local_n_rows ); arrayops::inplace_mul( slice_colptr(slice,col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator/= (const eT val) subview_cube<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice) for(uword slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < local_n_cols; ++col) for(uword col = 0; col < local_n_cols; ++col)
{ {
arrayops::inplace_div( slice_colptr(slice,col), val, local_n_rows ); arrayops::inplace_div( slice_colptr(slice,col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 170 skipping to change at line 170
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "copy into subcube"); arma_debug_assert_same_size(t, x, "copy into subcube");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows ); arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 198 skipping to change at line 198
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "addition"); arma_debug_assert_same_size(t, x, "addition");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli ce,col), t_n_rows ); arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli ce,col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 226 skipping to change at line 226
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "subtraction"); arma_debug_assert_same_size(t, x, "subtraction");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl ice,col), t_n_rows ); arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl ice,col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 254 skipping to change at line 254
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise multiplication"); arma_debug_assert_same_size(t, x, "element-wise multiplication");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows ); arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 282 skipping to change at line 282
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise division"); arma_debug_assert_same_size(t, x, "element-wise division");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows ); arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows );
} }
} }
} }
//! x.subcube(...) = y.subcube(...) //! x.subcube(...) = y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
skipping to change at line 313 skipping to change at line 313
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "copy into subcube"); arma_debug_assert_same_size(t, x, "copy into subcube");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows ); arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
skipping to change at line 350 skipping to change at line 350
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "addition"); arma_debug_assert_same_size(t, x, "addition");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli ce,col), t_n_rows ); arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli ce,col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
skipping to change at line 387 skipping to change at line 387
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "subtraction"); arma_debug_assert_same_size(t, x, "subtraction");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl ice,col), t_n_rows ); arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl ice,col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
skipping to change at line 424 skipping to change at line 424
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise multiplication"); arma_debug_assert_same_size(t, x, "element-wise multiplication");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows ); arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
skipping to change at line 461 skipping to change at line 461
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_i n.n_cols, x_in.n_slices) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise division"); arma_debug_assert_same_size(t, x, "element-wise division");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice) for(uword slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows ); arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic e,col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
skipping to change at line 494 skipping to change at line 494
void void
subview_cube<eT>::operator= (const Base<eT,T1>& in) subview_cube<eT>::operator= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) ) if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
{ {
// interpret the matrix as a cube with one slice // interpret the matrix as a cube with one slice
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::copy( t.slice_colptr(0, col), x.colptr(col), t_n_rows ); arrayops::copy( t.slice_colptr(0, col), x.colptr(col), t_n_rows );
} }
} }
else else
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
// interpret the matrix as a cube with one column // interpret the matrix as a cube with one column
// and with the number of slices equal to the number of columns in the matrix // and with the number of slices equal to the number of columns in the matrix
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::copy( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::copy( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) ) if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) )
{ {
// interpret the matrix as a cube with one row // interpret the matrix as a cube with one row
// and with the number of slices equal to the number of rows in the mat rix // and with the number of slices equal to the number of rows in the mat rix
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = *(t.m_ptr);
const u32 t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const u32 t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const u32 t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(u32 col=0; col < t_n_cols; ++col) for(uword col=0; col < t_n_cols; ++col)
{ {
const eT* x_colptr = x.colptr(col); const eT* x_colptr = x.colptr(col);
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) = x_colptr[i]; Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) = x_colptr[i];
} }
} }
} }
else else
{ {
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
arma_stop( arma_incompat_size_string(t, x, "copy into subcube") ); arma_stop( arma_incompat_size_string(t, x, "copy into subcube") );
skipping to change at line 565 skipping to change at line 565
void void
subview_cube<eT>::operator+= (const Base<eT,T1>& in) subview_cube<eT>::operator+= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) ) if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.slice_colptr(0, col), x.colptr(col), t_n_ro ws ); arrayops::inplace_plus( t.slice_colptr(0, col), x.colptr(col), t_n_ro ws );
} }
} }
else else
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_plus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ) ; arrayops::inplace_plus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ) ;
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) ) if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = *(t.m_ptr);
const u32 t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const u32 t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const u32 t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(u32 col=0; col < t_n_cols; ++col) for(uword col=0; col < t_n_cols; ++col)
{ {
const eT* x_colptr = x.colptr(col); const eT* x_colptr = x.colptr(col);
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) += x_colptr[i] ; Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) += x_colptr[i] ;
} }
} }
} }
else else
{ {
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
arma_stop( arma_incompat_size_string(t, x, "addition") ); arma_stop( arma_incompat_size_string(t, x, "addition") );
skipping to change at line 628 skipping to change at line 628
void void
subview_cube<eT>::operator-= (const Base<eT,T1>& in) subview_cube<eT>::operator-= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) ) if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.slice_colptr(0, col), x.colptr(col), t_n_r ows ); arrayops::inplace_minus( t.slice_colptr(0, col), x.colptr(col), t_n_r ows );
} }
} }
else else
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_minus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::inplace_minus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) ) if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = *(t.m_ptr);
const u32 t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const u32 t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const u32 t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(u32 col=0; col < t_n_cols; ++col) for(uword col=0; col < t_n_cols; ++col)
{ {
const eT* x_colptr = x.colptr(col); const eT* x_colptr = x.colptr(col);
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) -= x_colptr[i] ; Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) -= x_colptr[i] ;
} }
} }
} }
else else
{ {
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
arma_stop( arma_incompat_size_string(t, x, "subtraction") ); arma_stop( arma_incompat_size_string(t, x, "subtraction") );
skipping to change at line 691 skipping to change at line 691
void void
subview_cube<eT>::operator%= (const Base<eT,T1>& in) subview_cube<eT>::operator%= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) ) if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.slice_colptr(0, col), x.colptr(col), t_n_row s ); arrayops::inplace_mul( t.slice_colptr(0, col), x.colptr(col), t_n_row s );
} }
} }
else else
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_mul( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::inplace_mul( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) ) if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = *(t.m_ptr);
const u32 t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const u32 t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const u32 t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(u32 col=0; col < t_n_cols; ++col) for(uword col=0; col < t_n_cols; ++col)
{ {
const eT* x_colptr = x.colptr(col); const eT* x_colptr = x.colptr(col);
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) *= x_colptr[i] ; Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) *= x_colptr[i] ;
} }
} }
} }
else else
{ {
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
arma_stop( arma_incompat_size_string(t, x, "element-wise multiplicati on") ); arma_stop( arma_incompat_size_string(t, x, "element-wise multiplicati on") );
skipping to change at line 754 skipping to change at line 754
void void
subview_cube<eT>::operator/= (const Base<eT,T1>& in) subview_cube<eT>::operator/= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices; const uword t_n_slices = t.n_slices;
const u32 x_n_rows = x.n_rows; const uword x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const uword x_n_cols = x.n_cols;
if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) ) if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
{ {
for(u32 col = 0; col < t_n_cols; ++col) for(uword col = 0; col < t_n_cols; ++col)
{ {
arrayops::inplace_div( t.slice_colptr(0, col), x.colptr(col), t_n_row s ); arrayops::inplace_div( t.slice_colptr(0, col), x.colptr(col), t_n_row s );
} }
} }
else else
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_div( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::inplace_div( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) ) if( (t_n_rows == 1) && (t_n_cols == x_n_cols) && (t_n_slices == x_n_rows) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = *(t.m_ptr);
const u32 t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const u32 t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const u32 t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(u32 col=0; col < t_n_cols; ++col) for(uword col=0; col < t_n_cols; ++col)
{ {
const eT* x_colptr = x.colptr(col); const eT* x_colptr = x.colptr(col);
for(u32 i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) /= x_colptr[i] ; Q.at(t_aux_row1, t_aux_col1 + col, t_aux_slice1 + i) /= x_colptr[i] ;
} }
} }
} }
else else
{ {
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
arma_stop( arma_incompat_size_string(t, x, "element-wise division") ) ; arma_stop( arma_incompat_size_string(t, x, "element-wise division") ) ;
skipping to change at line 811 skipping to change at line 811
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::fill(const eT val) subview_cube<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_slices = n_slices; const uword local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice) for(uword slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < local_n_cols; ++col) for(uword col = 0; col < local_n_cols; ++col)
{ {
arrayops::inplace_set( slice_colptr(slice,col), val, local_n_rows ); arrayops::inplace_set( slice_colptr(slice,col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
skipping to change at line 848 skipping to change at line 848
subview_cube<eT>::ones() subview_cube<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(1)); fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_cube<eT>::operator[](const u32 i) subview_cube<eT>::operator[](const uword i)
{ {
const u32 in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const u32 j = i - offset; const uword j = i - offset;
const u32 in_col = j / n_rows; const uword in_col = j / n_rows;
const u32 in_row = j % n_rows; const uword in_row = j % n_rows;
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_cube<eT>::operator[](const u32 i) const subview_cube<eT>::operator[](const uword i) const
{ {
const u32 in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const u32 j = i - offset; const uword j = i - offset;
const u32 in_col = j / n_rows; const uword in_col = j / n_rows;
const u32 in_row = j % n_rows; const uword in_row = j % n_rows;
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_cube<eT>::operator()(const u32 i) subview_cube<eT>::operator()(const uword i)
{ {
arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
const u32 in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const u32 j = i - offset; const uword j = i - offset;
const u32 in_col = j / n_rows; const uword in_col = j / n_rows;
const u32 in_row = j % n_rows; const uword in_row = j % n_rows;
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_cube<eT>::operator()(const u32 i) const subview_cube<eT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
const u32 in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const u32 j = i - offset; const uword j = i - offset;
const u32 in_col = j / n_rows; const uword in_col = j / n_rows;
const u32 in_row = j % n_rows; const uword in_row = j % n_rows;
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice) subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice)
{ {
arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds"); arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice) const subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice) const
{ {
arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds"); arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice ) subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in _slice)
{ {
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice ) const subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in _slice) const
{ {
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col) subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col)
{ {
return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]); return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col) const subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col) co nst
{ {
return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_co l1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_co l1)*m.n_rows + aux_row1 ];
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview_cube<eT>::check_overlap(const subview_cube<eT>& x) const subview_cube<eT>::check_overlap(const subview_cube<eT>& x) const
{ {
const subview_cube<eT>& t = *this; const subview_cube<eT>& t = *this;
skipping to change at line 988 skipping to change at line 988
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (t.n_elem == 0) || (x.n_elem == 0) )
{ {
return false; return false;
} }
else else
{ {
const u32 t_row_start = t.aux_row1; const uword t_row_start = t.aux_row1;
const u32 t_row_end_p1 = t_row_start + t.n_rows; const uword t_row_end_p1 = t_row_start + t.n_rows;
const u32 t_col_start = t.aux_col1; const uword t_col_start = t.aux_col1;
const u32 t_col_end_p1 = t_col_start + t.n_cols; const uword t_col_end_p1 = t_col_start + t.n_cols;
const u32 t_slice_start = t.aux_slice1; const uword t_slice_start = t.aux_slice1;
const u32 t_slice_end_p1 = t_slice_start + t.n_slices; const uword t_slice_end_p1 = t_slice_start + t.n_slices;
const u32 x_row_start = x.aux_row1; const uword x_row_start = x.aux_row1;
const u32 x_row_end_p1 = x_row_start + x.n_rows; const uword x_row_end_p1 = x_row_start + x.n_rows;
const u32 x_col_start = x.aux_col1; const uword x_col_start = x.aux_col1;
const u32 x_col_end_p1 = x_col_start + x.n_cols; const uword x_col_end_p1 = x_col_start + x.n_cols;
const u32 x_slice_start = x.aux_slice1; const uword x_slice_start = x.aux_slice1;
const u32 x_slice_end_p1 = x_slice_start + x.n_slices; const uword x_slice_end_p1 = x_slice_start + x.n_slices;
const bool outside_rows = ( (x_row_start >= t_row_end_p1 ) || (t _row_start >= x_row_end_p1 ) ); const bool outside_rows = ( (x_row_start >= t_row_end_p1 ) || (t _row_start >= x_row_end_p1 ) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1 ) || (t _col_start >= x_col_end_p1 ) ); const bool outside_cols = ( (x_col_start >= t_col_end_p1 ) || (t _col_start >= x_col_end_p1 ) );
const bool outside_slices = ( (x_slice_start >= t_slice_end_p1) || (t _slice_start >= x_slice_end_p1) ); const bool outside_slices = ( (x_slice_start >= t_slice_end_p1) || (t _slice_start >= x_slice_end_p1) );
return ( (outside_rows == false) && (outside_cols == false) && (outsi de_slices == false) ); return ( (outside_rows == false) && (outside_cols == false) && (outsi de_slices == false) );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview_cube<eT>::check_overlap(const Mat<eT>& x) const subview_cube<eT>::check_overlap(const Mat<eT>& x) const
{ {
const subview_cube<eT>& t = *this; const subview_cube<eT>& t = *this;
const u32 t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
const u32 t_aux_slice2_plus_1 = t_aux_slice1 + t.n_slices; const uword t_aux_slice2_plus_1 = t_aux_slice1 + t.n_slices;
for(u32 slice = t_aux_slice1; slice < t_aux_slice2_plus_1; ++slice) for(uword slice = t_aux_slice1; slice < t_aux_slice2_plus_1; ++slice)
{ {
const Mat<eT>& y = *(t.m.mat_ptrs[slice]); const Mat<eT>& y = *(t.m.mat_ptrs[slice]);
if( x.memptr() == y.memptr() ) if( x.memptr() == y.memptr() )
{ {
return true; return true;
} }
} }
return false; return false;
} }
//! cube X = Y.subcube(...) //! cube X = Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::extract(Cube<eT>& actual_out, const subview_cube<eT>& in) subview_cube<eT>::extract(Cube<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// // NOTE: we're assuming that the cube has already been set to the correct
const bool alias = (&actual_out == &in.m); size and there is no aliasing;
// size setting and alias checking is done by either the Cube contructor
or operator=()
Cube<eT>* tmp = (alias) ? new Cube<eT> : 0; const uword n_rows = in.n_rows;
Cube<eT>& out = (alias) ? (*tmp) : actual_out; const uword n_cols = in.n_cols;
const uword n_slices = in.n_slices;
//
const u32 n_rows = in.n_rows;
const u32 n_cols = in.n_cols;
const u32 n_slices = in.n_slices;
out.set_size(n_rows, n_cols, n_slices);
arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_sl ices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n _cols % in.m.n_slices); arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_sl ices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n _cols % in.m.n_slices);
for(u32 slice = 0; slice < n_slices; ++slice) for(uword slice = 0; slice < n_slices; ++slice)
{ {
for(u32 col = 0; col < n_cols; ++col) for(uword col = 0; col < n_cols; ++col)
{ {
arrayops::copy( out.slice_colptr(slice,col), in.slice_colptr(slice,co l), n_rows ); arrayops::copy( out.slice_colptr(slice,col), in.slice_colptr(slice,co l), n_rows );
} }
} }
if(alias)
{
actual_out = out;
delete tmp;
}
} }
//! cube X += Y.subcube(...) //! cube X += Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "addition"); arma_debug_assert_same_size(out, in, "addition");
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const u32 n_slices = out.n_slices; const uword n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(uword slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(uword col = 0; col<n_cols; ++col)
{ {
arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr( slice,col), n_rows ); arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr( slice,col), n_rows );
} }
} }
} }
//! cube X -= Y.subcube(...) //! cube X -= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "subtraction"); arma_debug_assert_same_size(out, in, "subtraction");
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const u32 n_slices = out.n_slices; const uword n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(uword slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(uword col = 0; col<n_cols; ++col)
{ {
arrayops::inplace_minus( out.slice_colptr(slice,col), in.slice_colptr (slice,col), n_rows ); arrayops::inplace_minus( out.slice_colptr(slice,col), in.slice_colptr (slice,col), n_rows );
} }
} }
} }
//! cube X %= Y.subcube(...) //! cube X %= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise multiplication"); arma_debug_assert_same_size(out, in, "element-wise multiplication");
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const u32 n_slices = out.n_slices; const uword n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(uword slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(uword col = 0; col<n_cols; ++col)
{ {
arrayops::inplace_mul( out.slice_colptr(slice,col), in.slice_colptr(s lice,col), n_rows ); arrayops::inplace_mul( out.slice_colptr(slice,col), in.slice_colptr(s lice,col), n_rows );
} }
} }
} }
//! cube X /= Y.subcube(...) //! cube X /= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise division"); arma_debug_assert_same_size(out, in, "element-wise division");
const u32 n_rows = out.n_rows; const uword n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const uword n_cols = out.n_cols;
const u32 n_slices = out.n_slices; const uword n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(uword slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(uword col = 0; col<n_cols; ++col)
{ {
arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(s lice,col), n_rows ); arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(s lice,col), n_rows );
} }
} }
} }
//! mat X = Y.subcube(...) //! mat X = Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false); arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ) ; arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ) ;
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if(in_n_cols == 1) if(in_n_cols == 1)
{ {
out.set_size(in_n_rows, in_n_slices); out.set_size(in_n_rows, in_n_slices);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ) ; arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ) ;
} }
} }
else else
if(in_n_rows == 1) if(in_n_rows == 1)
{ {
out.set_size(in_n_slices, in_n_cols); out.set_size(in_n_slices, in_n_cols);
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] = Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sli ce1 + i); out_colptr[i] = Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sli ce1 + i);
} }
} }
} }
} }
else else
{ {
out.set_size(in_n_slices); out.set_size(in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] = Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); out_mem[i] = Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
} }
} }
} }
} }
//! mat X += Y.subcube(...) //! mat X += Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_cube_as_mat(out, in, "addition", true); arma_debug_assert_cube_as_mat(out, in, "addition", true);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_ n_rows ); arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_ n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_plus( out.colptr(i), in.slice_colptr(i, 0), in_ n_rows ); arrayops::inplace_plus( out.colptr(i), in.slice_colptr(i, 0), in_ n_rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] += Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i); out_colptr[i] += Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] += Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); out_mem[i] += Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
} }
} }
} }
} }
//! mat X -= Y.subcube(...) //! mat X -= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_cube_as_mat(out, in, "subtraction", true); arma_debug_assert_cube_as_mat(out, in, "subtraction", true);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in _n_rows ); arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in _n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_minus( out.colptr(i), in.slice_colptr(i, 0), in _n_rows ); arrayops::inplace_minus( out.colptr(i), in.slice_colptr(i, 0), in _n_rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] -= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i); out_colptr[i] -= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] -= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); out_mem[i] -= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
} }
} }
} }
} }
//! mat X %= Y.subcube(...) //! mat X %= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_cube_as_mat(out, in, "element-wise multiplication", tru e); arma_debug_assert_cube_as_mat(out, in, "element-wise multiplication", tru e);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n _rows ); arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n _rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_mul( out.colptr(i), in.slice_colptr(i, 0), in_n _rows ); arrayops::inplace_mul( out.colptr(i), in.slice_colptr(i, 0), in_n _rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] *= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i); out_colptr[i] *= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] *= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); out_mem[i] *= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
} }
} }
} }
} }
//! mat X /= Y.subcube(...) //! mat X /= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_cube_as_mat(out, in, "element-wise division", true); arma_debug_assert_cube_as_mat(out, in, "element-wise division", true);
const u32 in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const u32 in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const u32 in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const u32 out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const u32 out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n _rows ); arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n _rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n _rows ); arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n _rows );
} }
} }
else else
if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
{ {
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 col=0; col < in_n_cols; ++col) for(uword col=0; col < in_n_cols; ++col)
{ {
eT* out_colptr = out.colptr(col); eT* out_colptr = out.colptr(col);
for(u32 i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
out_colptr[i] /= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i); out_colptr[i] /= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_sl ice1 + i);
} }
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Cube<eT>& Q = in.m; const Cube<eT>& Q = in.m;
const u32 in_aux_row1 = in.aux_row1; const uword in_aux_row1 = in.aux_row1;
const u32 in_aux_col1 = in.aux_col1; const uword in_aux_col1 = in.aux_col1;
const u32 in_aux_slice1 = in.aux_slice1; const uword in_aux_slice1 = in.aux_slice1;
for(u32 i=0; i<in_n_slices; ++i) for(uword i=0; i<in_n_slices; ++i)
{ {
out_mem[i] /= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); out_mem[i] /= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
} }
} }
} }
} }
//! @} //! @}
 End of changes. 175 change blocks. 
329 lines changed or deleted 317 lines changed or added


 subview_elem1_bones.hpp   subview_elem1_bones.hpp 
skipping to change at line 27 skipping to change at line 27
class subview_elem1 : public Base<eT, subview_elem1<eT,T1> > class subview_elem1 : public Base<eT, subview_elem1<eT,T1> >
{ {
public: arma_aligned const Mat<eT>& m; public: arma_aligned const Mat<eT>& m;
protected: arma_aligned Mat<eT>* m_ptr; protected: arma_aligned Mat<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
arma_aligned const Base<u32,T1>& a; arma_aligned const Base<uword,T1>& a;
protected: protected:
arma_inline subview_elem1(const Mat<eT>& in_m, const Base<u32,T1>& in_a); arma_inline subview_elem1(const Mat<eT>& in_m, const Base<uword,T1>& in_a
arma_inline subview_elem1( Mat<eT>& in_m, const Base<u32,T1>& in_a); );
arma_inline subview_elem1( Mat<eT>& in_m, const Base<uword,T1>& in_a
);
public: public:
inline ~subview_elem1(); inline ~subview_elem1();
template<typename op_type> inline void inplace_op(const eT val); template<typename op_type> inline void inplace_op(const eT val);
template<typename op_type, typename T2> inline void inplace_op(const subv iew_elem1<eT,T2>& x ); template<typename op_type, typename T2> inline void inplace_op(const subv iew_elem1<eT,T2>& x );
template<typename op_type, typename T2> inline void inplace_op(const Base <eT,T2>& x ); template<typename op_type, typename T2> inline void inplace_op(const Base <eT,T2>& x );
inline void fill(const eT val); inline void fill(const eT val);
 End of changes. 2 change blocks. 
3 lines changed or deleted 5 lines changed or added


 subview_elem1_meat.hpp   subview_elem1_meat.hpp 
skipping to change at line 25 skipping to change at line 25
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
subview_elem1<eT,T1>::~subview_elem1() subview_elem1<eT,T1>::~subview_elem1()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline arma_inline
subview_elem1<eT,T1>::subview_elem1(const Mat<eT>& in_m, const Base<u32,T1> & in_a) subview_elem1<eT,T1>::subview_elem1(const Mat<eT>& in_m, const Base<uword,T 1>& in_a)
: m(in_m) : m(in_m)
, m_ptr(0) , m_ptr(0)
, a(in_a) , a(in_a)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline arma_inline
subview_elem1<eT,T1>::subview_elem1(Mat<eT>& in_m, const Base<u32,T1>& in_a ) subview_elem1<eT,T1>::subview_elem1(Mat<eT>& in_m, const Base<uword,T1>& in _a)
: m(in_m) : m(in_m)
, m_ptr(&in_m) , m_ptr(&in_m)
, a(in_a) , a(in_a)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type> template<typename op_type>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const eT val) subview_elem1<eT,T1>::inplace_op(const eT val)
{ {
Mat<eT>& m_local = *m_ptr; Mat<eT>& m_local = *m_ptr;
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = tmp.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const uword* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const uword aa_n_elem = aa.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
const u32 jj = aa_mem[j]; const uword jj = aa_mem[j];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; m_mem[jj] = val; } if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; m_mem[jj] = val; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; m_mem[jj] += val; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; m_mem[jj] += val; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; m_mem[jj] -= val; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; m_mem[jj] -= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; m_mem[jj] *= val; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; m_mem[jj] *= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; m_mem[jj] /= val; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; m_mem[jj] /= val; }
} }
if(i < aa_n_elem) if(i < aa_n_elem)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; } if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; }
} }
} }
skipping to change at line 132 skipping to change at line 132
const umat& t_aa = t_tmp.M; const umat& t_aa = t_tmp.M;
const umat& x_aa = x_tmp.M; const umat& x_aa = x_tmp.M;
arma_debug_check arma_debug_check
( (
( (t_aa.is_vec() == false) || (x_aa.is_vec() == false) ), ( (t_aa.is_vec() == false) || (x_aa.is_vec() == false) ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const u32* t_aa_mem = t_aa.memptr(); const uword* t_aa_mem = t_aa.memptr();
const u32* x_aa_mem = x_aa.memptr(); const uword* x_aa_mem = x_aa.memptr();
const u32 t_aa_n_elem = t_aa.n_elem; const uword t_aa_n_elem = t_aa.n_elem;
arma_debug_check( (t_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mism atch" ); arma_debug_check( (t_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mism atch" );
eT* t_m_mem = t_m_local.memptr(); eT* t_m_mem = t_m_local.memptr();
const u32 t_m_n_elem = t_m_local.n_elem; const uword t_m_n_elem = t_m_local.n_elem;
const eT* x_m_mem = x_m_local.memptr(); const eT* x_m_mem = x_m_local.memptr();
const u32 x_m_n_elem = x_m_local.n_elem; const uword x_m_n_elem = x_m_local.n_elem;
u32 i,j; uword i,j;
for(i=0, j=1; j<t_aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<t_aa_n_elem; i+=2, j+=2)
{ {
const u32 t_ii = t_aa_mem[i]; const uword t_ii = t_aa_mem[i];
const u32 t_jj = t_aa_mem[j]; const uword t_jj = t_aa_mem[j];
const u32 x_ii = x_aa_mem[i]; const uword x_ii = x_aa_mem[i];
const u32 x_jj = x_aa_mem[j]; const uword x_jj = x_aa_mem[j];
arma_debug_check arma_debug_check
( (
(t_ii >= t_m_n_elem) || (t_jj >= t_m_n_elem) || (x_ii >= x_m_n_elem ) || (x_jj >= x_m_n_elem), (t_ii >= t_m_n_elem) || (t_jj >= t_m_n_elem) || (x_ii >= x_m_n_elem ) || (x_jj >= x_m_n_elem),
"Mat::elem(): index out of bounds" "Mat::elem(): index out of bounds"
); );
if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { t_m_mem[t_ii] = x_m_mem[x_ii]; t_m_mem[t_jj] = x_m_mem[x_jj]; } if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { t_m_mem[t_ii] = x_m_mem[x_ii]; t_m_mem[t_jj] = x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { t_m_mem[t_ii] += x_m_mem[x_ii]; t_m_mem[t_jj] += x_m_mem[x_jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { t_m_mem[t_ii] += x_m_mem[x_ii]; t_m_mem[t_jj] += x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { t_m_mem[t_ii] -= x_m_mem[x_ii]; t_m_mem[t_jj] -= x_m_mem[x_jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { t_m_mem[t_ii] -= x_m_mem[x_ii]; t_m_mem[t_jj] -= x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { t_m_mem[t_ii] *= x_m_mem[x_ii]; t_m_mem[t_jj] *= x_m_mem[x_jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { t_m_mem[t_ii] *= x_m_mem[x_ii]; t_m_mem[t_jj] *= x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { t_m_mem[t_ii] /= x_m_mem[x_ii]; t_m_mem[t_jj] /= x_m_mem[x_jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { t_m_mem[t_ii] /= x_m_mem[x_ii]; t_m_mem[t_jj] /= x_m_mem[x_jj]; }
} }
if(i < t_aa_n_elem) if(i < t_aa_n_elem)
{ {
const u32 t_ii = t_aa_mem[i]; const uword t_ii = t_aa_mem[i];
const u32 x_ii = x_aa_mem[i]; const uword x_ii = x_aa_mem[i];
arma_debug_check arma_debug_check
( (
( (t_ii >= t_m_n_elem) || (x_ii >= x_m_n_elem) ), ( (t_ii >= t_m_n_elem) || (x_ii >= x_m_n_elem) ),
"Mat::elem(): index out of bounds" "Mat::elem(): index out of bounds"
); );
if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { t_m_mem[t_ii] = x_m_mem[x_ii]; } if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { t_m_mem[t_ii] = x_m_mem[x_ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { t_m_mem[t_ii] += x_m_mem[x_ii]; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { t_m_mem[t_ii] += x_m_mem[x_ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { t_m_mem[t_ii] -= x_m_mem[x_ii]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { t_m_mem[t_ii] -= x_m_mem[x_ii]; }
skipping to change at line 197 skipping to change at line 197
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type, typename T2> template<typename op_type, typename T2>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x) subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& m_local = *m_ptr; Mat<eT>& m_local = *m_ptr;
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = tmp.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const uword* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const uword aa_n_elem = aa.n_elem;
const Proxy<T2> P(x.get_ref()); const Proxy<T2> P(x.get_ref());
arma_debug_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size misma tch" ); arma_debug_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size misma tch" );
if(P.is_alias(m) == false) if(P.is_alias(m) == false)
{ {
typename Proxy<T2>::ea_type X = P.get_ea(); typename Proxy<T2>::ea_type X = P.get_ea();
u32 i,j; uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
const u32 jj = aa_mem[j]; const uword jj = aa_mem[j];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; m_mem[jj] = X[j]; } if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; m_mem[jj] = X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; m_mem[jj] += X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; m_mem[jj] += X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; m_mem[jj] -= X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; m_mem[jj] -= X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; m_mem[jj] *= X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; m_mem[jj] *= X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; m_mem[jj] /= X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; m_mem[jj] /= X[j]; }
} }
if(i < aa_n_elem) if(i < aa_n_elem)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" );
if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; } if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; }
} }
} }
else else
{ {
arma_extra_debug_print("subview_elem1::inplace_op(): aliasing detected" ); arma_extra_debug_print("subview_elem1::inplace_op(): aliasing detected" );
const unwrap_check<typename Proxy<T2>::stored_type> tmp(P.Q, m_local); const unwrap_check<typename Proxy<T2>::stored_type> tmp(P.Q, m_local);
const Mat<eT>& M = tmp.M; const Mat<eT>& M = tmp.M;
const eT* X = M.memptr(); const eT* X = M.memptr();
u32 i,j; uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
const u32 jj = aa_mem[j]; const uword jj = aa_mem[j];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; m_mem[jj] = X[j]; } if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; m_mem[jj] = X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; m_mem[jj] += X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; m_mem[jj] += X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; m_mem[jj] -= X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; m_mem[jj] -= X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; m_mem[jj] *= X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; m_mem[jj] *= X[j]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; m_mem[jj] /= X[j]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; m_mem[jj] /= X[j]; }
} }
if(i < aa_n_elem) if(i < aa_n_elem)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" );
if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; } if(is_same_type<op_type, op_subview_elem_equ >::value = = true) { m_mem[ii] = X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = = true) { m_mem[ii] += X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = = true) { m_mem[ii] -= X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; }
} }
} }
skipping to change at line 514 skipping to change at line 514
const unwrap_check_mixed<T1> tmp1(in.a.get_ref(), actual_out); const unwrap_check_mixed<T1> tmp1(in.a.get_ref(), actual_out);
const umat& aa = tmp1.M; const umat& aa = tmp1.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const uword* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const uword aa_n_elem = aa.n_elem;
const Mat<eT>& m_local = in.m; const Mat<eT>& m_local = in.m;
const eT* m_mem = m_local.memptr(); const eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
const bool alias = (&actual_out == &m_local); const bool alias = (&actual_out == &m_local);
arma_extra_debug_warn(alias, "subview_elem1::extract(): aliasing detected "); arma_extra_debug_warn(alias, "subview_elem1::extract(): aliasing detected ");
Mat<eT>* tmp_out = alias ? new Mat<eT>() : 0; Mat<eT>* tmp_out = alias ? new Mat<eT>() : 0;
Mat<eT>& out = alias ? *tmp_out : actual_out; Mat<eT>& out = alias ? *tmp_out : actual_out;
out.set_size(aa_n_elem, 1); out.set_size(aa_n_elem, 1);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i,j; uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
const u32 jj = aa_mem[j]; const uword jj = aa_mem[j];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" );
out_mem[i] = m_mem[ii]; out_mem[i] = m_mem[ii];
out_mem[j] = m_mem[jj]; out_mem[j] = m_mem[jj];
} }
if(i < aa_n_elem) if(i < aa_n_elem)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
out_mem[i] = m_mem[ii]; out_mem[i] = m_mem[ii];
} }
if(alias == true) if(alias == true)
{ {
actual_out = out; actual_out = out;
delete tmp_out; delete tmp_out;
skipping to change at line 578 skipping to change at line 578
const unwrap<T1> tmp1(in.a.get_ref()); const unwrap<T1> tmp1(in.a.get_ref());
const umat& aa = tmp1.M; const umat& aa = tmp1.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const uword* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const uword aa_n_elem = aa.n_elem;
const unwrap_check< Mat<eT> > tmp2(in.m, out); const unwrap_check< Mat<eT> > tmp2(in.m, out);
const Mat<eT>& m_local = tmp2.M; const Mat<eT>& m_local = tmp2.M;
const eT* m_mem = m_local.memptr(); const eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
arma_debug_check( (out.n_elem != aa_n_elem), "Mat::elem(): size mismatch" ); arma_debug_check( (out.n_elem != aa_n_elem), "Mat::elem(): size mismatch" );
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i,j; uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
const u32 jj = aa_mem[j]; const uword jj = aa_mem[j];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { out_mem[i] += m_mem[ii]; out_mem[j] += m_mem[jj]; } if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { out_mem[i] += m_mem[ii]; out_mem[j] += m_mem[jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { out_mem[i] -= m_mem[ii]; out_mem[j] -= m_mem[jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { out_mem[i] -= m_mem[ii]; out_mem[j] -= m_mem[jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { out_mem[i] *= m_mem[ii]; out_mem[j] *= m_mem[jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { out_mem[i] *= m_mem[ii]; out_mem[j] *= m_mem[jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { out_mem[i] /= m_mem[ii]; out_mem[j] /= m_mem[jj]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { out_mem[i] /= m_mem[ii]; out_mem[j] /= m_mem[jj]; }
} }
if(i < aa_n_elem) if(i < aa_n_elem)
{ {
const u32 ii = aa_mem[i]; const uword ii = aa_mem[i];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { out_mem[i] += m_mem[ii]; } if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { out_mem[i] += m_mem[ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { out_mem[i] -= m_mem[ii]; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { out_mem[i] -= m_mem[ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { out_mem[i] *= m_mem[ii]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { out_mem[i] *= m_mem[ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { out_mem[i] /= m_mem[ii]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { out_mem[i] /= m_mem[ii]; }
} }
} }
 End of changes. 33 change blocks. 
52 lines changed or deleted 52 lines changed or added


 subview_field_bones.hpp   subview_field_bones.hpp 
skipping to change at line 28 skipping to change at line 28
template<typename oT> template<typename oT>
class subview_field class subview_field
{ {
public: const field<oT>& f; public: const field<oT>& f;
protected: field<oT>* f_ptr; protected: field<oT>* f_ptr;
public: public:
typedef oT object_type; typedef oT object_type;
const u32 aux_row1; const uword aux_row1;
const u32 aux_col1; const uword aux_col1;
const u32 n_rows; const uword n_rows;
const u32 n_cols; const uword n_cols;
const u32 n_elem; const uword n_elem;
protected: protected:
arma_inline subview_field(const field<oT>& in_f, const u32 in_row1, const arma_inline subview_field(const field<oT>& in_f, const uword in_row1, con
u32 in_col1, const u32 in_n_rows, const u32 in_n_cols); st uword in_col1, const uword in_n_rows, const uword in_n_cols);
arma_inline subview_field( field<oT>& in_f, const u32 in_row1, const arma_inline subview_field( field<oT>& in_f, const uword in_row1, con
u32 in_col1, const u32 in_n_rows, const u32 in_n_cols); st uword in_col1, const uword in_n_rows, const uword in_n_cols);
public: public:
inline ~subview_field(); inline ~subview_field();
inline void operator= (const field<oT>& x); inline void operator= (const field<oT>& x);
inline void operator= (const subview_field& x); inline void operator= (const subview_field& x);
arma_inline oT& operator[](const u32 i); arma_inline oT& operator[](const uword i);
arma_inline const oT& operator[](const u32 i) const; arma_inline const oT& operator[](const uword i) const;
arma_inline oT& operator()(const u32 i); arma_inline oT& operator()(const uword i);
arma_inline const oT& operator()(const u32 i) const; arma_inline const oT& operator()(const uword i) const;
arma_inline oT& at(const u32 row, const u32 col); arma_inline oT& at(const uword row, const uword col);
arma_inline const oT& at(const u32 row, const u32 col) const; arma_inline const oT& at(const uword row, const uword col) const;
arma_inline oT& operator()(const u32 row, const u32 col); arma_inline oT& operator()(const uword row, const uword col);
arma_inline const oT& operator()(const u32 row, const u32 col) const; arma_inline const oT& operator()(const uword row, const uword col) const;
inline bool check_overlap(const subview_field& x) const; inline bool check_overlap(const subview_field& x) const;
inline static void extract(field<oT>& out, const subview_field& in); inline static void extract(field<oT>& out, const subview_field& in);
private: private:
friend class field<oT>; friend class field<oT>;
subview_field(); subview_field();
 End of changes. 7 change blocks. 
17 lines changed or deleted 17 lines changed or added


 subview_field_meat.hpp   subview_field_meat.hpp 
skipping to change at line 28 skipping to change at line 28
subview_field<oT>::~subview_field() subview_field<oT>::~subview_field()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
subview_field<oT>::subview_field subview_field<oT>::subview_field
( (
const field<oT>& in_f, const field<oT>& in_f,
const u32 in_row1, const uword in_row1,
const u32 in_col1, const uword in_col1,
const u32 in_n_rows, const uword in_n_rows,
const u32 in_n_cols const uword in_n_cols
) )
: f(in_f) : f(in_f)
, f_ptr(0) , f_ptr(0)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
subview_field<oT>::subview_field subview_field<oT>::subview_field
( (
field<oT>& in_f, field<oT>& in_f,
const u32 in_row1, const uword in_row1,
const u32 in_col1, const uword in_col1,
const u32 in_n_rows, const uword in_n_rows,
const u32 in_n_cols const uword in_n_cols
) )
: f(in_f) : f(in_f)
, f_ptr(&in_f) , f_ptr(&in_f)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 76 skipping to change at line 76
inline inline
void void
subview_field<oT>::operator= (const field<oT>& x) subview_field<oT>::operator= (const field<oT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_field<oT>& t = *this; subview_field<oT>& t = *this;
arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "inco mpatible field dimensions"); arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "inco mpatible field dimensions");
for(u32 col=0; col<t.n_cols; ++col) for(uword col=0; col<t.n_cols; ++col)
{ {
for(u32 row=0; row<t.n_rows; ++row) for(uword row=0; row<t.n_rows; ++row)
{ {
t.at(row,col) = x.at(row,col); t.at(row,col) = x.at(row,col);
} }
} }
} }
//! x.subfield(...) = y.subfield(...) //! x.subfield(...) = y.subfield(...)
template<typename oT> template<typename oT>
inline inline
void void
skipping to change at line 103 skipping to change at line 103
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
field<oT>* tmp_field = overlap ? new field<oT>(x_in.f) : 0; field<oT>* tmp_field = overlap ? new field<oT>(x_in.f) : 0;
const subview_field<oT>* tmp_subview = overlap ? new subview_field<oT>(*t mp_field, x_in.aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview_field<oT>* tmp_subview = overlap ? new subview_field<oT>(*t mp_field, x_in.aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview_field<oT>& x = overlap ? (*tmp_subview) : x_in; const subview_field<oT>& x = overlap ? (*tmp_subview) : x_in;
subview_field<oT>& t = *this; subview_field<oT>& t = *this;
arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "inco mpatible field dimensions"); arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "inco mpatible field dimensions");
for(u32 col=0; col<t.n_cols; ++col) for(uword col=0; col<t.n_cols; ++col)
{ {
for(u32 row=0; row<t.n_rows; ++row) for(uword row=0; row<t.n_rows; ++row)
{ {
t.at(row,col) = x.at(row,col); t.at(row,col) = x.at(row,col);
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_field; delete tmp_field;
} }
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::operator[](const u32 i) subview_field<oT>::operator[](const uword i)
{ {
arma_check( (f_ptr == 0), "subview_field::operator[]: field is read-only" ); arma_check( (f_ptr == 0), "subview_field::operator[]: field is read-only" );
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((*f_ptr).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::operator[](const u32 i) const subview_field<oT>::operator[](const uword i) const
{ {
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::operator()(const u32 i) subview_field<oT>::operator()(const uword i)
{ {
arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only" ); arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only" );
arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds");
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((*f_ptr).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::operator()(const u32 i) const subview_field<oT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds");
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::operator()(const u32 in_row, const u32 in_col) subview_field<oT>::operator()(const uword in_row, const uword in_col)
{ {
arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only" ); arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only" );
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds");
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((*f_ptr).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::operator()(const u32 in_row, const u32 in_col) const subview_field<oT>::operator()(const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds");
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::at(const u32 in_row, const u32 in_col) subview_field<oT>::at(const uword in_row, const uword in_col)
{ {
//arma_extra_debug_sigprint(); //arma_extra_debug_sigprint();
arma_check( (f_ptr == 0), "subview_field::at(): field is read-only"); arma_check( (f_ptr == 0), "subview_field::at(): field is read-only");
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((*f_ptr).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::at(const u32 in_row, const u32 in_col) const subview_field<oT>::at(const uword in_row, const uword in_col) const
{ {
//arma_extra_debug_sigprint(); //arma_extra_debug_sigprint();
const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
inline inline
bool bool
subview_field<oT>::check_overlap(const subview_field<oT>& x) const subview_field<oT>::check_overlap(const subview_field<oT>& x) const
{ {
const subview_field<oT>& t = *this; const subview_field<oT>& t = *this;
skipping to change at line 247 skipping to change at line 247
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (t.n_elem == 0) || (x.n_elem == 0) )
{ {
return false; return false;
} }
else else
{ {
const u32 t_row_start = t.aux_row1; const uword t_row_start = t.aux_row1;
const u32 t_row_end_p1 = t_row_start + t.n_rows; const uword t_row_end_p1 = t_row_start + t.n_rows;
const u32 t_col_start = t.aux_col1; const uword t_col_start = t.aux_col1;
const u32 t_col_end_p1 = t_col_start + t.n_cols; const uword t_col_end_p1 = t_col_start + t.n_cols;
const u32 x_row_start = x.aux_row1; const uword x_row_start = x.aux_row1;
const u32 x_row_end_p1 = x_row_start + x.n_rows; const uword x_row_end_p1 = x_row_start + x.n_rows;
const u32 x_col_start = x.aux_col1; const uword x_col_start = x.aux_col1;
const u32 x_col_end_p1 = x_col_start + x.n_cols; const uword x_col_end_p1 = x_col_start + x.n_cols;
const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s tart >= x_row_end_p1) ); const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s tart >= x_row_end_p1) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s tart >= x_col_end_p1) ); const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s tart >= x_col_end_p1) );
return ( (outside_rows == false) && (outside_cols == false) ); return ( (outside_rows == false) && (outside_cols == false) );
} }
} }
} }
//! X = Y.subfield(...) //! X = Y.subfield(...)
skipping to change at line 283 skipping to change at line 283
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// //
const bool alias = (&actual_out == &in.f); const bool alias = (&actual_out == &in.f);
field<oT>* tmp = (alias) ? new field<oT> : 0; field<oT>* tmp = (alias) ? new field<oT> : 0;
field<oT>& out = (alias) ? (*tmp) : actual_out; field<oT>& out = (alias) ? (*tmp) : actual_out;
// //
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
out.set_size(n_rows, n_cols); out.set_size(n_rows, n_cols);
arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d in.m.n_rows = %d in.m.n_cols = %d") % out.n_rows % out.n_cols % in. f.n_rows % in.f.n_cols ); arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d in.m.n_rows = %d in.m.n_cols = %d") % out.n_rows % out.n_cols % in. f.n_rows % in.f.n_cols );
for(u32 col = 0; col<n_cols; ++col) for(uword col = 0; col<n_cols; ++col)
{ {
for(u32 row = 0; row<n_rows; ++row) for(uword row = 0; row<n_rows; ++row)
{ {
out.at(row,col) = in.at(row,col); out.at(row,col) = in.at(row,col);
} }
} }
if(alias) if(alias)
{ {
actual_out = out; actual_out = out;
delete tmp; delete tmp;
} }
 End of changes. 33 change blocks. 
48 lines changed or deleted 48 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 26 skipping to change at line 26
template<typename eT> template<typename eT>
inline inline
subview<eT>::~subview() subview<eT>::~subview()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview<eT>::subview(const Mat<eT>& in_m, const u32 in_row1, const u32 in_c ol1, const u32 in_n_rows, const u32 in_n_cols) subview<eT>::subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols)
: m(in_m) : m(in_m)
, m_ptr(0) , m_ptr(0)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview<eT>::subview(Mat<eT>& in_m, const u32 in_row1, const u32 in_col1, c onst u32 in_n_rows, const u32 in_n_cols) subview<eT>::subview(Mat<eT>& in_m, const uword in_row1, const uword in_col 1, const uword in_n_rows, const uword in_n_cols)
: m(in_m) : m(in_m)
, m_ptr(&in_m) , m_ptr(&in_m)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator+= (const eT val) subview<eT>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
u32 i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) += val; X.at(row, i) += val;
X.at(row, j) += val; X.at(row, j) += val;
} }
if(i < end_col_plus1) if(i < end_col_plus1)
{ {
X.at(row, i) += val; X.at(row, i) += val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(uword col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_plus( colptr(col), val, local_n_rows ); arrayops::inplace_plus( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator-= (const eT val) subview<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
u32 i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) -= val; X.at(row, i) -= val;
X.at(row, j) -= val; X.at(row, j) -= val;
} }
if(i < end_col_plus1) if(i < end_col_plus1)
{ {
X.at(row, i) -= val; X.at(row, i) -= val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(uword col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_minus( colptr(col), val, local_n_rows ); arrayops::inplace_minus( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator*= (const eT val) subview<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
u32 i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) *= val; X.at(row, i) *= val;
X.at(row, j) *= val; X.at(row, j) *= val;
} }
if(i < end_col_plus1) if(i < end_col_plus1)
{ {
X.at(row, i) *= val; X.at(row, i) *= val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(uword col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_mul( colptr(col), val, local_n_rows ); arrayops::inplace_mul( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator/= (const eT val) subview<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
u32 i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) /= val; X.at(row, i) /= val;
X.at(row, j) /= val; X.at(row, j) /= val;
} }
if(i < end_col_plus1) if(i < end_col_plus1)
{ {
X.at(row, i) /= val; X.at(row, i) /= val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(uword col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_div( colptr(col), val, local_n_rows ); arrayops::inplace_div( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator= (const Base<eT,T1>& in) subview<eT>::operator= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "insert into submatrix"); arma_debug_assert_same_size(t, P, "insert into submatrix");
const bool alias = P.is_alias(t.m); const bool alias = P.is_alias(t.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) = x_mem[i]; A.at(row, start_col+i) = x_mem[i];
A.at(row, start_col+j) = x_mem[j]; A.at(row, start_col+j) = x_mem[j];
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) = x_mem[i]; A.at(row, start_col+i) = x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) = tmp1; A.at(row, start_col+i) = tmp1;
A.at(row, start_col+j) = tmp2; A.at(row, start_col+j) = tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i ) : P[i]; A.at(row, start_col+i) = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i ) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; uword i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
{ {
const eT tmp1 = P.at(i,col); const eT tmp1 = P.at(i,col);
const eT tmp2 = P.at(j,col); const eT tmp2 = P.at(j,col);
t_col_data[i] = tmp1; t_col_data[i] = tmp1;
t_col_data[j] = tmp2; t_col_data[j] = tmp2;
} }
if(i < t_n_rows) if(i < t_n_rows)
skipping to change at line 330 skipping to change at line 330
inline inline
void void
subview<eT>::operator+= (const Base<eT,T1>& in) subview<eT>::operator+= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "addition"); arma_debug_assert_same_size(t, P, "addition");
const bool alias = P.is_alias(t.m); const bool alias = P.is_alias(t.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) += x_mem[i]; A.at(row, start_col+i) += x_mem[i];
A.at(row, start_col+j) += x_mem[j]; A.at(row, start_col+j) += x_mem[j];
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) += x_mem[i]; A.at(row, start_col+i) += x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) += tmp1; A.at(row, start_col+i) += tmp1;
A.at(row, start_col+j) += tmp2; A.at(row, start_col+j) += tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) += (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(row, start_col+i) += (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; uword i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(i,col);
const eT val2 = P.at(j,col); const eT val2 = P.at(j,col);
t_col_data[i] += val1; t_col_data[i] += val1;
t_col_data[j] += val2; t_col_data[j] += val2;
} }
if(i < t_n_rows) if(i < t_n_rows)
skipping to change at line 436 skipping to change at line 436
inline inline
void void
subview<eT>::operator-= (const Base<eT,T1>& in) subview<eT>::operator-= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "subtraction"); arma_debug_assert_same_size(t, P, "subtraction");
const bool alias = P.is_alias(t.m); const bool alias = P.is_alias(t.m);
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) -= x_mem[i]; A.at(row, start_col+i) -= x_mem[i];
A.at(row, start_col+j) -= x_mem[j]; A.at(row, start_col+j) -= x_mem[j];
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) -= x_mem[i]; A.at(row, start_col+i) -= x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) -= tmp1; A.at(row, start_col+i) -= tmp1;
A.at(row, start_col+j) -= tmp2; A.at(row, start_col+j) -= tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) -= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(row, start_col+i) -= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; uword i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(i,col);
const eT val2 = P.at(j,col); const eT val2 = P.at(j,col);
t_col_data[i] -= val1; t_col_data[i] -= val1;
t_col_data[j] -= val2; t_col_data[j] -= val2;
} }
if(i < t_n_rows) if(i < t_n_rows)
skipping to change at line 540 skipping to change at line 540
inline inline
void void
subview<eT>::operator%= (const Base<eT,T1>& in) subview<eT>::operator%= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "element-wise multiplication"); arma_debug_assert_same_size(t, P, "element-wise multiplication");
const bool alias = P.is_alias(t.m); const bool alias = P.is_alias(t.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) *= x_mem[i]; A.at(row, start_col+i) *= x_mem[i];
A.at(row, start_col+j) *= x_mem[j]; A.at(row, start_col+j) *= x_mem[j];
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) *= x_mem[i]; A.at(row, start_col+i) *= x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) *= tmp1; A.at(row, start_col+i) *= tmp1;
A.at(row, start_col+j) *= tmp2; A.at(row, start_col+j) *= tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) *= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(row, start_col+i) *= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; uword i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(i,col);
const eT val2 = P.at(j,col); const eT val2 = P.at(j,col);
t_col_data[i] *= val1; t_col_data[i] *= val1;
t_col_data[j] *= val2; t_col_data[j] *= val2;
} }
if(i < t_n_rows) if(i < t_n_rows)
skipping to change at line 646 skipping to change at line 646
inline inline
void void
subview<eT>::operator/= (const Base<eT,T1>& in) subview<eT>::operator/= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "element-wise division"); arma_debug_assert_same_size(t, P, "element-wise division");
const bool alias = P.is_alias(t.m); const bool alias = P.is_alias(t.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) /= x_mem[i]; A.at(row, start_col+i) /= x_mem[i];
A.at(row, start_col+j) /= x_mem[j]; A.at(row, start_col+j) /= x_mem[j];
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) /= x_mem[i]; A.at(row, start_col+i) /= x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) /= tmp1; A.at(row, start_col+i) /= tmp1;
A.at(row, start_col+j) /= tmp2; A.at(row, start_col+j) /= tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row, start_col+i) /= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(row, start_col+i) /= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; uword i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(i,col);
const eT val2 = P.at(j,col); const eT val2 = P.at(j,col);
t_col_data[i] /= val1; t_col_data[i] /= val1;
t_col_data[j] /= val2; t_col_data[j] /= val2;
} }
if(i < t_n_rows) if(i < t_n_rows)
skipping to change at line 758 skipping to change at line 758
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix"); arma_debug_assert_same_size(t, x, "insert into submatrix");
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1; const uword row_A = t.aux_row1;
const u32 row_B = x.aux_row1; const uword row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) = tmp1; A.at(row_A, start_col_A + i) = tmp1;
A.at(row_A, start_col_A + j) = tmp2; A.at(row_A, start_col_A + j) = tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row_A, start_col_A + i) = B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + i) = B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
skipping to change at line 820 skipping to change at line 820
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "addition"); arma_debug_assert_same_size(t, x, "addition");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1; const uword row_A = t.aux_row1;
const u32 row_B = x.aux_row1; const uword row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) += tmp1; A.at(row_A, start_col_A + i) += tmp1;
A.at(row_A, start_col_A + j) += tmp2; A.at(row_A, start_col_A + j) += tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row_A, start_col_A + i) += B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + i) += B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
skipping to change at line 882 skipping to change at line 882
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "subtraction"); arma_debug_assert_same_size(t, x, "subtraction");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1; const uword row_A = t.aux_row1;
const u32 row_B = x.aux_row1; const uword row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) -= tmp1; A.at(row_A, start_col_A + i) -= tmp1;
A.at(row_A, start_col_A + j) -= tmp2; A.at(row_A, start_col_A + j) -= tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row_A, start_col_A + i) -= B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + i) -= B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
skipping to change at line 945 skipping to change at line 945
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise multiplication"); arma_debug_assert_same_size(t, x, "element-wise multiplication");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1; const uword row_A = t.aux_row1;
const u32 row_B = x.aux_row1; const uword row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) *= tmp1; A.at(row_A, start_col_A + i) *= tmp1;
A.at(row_A, start_col_A + j) *= tmp2; A.at(row_A, start_col_A + j) *= tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row_A, start_col_A + i) *= B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + i) *= B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
skipping to change at line 1008 skipping to change at line 1008
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise division"); arma_debug_assert_same_size(t, x, "element-wise division");
const u32 t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1; const uword row_A = t.aux_row1;
const u32 row_B = x.aux_row1; const uword row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) /= tmp1; A.at(row_A, start_col_A + i) /= tmp1;
A.at(row_A, start_col_A + j) /= tmp2; A.at(row_A, start_col_A + j) /= tmp2;
} }
if(i < t_n_cols) if(i < t_n_cols)
{ {
A.at(row_A, start_col_A + i) /= B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + i) /= B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::fill(const eT val) subview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1; const uword row = aux_row1;
const u32 start_col = aux_col1; const uword start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
u32 i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) = val; X.at(row, i) = val;
X.at(row, j) = val; X.at(row, j) = val;
} }
if(i < end_col_plus1) if(i < end_col_plus1)
{ {
X.at(row, i) = val; X.at(row, i) = val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(uword col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_set( colptr(col), val, local_n_rows ); arrayops::inplace_set( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::zeros() subview<eT>::zeros()
skipping to change at line 1123 skipping to change at line 1123
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::eye() subview<eT>::eye()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); fill(eT(0));
const u32 N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(u32 i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
at(i,i) = eT(1); at(i,i) = eT(1);
} }
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator[](const u32 i) subview<eT>::operator[](const uword i)
{ {
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator[](const u32 i) const subview<eT>::operator[](const uword i) const
{ {
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator()(const u32 i) subview<eT>::operator()(const uword i)
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator()(const u32 i) const subview<eT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const u32 in_col = i / n_rows; const uword in_col = i / n_rows;
const u32 in_row = i % n_rows; const uword in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator()(const u32 in_row, const u32 in_col) subview<eT>::operator()(const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator()(const u32 in_row, const u32 in_col) const subview<eT>::operator()(const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::at(const u32 in_row, const u32 in_col) subview<eT>::at(const uword in_row, const uword in_col)
{ {
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::at(const u32 in_row, const u32 in_col) const subview<eT>::at(const uword in_row, const uword in_col) const
{ {
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
subview<eT>::colptr(const u32 in_col) subview<eT>::colptr(const uword in_col)
{ {
return & access::rw((*m_ptr).mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]); return & access::rw((*m_ptr).mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
subview<eT>::colptr(const u32 in_col) const subview<eT>::colptr(const uword in_col) const
{ {
return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview<eT>::check_overlap(const subview<eT>& x) const subview<eT>::check_overlap(const subview<eT>& x) const
{ {
const subview<eT>& t = *this; const subview<eT>& t = *this;
skipping to change at line 1258 skipping to change at line 1258
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (t.n_elem == 0) || (x.n_elem == 0) )
{ {
return false; return false;
} }
else else
{ {
const u32 t_row_start = t.aux_row1; const uword t_row_start = t.aux_row1;
const u32 t_row_end_p1 = t_row_start + t.n_rows; const uword t_row_end_p1 = t_row_start + t.n_rows;
const u32 t_col_start = t.aux_col1; const uword t_col_start = t.aux_col1;
const u32 t_col_end_p1 = t_col_start + t.n_cols; const uword t_col_end_p1 = t_col_start + t.n_cols;
const u32 x_row_start = x.aux_row1; const uword x_row_start = x.aux_row1;
const u32 x_row_end_p1 = x_row_start + x.n_rows; const uword x_row_end_p1 = x_row_start + x.n_rows;
const u32 x_col_start = x.aux_col1; const uword x_col_start = x.aux_col1;
const u32 x_col_end_p1 = x_col_start + x.n_cols; const uword x_col_end_p1 = x_col_start + x.n_cols;
const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s tart >= x_row_end_p1) ); const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s tart >= x_row_end_p1) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s tart >= x_col_end_p1) ); const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s tart >= x_col_end_p1) );
return ( (outside_rows == false) && (outside_cols == false) ); return ( (outside_rows == false) && (outside_cols == false) );
} }
} }
} }
template<typename eT> template<typename eT>
skipping to change at line 1290 skipping to change at line 1290
bool bool
subview<eT>::is_vec() const subview<eT>::is_vec() const
{ {
return ( (n_rows == 1) || (n_cols == 1) ); return ( (n_rows == 1) || (n_cols == 1) );
} }
//! X = Y.submat(...) //! X = Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::extract(Mat<eT>& actual_out, const subview<eT>& in) subview<eT>::extract(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// // NOTE: we're assuming that the matrix has already been set to the corre
const bool alias = (&actual_out == &in.m); ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o
r operator=()
Mat<eT>* tmp = (alias) ? new Mat<eT> : 0; const uword n_rows = in.n_rows; // number of rows in the subview
Mat<eT>& out = (alias) ? (*tmp) : actual_out; const uword n_cols = in.n_cols; // number of columns in the subview
//
const u32 n_rows = in.n_rows; // number of rows in the subview
const u32 n_cols = in.n_cols; // number of columns in the subview
out.set_size(n_rows, n_cols);
arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d in.m.n_rows = %d in.m.n_cols = %d") % out.n_rows % out.n_cols % in. m.n_rows % in.m.n_cols ); arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d in.m.n_rows = %d in.m.n_cols = %d") % out.n_rows % out.n_cols % in. m.n_rows % in.m.n_cols );
if(in.is_vec() == true) if(in.is_vec() == true)
{ {
if(n_cols == 1) // a column vector if(n_cols == 1) // a column vector
{ {
arma_extra_debug_print("subview::extract(): copying col (going across rows)"); arma_extra_debug_print("subview::extract(): copying col (going across rows)");
// in.colptr(0) the first column of the subview, taking into account any row offset // in.colptr(0) the first column of the subview, taking into account any row offset
arrayops::copy( out.memptr(), in.colptr(0), n_rows ); arrayops::copy( out.memptr(), in.colptr(0), n_rows );
} }
else // a row vector (possibly empty) else // a row vector (possibly empty)
{ {
arma_extra_debug_print("subview::extract(): copying row (going across columns)"); arma_extra_debug_print("subview::extract(): copying row (going across columns)");
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 row = in.aux_row1; const uword row = in.aux_row1;
const u32 start_col = in.aux_col1; const uword start_col = in.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2) for(i=0, j=1; j < n_cols; i+=2, j+=2)
{ {
const eT tmp1 = X.at(row, start_col+i); const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j); const eT tmp2 = X.at(row, start_col+j);
out_mem[i] = tmp1; out_mem[i] = tmp1;
out_mem[j] = tmp2; out_mem[j] = tmp2;
} }
if(i < n_cols) if(i < n_cols)
{ {
out_mem[i] = X.at(row, start_col+i); out_mem[i] = X.at(row, start_col+i);
} }
} }
} }
else // general submatrix else // general submatrix
{ {
arma_extra_debug_print("subview::extract(): general submatrix"); arma_extra_debug_print("subview::extract(): general submatrix");
for(u32 col = 0; col<n_cols; ++col) for(uword col = 0; col<n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), in.colptr(col), n_rows ); arrayops::copy( out.colptr(col), in.colptr(col), n_rows );
} }
} }
if(alias)
{
actual_out = out;
delete tmp;
}
} }
//! X += Y.submat(...) //! X += Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "addition"); arma_debug_assert_same_size(out, in, "addition");
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
const u32 row = in.aux_row1; const uword row = in.aux_row1;
const u32 start_col = in.aux_col1; const uword start_col = in.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2) for(i=0, j=1; j < n_cols; i+=2, j+=2)
{ {
const eT tmp1 = X.at(row, start_col+i); const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j); const eT tmp2 = X.at(row, start_col+j);
out_mem[i] += tmp1; out_mem[i] += tmp1;
out_mem[j] += tmp2; out_mem[j] += tmp2;
} }
if(i < n_cols) if(i < n_cols)
{ {
out_mem[i] += X.at(row, start_col+i); out_mem[i] += X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
arrayops::inplace_plus(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_plus(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! X -= Y.submat(...) //! X -= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "subtraction"); arma_debug_assert_same_size(out, in, "subtraction");
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
const u32 row = in.aux_row1; const uword row = in.aux_row1;
const u32 start_col = in.aux_col1; const uword start_col = in.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2) for(i=0, j=1; j < n_cols; i+=2, j+=2)
{ {
const eT tmp1 = X.at(row, start_col+i); const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j); const eT tmp2 = X.at(row, start_col+j);
out_mem[i] -= tmp1; out_mem[i] -= tmp1;
out_mem[j] -= tmp2; out_mem[j] -= tmp2;
} }
if(i < n_cols) if(i < n_cols)
{ {
out_mem[i] -= X.at(row, start_col+i); out_mem[i] -= X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
arrayops::inplace_minus(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_minus(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! X %= Y.submat(...) //! X %= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise multiplication"); arma_debug_assert_same_size(out, in, "element-wise multiplication");
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
const u32 row = in.aux_row1; const uword row = in.aux_row1;
const u32 start_col = in.aux_col1; const uword start_col = in.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2) for(i=0, j=1; j < n_cols; i+=2, j+=2)
{ {
const eT tmp1 = X.at(row, start_col+i); const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j); const eT tmp2 = X.at(row, start_col+j);
out_mem[i] *= tmp1; out_mem[i] *= tmp1;
out_mem[j] *= tmp2; out_mem[j] *= tmp2;
} }
if(i < n_cols) if(i < n_cols)
{ {
out_mem[i] *= X.at(row, start_col+i); out_mem[i] *= X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
arrayops::inplace_mul(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_mul(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! X /= Y.submat(...) //! X /= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise division"); arma_debug_assert_same_size(out, in, "element-wise division");
const u32 n_rows = in.n_rows; const uword n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
const u32 row = in.aux_row1; const uword row = in.aux_row1;
const u32 start_col = in.aux_col1; const uword start_col = in.aux_col1;
u32 i,j; uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2) for(i=0, j=1; j < n_cols; i+=2, j+=2)
{ {
const eT tmp1 = X.at(row, start_col+i); const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j); const eT tmp2 = X.at(row, start_col+j);
out_mem[i] /= tmp1; out_mem[i] /= tmp1;
out_mem[j] /= tmp2; out_mem[j] /= tmp2;
} }
if(i < n_cols) if(i < n_cols)
{ {
out_mem[i] /= X.at(row, start_col+i); out_mem[i] /= X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
arrayops::inplace_div(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_div(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! creation of subview (row vector) //! creation of subview (row vector)
template<typename eT> template<typename eT>
inline inline
subview_row<eT> subview_row<eT>
subview<eT>::row(const u32 row_num) subview<eT>::row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" ); arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" );
const u32 base_row = aux_row1 + row_num; const uword base_row = aux_row1 + row_num;
return subview_row<eT>(*m_ptr, base_row, aux_col1, n_cols); return subview_row<eT>(*m_ptr, base_row, aux_col1, n_cols);
} }
//! creation of subview (row vector) //! creation of subview (row vector)
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview<eT>::row(const u32 row_num) const subview<eT>::row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" ); arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" );
const u32 base_row = aux_row1 + row_num; const uword base_row = aux_row1 + row_num;
return subview_row<eT>(m, base_row, aux_col1, n_cols); return subview_row<eT>(m, base_row, aux_col1, n_cols);
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT> subview_row<eT>
subview<eT>::operator()(const u32 row_num, const span& col_span) subview<eT>::operator()(const uword row_num, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
const u32 base_row = aux_row1 + row_num; const uword base_row = aux_row1 + row_num;
arma_debug_check arma_debug_check
( (
(row_num >= n_rows) (row_num >= n_rows)
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"subview::operator(): indices out of bounds or incorrectly used" "subview::operator(): indices out of bounds or incorrectly used"
); );
return subview_row<eT>(*m_ptr, base_row, base_col1, submat_n_cols); return subview_row<eT>(*m_ptr, base_row, base_col1, submat_n_cols);
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview<eT>::operator()(const u32 row_num, const span& col_span) const subview<eT>::operator()(const uword row_num, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
const u32 base_row = aux_row1 + row_num; const uword base_row = aux_row1 + row_num;
arma_debug_check arma_debug_check
( (
(row_num >= n_rows) (row_num >= n_rows)
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"subview::operator(): indices out of bounds or incorrectly used" "subview::operator(): indices out of bounds or incorrectly used"
); );
return subview_row<eT>(m, base_row, base_col1, submat_n_cols); return subview_row<eT>(m, base_row, base_col1, submat_n_cols);
} }
//! creation of subview (column vector) //! creation of subview (column vector)
template<typename eT> template<typename eT>
inline inline
subview_col<eT> subview_col<eT>
subview<eT>::col(const u32 col_num) subview<eT>::col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds"); arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds");
const u32 base_col = aux_col1 + col_num; const uword base_col = aux_col1 + col_num;
return subview_col<eT>(*m_ptr, base_col, aux_row1, n_rows); return subview_col<eT>(*m_ptr, base_col, aux_row1, n_rows);
} }
//! creation of subview (column vector) //! creation of subview (column vector)
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview<eT>::col(const u32 col_num) const subview<eT>::col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds"); arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds");
const u32 base_col = aux_col1 + col_num; const uword base_col = aux_col1 + col_num;
return subview_col<eT>(m, base_col, aux_row1, n_rows); return subview_col<eT>(m, base_col, aux_row1, n_rows);
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT> subview_col<eT>
subview<eT>::operator()(const span& row_span, const u32 col_num) subview<eT>::operator()(const span& row_span, const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const u32 base_col = aux_col1 + col_num; const uword base_col = aux_col1 + col_num;
arma_debug_check arma_debug_check
( (
(col_num >= n_cols) (col_num >= n_cols)
|| ||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
, ,
"subview::operator(): indices out of bounds or incorrectly used" "subview::operator(): indices out of bounds or incorrectly used"
); );
return subview_col<eT>(*m_ptr, base_col, base_row1, submat_n_rows); return subview_col<eT>(*m_ptr, base_col, base_row1, submat_n_rows);
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview<eT>::operator()(const span& row_span, const u32 col_num) const subview<eT>::operator()(const span& row_span, const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const u32 base_col = aux_col1 + col_num; const uword base_col = aux_col1 + col_num;
arma_debug_check arma_debug_check
( (
(col_num >= n_cols) (col_num >= n_cols)
|| ||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
, ,
"subview::operator(): indices out of bounds or incorrectly used" "subview::operator(): indices out of bounds or incorrectly used"
); );
skipping to change at line 1736 skipping to change at line 1722
} }
//! create a Col object which uses memory from an existing matrix object. //! create a Col object which uses memory from an existing matrix object.
//! this approach is currently not alias safe //! this approach is currently not alias safe
//! and does not take into account that the parent matrix object could be d eleted. //! and does not take into account that the parent matrix object could be d eleted.
//! if deleted memory is accessed by the created Col object, //! if deleted memory is accessed by the created Col object,
//! it will cause memory corruption and/or a crash //! it will cause memory corruption and/or a crash
template<typename eT> template<typename eT>
inline inline
Col<eT> Col<eT>
subview<eT>::unsafe_col(const u32 col_num) subview<eT>::unsafe_col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::unsafe_col(): out of bound s"); arma_debug_check( col_num >= n_cols, "subview::unsafe_col(): out of bound s");
return Col<eT>(colptr(col_num), n_rows, false, true); return Col<eT>(colptr(col_num), n_rows, false, true);
} }
//! create a Col object which uses memory from an existing matrix object. //! create a Col object which uses memory from an existing matrix object.
//! this approach is currently not alias safe //! this approach is currently not alias safe
//! and does not take into account that the parent matrix object could be d eleted. //! and does not take into account that the parent matrix object could be d eleted.
//! if deleted memory is accessed by the created Col object, //! if deleted memory is accessed by the created Col object,
//! it will cause memory corruption and/or a crash //! it will cause memory corruption and/or a crash
template<typename eT> template<typename eT>
inline inline
const Col<eT> const Col<eT>
subview<eT>::unsafe_col(const u32 col_num) const subview<eT>::unsafe_col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::unsafe_col(): out of bound s"); arma_debug_check( col_num >= n_cols, "subview::unsafe_col(): out of bound s");
return Col<eT>(const_cast<eT*>(colptr(col_num)), n_rows, false, true); return Col<eT>(const_cast<eT*>(colptr(col_num)), n_rows, false, true);
} }
//! creation of subview (submatrix comprised of specified row vectors) //! creation of subview (submatrix comprised of specified row vectors)
template<typename eT> template<typename eT>
inline inline
subview<eT> subview<eT>
subview<eT>::rows(const u32 in_row1, const u32 in_row2) subview<eT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"subview::rows(): indices out of bounds or incorrectly used" "subview::rows(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
return subview<eT>(*m_ptr, base_row1, aux_col1, subview_n_rows, n_cols ); return subview<eT>(*m_ptr, base_row1, aux_col1, subview_n_rows, n_cols );
} }
//! creation of subview (submatrix comprised of specified row vectors) //! creation of subview (submatrix comprised of specified row vectors)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::rows(const u32 in_row1, const u32 in_row2) const subview<eT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"subview::rows(): indices out of bounds or incorrectly used" "subview::rows(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
return subview<eT>(m, base_row1, aux_col1, subview_n_rows, n_cols ); return subview<eT>(m, base_row1, aux_col1, subview_n_rows, n_cols );
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
inline inline
subview<eT> subview<eT>
subview<eT>::cols(const u32 in_col1, const u32 in_col2) subview<eT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"subview::cols(): indices out of bounds or incorrectly used" "subview::cols(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, aux_row1, base_col1, n_rows, subview_n_cols); return subview<eT>(*m_ptr, aux_row1, base_col1, n_rows, subview_n_cols);
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::cols(const u32 in_col1, const u32 in_col2) const subview<eT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"subview::cols(): indices out of bounds or incorrectly used" "subview::cols(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(m, aux_row1, base_col1, n_rows, subview_n_cols); return subview<eT>(m, aux_row1, base_col1, n_rows, subview_n_cols);
} }
//! creation of subview (submatrix) //! creation of subview (submatrix)
template<typename eT> template<typename eT>
inline inline
subview<eT> subview<eT>
subview<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2 , const u32 in_col2) subview<eT>::submat(const uword in_row1, const uword in_col1, const uword i n_row2, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols),
"subview::submat(): indices out of bounds or incorrectly used" "subview::submat(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, base_row1, base_col1, subview_n_rows, subview_ n_cols); return subview<eT>(*m_ptr, base_row1, base_col1, subview_n_rows, subview_ n_cols);
} }
//! creation of subview (generic submatrix) //! creation of subview (generic submatrix)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2 , const u32 in_col2) const subview<eT>::submat(const uword in_row1, const uword in_col1, const uword i n_row2, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols),
"subview::submat(): indices out of bounds or incorrectly used" "subview::submat(): indices out of bounds or incorrectly used"
); );
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(m, base_row1, base_col1, subview_n_rows, subview_n_col s); return subview<eT>(m, base_row1, base_col1, subview_n_rows, subview_n_col s);
} }
//! creation of subview (submatrix) //! creation of subview (submatrix)
template<typename eT> template<typename eT>
inline inline
subview<eT> subview<eT>
subview<eT>::submat(const span& row_span, const span& col_span) subview<eT>::submat(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword in_col2 = col_span.b;
const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"subview::submat(): indices out of bounds or incorrectly used" "subview::submat(): indices out of bounds or incorrectly used"
); );
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, base_row1, base_col1, submat_n_rows, submat_n_ cols); return subview<eT>(*m_ptr, base_row1, base_col1, submat_n_rows, submat_n_ cols);
} }
//! creation of subview (generic submatrix) //! creation of subview (generic submatrix)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::submat(const span& row_span, const span& col_span) const subview<eT>::submat(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows; const uword local_n_rows = n_rows;
const u32 local_n_cols = n_cols; const uword local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b; const uword in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 +
1;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b; const uword in_col1 = col_all ? 0 : col_span.a;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword in_col2 = col_span.b;
const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 +
1;
arma_debug_check arma_debug_check
( (
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"subview::submat(): indices out of bounds or incorrectly used" "subview::submat(): indices out of bounds or incorrectly used"
); );
const u32 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(m, base_row1, base_col1, submat_n_rows, submat_n_cols) ; return subview<eT>(m, base_row1, base_col1, submat_n_rows, submat_n_cols) ;
} }
template<typename eT> template<typename eT>
inline inline
subview<eT> subview<eT>
subview<eT>::operator()(const span& row_span, const span& col_span) subview<eT>::operator()(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1986 skipping to change at line 1972
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).submat(row_span, col_span); return (*this).submat(row_span, col_span);
} }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
inline inline
diagview<eT> diagview<eT>
subview<eT>::diag(const s32 in_id) subview<eT>::diag(const sword in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; const uword row_offset = (in_id < 0) ? uword(-in_id) : 0;
const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; const uword col_offset = (in_id > 0) ? uword( in_id) : 0;
arma_debug_check arma_debug_check
( (
((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)), ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)),
"subview::diag(): requested diagonal out of bounds" "subview::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const uword len = (std::min)(n_rows - row_offset, n_cols - col_offset);
const u32 base_row_offset = aux_row1 + row_offset; const uword base_row_offset = aux_row1 + row_offset;
const u32 base_col_offset = aux_col1 + col_offset; const uword base_col_offset = aux_col1 + col_offset;
return diagview<eT>(*m_ptr, base_row_offset, base_col_offset, len); return diagview<eT>(*m_ptr, base_row_offset, base_col_offset, len);
} }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
inline inline
const diagview<eT> const diagview<eT>
subview<eT>::diag(const s32 in_id) const subview<eT>::diag(const sword in_id) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0; const uword row_offset = (in_id < 0) ? -in_id : 0;
const u32 col_offset = (in_id > 0) ? in_id : 0; const uword col_offset = (in_id > 0) ? in_id : 0;
arma_debug_check arma_debug_check
( (
((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)), ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)),
"subview::diag(): requested diagonal out of bounds" "subview::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const uword len = (std::min)(n_rows - row_offset, n_cols - col_offset);
const u32 base_row_offset = aux_row1 + row_offset; const uword base_row_offset = aux_row1 + row_offset;
const u32 base_col_offset = aux_col1 + col_offset; const uword base_col_offset = aux_col1 + col_offset;
return diagview<eT>(m, base_row_offset, base_col_offset, len); return diagview<eT>(m, base_row_offset, base_col_offset, len);
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::swap_rows(const u32 in_row1, const u32 in_row2) subview<eT>::swap_rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 >= n_rows) || (in_row2 >= n_rows), (in_row1 >= n_rows) || (in_row2 >= n_rows),
"subview::swap_rows(): out of bounds" "subview::swap_rows(): out of bounds"
); );
eT* mem = (*m_ptr).memptr(); eT* mem = (*m_ptr).memptr();
for(u32 col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
const u32 offset = (aux_col1 + col) * m.n_rows; const uword offset = (aux_col1 + col) * m.n_rows;
const u32 pos1 = aux_row1 + in_row1 + offset; const uword pos1 = aux_row1 + in_row1 + offset;
const u32 pos2 = aux_row1 + in_row2 + offset; const uword pos2 = aux_row1 + in_row2 + offset;
const eT tmp = mem[pos1]; const eT tmp = mem[pos1];
access::rw(mem[pos1]) = mem[pos2]; access::rw(mem[pos1]) = mem[pos2];
access::rw(mem[pos2]) = tmp; access::rw(mem[pos2]) = tmp;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::swap_cols(const u32 in_col1, const u32 in_col2) subview<eT>::swap_cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 >= n_cols) || (in_col2 >= n_cols), (in_col1 >= n_cols) || (in_col2 >= n_cols),
"subview::swap_cols(): out of bounds" "subview::swap_cols(): out of bounds"
); );
if(n_elem > 0) if(n_elem > 0)
{ {
eT* ptr1 = colptr(in_col1); eT* ptr1 = colptr(in_col1);
eT* ptr2 = colptr(in_col2); eT* ptr2 = colptr(in_col2);
for(u32 row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
const eT tmp = ptr1[row]; const eT tmp = ptr1[row];
ptr1[row] = ptr2[row]; ptr1[row] = ptr2[row];
ptr2[row] = tmp; ptr2[row] = tmp;
} }
} }
} }
template<typename eT>
inline
void
subview<eT>::print(const std::string extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).print(extra_text);
}
template<typename eT>
inline
void
subview<eT>::print(std::ostream& user_stream, const std::string extra_text)
const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).print(user_stream, extra_text);
}
template<typename eT>
inline
void
subview<eT>::print_trans(const std::string extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).print_trans(extra_text);
}
template<typename eT>
inline
void
subview<eT>::print_trans(std::ostream& user_stream, const std::string extra
_text) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).print_trans(user_stream, extra_text);
}
template<typename eT>
inline
void
subview<eT>::raw_print(const std::string extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).raw_print(extra_text);
}
template<typename eT>
inline
void
subview<eT>::raw_print(std::ostream& user_stream, const std::string extra_t
ext) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).raw_print(user_stream, extra_text);
}
template<typename eT>
inline
void
subview<eT>::raw_print_trans(const std::string extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).raw_print_trans(extra_text);
}
template<typename eT>
inline
void
subview<eT>::raw_print_trans(std::ostream& user_stream, const std::string e
xtra_text) const
{
arma_extra_debug_sigprint();
Mat<eT>(*this).raw_print_trans(user_stream, extra_text);
}
// template<typename eT> // template<typename eT>
// inline // inline
// subview<eT>::iter::iter(const subview<eT>& S) // subview<eT>::iter::iter(const subview<eT>& S)
// : mem (S.m.mem) // : mem (S.m.mem)
// , n_rows (S.m.n_rows) // , n_rows (S.m.n_rows)
// , row_start (S.aux_row1) // , row_start (S.aux_row1)
// , row_end_p1(row_start + S.n_rows) // , row_end_p1(row_start + S.n_rows)
// , row (row_start) // , row (row_start)
// , col (S.aux_col1) // , col (S.aux_col1)
// , i (row + col*n_rows) // , i (row + col*n_rows)
skipping to change at line 2228 skipping to change at line 2134
// { // {
// operator++(); // operator++();
// } // }
// //
// //
// //
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col) subview_col<eT>::subview_col(const Mat<eT>& in_m, const uword in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1) : subview<eT>(in_m, 0, in_col, in_m.n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col) subview_col<eT>::subview_col(Mat<eT>& in_m, const uword in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1) : subview<eT>(in_m, 0, in_col, in_m.n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col, const u 32 in_row1, const u32 in_n_rows) subview_col<eT>::subview_col(const Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1) : subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col, const u32 in_ row1, const u32 in_n_rows) subview_col<eT>::subview_col(Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1) : subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_col<eT>::operator=(const subview<eT>& X) subview_col<eT>::operator=(const subview<eT>& X)
{ {
skipping to change at line 2295 skipping to change at line 2201
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT> subview_col<eT>
subview_col<eT>::rows(const u32 in_row1, const u32 in_row2) subview_col<eT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1; const uword base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview _n_rows); return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview _n_rows);
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview_col<eT>::rows(const u32 in_row1, const u32 in_row2) const subview_col<eT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1; const uword base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows ); return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows );
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT> subview_col<eT>
subview_col<eT>::subvec(const u32 in_row1, const u32 in_row2) subview_col<eT>::subvec(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1; const uword base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview _n_rows); return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview _n_rows);
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview_col<eT>::subvec(const u32 in_row1, const u32 in_row2) const subview_col<eT>::subvec(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1; const uword base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows ); return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows );
} }
// //
// //
// //
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row) subview_row<eT>::subview_row(const Mat<eT>& in_m, const uword in_row)
: subview<eT>(in_m, in_row, 0, 1, in_m.n_cols) : subview<eT>(in_m, in_row, 0, 1, in_m.n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row) subview_row<eT>::subview_row(Mat<eT>& in_m, const uword in_row)
: subview<eT>(in_m, in_row, 0, 1, in_m.n_cols) : subview<eT>(in_m, in_row, 0, 1, in_m.n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row, const u 32 in_col1, const u32 in_n_cols) subview_row<eT>::subview_row(const Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols)
: subview<eT>(in_m, in_row, in_col1, 1, in_n_cols) : subview<eT>(in_m, in_row, in_col1, 1, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row, const u32 in_ col1, const u32 in_n_cols) subview_row<eT>::subview_row(Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols)
: subview<eT>(in_m, in_row, in_col1, 1, in_n_cols) : subview<eT>(in_m, in_row, in_col1, 1, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_row<eT>::operator=(const subview<eT>& X) subview_row<eT>::operator=(const subview<eT>& X)
{ {
skipping to change at line 2429 skipping to change at line 2335
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT> subview_row<eT>
subview_row<eT>::cols(const u32 in_col1, const u32 in_col2) subview_row<eT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used" ); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used" );
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1; const uword base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview _n_cols); return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview _n_cols);
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview_row<eT>::cols(const u32 in_col1, const u32 in_col2) const subview_row<eT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1; const uword base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols ); return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols );
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT> subview_row<eT>
subview_row<eT>::subvec(const u32 in_col1, const u32 in_col2) subview_row<eT>::subvec(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1; const uword base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview _n_cols); return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview _n_cols);
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview_row<eT>::subvec(const u32 in_col1, const u32 in_col2) const subview_row<eT>::subvec(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1; const uword base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols ); return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols );
} }
//! @} //! @}
 End of changes. 230 change blocks. 
432 lines changed or deleted 344 lines changed or added


 traits.hpp   traits.hpp 
skipping to change at line 105 skipping to change at line 105
template<typename eT> template<typename eT>
struct is_subview_cube< subview_cube<eT> > struct is_subview_cube< subview_cube<eT> >
{ static const bool value = true; }; { static const bool value = true; };
// //
// //
// //
template<typename T> template<typename T>
struct is_Gen
{ static const bool value = false; };
template<typename eT, typename gen_type>
struct is_Gen< Gen<eT,gen_type> >
{ static const bool value = true; };
template<typename T>
struct is_Op struct is_Op
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1, typename op_type> template<typename T1, typename op_type>
struct is_Op< Op<T1,op_type> > struct is_Op< Op<T1,op_type> >
{ static const bool value = true; }; { static const bool value = true; };
template<typename T> template<typename T>
struct is_eOp struct is_eOp
{ static const bool value = false; }; { static const bool value = false; };
skipping to change at line 183 skipping to change at line 191
{ 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 T> template<typename T>
struct is_GenCube
{ static const bool value = false; };
template<typename eT, typename gen_type>
struct is_GenCube< GenCube<eT,gen_type> >
{ static const bool value = true; };
template<typename T>
struct is_OpCube struct is_OpCube
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1, typename op_type> template<typename T1, typename op_type>
struct is_OpCube< OpCube<T1,op_type> > struct is_OpCube< OpCube<T1,op_type> >
{ static const bool value = true; }; { static const bool value = true; };
template<typename T> template<typename T>
struct is_eOpCube struct is_eOpCube
{ static const bool value = false; }; { static const bool value = false; };
skipping to change at line 287 skipping to change at line 303
// //
// //
// //
template<typename T1> template<typename T1>
struct is_arma_type struct is_arma_type
{ {
static const bool value static const bool value
= is_Mat<T1>::value = is_Mat<T1>::value
|| is_Gen<T1>::value
|| is_Op<T1>::value || is_Op<T1>::value
|| is_eOp<T1>::value || is_eOp<T1>::value
|| is_mtOp<T1>::value || is_mtOp<T1>::value
|| is_Glue<T1>::value || is_Glue<T1>::value
|| is_eGlue<T1>::value || is_eGlue<T1>::value
|| is_mtGlue<T1>::value || is_mtGlue<T1>::value
|| is_subview<T1>::value || is_subview<T1>::value
|| is_diagview<T1>::value || is_diagview<T1>::value
; ;
}; };
template<typename T1> template<typename T1>
struct is_arma_cube_type struct is_arma_cube_type
{ {
static const bool value static const bool value
= is_Cube<T1>::value = is_Cube<T1>::value
|| is_GenCube<T1>::value
|| is_OpCube<T1>::value || is_OpCube<T1>::value
|| is_eOpCube<T1>::value || is_eOpCube<T1>::value
|| is_mtOpCube<T1>::value || is_mtOpCube<T1>::value
|| is_GlueCube<T1>::value || is_GlueCube<T1>::value
|| is_eGlueCube<T1>::value || is_eGlueCube<T1>::value
|| is_mtGlueCube<T1>::value || is_mtGlueCube<T1>::value
|| is_subview_cube<T1>::value || is_subview_cube<T1>::value
; ;
}; };
skipping to change at line 377 skipping to change at line 395
{ static const bool value = true; }; { static const bool value = true; };
template<typename T1> template<typename T1>
struct is_s32 struct is_s32
{ static const bool value = false; }; { static const bool value = false; };
template<> template<>
struct is_s32<s32> struct is_s32<s32>
{ static const bool value = true; }; { static const bool value = true; };
// template<typename T1> #if defined(ARMA_64BIT_WORD)
// struct is_u64 template<typename T1>
// { static const bool value = false; }; struct is_u64
// { static const bool value = false; };
// template<>
// struct is_u64<u64> template<>
// { static const bool value = true; }; struct is_u64<u64>
{ static const bool value = true; };
template<typename T1>
struct is_s64
{ static const bool value = false; };
template<>
struct is_s64<s64>
{ static const bool value = true; };
#endif
template<typename T1>
struct is_uword
{ static const bool value = false; };
template<>
struct is_uword<uword>
{ static const bool value = true; };
template<typename T1>
struct is_sword
{ static const bool value = false; };
template<>
struct is_sword<sword>
{ static const bool value = true; };
template<typename T1> template<typename T1>
struct is_float struct is_float
{ static const bool value = false; }; { static const bool value = false; };
template<> template<>
struct is_float<float> struct is_float<float>
{ static const bool value = true; }; { static const bool value = true; };
template<typename T1> template<typename T1>
skipping to change at line 462 skipping to change at line 506
template<typename T1> template<typename T1>
struct is_supported_elem_type struct is_supported_elem_type
{ {
static const bool value = \ static const bool value = \
is_u8<T1>::value || is_u8<T1>::value ||
is_s8<T1>::value || is_s8<T1>::value ||
is_u16<T1>::value || is_u16<T1>::value ||
is_s16<T1>::value || is_s16<T1>::value ||
is_u32<T1>::value || is_u32<T1>::value ||
is_s32<T1>::value || is_s32<T1>::value ||
// is_u64<T1>::value || #if defined(ARMA_64BIT_WORD)
is_u64<T1>::value ||
is_s64<T1>::value ||
#endif
is_float<T1>::value || is_float<T1>::value ||
is_double<T1>::value || is_double<T1>::value ||
is_supported_complex_float<T1>::value || is_supported_complex_float<T1>::value ||
is_supported_complex_double<T1>::value; is_supported_complex_double<T1>::value;
}; };
template<typename T1> template<typename T1>
struct is_supported_blas_type struct is_supported_blas_type
{ {
static const bool value = \ static const bool value = \
skipping to change at line 485 skipping to change at line 532
is_supported_complex_float<T1>::value || is_supported_complex_float<T1>::value ||
is_supported_complex_double<T1>::value; is_supported_complex_double<T1>::value;
}; };
template<typename T> template<typename T>
struct is_signed struct is_signed
{ {
static const bool value = true; static const bool value = true;
}; };
template<> struct is_signed<unsigned char > { static const bool value = fal template<> struct is_signed<u8> { static const bool value = false; };
se; }; template<> struct is_signed<u16> { static const bool value = false; };
template<> struct is_signed<unsigned short> { static const bool value = fal template<> struct is_signed<u32> { static const bool value = false; };
se; }; #if defined(ARMA_64BIT_WORD)
template<> struct is_signed<unsigned int > { static const bool value = fal template<> struct is_signed<u64> { static const bool value = false; };
se; }; #endif
template<> struct is_signed<unsigned long > { static const bool value = fal
se; };
template<typename T> template<typename T>
struct is_non_integral struct is_non_integral
{ {
static const bool value = false; static const bool value = false;
}; };
template<> struct is_non_integral< float > { static const bo ol value = true; }; template<> struct is_non_integral< float > { static const bo ol value = true; };
template<> struct is_non_integral< double > { static const bo ol value = true; }; template<> struct is_non_integral< double > { static const bo ol value = true; };
template<> struct is_non_integral< std::complex<float> > { static const bo ol value = true; }; template<> struct is_non_integral< std::complex<float> > { static const bo ol value = true; };
 End of changes. 7 change blocks. 
16 lines changed or deleted 61 lines changed or added


 typedef.hpp   typedef.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 47 skipping to change at line 47
#if UINT_MAX >= 0xffffffff #if UINT_MAX >= 0xffffffff
typedef unsigned int u32; typedef unsigned int u32;
typedef int s32; typedef int s32;
#elif ULONG_MAX >= 0xffffffff #elif ULONG_MAX >= 0xffffffff
typedef unsigned long u32; typedef unsigned long u32;
typedef long s32; typedef long s32;
#else #else
#error "don't know how to typedef 'u32' on this system" #error "don't know how to typedef 'u32' on this system"
#endif #endif
// // #if defined(ARMA_64BIT_WORD)
// // only supported by C++0x, via #include <cstdint>, or by C99, via #incl #if ULONG_MAX >= 0xffffffffffffffff
ude <stdint.h> typedef unsigned long u64;
typedef long s64;
#else
#if ULLONG_MAX >= 0xffffffffffffffff
typedef unsigned long long u64;
typedef long long s64;
#else
#error "don't know how to typedef 'u64' on this system"
#endif
#endif
#endif
// // only supported by C++11, via #include <cstdint>, or by C99, via #incl
ude <stdint.h>
// //
// //! unsigned 8 bit type // typedef uint8_t u8;
// typedef uint8_t u8; // typedef int8_t s8;
// //
// //! unsigned 16 bit type
// typedef uint16_t u16; // typedef uint16_t u16;
// typedef int16_t s16;
// //
// //! unsigned 32 bit type
// typedef uint32_t u32; // typedef uint32_t u32;
// typedef int32_t s32;
// //
// //! signed 32 bit type // typedef uint64_t u64;
// typedef int32_t s32; // typedef int64_t s64;
#if !defined(ARMA_64BIT_WORD)
typedef u32 uword;
typedef s32 sword;
typedef u16 uhword;
typedef s16 shword;
#define ARMA_MAX_UWORD 0xffffffff
#define ARMA_MAX_UHWORD 0xffff
#else
typedef u64 uword;
typedef s64 sword;
typedef u32 uhword;
typedef s32 shword;
#define ARMA_MAX_UWORD 0xffffffffffffffff
#define ARMA_MAX_UHWORD 0xffffffff
#endif
#if defined(ARMA_BLAS_LONG_LONG) #if defined(ARMA_BLAS_LONG_LONG)
typedef long long blas_int; typedef long long blas_int;
#elif defined(ARMA_BLAS_LONG) #elif defined(ARMA_BLAS_LONG)
typedef long blas_int; typedef long blas_int;
#else #else
typedef int blas_int; typedef int blas_int;
#endif #endif
typedef std::complex<float> cx_float; typedef std::complex<float> cx_float;
typedef std::complex<double> cx_double; typedef std::complex<double> cx_double;
typedef Mat<unsigned char> uchar_mat; typedef Mat <unsigned char> uchar_mat;
typedef Col<unsigned char> uchar_vec; typedef Col <unsigned char> uchar_vec;
typedef Col<unsigned char> uchar_colvec; typedef Col <unsigned char> uchar_colvec;
typedef Row<unsigned char> uchar_rowvec; typedef Row <unsigned char> uchar_rowvec;
typedef Cube<unsigned char> uchar_cube; typedef Cube<unsigned char> uchar_cube;
typedef Mat<u32> umat; typedef Mat <u32> u32_mat;
typedef Col<u32> uvec; typedef Col <u32> u32_vec;
typedef Col<u32> ucolvec; typedef Col <u32> u32_colvec;
typedef Row<u32> urowvec; typedef Row <u32> u32_rowvec;
typedef Cube<u32> ucube; typedef Cube<u32> u32_cube;
typedef Mat<s32> imat; typedef Mat <s32> s32_mat;
typedef Col<s32> ivec; typedef Col <s32> s32_vec;
typedef Col<s32> icolvec; typedef Col <s32> s32_colvec;
typedef Row<s32> irowvec; typedef Row <s32> s32_rowvec;
typedef Cube<s32> icube; typedef Cube<s32> s32_cube;
typedef Mat<float> fmat; typedef Mat <uword> umat;
typedef Col<float> fvec; typedef Col <uword> uvec;
typedef Col<float> fcolvec; typedef Col <uword> ucolvec;
typedef Row<float> frowvec; typedef Row <uword> urowvec;
typedef Cube<uword> ucube;
typedef Mat <sword> imat;
typedef Col <sword> ivec;
typedef Col <sword> icolvec;
typedef Row <sword> irowvec;
typedef Cube<sword> icube;
typedef Mat <float> fmat;
typedef Col <float> fvec;
typedef Col <float> fcolvec;
typedef Row <float> frowvec;
typedef Cube<float> fcube; typedef Cube<float> fcube;
typedef Mat<double> mat; typedef Mat <double> mat;
typedef Col<double> vec; typedef Col <double> vec;
typedef Col<double> colvec; typedef Col <double> colvec;
typedef Row<double> rowvec; typedef Row <double> rowvec;
typedef Cube<double> cube; typedef Cube<double> cube;
typedef Mat<cx_float> cx_fmat; typedef Mat <cx_float> cx_fmat;
typedef Col<cx_float> cx_fvec; typedef Col <cx_float> cx_fvec;
typedef Col<cx_float> cx_fcolvec; typedef Col <cx_float> cx_fcolvec;
typedef Row<cx_float> cx_frowvec; typedef Row <cx_float> cx_frowvec;
typedef Cube<cx_float> cx_fcube; typedef Cube<cx_float> cx_fcube;
typedef Mat<cx_double> cx_mat; typedef Mat <cx_double> cx_mat;
typedef Col<cx_double> cx_vec; typedef Col <cx_double> cx_vec;
typedef Col<cx_double> cx_colvec; typedef Col <cx_double> cx_colvec;
typedef Row<cx_double> cx_rowvec; typedef Row <cx_double> cx_rowvec;
typedef Cube<cx_double> cx_cube; typedef Cube<cx_double> cx_cube;
typedef void* void_ptr; typedef void* void_ptr;
namespace junk namespace junk
{ {
struct arma_elem_size_test struct arma_elem_size_test
{ {
arma_static_assert<sizeof(u8) == 1> ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZ arma_static_check( (sizeof(u8) != 1), ERROR___TYPE_U8_HAS_UNSUPPORTED_S
E; IZE );
arma_static_assert<sizeof(s8) == 1> ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZ arma_static_check( (sizeof(s8) != 1), ERROR___TYPE_S8_HAS_UNSUPPORTED_S
E; IZE );
arma_static_check( (sizeof(u16) != 2), ERROR___TYPE_U16_HAS_UNSUPPORTED
_SIZE );
arma_static_check( (sizeof(s16) != 2), ERROR___TYPE_S16_HAS_UNSUPPORTED
_SIZE );
arma_static_assert<sizeof(u16) == 2> ERROR___TYPE_U16_HAS_UNSUPPORTED_S arma_static_check( (sizeof(u32) != 4), ERROR___TYPE_U32_HAS_UNSUPPORTED
IZE; _SIZE );
arma_static_assert<sizeof(s16) == 2> ERROR___TYPE_S16_HAS_UNSUPPORTED_S arma_static_check( (sizeof(s32) != 4), ERROR___TYPE_S32_HAS_UNSUPPORTED
IZE; _SIZE );
arma_static_assert<sizeof(u32) == 4> ERROR___TYPE_U32_HAS_UNSUPPORTED_S #if defined(ARMA_64BIT_WORD)
IZE; arma_static_check( (sizeof(u64) != 8), ERROR___TYPE_U64_HAS_UNSUPPORTED
arma_static_assert<sizeof(s32) == 4> ERROR___TYPE_S32_HAS_UNSUPPORTED_S _SIZE );
IZE; arma_static_check( (sizeof(s64) != 8), ERROR___TYPE_S64_HAS_UNSUPPORTED
_SIZE );
#endif
arma_static_assert<sizeof(float) == 4> ERROR___TYPE_FLOAT_HAS_UNSUPPOR arma_static_check( (sizeof(float) != 4), ERROR___TYPE_FLOAT_HAS_UNSUPP
TED_SIZE; ORTED_SIZE );
arma_static_assert<sizeof(double) == 8> ERROR___TYPE_DOUBLE_HAS_UNSUPPO arma_static_check( (sizeof(double) != 8), ERROR___TYPE_DOUBLE_HAS_UNSUP
RTED_SIZE; PORTED_SIZE );
arma_static_assert<sizeof(std::complex<float>) == 8> ERROR___TYPE_COM arma_static_check( (sizeof(std::complex<float>) != 8), ERROR___TYPE_C
PLEX_FLOAT_HAS_UNSUPPORTED_SIZE; OMPLEX_FLOAT_HAS_UNSUPPORTED_SIZE );
arma_static_assert<sizeof(std::complex<double>) == 16> ERROR___TYPE_COM arma_static_check( (sizeof(std::complex<double>) != 16), ERROR___TYPE_C
PLEX_DOUBLE_HAS_UNSUPPORTED_SIZE; OMPLEX_DOUBLE_HAS_UNSUPPORTED_SIZE );
}; };
} }
//! @} //! @}
 End of changes. 18 change blocks. 
63 lines changed or deleted 115 lines changed or added


 undefine_conflicts.hpp   undefine_conflicts.hpp 
skipping to change at line 22 skipping to change at line 22
#if defined(log2) #if defined(log2)
#undef log2 #undef log2
#if defined(__GNUG__) #if defined(__GNUG__)
#warning "detected 'log2' macro and undefined it" #warning "detected 'log2' macro and undefined it"
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#pragma message ("detected 'log2' macro and undefined it") #pragma message ("detected 'log2' macro and undefined it")
#endif #endif
#endif #endif
//
// whoever defined macros with the names "min" and "max" should be permanen
tly removed from the gene pool
#if defined(min)
#undef min
#if defined(__GNUG__)
#warning "detected 'min' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header"
#elif defined(_MSC_VER)
#pragma message ("detected 'min' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header")
#endif
#endif
#if defined(max)
#undef max
#if defined(__GNUG__)
#warning "detected 'max' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header"
#elif defined(_MSC_VER)
#pragma message ("detected 'max' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header")
#endif
#endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added


 unwrap_cube.hpp   unwrap_cube.hpp 
skipping to change at line 63 skipping to change at line 63
class unwrap_cube_check class unwrap_cube_check
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
unwrap_cube_check(const T1& A, const Cube<eT>& B) unwrap_cube_check(const T1& A, const Cube<eT>& B)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_arma_cube_type<T1>::value == false >::apply(); arma_type_check(( is_arma_cube_type<T1>::value == false ));
} }
const Cube<eT> M; const Cube<eT> M;
}; };
template<typename eT> template<typename eT>
class unwrap_cube_check< Cube<eT> > class unwrap_cube_check< Cube<eT> >
{ {
public: public:
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/