Col_meat.hpp   Col_meat.hpp 
skipping to change at line 55 skipping to change at line 55
//! 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)
: Mat<eT>(text) : Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
} }
//! construct a column vector from specified text //! construct a column vector from specified text
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const char* text) Col<eT>::operator=(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
return *this;
}
//! construct a column vector from specified text
template<typename eT>
inline
Col<eT>::Col(const std::string& text)
: Mat<eT>(text)
{
arma_extra_debug_sigprint();
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! construct a column vector from specified text
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator=(const std::string& text)
{
arma_extra_debug_sigprint();
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) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
//! construct a column vector from a given column vector //! construct a column vector from a given column vector
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const Col<eT>& X) Col<eT>::Col(const Col<eT>& X)
: Mat<eT>(X) : Mat<eT>(X)
skipping to change at line 91 skipping to change at line 124
//! construct a column vector from a given column vector //! construct a column vector from a given column vector
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const Col<eT>& X) Col<eT>::operator=(const Col<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
return *this; return *this;
} }
//! construct a column vector from a given matrix; the matrix must have exa ctly one column //! construct a column vector from a given matrix; the matrix must have exa ctly one column
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const Mat<eT>& X) Col<eT>::Col(const Mat<eT>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 114 skipping to change at line 148
//! construct a column vector from a given matrix; the matrix must have exa ctly one column //! construct a column vector from a given matrix; the matrix must have exa ctly one column
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const Mat<eT>& X) Col<eT>::operator=(const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator*=(const Mat<eT>& X) Col<eT>::operator*=(const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
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_n_rows, const u32 aux_n_cols, const bool copy_aux_mem) Col<eT>::Col(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const bool copy_aux_mem)
: Mat<eT>(aux_mem, aux_n_rows, aux_n_cols, copy_aux_mem) : Mat<eT>(aux_mem, aux_n_rows, aux_n_cols, copy_aux_mem)
skipping to change at line 219 skipping to change at line 255
//! construct a column vector from given a submatrix; the submatrix must ha ve exactly one column //! construct a column vector from given a submatrix; the submatrix must ha ve exactly one column
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const subview<eT>& X) Col<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator*=(const subview<eT>& X) Col<eT>::operator*=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
return *this;
}
//! construct a column vector from given a subcube; the subcube must have e
xactly one column
template<typename eT>
inline
Col<eT>::Col(const subview_cube<eT>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! construct a column vector from given a subcube; the subcube must have e
xactly one column
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
return *this;
}
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator*=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
//! construct a column vector from given a diagview //! construct a column vector from given a diagview
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const diagview<eT>& X) Col<eT>::Col(const diagview<eT>& X)
: Mat<eT>(X) : Mat<eT>(X)
skipping to change at line 257 skipping to change at line 335
//! construct a column vector from given a diagview //! construct a column vector from given a diagview
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const diagview<eT>& X) Col<eT>::operator=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator*=(const diagview<eT>& X) Col<eT>::operator*=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT>
arma_inline
eT&
Col<eT>::row(const u32 row_num)
{
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound
s" );
return access::rw(Mat<eT>::mem[row_num]);
}
template<typename eT>
arma_inline
eT
Col<eT>::row(const u32 row_num)
const
{
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound
s" );
return Mat<eT>::mem[row_num];
}
template<typename eT>
arma_inline
subview_col<eT>
Col<eT>::rows(const u32 in_row1, const u32 in_row2)
{
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) )
, "Col::rows(): indices out of bounds or incorrectly used");
return subview_col<eT>(*this, 0, in_row1, in_row2);
}
template<typename eT>
arma_inline
const subview_col<eT>
Col<eT>::rows(const u32 in_row1, const u32 in_row2)
const
{
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) )
, "Col::rows(): indices out of bounds or incorrectly used");
return subview_col<eT>(*this, 0, in_row1, in_row2);
}
//! construct a column vector from Op, i.e. run the previously delayed oper ations; the result of the operations must have exactly one column //! construct a column vector from Op, i.e. run the previously delayed oper ations; the result of the operations must have exactly one column
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Col<eT>::Col(const Op<T1, op_type>& X) Col<eT>::Col(const Op<T1, op_type>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
skipping to change at line 308 skipping to change at line 432
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator*=(const Op<T1, op_type>& X) Col<eT>::operator*=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col::operator=(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col::operator=(): incompatible dimensions" );
return *this; return *this;
} }
//! construct a column vector from Glue, i.e. run the previously delayed op erations; the result of the operations must have exactly one column //! construct a column vector from Glue, i.e. run the previously delayed op erations; the result of the operations must have exactly one column
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Col<eT>::Col(const Glue<T1, T2, glue_type>& X) Col<eT>::Col(const Glue<T1, T2, glue_type>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
skipping to change at line 334 skipping to change at line 460
//! construct a column vector from Glue, i.e. run the previously delayed op erations; the result of the operations must have exactly one column //! construct a column vector from Glue, i.e. run the previously delayed op erations; the result of the operations must have exactly one column
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 Col<eT>& const Col<eT>&
Col<eT>::operator=(const Glue<T1, T2, glue_type>& X) Col<eT>::operator=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
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 Col<eT>& const Col<eT>&
Col<eT>::operator*=(const Glue<T1, T2, glue_type>& X) Col<eT>::operator*=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
//! change the number of n_rows //! change the number of rows
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::set_size(const u32 in_n_elem) Col<eT>::set_size(const u32 in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::set_size(in_n_elem,1); Mat<eT>::set_size(in_n_elem,1);
} }
//! change the number of n_rows (this function re-implements mat::set_size () in order to check the number of columns) //! change the number of rows (this function re-implements mat::set_size() in order to check the number of columns)
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min() is used in case in_n_cols is zero
Mat<eT>::set_size( in_n_rows, (std::min)( u32(1), in_n_cols ) ); Mat<eT>::set_size( in_n_rows, (std::min)( u32(1), in_n_cols ) );
arma_debug_check( (in_n_cols > 1), "Col::set_size(): incompatible dimensi ons" ); arma_debug_check( (in_n_cols > 1), "Col::set_size(): incompatible dimensi ons" );
} }
//! change the number of n_rows (this function re-implements mat::copy_siz e() in order to check the number of columns) //! change the number of rows (this function re-implements mat::copy_size( ) in order to check the number of columns)
template<typename eT> template<typename eT>
template<typename eT2>
inline inline
void void
Col<eT>::copy_size(const Mat<eT>& x) Col<eT>::copy_size(const Mat<eT2>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min() is used in case x.n_cols is zero
Mat<eT>::set_size( x.n_rows, (std::min)( u32(1), x.n_cols ) ); Mat<eT>::set_size( x.n_rows, (std::min)( u32(1), x.n_cols ) );
arma_debug_check( (x.n_cols > 1), "Col::copy_size(): incompatible dimensi ons" ); arma_debug_check( (x.n_cols > 1), "Col::copy_size(): incompatible dimensi ons" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::zeros() Col<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 415 skipping to change at line 548
Mat<eT>::zeros(in_n_elem, 1); Mat<eT>::zeros(in_n_elem, 1);
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min() is used in case in_n_cols is zero
Mat<eT>::zeros( in_n_rows, (std::min)( u32(1), in_n_cols ) ); Mat<eT>::zeros( in_n_rows, (std::min)( u32(1), in_n_cols ) );
arma_debug_check( (in_n_cols > 1), "Col::zeros(): incompatible dimensions " ); arma_debug_check( (in_n_cols > 1), "Col::zeros(): incompatible dimensions " );
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::ones() Col<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 446 skipping to change at line 581
Mat<eT>::ones(in_n_elem, 1); Mat<eT>::ones(in_n_elem, 1);
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::ones(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::ones(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min() is used in case in_n_cols is zero
Mat<eT>::ones( in_n_rows, (std::min)( u32(1), in_n_cols ) ); Mat<eT>::ones( in_n_rows, (std::min)( u32(1), in_n_cols ) );
arma_debug_check( (in_n_cols > 1), "Col::ones(): incompatible dimensions" ); arma_debug_check( (in_n_cols > 1), "Col::ones(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::load(const std::string name, const file_type type) Col<eT>::load(const std::string name, const file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(name,type); Mat<eT>::load(name,type);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
} }
//! @} //! @}
 End of changes. 31 change blocks. 
4 lines changed or deleted 153 lines changed or added


 Col_proto.hpp   Col_proto.hpp 
skipping to change at line 32 skipping to change at line 32
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
inline Col(); inline Col();
inline explicit Col(const u32 n_elem); inline explicit Col(const u32 n_elem);
inline Col(const u32 in_rows, const u32 in_cols); inline Col(const u32 in_rows, const u32 in_cols);
inline Col(const char* text); inline Col(const char* text);
inline const Col& operator=(const char* text); // TODO: std::string i inline const Col& operator=(const char* text);
nput inline Col(const std::string& text);
inline const Col& operator=(const std::string& text);
inline Col(const Col& X); inline Col(const Col& X);
inline const Col& operator=(const Col& X); inline const Col& operator=(const Col& X);
//inline explicit Col(const Mat<eT>& X); //inline explicit Col(const Mat<eT>& X);
inline Col(const Mat<eT>& X); inline Col(const Mat<eT>& X);
inline const Col& operator=(const Mat<eT>& X); inline const Col& operator=(const Mat<eT>& X);
inline const Col& operator*=(const Mat<eT>& X); inline const Col& operator*=(const Mat<eT>& X);
inline Col( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const bool copy_aux_mem = true); inline Col( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const bool copy_aux_mem = true);
skipping to change at line 56 skipping to change at line 58
inline Col( eT* aux_mem, const u32 aux_length, const bool copy_aux_m em = true); inline Col( eT* aux_mem, const u32 aux_length, const bool copy_aux_m em = true);
inline Col(const eT* aux_mem, const u32 aux_length); inline Col(const eT* aux_mem, const u32 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);
inline Col(const subview<eT>& X); inline Col(const subview<eT>& X);
inline const Col& operator=(const subview<eT>& X); inline const Col& operator=(const subview<eT>& X);
inline const Col& operator*=(const subview<eT>& X); inline const Col& operator*=(const subview<eT>& X);
// TODO: handling of subview_cube 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 Col(const diagview<eT>& X); inline Col(const diagview<eT>& X);
inline const Col& operator=(const diagview<eT>& X); inline const Col& operator=(const diagview<eT>& X);
inline const Col& operator*=(const diagview<eT>& X); inline const Col& operator*=(const diagview<eT>& X);
arma_inline eT& row(const u32 row_num);
arma_inline eT row(const u32 row_num) const;
arma_inline subview_col<eT> rows(const u32 in_row1, const u32 in_ro
w2);
arma_inline const subview_col<eT> rows(const u32 in_row1, const u32 in_ro
w2) const;
template<typename T1, typename op_type> inline Col(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline Col(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Col& operator=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Col& operator=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Col& operator*=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Col& operator*=(cons t Op<T1, op_type>& X);
template<typename T1, typename T2, typename glue_type> inline Col(const Glue<T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline Col(const Glue<T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Col& operator=(const Glue<T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Col& operator=(const Glue<T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Col& operator*=(const Glue<T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Col& operator*=(const Glue<T1, T2, glue_type>& X);
inline void set_size(const u32 n_elem); inline void set_size(const u32 n_elem);
inline void set_size(const u32 n_rows, const u32 n_cols); inline void set_size(const u32 n_rows, const u32 n_cols);
inline void copy_size(const Mat<eT>& x);
template<typename eT2>
inline void copy_size(const Mat<eT2>& m);
inline void zeros(); inline void zeros();
inline void zeros(const u32 n_elem); inline void zeros(const u32 n_elem);
inline void zeros(const u32 n_rows, const u32 n_cols); inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones(); inline void ones();
inline void ones(const u32 n_elem); inline void ones(const u32 n_elem);
inline void ones(const u32 n_rows, const u32 n_cols); inline void ones(const u32 n_rows, const u32 n_cols);
inline void load(const std::string name, const file_type type = auto_dete ct); inline void load(const std::string name, const file_type type = auto_dete ct);
 End of changes. 4 change blocks. 
5 lines changed or deleted 18 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 639 skipping to change at line 639
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"
); );
return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, in_row2, in_c ol2, in_slice2); return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, in_row2, in_c ol2, in_slice2);
} }
//! create a matrix from Op, i.e. run the previously delayed unary operatio ns //! 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_cube_type> template<typename T1, typename op_cube_type>
inline inline
Cube<eT>::Cube(const OpCube<T1, op_cube_type>& X) Cube<eT>::Cube(const OpCube<T1, op_cube_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)
, use_aux_mem(false) , use_aux_mem(false)
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 Glue_meat.hpp   Glue_meat.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 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();
isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check();
}
template<typename T1, typename T2, typename glue_type>
inline
Glue<T1,T2,glue_type>::Glue(const T1& in_A, const T2& in_B, const u32 in_au
x_u32)
: A(in_A)
, B(in_B)
, aux_u32(in_aux_u32)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check();
} }
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()
{ {
 End of changes. 1 change blocks. 
0 lines changed or deleted 14 lines changed or added


 Glue_proto.hpp   Glue_proto.hpp 
skipping to change at line 41 skipping to change at line 41
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>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type 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(); 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
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
3 lines changed or deleted 4 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 1477 skipping to change at line 1477
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
eam),
//! optionally preceding with a user specified line of text.
//! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values.
template<typename eT>
inline
void
Mat<eT>::print_trans(const std::string extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this);
tmp.print(extra_text);
}
//! print contents of the transposed version of matrix to a user specified
stream,
//! optionally preceding with a user specified line of text.
//! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values.
template<typename eT>
inline
void
Mat<eT>::print_trans(std::ostream& user_stream, const std::string extra_tex
t) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this);
tmp.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 flags are used as is and are not modified //! the stream's flags 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>::raw_print(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1523 skipping to change at line 1557
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
eam),
//! optionally preceding with a user specified line of text.
//! the stream's flags are used as is and are not modified
//! (i.e. the precision and cell width are not modified).
template<typename eT>
inline
void
Mat<eT>::raw_print_trans(const std::string extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this);
tmp.raw_print(extra_text);
}
//! print contents of the transposed version of the matrix to a user specif
ied stream,
//! optionally preceding with a user specified line of text.
//! the stream's flags are used as is and are not modified.
//! (i.e. the precision and cell width are not modified).
template<typename eT>
inline
void
Mat<eT>::raw_print_trans(std::ostream& user_stream, const std::string extra
_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this);
tmp.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_n_rows, const u32 in_n_cols) Mat<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(in_n_rows, in_n_cols); init(in_n_rows, in_n_cols);
} }
 End of changes. 2 change blocks. 
0 lines changed or deleted 74 lines changed or added


 Mat_proto.hpp   Mat_proto.hpp 
skipping to change at line 48 skipping to change at line 48
protected: protected:
arma_aligned eT mem_local[ 16 ]; arma_aligned eT mem_local[ 16 ];
public: public:
inline ~Mat(); inline ~Mat();
inline Mat(); inline Mat();
inline Mat(const u32 in_rows, const u32 in_cols); inline Mat(const u32 in_rows, const u32 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, const bool copy_aux_mem = true); inline Mat( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const bool copy_aux_mem = true);
inline Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) ; inline Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) ;
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);
skipping to change at line 160 skipping to change at line 160
arma_inline eT* colptr(const u32 in_col); arma_inline eT* colptr(const u32 in_col);
arma_inline const eT* colptr(const u32 in_col) const; arma_inline const eT* colptr(const u32 in_col) const;
arma_inline eT* memptr(); arma_inline eT* memptr();
arma_inline const eT* memptr() const; arma_inline const eT* memptr() 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 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(const std::string extra_text = "") const;
inline void raw_print(std::ostream& user_stream, const std::string extra_ text = "") const; inline void raw_print(std::ostream& user_stream, const std::string extra_ text = "") const;
inline void set_size(const u32 in_rows, const u32 in_cols); 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;
template<typename eT2> inline void copy_size(const Mat<eT2>& m); template<typename eT2>
inline void copy_size(const Mat<eT2>& m);
inline void set_size(const u32 in_rows, const u32 in_cols);
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const u32 in_rows, const u32 in_cols); inline void zeros(const u32 in_rows, const u32 in_cols);
inline void ones(); inline void ones();
inline void ones(const u32 in_rows, const u32 in_cols); inline void ones(const u32 in_rows, const u32 in_cols);
inline void reset(); inline void reset();
 End of changes. 4 change blocks. 
4 lines changed or deleted 13 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 62 skipping to change at line 62
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const char* text) Row<eT>::operator=(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
return *this;
}
template<typename eT>
inline
Row<eT>::Row(const std::string& text)
: Mat<eT>(text)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator=(const std::string& text)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(text);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const Row<eT>& X) Row<eT>::Row(const Row<eT>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
skipping to change at line 86 skipping to change at line 112
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const Row<eT>& X) Row<eT>::operator=(const Row<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline Row<eT>::Row(const Mat<eT>& X) inline
Row<eT>::Row(const Mat<eT>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
skipping to change at line 201 skipping to change at line 228
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const subview<eT>& X) Row<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator*=(const subview<eT>& X) Row<eT>::operator*=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
return *this;
}
template<typename eT>
inline
Row<eT>::Row(const subview_cube<eT>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
return *this;
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator*=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
//! construct a row vector from given a diagview //! construct a row vector from given a diagview
template<typename eT> template<typename eT>
inline Row<eT>::Row(const diagview<eT>& X) inline
Row<eT>::Row(const diagview<eT>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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) );
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
//! construct a row vector from given a diagview //! construct a row vector from given a diagview
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const diagview<eT>& X) Row<eT>::operator=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 259 skipping to change at line 330
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
arma_inline
eT&
Row<eT>::col(const u32 col_num)
{
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound
s" );
return access::rw(Mat<eT>::mem[col_num]);
}
template<typename eT>
arma_inline
eT
Row<eT>::col(const u32 col_num)
const
{
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound
s" );
return Mat<eT>::mem[col_num];
}
template<typename eT>
arma_inline
subview_row<eT>
Row<eT>::cols(const u32 in_col1, const u32 in_col2)
{
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) )
, "Row::cols(): indices out of bounds or incorrectly used");
return subview_row<eT>(*this, 0, in_col1, in_col2);
}
template<typename eT>
arma_inline
const subview_row<eT>
Row<eT>::cols(const u32 in_col1, const u32 in_col2)
const
{
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) )
, "Row::cols(): indices out of bounds or incorrectly used");
return subview_row<eT>(*this, 0, in_col1, in_col2);
}
template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Row<eT>::Row(const Op<T1, op_type>& X) Row<eT>::Row(const Op<T1, op_type>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const Op<T1, op_type>& X) Row<eT>::operator=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator*=(const Op<T1, op_type>& X) Row<eT>::operator*=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Row<eT>::Row(const Glue<T1, T2, glue_type>& X) Row<eT>::Row(const Glue<T1, T2, glue_type>& X)
: Mat<eT>(X) : Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 315 skipping to change at line 432
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 Row<eT>& const Row<eT>&
Row<eT>::operator=(const Glue<T1, T2, glue_type>& X) Row<eT>::operator=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
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 Row<eT>& const Row<eT>&
Row<eT>::operator*=(const Glue<T1, T2, glue_type>& X) Row<eT>::operator*=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::set_size(const u32 in_n_elem) Row<eT>::set_size(const u32 in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::set_size(1,in_n_elem); Mat<eT>::set_size(1,in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min is used in case in_n_rows is zero
Mat<eT>::set_size( (std::min)( u32(1), in_n_rows), in_n_cols ); Mat<eT>::set_size( (std::min)( u32(1), in_n_rows), in_n_cols );
arma_debug_check( (in_n_rows > 1), "Row::set_size(): incompatible dimensi ons" ); arma_debug_check( (in_n_rows > 1), "Row::set_size(): incompatible dimensi ons" );
} }
template<typename eT> template<typename eT>
template<typename eT2>
inline inline
void void
Row<eT>::copy_size(const Mat<eT>& x) Row<eT>::copy_size(const Mat<eT2>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min is used in case x.n_rows is zero
Mat<eT>::set_size( (std::min)( u32(1), x.n_rows), x.n_cols ); Mat<eT>::set_size( (std::min)( u32(1), x.n_rows), x.n_cols );
arma_debug_check( (x.n_rows > 1), "Row::copy_size(): incompatible dimensi ons" ); arma_debug_check( (x.n_rows > 1), "Row::copy_size(): incompatible dimensi ons" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::zeros() Row<eT>::zeros()
{ {
skipping to change at line 393 skipping to change at line 517
Mat<eT>::zeros(1, in_n_elem); Mat<eT>::zeros(1, in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min is used in case in_n_rows is zero
Mat<eT>::zeros( (std::min)( u32(1), in_n_rows), in_n_cols ); Mat<eT>::zeros( (std::min)( u32(1), in_n_rows), in_n_cols );
arma_debug_check( (in_n_rows > 1), "Row<eT>::zeros(): incompatible dimens ions" ); arma_debug_check( (in_n_rows > 1), "Row<eT>::zeros(): incompatible dimens ions" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::ones() Row<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 424 skipping to change at line 550
Mat<eT>::ones(1, in_n_elem); Mat<eT>::ones(1, in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::ones(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::ones(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// min is used in case in_n_rows is zero
Mat<eT>::ones( (std::min)( u32(1), in_n_rows), in_n_cols ); Mat<eT>::ones( (std::min)( u32(1), in_n_rows), in_n_cols );
arma_debug_check( (in_n_rows > 1), "Row<eT>::ones(): incompatible dimensi ons" ); arma_debug_check( (in_n_rows > 1), "Row<eT>::ones(): incompatible dimensi ons" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::load(const std::string name, const file_type type) Row<eT>::load(const std::string name, const file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(name,type); Mat<eT>::load(name,type);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
//! @} //! @}
 End of changes. 27 change blocks. 
3 lines changed or deleted 141 lines changed or added


 Row_proto.hpp   Row_proto.hpp 
skipping to change at line 32 skipping to change at line 32
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
inline Row(); inline Row();
inline explicit Row(const u32 N); inline explicit Row(const u32 N);
inline Row(const u32 in_rows, const u32 in_cols); inline Row(const u32 in_rows, const u32 in_cols);
inline Row(const char* text); inline Row(const char* text);
inline const Row& operator=(const char* text); // TODO: std::string i inline const Row& operator=(const char* text);
nput inline Row(const std::string& text);
inline const Row& operator=(const std::string& text);
inline Row(const Row& X); inline Row(const Row& X);
inline const Row& operator=(const Row& X); inline const Row& operator=(const Row& X);
inline const Row& operator*=(const Row& X); inline const Row& operator*=(const Row& X);
//inline explicit Row(const Mat<eT>& X); //inline explicit Row(const Mat<eT>& X);
inline Row(const Mat<eT>& X); inline Row(const Mat<eT>& X);
inline const Row& operator=(const Mat<eT>& X); inline const Row& operator=(const Mat<eT>& X);
inline const Row& operator*=(const Mat<eT>& X); inline const Row& operator*=(const Mat<eT>& X);
skipping to change at line 57 skipping to change at line 59
inline Row( eT* aux_mem, const u32 aux_length, const bool copy_aux_m em = true); inline Row( eT* aux_mem, const u32 aux_length, const bool copy_aux_m em = true);
inline Row(const eT* aux_mem, const u32 aux_length); inline Row(const eT* aux_mem, const u32 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);
inline Row(const subview<eT>& X); inline Row(const subview<eT>& X);
inline const Row& operator=(const subview<eT>& X); inline const Row& operator=(const subview<eT>& X);
inline const Row& operator*=(const subview<eT>& X); inline const Row& operator*=(const subview<eT>& X);
// TODO: handling of subview_cube 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 explicit Row(const diagview<eT>& X); inline explicit Row(const diagview<eT>& X);
inline const Row& operator=(const diagview<eT>& X); inline const Row& operator=(const diagview<eT>& X);
inline const Row& operator*=(const diagview<eT>& X); inline const Row& operator*=(const diagview<eT>& X);
arma_inline eT& col(const u32 col_num);
arma_inline eT col(const u32 col_num) const;
arma_inline subview_row<eT> cols(const u32 in_col1, const u32 in_co
l2);
arma_inline const subview_row<eT> cols(const u32 in_col1, const u32 in_co
l2) const;
template<typename T1, typename op_type> inline Row(cons t Op<T1, op_type> &X); template<typename T1, typename op_type> inline Row(cons t Op<T1, op_type> &X);
template<typename T1, typename op_type> inline const Row& operator=(cons t Op<T1, op_type> &X); template<typename T1, typename op_type> inline const Row& operator=(cons t Op<T1, op_type> &X);
template<typename T1, typename op_type> inline const Row& operator*=(cons t Op<T1, op_type> &X); template<typename T1, typename op_type> inline const Row& operator*=(cons t Op<T1, op_type> &X);
template<typename T1, typename T2, typename glue_type> inline Row(const Glue<T1, T2, glue_type> &X); template<typename T1, typename T2, typename glue_type> inline Row(const Glue<T1, T2, glue_type> &X);
template<typename T1, typename T2, typename glue_type> inline const Row& operator=(const Glue<T1, T2, glue_type> &X); template<typename T1, typename T2, typename glue_type> inline const Row& operator=(const Glue<T1, T2, glue_type> &X);
template<typename T1, typename T2, typename glue_type> inline const Row& operator*=(const Glue<T1, T2, glue_type> &X); template<typename T1, typename T2, typename glue_type> inline const Row& operator*=(const Glue<T1, T2, glue_type> &X);
inline void set_size(const u32 N); inline void set_size(const u32 N);
inline void set_size(const u32 n_rows, const u32 n_cols); inline void set_size(const u32 n_rows, const u32 n_cols);
inline void copy_size(const Mat<eT>& x);
template<typename eT2>
inline void copy_size(const Mat<eT2>& m);
inline void zeros(); inline void zeros();
inline void zeros(const u32 N); inline void zeros(const u32 N);
inline void zeros(const u32 n_rows, const u32 n_cols); inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones(); inline void ones();
inline void ones(const u32 N); inline void ones(const u32 N);
inline void ones(const u32 n_rows, const u32 n_cols); inline void ones(const u32 n_rows, const u32 n_cols);
inline void load(const std::string name, const file_type type = auto_dete ct); inline void load(const std::string name, const file_type type = auto_dete ct);
 End of changes. 4 change blocks. 
5 lines changed or deleted 18 lines changed or added


 armadillo   armadillo 
skipping to change at line 25 skipping to change at line 25
#ifndef ARMA_INCLUDES #ifndef ARMA_INCLUDES
#define ARMA_INCLUDES #define ARMA_INCLUDES
#define arma_hot #define arma_hot
#define arma_pure #define arma_pure
#define arma_const #define arma_const
#define arma_inline inline #define arma_inline inline
#define arma_aligned #define arma_aligned
#if defined(__GNUG__) #if defined(__GNUG__)
#if(__GNUC__ < 4)
#if (__GNUC__ < 4)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#if(__GNUC_MINOR__ >= 3)
#if (__GNUC_MINOR__ >= 3)
#undef arma_hot #undef arma_hot
#define arma_hot __attribute__((hot)) #define arma_hot __attribute__((hot))
#endif #endif
#undef arma_pure #undef arma_pure
#undef arma_const #undef arma_const
#undef arma_inline #undef arma_inline
#undef arma_aligned #undef arma_aligned
#define arma_pure __attribute__((pure)) #define arma_pure __attribute__((pure))
#define arma_const __attribute__((const)) #define arma_const __attribute__((const))
#define arma_inline inline __attribute__((always_inline)) #define arma_inline inline __attribute__((always_inline))
#define arma_aligned __attribute__((aligned)) #define arma_aligned __attribute__((aligned))
#define ARMA_GOOD_COMPILER
#elif defined(__INTEL_COMPILER) #elif defined(__INTEL_COMPILER)
#if(__INTEL_COMPILER < 1000)
#if (__INTEL_COMPILER < 1000)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#define ARMA_GOOD_COMPILER
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#if(_MSC_VER <= 1500)
#error "*** This compiler is not supported due to its incomplete implem #pragma message ("*** WARNING: This compiler may have an incomplete imple
entation of the C++ standard -- please try the gcc, mingw-gcc or intel comp mentation of the C++ standard ***")
ilers instead ***" #undef ARMA_GOOD_COMPILER
#else
#pragma message ("*** WARNING: This compiler may have an incomplete imp
lementation of the C++ standard ***")
#endif
#endif #endif
#include "armadillo_bits/config.hpp" #include "armadillo_bits/config.hpp"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <climits> #include <climits>
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
skipping to change at line 149 skipping to change at line 157
#include "armadillo_bits/field_proto.hpp" #include "armadillo_bits/field_proto.hpp"
#include "armadillo_bits/subview_proto.hpp" #include "armadillo_bits/subview_proto.hpp"
#include "armadillo_bits/subview_field_proto.hpp" #include "armadillo_bits/subview_field_proto.hpp"
#include "armadillo_bits/subview_cube_proto.hpp" #include "armadillo_bits/subview_cube_proto.hpp"
#include "armadillo_bits/diagview_proto.hpp" #include "armadillo_bits/diagview_proto.hpp"
#include "armadillo_bits/diskio_proto.hpp" #include "armadillo_bits/diskio_proto.hpp"
#include "armadillo_bits/wall_clock_proto.hpp" #include "armadillo_bits/wall_clock_proto.hpp"
#include "armadillo_bits/running_stat_proto.hpp" #include "armadillo_bits/running_stat_proto.hpp"
#include "armadillo_bits/running_stat_vec_proto.hpp"
#include "armadillo_bits/Op_proto.hpp" #include "armadillo_bits/Op_proto.hpp"
#include "armadillo_bits/OpCube_proto.hpp" #include "armadillo_bits/OpCube_proto.hpp"
#include "armadillo_bits/Glue_proto.hpp" #include "armadillo_bits/Glue_proto.hpp"
#include "armadillo_bits/GlueCube_proto.hpp" #include "armadillo_bits/GlueCube_proto.hpp"
#include "armadillo_bits/op_diagmat_proto.hpp" #include "armadillo_bits/op_diagmat_proto.hpp"
#include "armadillo_bits/op_dot_proto.hpp" #include "armadillo_bits/op_dot_proto.hpp"
#include "armadillo_bits/op_inv_proto.hpp" #include "armadillo_bits/op_inv_proto.hpp"
#include "armadillo_bits/op_htrans_proto.hpp" #include "armadillo_bits/op_htrans_proto.hpp"
skipping to change at line 180 skipping to change at line 189
#include "armadillo_bits/op_sum_proto.hpp" #include "armadillo_bits/op_sum_proto.hpp"
#include "armadillo_bits/op_stddev_proto.hpp" #include "armadillo_bits/op_stddev_proto.hpp"
#include "armadillo_bits/op_trig_proto.hpp" #include "armadillo_bits/op_trig_proto.hpp"
#include "armadillo_bits/op_trans_proto.hpp" #include "armadillo_bits/op_trans_proto.hpp"
#include "armadillo_bits/op_var_proto.hpp" #include "armadillo_bits/op_var_proto.hpp"
#include "armadillo_bits/op_zeros_proto.hpp" #include "armadillo_bits/op_zeros_proto.hpp"
#include "armadillo_bits/op_repmat_proto.hpp" #include "armadillo_bits/op_repmat_proto.hpp"
#include "armadillo_bits/op_reshape_proto.hpp" #include "armadillo_bits/op_reshape_proto.hpp"
#include "armadillo_bits/op_cov_proto.hpp" #include "armadillo_bits/op_cov_proto.hpp"
#include "armadillo_bits/op_cor_proto.hpp" #include "armadillo_bits/op_cor_proto.hpp"
#include "armadillo_bits/op_shuffle_proto.hpp"
#include "armadillo_bits/op_prod_proto.hpp"
#include "armadillo_bits/op_eps_proto.hpp"
#include "armadillo_bits/op_pinv_proto.hpp"
#include "armadillo_bits/glue_plus_proto.hpp" #include "armadillo_bits/glue_plus_proto.hpp"
#include "armadillo_bits/glue_minus_proto.hpp" #include "armadillo_bits/glue_minus_proto.hpp"
#include "armadillo_bits/glue_times_proto.hpp" #include "armadillo_bits/glue_times_proto.hpp"
#include "armadillo_bits/glue_schur_proto.hpp" #include "armadillo_bits/glue_schur_proto.hpp"
#include "armadillo_bits/glue_div_proto.hpp" #include "armadillo_bits/glue_div_proto.hpp"
#include "armadillo_bits/glue_cov_proto.hpp" #include "armadillo_bits/glue_cov_proto.hpp"
#include "armadillo_bits/glue_cor_proto.hpp" #include "armadillo_bits/glue_cor_proto.hpp"
#include "armadillo_bits/glue_kron_proto.hpp"
#include "armadillo_bits/glue_cube_plus_proto.hpp" #include "armadillo_bits/glue_cube_plus_proto.hpp"
#include "armadillo_bits/glue_cube_minus_proto.hpp" #include "armadillo_bits/glue_cube_minus_proto.hpp"
#include "armadillo_bits/glue_cube_schur_proto.hpp" #include "armadillo_bits/glue_cube_schur_proto.hpp"
#include "armadillo_bits/glue_cube_div_proto.hpp" #include "armadillo_bits/glue_cube_div_proto.hpp"
// //
// debugging functions // debugging functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
skipping to change at line 243 skipping to change at line 257
#include "armadillo_bits/operator_cube_times.hpp" #include "armadillo_bits/operator_cube_times.hpp"
#include "armadillo_bits/operator_cube_schur.hpp" #include "armadillo_bits/operator_cube_schur.hpp"
#include "armadillo_bits/operator_cube_div.hpp" #include "armadillo_bits/operator_cube_div.hpp"
#include "armadillo_bits/operator_cube_relational.hpp" #include "armadillo_bits/operator_cube_relational.hpp"
#include "armadillo_bits/operator_ostream.hpp" #include "armadillo_bits/operator_ostream.hpp"
// //
// user accessible functions // user accessible functions
// the order of the fn_*.hpp include files matters,
// as some files require functionality given in preceding files
#include "armadillo_bits/fn_conv_to.hpp" #include "armadillo_bits/fn_conv_to.hpp"
#include "armadillo_bits/fn_min.hpp" #include "armadillo_bits/fn_min.hpp"
#include "armadillo_bits/fn_max.hpp" #include "armadillo_bits/fn_max.hpp"
#include "armadillo_bits/fn_accu.hpp" #include "armadillo_bits/fn_accu.hpp"
#include "armadillo_bits/fn_sum.hpp" #include "armadillo_bits/fn_sum.hpp"
#include "armadillo_bits/fn_diagmat.hpp" #include "armadillo_bits/fn_diagmat.hpp"
#include "armadillo_bits/fn_inv.hpp" #include "armadillo_bits/fn_inv.hpp"
#include "armadillo_bits/fn_trace.hpp" #include "armadillo_bits/fn_trace.hpp"
#include "armadillo_bits/fn_trans.hpp" #include "armadillo_bits/fn_trans.hpp"
#include "armadillo_bits/fn_det.hpp" #include "armadillo_bits/fn_det.hpp"
skipping to change at line 278 skipping to change at line 295
#include "armadillo_bits/fn_sort_index.hpp" #include "armadillo_bits/fn_sort_index.hpp"
#include "armadillo_bits/fn_htrans.hpp" #include "armadillo_bits/fn_htrans.hpp"
#include "armadillo_bits/fn_chol.hpp" #include "armadillo_bits/fn_chol.hpp"
#include "armadillo_bits/fn_qr.hpp" #include "armadillo_bits/fn_qr.hpp"
#include "armadillo_bits/fn_svd.hpp" #include "armadillo_bits/fn_svd.hpp"
#include "armadillo_bits/fn_solve.hpp" #include "armadillo_bits/fn_solve.hpp"
#include "armadillo_bits/fn_repmat.hpp" #include "armadillo_bits/fn_repmat.hpp"
#include "armadillo_bits/fn_reshape.hpp" #include "armadillo_bits/fn_reshape.hpp"
#include "armadillo_bits/fn_cov.hpp" #include "armadillo_bits/fn_cov.hpp"
#include "armadillo_bits/fn_cor.hpp" #include "armadillo_bits/fn_cor.hpp"
#include "armadillo_bits/fn_shuffle.hpp"
#include "armadillo_bits/fn_prod.hpp"
#include "armadillo_bits/fn_eps.hpp"
#include "armadillo_bits/fn_pinv.hpp"
#include "armadillo_bits/fn_rank.hpp"
#include "armadillo_bits/fn_kron.hpp"
// //
// class meat // class meat
#include "armadillo_bits/gemm.hpp" #include "armadillo_bits/gemm.hpp"
#include "armadillo_bits/gemv.hpp" #include "armadillo_bits/gemv.hpp"
#include "armadillo_bits/gemm_mixed.hpp" #include "armadillo_bits/gemm_mixed.hpp"
#include "armadillo_bits/podarray_meat.hpp" #include "armadillo_bits/podarray_meat.hpp"
#include "armadillo_bits/auxlib_meat.hpp" #include "armadillo_bits/auxlib_meat.hpp"
skipping to change at line 302 skipping to change at line 325
#include "armadillo_bits/Cube_meat.hpp" #include "armadillo_bits/Cube_meat.hpp"
#include "armadillo_bits/field_meat.hpp" #include "armadillo_bits/field_meat.hpp"
#include "armadillo_bits/subview_meat.hpp" #include "armadillo_bits/subview_meat.hpp"
#include "armadillo_bits/subview_field_meat.hpp" #include "armadillo_bits/subview_field_meat.hpp"
#include "armadillo_bits/subview_cube_meat.hpp" #include "armadillo_bits/subview_cube_meat.hpp"
#include "armadillo_bits/diagview_meat.hpp" #include "armadillo_bits/diagview_meat.hpp"
#include "armadillo_bits/diskio_meat.hpp" #include "armadillo_bits/diskio_meat.hpp"
#include "armadillo_bits/wall_clock_meat.hpp" #include "armadillo_bits/wall_clock_meat.hpp"
#include "armadillo_bits/running_stat_meat.hpp" #include "armadillo_bits/running_stat_meat.hpp"
#include "armadillo_bits/running_stat_vec_meat.hpp"
#include "armadillo_bits/op_diagmat_meat.hpp" #include "armadillo_bits/op_diagmat_meat.hpp"
#include "armadillo_bits/op_dot_meat.hpp" #include "armadillo_bits/op_dot_meat.hpp"
#include "armadillo_bits/op_inv_meat.hpp" #include "armadillo_bits/op_inv_meat.hpp"
#include "armadillo_bits/op_htrans_meat.hpp" #include "armadillo_bits/op_htrans_meat.hpp"
#include "armadillo_bits/op_misc_meat.hpp" #include "armadillo_bits/op_misc_meat.hpp"
#include "armadillo_bits/op_max_meat.hpp" #include "armadillo_bits/op_max_meat.hpp"
#include "armadillo_bits/op_min_meat.hpp" #include "armadillo_bits/op_min_meat.hpp"
#include "armadillo_bits/op_mean_meat.hpp" #include "armadillo_bits/op_mean_meat.hpp"
#include "armadillo_bits/op_median_meat.hpp" #include "armadillo_bits/op_median_meat.hpp"
skipping to change at line 328 skipping to change at line 352
#include "armadillo_bits/op_sum_meat.hpp" #include "armadillo_bits/op_sum_meat.hpp"
#include "armadillo_bits/op_stddev_meat.hpp" #include "armadillo_bits/op_stddev_meat.hpp"
#include "armadillo_bits/op_trans_meat.hpp" #include "armadillo_bits/op_trans_meat.hpp"
#include "armadillo_bits/op_trig_meat.hpp" #include "armadillo_bits/op_trig_meat.hpp"
#include "armadillo_bits/op_var_meat.hpp" #include "armadillo_bits/op_var_meat.hpp"
#include "armadillo_bits/op_zeros_meat.hpp" #include "armadillo_bits/op_zeros_meat.hpp"
#include "armadillo_bits/op_repmat_meat.hpp" #include "armadillo_bits/op_repmat_meat.hpp"
#include "armadillo_bits/op_reshape_meat.hpp" #include "armadillo_bits/op_reshape_meat.hpp"
#include "armadillo_bits/op_cov_meat.hpp" #include "armadillo_bits/op_cov_meat.hpp"
#include "armadillo_bits/op_cor_meat.hpp" #include "armadillo_bits/op_cor_meat.hpp"
#include "armadillo_bits/op_shuffle_meat.hpp"
#include "armadillo_bits/op_prod_meat.hpp"
#include "armadillo_bits/op_eps_meat.hpp"
#include "armadillo_bits/op_pinv_meat.hpp"
#include "armadillo_bits/glue_plus_meat.hpp" #include "armadillo_bits/glue_plus_meat.hpp"
#include "armadillo_bits/glue_minus_meat.hpp" #include "armadillo_bits/glue_minus_meat.hpp"
#include "armadillo_bits/glue_times_meat.hpp" #include "armadillo_bits/glue_times_meat.hpp"
#include "armadillo_bits/glue_schur_meat.hpp" #include "armadillo_bits/glue_schur_meat.hpp"
#include "armadillo_bits/glue_div_meat.hpp" #include "armadillo_bits/glue_div_meat.hpp"
#include "armadillo_bits/glue_cov_meat.hpp" #include "armadillo_bits/glue_cov_meat.hpp"
#include "armadillo_bits/glue_cor_meat.hpp" #include "armadillo_bits/glue_cor_meat.hpp"
#include "armadillo_bits/glue_kron_meat.hpp"
#include "armadillo_bits/glue_cube_plus_meat.hpp" #include "armadillo_bits/glue_cube_plus_meat.hpp"
#include "armadillo_bits/glue_cube_minus_meat.hpp" #include "armadillo_bits/glue_cube_minus_meat.hpp"
#include "armadillo_bits/glue_cube_schur_meat.hpp" #include "armadillo_bits/glue_cube_schur_meat.hpp"
#include "armadillo_bits/glue_cube_div_meat.hpp" #include "armadillo_bits/glue_cube_div_meat.hpp"
} }
#endif #endif
 End of changes. 14 change blocks. 
11 lines changed or deleted 38 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
skipping to change at line 511 skipping to change at line 511
} }
#endif #endif
} }
} }
} }
//! immediate LU decomposition of a matrix using ATLAS or LAPACK //! immediate LU decomposition of a matrix using ATLAS or LAPACK
template<typename eT> template<typename eT>
inline inline
void void
auxlib::lu(Mat<eT>& L, Mat<eT>& U, podarray<int>& ipiv, const Mat<eT>& X_or ig) auxlib::lu(Mat<eT>& L, Mat<eT>& U, podarray<int>& ipiv, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (&L == &U), "auxlib::lu(): L and U are the same object"
);
unwrap_check< Mat<eT> > tmp1(X_orig, U);
const Mat<eT>& X_tmp = tmp1.M;
unwrap_check< Mat<eT> > tmp2(X_tmp, L);
const Mat<eT>& X = tmp2.M;
U = X; U = X;
#if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK)
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
ipiv.set_size(U.n_rows); ipiv.set_size(U.n_rows);
//int info = //int info =
skipping to change at line 589 skipping to change at line 581
} }
template<typename eT> template<typename eT>
inline inline
void void
auxlib::lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Mat<eT>& X) auxlib::lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (&P == &L) || (&P == &U) ), "auxlib::lu(): P is the s
ame object as L or U" );
podarray<int> ipiv; podarray<int> ipiv;
auxlib::lu(L, U, ipiv, X); auxlib::lu(L, U, ipiv, X);
const u32 n = ipiv.n_elem; const u32 n = ipiv.n_elem;
Mat<u32> P_tmp(n,n); Mat<u32> P_tmp(n,n);
Mat<u32> ident = eye< Mat<u32> >(n,n); Mat<u32> ident = eye< Mat<u32> >(n,n);
for(u32 i=n; i>0; --i) for(u32 i=n; i>0; --i)
{ {
skipping to change at line 973 skipping to change at line 963
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::chol(Mat<eT>& out, const Mat<eT>& X) auxlib::chol(Mat<eT>& out, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// TODO: check for aliasing
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
char uplo = 'U'; char uplo = 'U';
int n = X.n_rows; int n = X.n_rows;
int lda = X.n_rows; int lda = X.n_rows;
int info; int info;
out = X; out = X;
lapack::potrf_(&uplo, &n, out.memptr(), &lda, &info); lapack::potrf_(&uplo, &n, out.memptr(), &lda, &info);
skipping to change at line 1011 skipping to change at line 999
#endif #endif
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Mat<eT>& X) auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// TODO: check for aliasing
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
int m = static_cast<int>(X.n_rows); int m = static_cast<int>(X.n_rows);
int n = static_cast<int>(X.n_cols); int n = static_cast<int>(X.n_cols);
int work_len = (std::max)(1,n); int work_len = (std::max)(1,n);
int work_len_tmp; int work_len_tmp;
int k = (std::min)(m,n); int k = (std::min)(m,n);
int info; int info;
podarray<eT> tau(k); podarray<eT> tau(k);
skipping to change at line 1039 skipping to change at line 1025
lapack::geqrf_(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wo rk_len_tmp, &info); lapack::geqrf_(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wo rk_len_tmp, &info);
if(info == 0) if(info == 0)
{ {
work_len = static_cast<int>(auxlib::tmp_real(work[0])); work_len = static_cast<int>(auxlib::tmp_real(work[0]));
work.set_size(work_len); work.set_size(work_len);
} }
lapack::geqrf_(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wo rk_len, &info); lapack::geqrf_(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wo rk_len, &info);
Q.set_size(X.n_rows,X.n_rows); Q.set_size(X.n_rows, X.n_rows);
eT* Q_mem = Q.memptr(); eT* Q_mem = Q.memptr();
const eT* R_mem = R.mem; const eT* R_mem = R.mem;
const u32 n_elem_copy = (std::min)(Q.n_elem, R.n_elem); const u32 n_elem_copy = (std::min)(Q.n_elem, R.n_elem);
for(u32 i=0; i < n_elem_copy; ++i) for(u32 i=0; i < n_elem_copy; ++i)
{ {
Q_mem[i] = R_mem[i]; Q_mem[i] = R_mem[i];
} }
skipping to change at line 1107 skipping to change at line 1093
#endif #endif
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::svd(Col<eT>& S, const Mat<eT>& X) auxlib::svd(Col<eT>& S, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// TODO: check for aliasing
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A = X; Mat<eT> A = X;
char jobu = 'N'; char jobu = 'N';
char jobvt = 'N'; char jobvt = 'N';
int m = A.n_rows; int m = A.n_rows;
int n = A.n_cols; int n = A.n_cols;
int lda = A.n_rows; int lda = A.n_rows;
skipping to change at line 1187 skipping to change at line 1171
template<typename T> template<typename T>
inline inline
bool bool
auxlib::svd(Col<T>& S, const Mat< std::complex<T> >& X) auxlib::svd(Col<T>& S, const Mat< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
// TODO: check for aliasing
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A = X; Mat<eT> A = X;
char jobu = 'N'; char jobu = 'N';
char jobvt = 'N'; char jobvt = 'N';
int m = A.n_rows; int m = A.n_rows;
int n = A.n_cols; int n = A.n_cols;
int lda = A.n_rows; int lda = A.n_rows;
skipping to change at line 1272 skipping to change at line 1254
#endif #endif
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Mat<eT>& X) auxlib::svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// TODO: check for aliasing
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A = X; Mat<eT> A = X;
char jobu = 'A'; char jobu = 'A';
char jobvt = 'A'; char jobvt = 'A';
int m = A.n_rows; int m = A.n_rows;
int n = A.n_cols; int n = A.n_cols;
int lda = A.n_rows; int lda = A.n_rows;
skipping to change at line 1353 skipping to change at line 1333
template<typename T> template<typename T>
inline inline
bool bool
auxlib::svd(Mat< std::complex<T> >& U, Col<T> &S, Mat< std::complex<T> >& V , const Mat< std::complex<T> >& X) auxlib::svd(Mat< std::complex<T> >& U, Col<T> &S, Mat< std::complex<T> >& V , const Mat< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
// TODO: check for aliasing
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A = X; Mat<eT> A = X;
char jobu = 'A'; char jobu = 'A';
char jobvt = 'A'; char jobvt = 'A';
int m = A.n_rows; int m = A.n_rows;
int n = A.n_cols; int n = A.n_cols;
int lda = A.n_rows; int lda = A.n_rows;
skipping to change at line 1413 skipping to change at line 1391
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork, work.memptr(), &lwork,
rwork.memptr(), rwork.memptr(),
&info &info
); );
op_htrans::apply(V,V); // op_htrans will work out that an in-place t ranspose can be done op_htrans::apply(V,V); // op_htrans will work out that an in-place t ranspose can be done
for(u32 i=0; i<A.n_cols; ++i)
{
V.at(i,i) = std::conj( V.at(i,i) );
}
return (info == 0); return (info == 0);
} }
else else
{ {
return false; return false;
} }
} }
#else #else
{ {
arma_stop("auxlib::svd(): need LAPACK library"); arma_stop("auxlib::svd(): need LAPACK library");
 End of changes. 11 change blocks. 
26 lines changed or deleted 7 lines changed or added


 constants.hpp   constants.hpp 
skipping to change at line 157 skipping to change at line 157
typedef Math<float> fmath; typedef Math<float> fmath;
typedef Math<double> math; typedef Math<double> math;
typedef Phy<float> fphy; typedef Phy<float> fphy;
typedef Phy<double> phy; typedef Phy<double> phy;
struct arma_version struct arma_version
{ {
static const unsigned int major = 0; static const unsigned int major = 0;
static const unsigned int minor = 7; static const unsigned int minor = 8;
static const unsigned int patch = 2; static const unsigned int patch = 0;
}; };
struct arma_config struct arma_config
{ {
#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
skipping to change at line 204 skipping to change at line 204
static const bool debug = true; static const bool debug = true;
#else #else
static const bool debug = false; static const bool debug = false;
#endif #endif
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
static const bool extra_debug = true; static const bool extra_debug = true;
#else #else
static const bool extra_debug = false; static const bool extra_debug = false;
#endif #endif
#if defined(ARMA_GOOD_COMPILER)
static const bool good_comp = true;
#else
static const bool good_comp = false;
#endif
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 8 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 637 skipping to change at line 637
inline inline
arma_first_extra_debug_message() arma_first_extra_debug_message()
{ {
std::cout << "@ ---" << '\n'; std::cout << "@ ---" << '\n';
std::cout << "@ Armadillo " << arma_version::major << '.' << arma_v ersion::minor << '.' << arma_version::patch << '\n'; std::cout << "@ Armadillo " << arma_version::major << '.' << arma_v ersion::minor << '.' << arma_version::patch << '\n';
std::cout << "@ arma_config::atlas = " << arma_config::atlas << '\n'; std::cout << "@ arma_config::atlas = " << arma_config::atlas << '\n';
std::cout << "@ arma_config::lapack = " << arma_config::lapack << '\n'; std::cout << "@ arma_config::lapack = " << arma_config::lapack << '\n';
std::cout << "@ arma_config::blas = " << arma_config::blas << '\n'; std::cout << "@ arma_config::blas = " << arma_config::blas << '\n';
std::cout << "@ arma_config::boost = " << arma_config::boost << '\n'; std::cout << "@ arma_config::boost = " << arma_config::boost << '\n';
std::cout << "@ arma_config::boost_date = " << arma_config::boost_d ate << '\n'; std::cout << "@ arma_config::boost_date = " << arma_config::boost_d ate << '\n';
std::cout << "@ arma_config::good_comp = " << arma_config::good_co mp << '\n';
std::cout << "@ sizeof(int) = " << sizeof(int) << '\n'; std::cout << "@ sizeof(int) = " << sizeof(int) << '\n';
std::cout << "@ sizeof(int*) = " << sizeof(int*) << '\n'; std::cout << "@ sizeof(int*) = " << sizeof(int*) << '\n';
std::cout << "@ sizeof(long) = " << sizeof(long) << '\n'; std::cout << "@ sizeof(long) = " << sizeof(long) << '\n';
std::cout << "@ ---" << std::endl; std::cout << "@ ---" << 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. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 diagview_meat.hpp   diagview_meat.hpp 
skipping to change at line 156 skipping to change at line 156
{ {
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 u32 i)
{ {
arma_check( (m_ptr == 0), "diagview::operator(): matrix is read only"); arma_check( (m_ptr == 0), "diagview::operator(): matrix is read only");
arma_debug_check( (i > n_elem), "diagview::operator(): index out of bound s" ); arma_debug_check( (i >= n_elem), "diagview::operator(): index out of boun ds" );
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 u32 i) const
{ {
arma_debug_check( (i > n_elem), "diagview::operator(): index out of bound s" ); arma_debug_check( (i >= n_elem), "diagview::operator(): index out of boun ds" );
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+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();
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 927 skipping to change at line 927
} }
if(load_okay == false) if(load_okay == false)
{ {
x.reset(); x.reset();
} }
} }
inline inline
void void
diskio::pnm_skip_comments(std::fstream& f) diskio::pnm_skip_comments(std::istream& f)
{ {
while( isspace(f.peek()) ) while( isspace(f.peek()) )
{ {
while( isspace(f.peek()) ) while( isspace(f.peek()) )
f.get(); f.get();
if(f.peek() == '#') if(f.peek() == '#')
{ {
while( (f.peek() != '\r') && (f.peek()!='\n') ) while( (f.peek() != '\r') && (f.peek()!='\n') )
f.get(); f.get();
skipping to change at line 953 skipping to change at line 953
template<typename eT> template<typename eT>
inline inline
void void
diskio::load_pgm_binary(Mat<eT>& x, const std::string& name) diskio::load_pgm_binary(Mat<eT>& x, const std::string& name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
bool load_okay = true;
if(f.is_open() == false) if(f.is_open() == false)
{ {
load_okay = false;
arma_extra_debug_print("unable to read ", name); arma_extra_debug_print("unable to read ", name);
x.reset();
} }
else else
{ {
std::string f_header; diskio::load_pgm_binary(x, name, f); // Do the actual load
f >> f_header; f.close();
}
}
if(f_header == "P5") //! Load a PGM greyscale image as a matrix
{ template<typename eT>
u32 f_n_rows = 0; inline
u32 f_n_cols = 0; void
int f_maxval = 0; diskio::load_pgm_binary(Mat<eT>& x, const std::string& name, std::istream&
f)
{
bool load_okay = true;
diskio::pnm_skip_comments(f); std::string f_header;
f >> f_header;
f >> f_n_cols; if(f_header == "P5")
diskio::pnm_skip_comments(f); {
u32 f_n_rows = 0;
u32 f_n_cols = 0;
int f_maxval = 0;
f >> f_n_rows; diskio::pnm_skip_comments(f);
diskio::pnm_skip_comments(f);
f >> f_maxval; f >> f_n_cols;
f.get(); diskio::pnm_skip_comments(f);
if( (f_maxval > 0) || (f_maxval <= 65535) ) f >> f_n_rows;
{ diskio::pnm_skip_comments(f);
x.set_size(f_n_rows,f_n_cols);
if(f_maxval <= 255) f >> f_maxval;
{ f.get();
const u32 n_elem = f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem); if( (f_maxval > 0) || (f_maxval <= 65535) )
{
x.set_size(f_n_rows,f_n_cols);
f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem); if(f_maxval <= 255)
{
const u32 n_elem = f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem);
u32 i = 0; f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem);
//cout << "f_n_cols = " << f_n_cols << endl; u32 i = 0;
//cout << "f_n_rows = " << f_n_rows << endl;
for(u32 row=0; row < f_n_rows; ++row) //cout << "f_n_cols = " << f_n_cols << endl;
{ //cout << "f_n_rows = " << f_n_rows << endl;
for(u32 col=0; col < f_n_cols; ++col)
{
x.at(row,col) = eT(tmp[i]);
++i;
}
for(u32 row=0; row < f_n_rows; ++row)
{
for(u32 col=0; col < f_n_cols; ++col)
{
x.at(row,col) = eT(tmp[i]);
++i;
} }
} }
else
{
const u32 n_elem = f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), n_elem*2); }
else
{
const u32 n_elem = f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), n_elem*2);
u32 i = 0; u32 i = 0;
for(u32 row=0; row < f_n_rows; ++row) for(u32 row=0; row < f_n_rows; ++row)
{
for(u32 col=0; col < f_n_cols; ++col)
{ {
for(u32 col=0; col < f_n_cols; ++col) x.at(row,col) = eT(tmp[i]);
{ ++i;
x.at(row,col) = eT(tmp[i]);
++i;
}
} }
} }
} }
if(f.good() == false)
{
arma_print("trouble reading ", name);
load_okay = false;
}
} }
else
if(f.good() == false)
{ {
arma_print("unsupported header in ", name); arma_print("trouble reading ", name);
load_okay = false; load_okay = false;
} }
}
f.close(); else
{
arma_print("unsupported header in ", name);
load_okay = false;
} }
if(load_okay == false) if(load_okay == false)
{ {
x.reset(); x.reset();
} }
} }
//! Load a PGM greyscale image as a matrix //! Load a PGM greyscale image as a matrix
template<typename T> template<typename T>
skipping to change at line 1593 skipping to change at line 1600
inline inline
void void
diskio::load_arma_binary(field<T1>& x, const std::string& name) diskio::load_arma_binary(field<T1>& x, const std::string& name)
{ {
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 == f alse) >::apply();
bool load_okay = true; bool load_okay = true;
std::ifstream f( name.c_str() ); std::ifstream f( name.c_str(), std::fstream::binary );
if(f.fail()) if(f.fail())
{ {
load_okay = false; load_okay = false;
arma_extra_debug_print("unable to read ", name); arma_extra_debug_print("unable to read ", name);
} }
else else
{ {
std::string f_type; std::string f_type;
f >> f_type; f >> f_type;
 End of changes. 28 change blocks. 
60 lines changed or deleted 68 lines changed or added


 diskio_proto.hpp   diskio_proto.hpp 
skipping to change at line 76 skipping to change at line 76
// //
// matrix loading // matrix loading
template<typename eT> inline static void load_raw_ascii (Mat<eT>& x, con st std::string& name); template<typename eT> inline static void load_raw_ascii (Mat<eT>& x, con st std::string& name);
template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con st std::string& name); template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con st std::string& name);
template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con st std::string& name, std::ifstream& f); template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con st std::string& name, std::ifstream& f);
template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con st std::string& name); template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con st std::string& name);
template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con st std::string& name, std::ifstream& f); template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con st std::string& name, std::ifstream& f);
template<typename eT> inline static void load_pgm_binary (Mat<eT>& x, con st std::string& name); template<typename eT> inline static void load_pgm_binary (Mat<eT>& x, con st std::string& name);
template<typename T> inline static void load_pgm_binary (Mat< std::compl ex<T> >& x, const std::string& name); template<typename T> inline static void load_pgm_binary (Mat< std::compl ex<T> >& x, const std::string& name);
template<typename eT> inline static void load_pgm_binary (Mat<eT>& x, con st std::string& name, std::istream& is);
template<typename eT> inline static void load_auto_detect(Mat<eT>& x, con st std::string& name); template<typename eT> inline static void load_auto_detect(Mat<eT>& x, con st std::string& name);
inline static void pnm_skip_comments(std::fstream& f); inline static void pnm_skip_comments(std::istream& f);
// //
// cube saving // cube saving
template<typename eT> inline static void save_raw_ascii (const Cube<eT>& x, const std::string& name); template<typename eT> inline static void save_raw_ascii (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static void save_arma_ascii (const Cube<eT>& x, const std::string& name); template<typename eT> inline static void save_arma_ascii (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static void save_arma_ascii (const Cube<eT>& x, const std::string& name, std::ofstream& f); template<typename eT> inline static void save_arma_ascii (const Cube<eT>& x, const std::string& name, std::ofstream& f);
template<typename eT> inline static void save_arma_binary(const Cube<eT>& x, const std::string& name); template<typename eT> inline static void save_arma_binary(const Cube<eT>& x, const std::string& name);
template<typename eT> inline static void save_arma_binary(const Cube<eT>& x, const std::string& name, std::ofstream& f); template<typename eT> inline static void save_arma_binary(const Cube<eT>& x, const std::string& name, std::ofstream& f);
 End of changes. 2 change blocks. 
1 lines changed or deleted 2 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
skipping to change at line 44 skipping to change at line 44
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<A_n_elem; ++i) for(u32 i=0; i<A_n_elem; ++i)
{ {
val += A_mem[i]; val += A_mem[i];
} }
return val; return val;
} }
//! sum of values along the main diagonal //! accumulate the elements of a cube
template<typename T1> template<typename T1>
inline inline
typename T1::elem_type typename T1::elem_type
accu(const Op<T1, op_diagmat>& X) accu(const BaseCube<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.m); const unwrap_cube<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Cube<eT>& A = tmp.M;
arma_debug_check( !A.is_square(), "accu(): sum of diagonal values of a no const u32 A_n_elem = A.n_elem;
n-square matrix requested" ); const eT* A_mem = A.mem;
eT acc = eT(0); eT val = eT(0);
for(u32 i=0; i<A.n_rows; ++i) for(u32 i=0; i<A_n_elem; ++i)
{ {
acc += A.at(i,i); val += A_mem[i];
} }
return acc; return val;
} }
template<typename eT> #if defined(ARMA_GOOD_COMPILER)
//! sum of squares
template<typename T1>
inline inline
eT typename T1::elem_type
accu(const Op<Mat<eT>, op_diagmat_vec>& X) accu(const Op<T1, op_square>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& A = X.m; typedef typename T1::elem_type eT;
arma_debug_check( !A.is_vec(), "accu(): internal error: expected a vector
" );
return accu(A); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i)
{
const eT val = A_mem[i];
acc += val*val;
}
return acc;
} }
//! sum of squares //! sum of squares
template<typename T1> template<typename T1>
inline inline
typename T1::elem_type typename T1::elem_type
accu(const Op<T1, op_square>& in) accu(const OpCube<T1, op_square>& 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_cube<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem; const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
eT acc = eT(0); eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i) for(u32 i=0; i<A_n_elem; ++i)
{ {
const eT val = A_mem[i]; const eT val = A_mem[i];
acc += val*val; acc += val*val;
skipping to change at line 134 skipping to change at line 151
eT acc = eT(0); eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i) for(u32 i=0; i<A_n_elem; ++i)
{ {
acc += std::sqrt(A_mem[i]); acc += std::sqrt(A_mem[i]);
} }
return acc; return acc;
} }
//! sum of square roots
template<typename T1>
inline
typename T1::elem_type
accu(const OpCube<T1, op_sqrt>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i)
{
acc += std::sqrt(A_mem[i]);
}
return acc;
}
//! sum of squares of differences //! sum of squares of differences
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
typename T1::elem_type typename T1::elem_type
accu(const Op< Glue<T1,T2, glue_minus>, op_square>& in) accu(const Op< Glue<T1,T2, glue_minus>, op_square>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
skipping to change at line 164 skipping to change at line 206
eT acc = eT(0); eT acc = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT val = A.mem[i] - B.mem[i]; const eT val = A.mem[i] - B.mem[i];
acc += val*val; acc += val*val;
} }
return acc; return acc;
} }
//! accumulate the elements of a subview (submatrix) //! sum of squares of differences
template<typename eT> template<typename T1, typename T2>
inline inline
eT typename T1::elem_type
accu(const subview<eT>& X) accu(const OpCube< GlueCube<T1,T2, glue_cube_minus>, op_square>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); typedef typename T1::elem_type eT;
for(u32 col=0; col<X.n_cols; ++col)
{
const eT* coldata = X.colptr(col);
for(u32 row=0; row<X.n_rows; ++row) const unwrap_cube<T1> tmp1(in.m.A);
{ const unwrap_cube<T2> tmp2(in.m.B);
val += coldata[row];
}
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A,B, "accu()");
const u32 n_elem = A.n_elem;
eT acc = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
const eT val = A.mem[i] - B.mem[i];
acc += val*val;
} }
return val; return acc;
} }
//! accumulate the elements of a diagview //! accumulate the result of A % B, where % is the Schur product (element-w ise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu(const diagview<eT>& X) accu_schur(const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; arma_debug_assert_same_size(A,B, "accu()");
const eT* const A_mem = A.mem;
const eT* const B_mem = B.mem;
const u32 n_elem = A.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
val += X[i]; val += A_mem[i] * B_mem[i];
} }
return val; return val;
} }
//! accumulate the result of A % B, where % is the Schur product (element-w ise multiplication) //! accumulate the result of A % B, where % is the Schur product (element-w ise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu_schur(const Mat<eT>& A, const Mat<eT>& B) accu_schur(const Cube<eT>& A, const Cube<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A,B, "accu()"); arma_debug_assert_same_size(A,B, "accu()");
const eT* const A_mem = A.mem; const eT* const A_mem = A.mem;
const eT* const B_mem = B.mem; const eT* const B_mem = B.mem;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
eT val = eT(0); eT val = eT(0);
skipping to change at line 239 skipping to change at line 293
//! accumulate the result of A % B, where % is the Schur product (element-w ise multiplication) //! accumulate the result of A % B, where % is the Schur product (element-w ise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu(const Glue<Mat<eT>,Mat<eT>,glue_schur>& X) accu(const Glue<Mat<eT>,Mat<eT>,glue_schur>& X)
{ {
return accu_schur(X.A, X.B); return accu_schur(X.A, X.B);
} }
//! accumulate the result of A % B, where % is the Schur product (element-w
ise multiplication)
template<typename eT>
inline
eT
accu(const GlueCube< Cube<eT>, Cube<eT>, glue_cube_schur >& X)
{
return accu_schur(X.A, X.B);
}
//! accumulate the result of A % B % C, where % is the Schur product (eleme nt-wise multiplication) //! accumulate the result of A % B % C, where % is the Schur product (eleme nt-wise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu(const Glue<Glue<Mat<eT>,Mat<eT>,glue_schur>,Mat<eT>,glue_schur>& X) accu(const Glue<Glue<Mat<eT>,Mat<eT>,glue_schur>,Mat<eT>,glue_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& A = X.A.A; const Mat<eT>& A = X.A.A;
const Mat<eT>& B = X.A.B; const Mat<eT>& B = X.A.B;
skipping to change at line 269 skipping to change at line 332
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
val += A_mem[i] * B_mem[i] * C_mem[i]; val += A_mem[i] * B_mem[i] * C_mem[i];
} }
return val; return val;
} }
//! accumulate the result of A % B % C, where % is the Schur product (eleme
nt-wise multiplication)
template<typename eT>
inline
eT
accu(const GlueCube< GlueCube< Cube<eT>, Cube<eT>, glue_cube_schur >, Cube<
eT>, glue_cube_schur >& X)
{
arma_extra_debug_sigprint();
const Cube<eT>& A = X.A.A;
const Cube<eT>& B = X.A.B;
const Cube<eT>& C = X.B;
arma_debug_assert_same_size(A,B, "accu()");
arma_debug_assert_same_size(B,C, "accu()");
const eT* const A_mem = A.mem;
const eT* const B_mem = B.mem;
const eT* const C_mem = C.mem;
const u32 n_elem = A.n_elem;
eT val = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
val += A_mem[i] * B_mem[i] * C_mem[i];
}
return val;
}
//! \brief //! \brief
//! accumulate the result of T1 % T2 //! accumulate the result of T1 % T2
//! where % is the Schur product (element-wise multiplication), //! where % is the Schur product (element-wise multiplication),
//! while T1 and T2 can be 'mat', 'rowvec', 'colvec', 'Op', 'Glue' //! while T1 and T2 can be 'mat', 'rowvec', 'colvec', 'Op', 'Glue'
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
typename T1::elem_type typename T1::elem_type
accu(const Glue<T1,T2,glue_schur>& X) accu(const Glue<T1,T2,glue_schur>& X)
{ {
skipping to change at line 290 skipping to change at line 383
isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_mat = 1 + depth_lhs< glue_schur, Glue<T1,T2,glue_schur> >::nu m; const u32 N_mat = 1 + depth_lhs< glue_schur, Glue<T1,T2,glue_schur> >::nu m;
arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat ); arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat );
if(N_mat == 2) if(N_mat == 2)
{ {
return accu_schur(Mat<eT>(X.A), Mat<eT>(X.B)); const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
return accu_schur(tmp1.M, tmp2.M);
} }
else else
{ {
const Mat<eT>* ptrs[N_mat]; const Mat<eT>* ptrs[N_mat];
bool del[N_mat]; bool del[N_mat];
mat_ptrs<glue_schur, Glue<T1,T2,glue_schur> >::get_ptrs(ptrs, del, X); mat_ptrs<glue_schur, Glue<T1,T2,glue_schur> >::get_ptrs(ptrs, del, X);
for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] ); for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] );
for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( " del[%d] = %d") % i % del[i] ); for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( " del[%d] = %d") % i % del[i] );
skipping to change at line 341 skipping to change at line 437
{ {
arma_extra_debug_print( arma_boost::format("delete mat_ptr[%d]") % i ); arma_extra_debug_print( arma_boost::format("delete mat_ptr[%d]") % i );
delete ptrs[i]; delete ptrs[i];
} }
} }
return val; return val;
} }
} }
//! accumulate the result of submatrix % matrix, where % is the Schur produ //! sum of values along the main diagonal
ct (element-wise multiplication) template<typename T1>
template<typename eT>
inline inline
eT typename T1::elem_type
accu(const Glue<subview<eT>,Mat<eT>,glue_schur>& X) accu(const Op<T1, op_diagmat>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(X.A, X.B, "accu()"); typedef typename T1::elem_type eT;
const Mat<eT>& A = X.A.m;
const Mat<eT>& B = X.B;
const u32 A_sub_n_rows = X.A.n_rows; const unwrap<T1> tmp(X.m);
const u32 A_sub_n_cols = X.A.n_cols; const Mat<eT>& A = tmp.M;
const u32 A_aux_row1 = X.A.aux_row1; arma_debug_check( !A.is_square(), "accu(): sum of diagonal values of a no
const u32 A_aux_col1 = X.A.aux_col1; n-square matrix requested" );
eT val = eT(0); eT acc = eT(0);
for(u32 col = 0; col<A_sub_n_cols; ++col) for(u32 i=0; i<A.n_rows; ++i)
{ {
const u32 col_mod = A_aux_col1 + col; acc += A.at(i,i);
for(u32 row = 0; row<A_sub_n_rows; ++row)
{
const u32 row_mod = A_aux_row1 + row;
val += A.at(row_mod, col_mod) * B.at(row,col);
}
} }
return val; return acc;
} }
//! accumulate the result of matrix % submatrix, where % is the Schur produ ct (element-wise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu(const Glue<Mat<eT>,subview<eT>,glue_schur>& X) accu(const Op<Mat<eT>, op_diagmat_vec>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(X.A, X.B, "accu()"); const Mat<eT>& A = X.m;
arma_debug_check( !A.is_vec(), "accu(): internal error: expected a vector
const Mat<eT>& A = X.A; " );
const Mat<eT>& B = X.B.m;
// const u32 B_sub_n_rows = X.B.n_rows; return accu(A);
// const u32 B_sub_n_cols = X.B.n_cols; }
const u32 B_aux_row1 = X.B.aux_row1; //! accumulate the elements of a diagview
const u32 B_aux_col1 = X.B.aux_col1; template<typename eT>
inline
eT
accu(const diagview<eT>& X)
{
arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 col = 0; col<A.n_cols; ++col) for(u32 i=0; i<n_elem; ++i)
{ {
const u32 col_mod = B_aux_col1 + col; val += X[i];
for(u32 row = 0; row<A.n_rows; ++row)
{
const u32 row_mod = B_aux_row1 + row;
val += A.at(row, col) * B.at(row_mod, col_mod);
}
} }
return val; return val;
} }
//! accumulate the result of submatrix % submatrix, where % is the Schur pr oduct (element-wise multiplication) //! accumulate the elements of a subview (submatrix)
template<typename eT> template<typename eT>
inline inline
eT eT
accu(const Glue<subview<eT>,subview<eT>,glue_schur>& X) accu(const subview<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(X.A, X.B, "accu()");
const Mat<eT>& A = X.A.m;
const Mat<eT>& B = X.B.m;
const u32 A_sub_n_rows = X.A.n_rows;
const u32 A_sub_n_cols = X.A.n_cols;
// const u32 B_sub_n_rows = X.B.n_rows;
// const u32 B_sub_n_cols = X.B.n_cols;
const u32 A_aux_row1 = X.A.aux_row1;
const u32 A_aux_col1 = X.A.aux_col1;
const u32 B_aux_row1 = X.B.aux_row1;
const u32 B_aux_col1 = X.B.aux_col1;
eT val = eT(0); eT val = eT(0);
for(u32 col = 0; col<A_sub_n_cols; ++col) for(u32 col=0; col<S.n_cols; ++col)
{ {
const u32 A_col_mod = A_aux_col1 + col; const eT* coldata = S.colptr(col);
const u32 B_col_mod = B_aux_col1 + col;
for(u32 row = 0; row<A_sub_n_rows; ++row) for(u32 row=0; row<S.n_rows; ++row)
{ {
const u32 A_row_mod = A_aux_row1 + row; val += coldata[row];
const u32 B_row_mod = B_aux_row1 + row;
val += A.at(A_row_mod, A_col_mod) * B.at(B_row_mod, B_col_mod);
} }
} }
return val; return val;
} }
// //! accumulate the elements of a subview_row
// template<typename eT>
// Cube handling
//! accumulate the elements of a cube
template<typename T1>
inline inline
typename T1::elem_type eT
accu(const BaseCube<typename T1::elem_type,T1>& X) accu(const subview_row<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; const Mat<eT>& X = S.m;
const unwrap_cube<T1> tmp(X.get_ref()); const u32 row = S.aux_row1;
const Cube<eT>& A = tmp.M; const u32 start_col = S.aux_col1;
const u32 end_col = S.aux_col2;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<A_n_elem; ++i) for(u32 col=start_col; col<=end_col; ++col)
{ {
val += A_mem[i]; val += X.at(row,col);
} }
return val; return val;
} }
//! sum of squares //! accumulate the elements of a subview_col
template<typename T1> template<typename eT>
inline inline
typename T1::elem_type eT
accu(const OpCube<T1, op_square>& in) accu(const subview_col<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; const eT* S_colptr = S.colptr(0);
const u32 n_rows = S.n_rows;
const unwrap_cube<T1> tmp(in.m); eT val = eT(0);
const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i) for(u32 row=0; row<n_rows; ++row)
{ {
const eT val = A_mem[i]; val += S_colptr[row];
acc += val*val;
} }
return acc; return val;
} }
//! sum of square roots //! accumulate the result of submatrix % matrix, where % is the Schur produ
template<typename T1> ct (element-wise multiplication)
template<typename eT>
inline inline
typename T1::elem_type eT
accu(const OpCube<T1, op_sqrt>& in) accu(const Glue<subview<eT>,Mat<eT>,glue_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; arma_debug_assert_same_size(X.A, X.B, "accu()");
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i)
{
acc += std::sqrt(A_mem[i]);
}
return acc; const Mat<eT>& A = X.A.m;
} const Mat<eT>& B = X.B;
//! sum of squares of differences const u32 A_sub_n_rows = X.A.n_rows;
template<typename T1, typename T2> const u32 A_sub_n_cols = X.A.n_cols;
inline
typename T1::elem_type
accu(const OpCube< GlueCube<T1,T2, glue_cube_minus>, op_square>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; const u32 A_aux_row1 = X.A.aux_row1;
const u32 A_aux_col1 = X.A.aux_col1;
const unwrap_cube<T1> tmp1(in.m.A); eT val = eT(0);
const unwrap_cube<T2> tmp2(in.m.B);
const Cube<eT>& A = tmp1.M; for(u32 col = 0; col<A_sub_n_cols; ++col)
const Cube<eT>& B = tmp2.M; {
const u32 col_mod = A_aux_col1 + col;
arma_debug_assert_same_size(A,B, "accu()"); for(u32 row = 0; row<A_sub_n_rows; ++row)
{
const u32 row_mod = A_aux_row1 + row;
const u32 n_elem = A.n_elem; val += A.at(row_mod, col_mod) * B.at(row,col);
}
eT acc = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
const eT val = A.mem[i] - B.mem[i];
acc += val*val;
} }
return acc; return val;
} }
//! accumulate the result of A % B, where % is the Schur product (element-w ise multiplication) //! accumulate the result of matrix % submatrix, where % is the Schur produ ct (element-wise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu_schur(const Cube<eT>& A, const Cube<eT>& B) accu(const Glue<Mat<eT>,subview<eT>,glue_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A,B, "accu()"); arma_debug_assert_same_size(X.A, X.B, "accu()");
const eT* const A_mem = A.mem; const Mat<eT>& A = X.A;
const eT* const B_mem = B.mem; const Mat<eT>& B = X.B.m;
// const u32 B_sub_n_rows = X.B.n_rows;
// const u32 B_sub_n_cols = X.B.n_cols;
const u32 B_aux_row1 = X.B.aux_row1;
const u32 B_aux_col1 = X.B.aux_col1;
const u32 n_elem = A.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 col = 0; col<A.n_cols; ++col)
{ {
val += A_mem[i] * B_mem[i]; const u32 col_mod = B_aux_col1 + col;
for(u32 row = 0; row<A.n_rows; ++row)
{
const u32 row_mod = B_aux_row1 + row;
val += A.at(row, col) * B.at(row_mod, col_mod);
}
} }
return val; return val;
} }
//! accumulate the result of A % B, where % is the Schur product (element-w //! accumulate the result of submatrix % submatrix, where % is the Schur pr
ise multiplication) oduct (element-wise multiplication)
template<typename eT>
inline
eT
accu(const GlueCube< Cube<eT>, Cube<eT>, glue_cube_schur >& X)
{
return accu_schur(X.A, X.B);
}
//! accumulate the result of A % B % C, where % is the Schur product (eleme
nt-wise multiplication)
template<typename eT> template<typename eT>
inline inline
eT eT
accu(const GlueCube< GlueCube< Cube<eT>, Cube<eT>, glue_cube_schur >, Cube< eT>, glue_cube_schur >& X) accu(const Glue<subview<eT>,subview<eT>,glue_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Cube<eT>& A = X.A.A; arma_debug_assert_same_size(X.A, X.B, "accu()");
const Cube<eT>& B = X.A.B;
const Cube<eT>& C = X.B;
arma_debug_assert_same_size(A,B, "accu()"); const Mat<eT>& A = X.A.m;
arma_debug_assert_same_size(B,C, "accu()"); const Mat<eT>& B = X.B.m;
const eT* const A_mem = A.mem; const u32 A_sub_n_rows = X.A.n_rows;
const eT* const B_mem = B.mem; const u32 A_sub_n_cols = X.A.n_cols;
const eT* const C_mem = C.mem;
// const u32 B_sub_n_rows = X.B.n_rows;
// const u32 B_sub_n_cols = X.B.n_cols;
const u32 A_aux_row1 = X.A.aux_row1;
const u32 A_aux_col1 = X.A.aux_col1;
const u32 B_aux_row1 = X.B.aux_row1;
const u32 B_aux_col1 = X.B.aux_col1;
const u32 n_elem = A.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 col = 0; col<A_sub_n_cols; ++col)
{ {
val += A_mem[i] * B_mem[i] * C_mem[i]; const u32 A_col_mod = A_aux_col1 + col;
const u32 B_col_mod = B_aux_col1 + col;
for(u32 row = 0; row<A_sub_n_rows; ++row)
{
const u32 A_row_mod = A_aux_row1 + row;
const u32 B_row_mod = B_aux_row1 + row;
val += A.at(A_row_mod, A_col_mod) * B.at(B_row_mod, B_col_mod);
}
} }
return val; return val;
} }
#endif
//! @} //! @}
 End of changes. 94 change blocks. 
214 lines changed or deleted 265 lines changed or added


 fn_chol.hpp   fn_chol.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_chol //! \addtogroup fn_chol
//! @{ //! @{
template<typename eT, typename T1> template<typename T1>
inline inline
bool bool
chol(Mat<eT>& out, const Base<eT,T1>& X) chol(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type,T1 >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); typedef typename T1::elem_type eT;
arma_debug_check( !tmp.M.is_square(), "chol(): given matrix is not square
");
return auxlib::chol(out, tmp.M); const unwrap_check<T1> tmp(X.get_ref(), out);
const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "chol(): given matrix is not
square");
return auxlib::chol(out, A);
} }
template<typename eT, typename T1> template<typename T1>
inline inline
Mat<eT> Mat<typename T1::elem_type>
chol(const Base<eT,T1>& X) chol(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
Mat<eT> out; Mat<eT> out;
const bool ok = chol(out, X); const bool ok = chol(out, X);
if(ok == false) if(ok == false)
{ {
arma_print("chol(): matrix factorisation failed"); arma_print("chol(): matrix factorisation failed");
} }
return out; return out;
} }
//! @} //! @}
 End of changes. 8 change blocks. 
9 lines changed or deleted 16 lines changed or added


 fn_cor.hpp   fn_cor.hpp 
skipping to change at line 26 skipping to change at line 26
//! \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 u32 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) cor(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ type,T2>& B, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Glue<T1, T2, glue_cor>(A.get_ref(), B.get_ref());
}
template<typename T1, typename T2>
inline
Mat<typename T1::elem_type>
cor(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_
type,T2>& B, const u32 norm_type)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
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");
if(&A != &B) return Glue<T1, T2, glue_cor>(A.get_ref(), B.get_ref(), norm_type);
{
if(norm_type == 0)
{
return cor(A,B);
}
else
{
const unwrap<T1> A_tmp(A.get_ref());
const unwrap<T2> B_tmp(B.get_ref());
Mat<eT> out;
glue_cor::direct_cor(out, A_tmp.M, B_tmp.M, 1);
return out;
}
}
else
{
return cor(A, norm_type);
}
} }
//! @} //! @}
 End of changes. 4 change blocks. 
35 lines changed or deleted 3 lines changed or added


 fn_cov.hpp   fn_cov.hpp 
skipping to change at line 35 skipping to change at line 35
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) cov(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ type,T2>& B, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Glue<T1, T2, glue_cov>(A.get_ref(), B.get_ref());
}
template<typename T1, typename T2>
inline
Mat<typename T1::elem_type>
cov(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_
type,T2>& B, const u32 norm_type)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
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");
if(&A != &B) return Glue<T1, T2, glue_cov>(A.get_ref(), B.get_ref(), norm_type);
{
if(norm_type == 0)
{
return cov(A,B);
}
else
{
const unwrap<T1> A_tmp(A.get_ref());
const unwrap<T2> B_tmp(B.get_ref());
Mat<eT> out;
glue_cov::direct_cov(out, A_tmp.M, B_tmp.M, 1);
return out;
}
}
else
{
return cov(A, norm_type);
}
} }
//! @} //! @}
 End of changes. 3 change blocks. 
35 lines changed or deleted 2 lines changed or added


 fn_diagmat.hpp   fn_diagmat.hpp 
skipping to change at line 19 skipping to change at line 19
// 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_diagmat //! \addtogroup fn_diagmat
//! @{ //! @{
//! interpret a mat as a diagonal matrix (i.e. off-diagonal entries are zer o) //! interpret a mat as a diagonal matrix (i.e. off-diagonal entries are zer o)
template<typename eT, typename T1> template<typename T1>
inline inline
const Op<T1, op_diagmat> const Op<T1, op_diagmat>
diagmat(const Base<eT,T1>& X) diagmat(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_diagmat>(X.get_ref()); return Op<T1, op_diagmat>(X.get_ref());
} }
//! interpret a colvec as a diagonal matrix //! interpret a colvec as a diagonal matrix
template<typename eT> template<typename eT>
inline inline
const Op<Mat<eT>, op_diagmat_vec> const Op<Mat<eT>, op_diagmat_vec>
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_lu.hpp   fn_lu.hpp 
skipping to change at line 19 skipping to change at line 19
// 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_lu //! \addtogroup fn_lu
//! @{ //! @{
//! immediate lower upper decomposition //! immediate lower upper decomposition
template<typename eT, typename T1> template<typename T1>
inline inline
void void
lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X) lu(Mat<typename T1::elem_type>& L, Mat<typename T1::elem_type>& U, const Ba se<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); typedef typename T1::elem_type eT;
auxlib::lu(L, U, tmp.M); arma_debug_check( (&L == &U), "lu(): L and U are the same object");
const unwrap_check<T1> tmp1(X.get_ref(), L);
const Mat<eT>& A = tmp1.M;
const unwrap_check< Mat<eT> > tmp2(A, U);
const Mat<eT>& B = tmp2.M;
auxlib::lu(L, U, B);
} }
//! immediate lower upper decomposition, also providing the permutation mat rix //! immediate lower upper decomposition, also providing the permutation mat rix
template<typename eT, typename T1> template<typename T1>
inline inline
void void
lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X) lu(Mat<typename T1::elem_type>& L, Mat<typename T1::elem_type>& U, Mat<type name T1::elem_type>& P, const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); typedef typename T1::elem_type eT;
arma_debug_check( ( (&L == &U) || (&L == &P) || (&U == &P) ), "lu(): two
or more output objects are the same object");
const unwrap_check<T1> tmp1(X.get_ref(), L);
const Mat<eT>& A = tmp1.M;
const unwrap_check< Mat<eT> > tmp2(A, U);
const Mat<eT>& B = tmp2.M;
const unwrap_check< Mat<eT> > tmp3(B, P);
const Mat<eT>& C = tmp3.M;
auxlib::lu(L, U, P, tmp.M); auxlib::lu(L, U, P, C);
} }
//! @} //! @}
 End of changes. 8 change blocks. 
8 lines changed or deleted 28 lines changed or added


 fn_min.hpp   fn_min.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_min //! \addtogroup fn_min
//! @{ //! @{
//! \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 maximum value of each column is found. //! For dim = 0, the maximum value of each column is found (i.e. searches b
//! For dim = 1, the maximum value of each row is found. y traversing across rows).
//! 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.
//! NOTE: This function works differently than in Matlab/Octave. //! NOTE: This function works differently than in Matlab/Octave.
template<typename T1> template<typename T1>
inline 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 u32 dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 1 change blocks. 
2 lines changed or deleted 4 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 212 skipping to change at line 212
if(std::numeric_limits<eT>::is_iec559) if(std::numeric_limits<eT>::is_iec559)
{ {
if(x == std::numeric_limits<eT>::infinity()) if(x == std::numeric_limits<eT>::infinity())
{ {
return Math<eT>::log_max(); return Math<eT>::log_max();
} }
if(x <= 0) if(x <= 0)
{ {
return Math<eT>::log_min(); return Math<eT>::log_min();
} }
else
{
return std::log(x);
}
} }
else else
{ {
return std::log(x); return std::log(x);
} }
} }
template<typename eT> template<typename eT>
inline inline
eT eT
skipping to change at line 527 skipping to change at line 531
template<typename T1> template<typename T1>
inline inline
const OpCube<T1, op_pow> const OpCube<T1, op_pow>
pow(const BaseCube<typename T1::elem_type,T1>& A, const typename T1::elem_t ype::value_type exponent) pow(const BaseCube<typename T1::elem_type,T1>& A, const typename T1::elem_t ype::value_type exponent)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return OpCube<T1, op_pow>(A.get_ref(), eT(exponent)); return OpCube<T1, op_pow>(A.get_ref(), eT(exponent));
} }
#if defined(ARMA_GOOD_COMPILER)
// pow_s32 (integer exponent) // pow_s32 (integer exponent)
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pow_s32> const Op<T1, op_pow_s32>
pow(const Base<typename T1::elem_type,T1>& A, const s32 exponent) pow(const Base<typename T1::elem_type,T1>& A, const s32 exponent)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(exponent >= 0) if(exponent >= 0)
skipping to change at line 563 skipping to change at line 569
if(exponent >= 0) if(exponent >= 0)
{ {
return OpCube<T1, op_pow_s32>(A.get_ref(), exponent, 0); return OpCube<T1, op_pow_s32>(A.get_ref(), exponent, 0);
} }
else else
{ {
return OpCube<T1, op_pow_s32>(A.get_ref(), -exponent, 1); return OpCube<T1, op_pow_s32>(A.get_ref(), -exponent, 1);
} }
} }
#endif
// conj // conj
template<typename T, typename T1> template<typename T, typename T1>
inline inline
const Op<T1, op_conj> const Op<T1, op_conj>
conj(const Base<std::complex<T>,T1>& A) conj(const Base<std::complex<T>,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_conj>(A.get_ref()); return Op<T1, op_conj>(A.get_ref());
 End of changes. 3 change blocks. 
0 lines changed or deleted 8 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
skipping to change at line 60 skipping to change at line 60
template<typename vec_type> template<typename vec_type>
inline inline
const Op<vec_type, op_ones_full> const Op<vec_type, op_ones_full>
ones(const u32 n_elem) ones(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply(); arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply();
return Op<vec_type, op_ones_full>(n_elem, 0, 'j'); if(is_Row<vec_type>::value == true)
{
return Op<vec_type, op_ones_full>(1, n_elem, 'j');
}
else
{
return Op<vec_type, op_ones_full>(n_elem, 1, 'j');
}
} }
//! Delayed generation of a diagonal matrix with the diagonal elements set to one //! Delayed generation of a diagonal matrix with the diagonal elements set to one
inline inline
const Op<mat,op_ones_diag> const Op<mat,op_ones_diag>
eye(const u32 n_rows, const u32 n_cols) eye(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<mat,op_ones_diag>(n_rows, n_cols, 'j'); return Op<mat,op_ones_diag>(n_rows, n_cols, 'j');
 End of changes. 1 change blocks. 
1 lines changed or deleted 8 lines changed or added


 fn_qr.hpp   fn_qr.hpp 
skipping to change at line 19 skipping to change at line 19
// 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_qr //! \addtogroup fn_qr
//! @{ //! @{
//! QR decomposition //! QR decomposition
template<typename eT, typename T1> template<typename T1>
inline inline
void void
qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X) qr(Mat<typename T1::elem_type>& Q, Mat<typename T1::elem_type>& R, const Ba se<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); typedef typename T1::elem_type eT;
arma_debug_check( (&Q == &R), "qr(): Q and R are the same object");
const unwrap_check<T1> tmp1(X.get_ref(), Q);
const Mat<eT>& A = tmp1.M;
const unwrap_check< Mat<eT> > tmp2(A, R);
const Mat<eT>& B = tmp2.M;
const bool ok = auxlib::qr(Q, R, B);
const bool ok = auxlib::qr(Q, R, tmp.M);
if(ok == false) if(ok == false)
{ {
arma_print("qr(): matrix factorisation failed"); arma_print("qr(): matrix factorisation failed");
} }
} }
//! @} //! @}
 End of changes. 4 change blocks. 
4 lines changed or deleted 13 lines changed or added


 fn_rand.hpp   fn_rand.hpp 
skipping to change at line 61 skipping to change at line 61
template<typename vec_type> template<typename vec_type>
inline inline
const Op<vec_type,op_rand> const Op<vec_type,op_rand>
rand(const u32 n_elem) rand(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply(); arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply();
return Op<vec_type,op_rand>(n_elem, 0, 'j'); if(is_Row<vec_type>::value == true)
{
return Op<vec_type,op_rand>(1, n_elem, 'j');
}
else
{
return Op<vec_type,op_rand>(n_elem, 1, 'j');
}
} }
// //
// //
// handling of cubes // handling of cubes
//! Generate a dense cube with all elements set to random values in the [0, 1] interval (uniform distribution) //! Generate a dense cube with all elements set to random values in the [0, 1] interval (uniform distribution)
inline inline
const OpCube<cube, op_rand> const OpCube<cube, op_rand>
rand(const u32 n_rows, const u32 n_cols, const u32 n_slices) rand(const u32 n_rows, const u32 n_cols, const u32 n_slices)
 End of changes. 1 change blocks. 
1 lines changed or deleted 8 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
skipping to change at line 59 skipping to change at line 59
template<typename vec_type> template<typename vec_type>
inline inline
const Op<vec_type,op_randn> const Op<vec_type,op_randn>
randn(const u32 n_elem) randn(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply(); arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply();
return Op<vec_type,op_randn>(n_elem, 0, 'j'); if(is_Row<vec_type>::value == true)
{
return Op<vec_type,op_randn>(1, n_elem, 'j');
}
else
{
return Op<vec_type,op_randn>(n_elem, 1, 'j');
}
} }
// //
// //
// handling of cubes // handling of cubes
//! Generate a dense cube with all elements set to random values with a gau ssian distribution (zero mean, unit variance) //! Generate a dense cube with all elements set to random values with a gau ssian distribution (zero mean, unit variance)
inline inline
const OpCube<cube, op_randn> const OpCube<cube, op_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices) randn(const u32 n_rows, const u32 n_cols, const u32 n_slices)
 End of changes. 1 change blocks. 
1 lines changed or deleted 8 lines changed or added


 fn_stddev.hpp   fn_stddev.hpp 
skipping to change at line 51 skipping to change at line 51
} }
//! 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
eT eT
stddev(const Row<eT>& A, const u32 norm_type = 0) stddev(const Row<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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 row vector' operation (vers ion for complex numbers) //! Immediate 'find the standard deviation of a row vector' operation (vers ion for complex numbers)
template<typename T> template<typename T>
inline inline
T T
stddev(const Row< std::complex<T> >& A, const u32 norm_type = 0) stddev(const Row< std::complex<T> >& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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
eT eT
stddev(const Col<eT>& A, const u32 norm_type = 0) stddev(const Col<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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 (v ersion for complex numbers) //! Immediate 'find the standard deviation of a column vector' operation (v ersion for complex numbers)
template<typename T> template<typename T>
inline inline
T T
stddev(const Col< std::complex<T> >& A, const u32 norm_type = 0) stddev(const Col< std::complex<T> >& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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
eT eT
stddev(const subview_row<eT>& A, const u32 norm_type = 0) stddev(const subview_row<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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_row (version for complex numbe rs) //! find the standard deviation of a subview_row (version for complex numbe rs)
template<typename T> template<typename T>
inline inline
T T
stddev(const subview_row< std::complex<T> >& A, const u32 norm_type = 0) stddev(const subview_row< std::complex<T> >& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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
eT eT
stddev(const subview_col<eT>& A, const u32 norm_type = 0) stddev(const subview_col<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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 (version for complex numbe rs) //! find the standard deviation of a subview_col (version for complex numbe rs)
template<typename T> template<typename T>
inline inline
T T
stddev(const subview_col< std::complex<T> >& A, const u32 norm_type = 0) stddev(const subview_col< std::complex<T> >& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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 diagview //! find the standard deviation of a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
stddev(const diagview<eT>& A, const u32 norm_type = 0) stddev(const diagview<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector 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 diagview (version for complex numbers) //! find the standard deviation of a diagview (version for complex numbers)
template<typename T> template<typename T>
inline inline
T T
stddev(const diagview< std::complex<T> >& A, const u32 norm_type = 0) stddev(const diagview< std::complex<T> >& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "stddev(): given vector has no element s" );
return std::sqrt( op_var::direct_var(A, norm_type) ); return std::sqrt( op_var::direct_var(A, norm_type) );
} }
//! @} //! @}
 End of changes. 10 change blocks. 
10 lines changed or deleted 10 lines changed or added


 fn_svd.hpp   fn_svd.hpp 
skipping to change at line 61 skipping to change at line 61
svd(out, X); svd(out, X);
return out; return out;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
svd svd
( (
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
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); arma_debug_check( ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*
)(&S) == (void*)(&V)) ), "svd(): two or more output objects are the same ob
ject" );
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
// auxlib::svd() makes an internal copy of A
const bool status = auxlib::svd(U, S, V, A); const bool status = auxlib::svd(U, S, V, A);
if(status == false) if(status == false)
{ {
arma_print("svd(): singular value decomposition failed"); arma_print("svd(): singular value decomposition failed");
} }
return status; return status;
} }
 End of changes. 3 change blocks. 
4 lines changed or deleted 9 lines changed or added


 fn_trace.hpp   fn_trace.hpp 
skipping to change at line 43 skipping to change at line 43
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<A.n_rows; ++i) for(u32 i=0; i<A.n_rows; ++i)
{ {
val += A.at(i,i); val += A.at(i,i);
} }
return val; return val;
} }
#if defined(ARMA_GOOD_COMPILER)
//! \brief //! \brief
//! Immediate trace (sum of diagonal elements) of A + B. //! Immediate trace (sum of diagonal elements) of A + B.
//! A and B must be square and have the same dimensions. //! A and B must be square and have the same dimensions.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
typename T1::elem_type typename T1::elem_type
trace(const Glue<T1,T2,glue_plus>& X) trace(const Glue<T1,T2,glue_plus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check();
const unwrap<T1> tmp1(X.A); const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B); const unwrap<T2> tmp2(X.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
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_rows != B.n_rows) || (A.n_cols != B.n_cols), "trac e(): incompatible matrix dimensions"); arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_check( !A.is_square(), "trace(): matrices must be square"); arma_debug_check( !A.is_square(), "trace(): matrices must be square");
return trace(A) + trace(B); return trace(A) + trace(B);
} }
//! \brief //! \brief
//! Immediate trace (sum of diagonal elements) of A - B. //! Immediate trace (sum of diagonal elements) of A - B.
//! A and B must be square and have the same dimensions. //! A and B must be square and have the same dimensions.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 89 skipping to change at line 91
isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check();
const unwrap<T1> tmp1(X.A); const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B); const unwrap<T2> tmp2(X.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
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_rows != B.n_rows) || (A.n_cols != B.n_cols), "trac e(): incompatible matrix dimensions"); arma_debug_assert_same_size(A, B, "matrix subtraction");
arma_debug_check( !A.is_square(), "trace(): matrices must be square"); arma_debug_check( !A.is_square(), "trace(): matrices must be square");
return trace(A) - trace(B); return trace(A) - trace(B);
} }
//! \brief //! \brief
//! Immediate trace (sum of diagonal elements) of A % B (where % is the ele ment-wise multiplication operator). //! Immediate trace (sum of diagonal elements) of A % B (where % is the ele ment-wise multiplication operator).
//! A and B must be square and have the same dimensions. //! A and B must be square and have the same dimensions.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 115 skipping to change at line 117
isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check();
const unwrap<T1> tmp1(X.A); const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B); const unwrap<T2> tmp2(X.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
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_rows != B.n_rows) || (A.n_cols != B.n_cols), "trac e(): incompatible matrix dimensions" ); arma_debug_assert_same_size(A, B, "matrix schur product");
arma_debug_check( !A.is_square(), "trace(): matrices must be square" ); arma_debug_check( !A.is_square(), "trace(): matrices must be square" );
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<A.n_rows; ++i) for(u32 i=0; i<A.n_rows; ++i)
{ {
val += A.at(i,i) * B.at(i,i); val += A.at(i,i) * B.at(i,i);
} }
return val; return val;
} }
skipping to change at line 169 skipping to change at line 171
trace(const Op<Mat<eT>, op_diagmat_vec>& X) trace(const Op<Mat<eT>, op_diagmat_vec>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& A = X.m; const Mat<eT>& A = X.m;
arma_debug_check( !A.is_vec(), "trace(): internal error: can't interpret as a vector" ); arma_debug_check( !A.is_vec(), "trace(): internal error: can't interpret as a vector" );
return accu(X.m); return accu(X.m);
} }
#endif
//! @} //! @}
 End of changes. 5 change blocks. 
3 lines changed or deleted 7 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
skipping to change at line 59 skipping to change at line 59
template<typename vec_type> template<typename vec_type>
inline inline
const Op<vec_type,op_zeros> const Op<vec_type,op_zeros>
zeros(const u32 n_elem) zeros(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply(); arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply();
return Op<vec_type,op_zeros>(n_elem, 0, 'j'); if(is_Row<vec_type>::value == true)
{
return Op<vec_type,op_zeros>(1, n_elem, 'j');
}
else
{
return Op<vec_type,op_zeros>(n_elem, 1, 'j');
}
} }
// //
// //
// handling of cubes // handling of cubes
//! Generate a dense cube with all elements set to zero //! Generate a dense cube with all elements set to zero
inline inline
const OpCube<cube, op_zeros> const OpCube<cube, op_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices)
 End of changes. 1 change blocks. 
1 lines changed or deleted 8 lines changed or added


 glue_cor_meat.hpp   glue_cor_meat.hpp 
skipping to change at line 151 skipping to change at line 151
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;
glue_cor::direct_cor(out, A, B, 0); const u32 norm_type = X.aux_u32;
if(&A != &B)
{
glue_cor::direct_cor(out, A, B, norm_type);
}
else
{
op_cor::direct_cor(out, A, norm_type);
}
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 11 lines changed or added


 glue_cov_meat.hpp   glue_cov_meat.hpp 
skipping to change at line 139 skipping to change at line 139
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;
glue_cov::direct_cov(out, A, B, 0); const u32 norm_type = X.aux_u32;
if(&A != &B)
{
glue_cov::direct_cov(out, A, B, norm_type);
}
else
{
op_cov::direct_cov(out, A, norm_type);
}
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 11 lines changed or added


 glue_cube_div_meat.hpp   glue_cube_div_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_cube_div //! \addtogroup glue_cube_div
//! @{ //! @{
template<typename eT>
inline
void
glue_cube_div::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "element-wise cube division");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
const u32 n_elem = A.n_elem;
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] / B_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_div::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B, c
onst Cube<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "element-wise cube division");
arma_debug_assert_same_size(B, C, "element-wise cube division");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
const u32 n_elem = A.n_elem;
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] / B_mem[i] / C_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_div::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue_c
ube_div>& X)
{
glue_cube_div::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_cube_div::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cube<
eT>,glue_cube_div>, Cube<eT>,glue_cube_div>& X)
{
glue_cube_div::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline
void void
glue_cube_div::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1,T 2,glue_cube_div>& X) glue_cube_div::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1,T 2,glue_cube_div>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_cube = 1 + depth_lhs_cube< glue_cube_div, GlueCube<T1,T2,glue _cube_div> >::num; const u32 N_cube = 1 + depth_lhs_cube< glue_cube_div, GlueCube<T1,T2,glue _cube_div> >::num;
arma_extra_debug_print( arma_boost::format("N_cube = %d") % N_cube ); arma_extra_debug_print( arma_boost::format("N_cube = %d") % N_cube );
skipping to change at line 156 skipping to change at line 87
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename eT> template<typename T1>
inline inline
void void
glue_cube_div::apply_inplace(Cube<eT>& out, const Cube<eT>& B) glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const T1& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X);
const Cube<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "element-wise cube division"); arma_debug_assert_same_size(out, B, "element-wise cube division");
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= B_mem[i]; out_mem[i] /= B_mem[i];
} }
} }
template<typename T1, typename op_cube_type> //! element-wise division with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const OpCub e<T1, op_cube_type>& X) glue_cube_div::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& ou t, const Cube<eT1>& X, const Cube<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
const Cube<eT> tmp(X); arma_debug_assert_same_size(X,Y, "element-wise cube division");
glue_cube_div::apply_inplace(out, tmp);
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
} }
template<typename T1, typename T2, typename glue_cube_type> template<typename eT>
inline inline
void void
glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const GlueC ube<T1, T2, glue_cube_type>& X) glue_cube_div::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; arma_debug_assert_same_size(A, B, "element-wise cube division");
const Cube<eT> tmp(X); // no aliasing problem
glue_cube_div::apply_inplace(out, tmp); //out.set_size(A.n_rows, A.n_cols, A.n_slices);
} out.copy_size(A);
// const u32 n_elem = A.n_elem;
// element-wise division with different element types
template<typename eT1, typename eT2> eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] / B_mem[i];
}
}
template<typename eT>
inline inline
void void
glue_cube_div::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& ou t, const Cube<eT1>& X, const Cube<eT2>& Y) glue_cube_div::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B, c onst Cube<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; arma_debug_assert_same_size(A, B, "element-wise cube division");
arma_debug_assert_same_size(B, C, "element-wise cube division");
arma_debug_assert_same_size(X,Y, "element-wise cube division");
//out.set_size(X.n_rows, X.n_cols, X.n_slices); // no aliasing problem
out.copy_size(X); //out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out_eT* out_mem = out.memptr(); const u32 n_elem = A.n_elem;
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = A_mem[i] / B_mem[i] / C_mem[i];
} }
}
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_cube_div::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue_c
ube_div>& X)
{
glue_cube_div::apply(out, X.A, X.B);
} }
template<typename eT>
inline
void
glue_cube_div::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cube<
eT>,glue_cube_div>, Cube<eT>,glue_cube_div>& X)
{
glue_cube_div::apply(out, X.A.A, X.A.B, X.B);
}
#endif
//! @} //! @}
 End of changes. 23 change blocks. 
100 lines changed or deleted 82 lines changed or added


 glue_cube_div_proto.hpp   glue_cube_div_proto.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 glue_cube_div //! \addtogroup glue_cube_div
//! @{ //! @{
//! Class which implements the immediate element-wise division of two or mo re cubes //! Class which implements the immediate element-wise division of two or mo re cubes
class glue_cube_div class glue_cube_div
{ {
public: public:
template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1,T2,glue_cube_div>& X);
template<typename T1>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
T1& X);
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>, glue_cube_div>& X); inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>, glue_cube_div>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT> ,Cube<eT>, glue_cube_div>, Cube<eT>, glue_cube_div>& X); inline static void apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT> ,Cube<eT>, glue_cube_div>, Cube<eT>, glue_cube_div>& X);
template<typename T1, typename T2> #endif
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1,T2,glue_cube_div>& X);
template<typename eT>
inline static void apply_inplace(Cube<eT>& out, const Cube<eT>& B);
template<typename T1, typename op_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
OpCube<T1, op_cube_type>& X);
template<typename T1, typename T2, typename glue_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
GlueCube<T1, T2, glue_cube_type>& X);
// element-wise division with different element types
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
20 lines changed or deleted 15 lines changed or added


 glue_cube_minus_meat.hpp   glue_cube_minus_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_cube_minus //! \addtogroup glue_cube_minus
//! @{ //! @{
//! Immediate out = A-B
template<typename eT>
inline
void
glue_cube_minus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube subtraction");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i];
}
}
//! Immediate out = A-B-C
template<typename eT>
inline
void
glue_cube_minus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B,
const Cube<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube subtraction");
arma_debug_assert_same_size(B, C, "cube subtraction");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i] - C_mem[i];
}
}
//! Immediate out = A-B (operands obtained from Glue)
template<typename eT>
inline
void
glue_cube_minus::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue
_cube_minus>& X)
{
glue_cube_minus::apply(out, X.A, X.B);
}
//! Immediate out = A-B-C (operands obtained from Glue)
template<typename eT>
inline
void
glue_cube_minus::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cub
e<eT>,glue_cube_minus>, Cube<eT>, glue_cube_minus> &X)
{
glue_cube_minus::apply(out, X.A.A, X.A.B, X.B);
}
//! Immediate out = A-B-...-Z (operands obtained from Glue) //! Immediate out = A-B-...-Z (operands obtained from Glue)
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_cube_minus::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1 ,T2,glue_cube_minus>& X) glue_cube_minus::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1 ,T2,glue_cube_minus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
skipping to change at line 163 skipping to change at line 89
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
//! Immediate out -= B //! Immediate out -= B
template<typename eT> template<typename T1>
inline inline
void void
glue_cube_minus::apply_inplace(Cube<eT>& out, const Cube<eT>& B) glue_cube_minus::apply_inplace(Cube<typename T1::elem_type>& out, const T1& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X);
const Cube<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "cube subtraction"); arma_debug_assert_same_size(out, B, "cube subtraction");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] -= B_mem[i]; out_mem[i] -= B_mem[i];
} }
} }
template<typename T1, typename op_cube_type> //! cube subtraction with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_cube_minus::apply_inplace(Cube<typename T1::elem_type>& out, const OpC ube<T1, op_cube_type>& X) glue_cube_minus::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& out, const Cube<eT1>& X, const Cube<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
const Cube<eT> tmp(X); arma_debug_assert_same_size(X,Y, "cube subtraction");
glue_cube_minus::apply_inplace(out, tmp);
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
} }
template<typename T1, typename T2, typename glue_cube_type> //! Immediate out = A-B
template<typename eT>
inline inline
void void
glue_cube_minus::apply_inplace(Cube<typename T1::elem_type>& out, const Glu eCube<T1, T2, glue_cube_type>& X) glue_cube_minus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; arma_debug_assert_same_size(A, B, "cube subtraction");
out = out - X; // no aliasing problem
} //out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
// const u32 n_elem = A.n_elem;
// cube subtraction with different element types
template<typename eT1, typename eT2> for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i];
}
}
//! Immediate out = A-B-C
template<typename eT>
inline inline
void void
glue_cube_minus::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& out, const Cube<eT1>& X, const Cube<eT2>& Y) glue_cube_minus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B, const Cube<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; arma_debug_assert_same_size(A, B, "cube subtraction");
arma_debug_assert_same_size(B, C, "cube subtraction");
arma_debug_assert_same_size(X,Y, "cube subtraction");
//out.set_size(X.n_rows, X.n_cols, X.n_slices); // no aliasing problem
out.copy_size(X); //out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out_eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT* A_mem = A.mem;
const eT2* Y_mem = Y.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = A_mem[i] - B_mem[i] - C_mem[i];
} }
} }
#if defined(ARMA_GOOD_COMPILER)
//! Immediate out = A-B (operands obtained from Glue)
template<typename eT>
inline
void
glue_cube_minus::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue
_cube_minus>& X)
{
glue_cube_minus::apply(out, X.A, X.B);
}
//! Immediate out = A-B-C (operands obtained from Glue)
template<typename eT>
inline
void
glue_cube_minus::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cub
e<eT>,glue_cube_minus>, Cube<eT>, glue_cube_minus> &X)
{
glue_cube_minus::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2>
inline
void
glue_cube_minus::apply_inplace(Cube<typename T1::elem_type>& out, const Glu
eCube<T1, T2, glue_cube_minus>& X)
{
arma_extra_debug_sigprint();
out = out - X;
}
#endif
//! @} //! @}
 End of changes. 22 change blocks. 
103 lines changed or deleted 96 lines changed or added


 glue_cube_minus_proto.hpp   glue_cube_minus_proto.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 glue_cube_minus //! \addtogroup glue_cube_minus
//! @{ //! @{
//! Class which implements the immediate subtraction of cubes //! Class which implements the immediate subtraction of cubes
class glue_cube_minus class glue_cube_minus
{ {
public: public:
// cube template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1,T2,glue_cube_minus>& X);
template<typename T1>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
T1& X);
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube< Cube<eT>, Cube<eT >, glue_cube_minus>& X); inline static void apply(Cube<eT>& out, const GlueCube< Cube<eT>, Cube<eT >, glue_cube_minus>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube< GlueCube< Cube<eT >,Cube<eT>,glue_cube_minus>, Cube<eT>, glue_cube_minus>& X); inline static void apply(Cube<eT>& out, const GlueCube< GlueCube< Cube<eT >,Cube<eT>,glue_cube_minus>, Cube<eT>, glue_cube_minus>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub e<T1,T2,glue_cube_minus>& X); inline static void apply_inplace(Cube<typename T1::elem_type>& out, const GlueCube<T1, T2, glue_cube_minus>& X);
// cube, inplace #endif
template<typename eT>
inline static void apply_inplace(Cube<eT>& out, const Cube<eT>& B);
template<typename T1, typename op_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
OpCube<T1, op_cube_type>& X);
template<typename T1, typename T2, typename glue_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
GlueCube<T1, T2, glue_cube_type>& X);
// cube subtraction with different element types
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
20 lines changed or deleted 15 lines changed or added


 glue_cube_plus_meat.hpp   glue_cube_plus_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_cube_plus //! \addtogroup glue_cube_plus
//! @{ //! @{
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube addition");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B,
const Cube<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube addition");
arma_debug_assert_same_size(B, C, "cube addition");
// no aliasing problem
//out.set_size(A);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i] + C_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue_
cube_plus>& X)
{
glue_cube_plus::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cube
<eT>,glue_cube_plus>, Cube<eT>, glue_cube_plus>& X)
{
glue_cube_plus::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_cube_plus::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1, T2,glue_cube_plus>& X) glue_cube_plus::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1, T2,glue_cube_plus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_cube = 1 + depth_lhs_cube< glue_cube_plus, GlueCube<T1,T2,glu e_cube_plus> >::num; const u32 N_cube = 1 + depth_lhs_cube< glue_cube_plus, GlueCube<T1,T2,glu e_cube_plus> >::num;
skipping to change at line 159 skipping to change at line 89
{ {
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename T1>
inline
void
glue_cube_plus::apply_inplace(Cube<typename T1::elem_type>& out, const T1&
X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X);
const Cube<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "cube addition");
eT* out_mem = out.memptr();
const eT* B_mem = B.mem;
const u32 n_elem = B.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += B_mem[i];
}
}
//! cube addition with different element types
template<typename eT1, typename eT2>
inline
void
glue_cube_plus::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& o
ut, const Cube<eT1>& X, const Cube<eT2>& Y)
{
arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "cube addition");
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
}
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube addition");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B,
const Cube<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube addition");
arma_debug_assert_same_size(B, C, "cube addition");
// no aliasing problem
//out.set_size(A);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i] + C_mem[i];
}
}
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue_
cube_plus>& X)
{
glue_cube_plus::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_cube_plus::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cube
<eT>,glue_cube_plus>, Cube<eT>, glue_cube_plus>& X)
{
glue_cube_plus::apply(out, X.A.A, X.A.B, X.B);
}
template<typename eT> template<typename eT>
inline inline
void void
glue_cube_plus::apply(Cube<eT>& out, const GlueCube<Cube<eT>, subview_cube< eT>, glue_cube_plus>& X) glue_cube_plus::apply(Cube<eT>& out, const GlueCube<Cube<eT>, subview_cube< eT>, glue_cube_plus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Cube<eT>& orig_A = X.A; const Cube<eT>& orig_A = X.A;
const Cube<eT>& orig_B = X.B.m; const Cube<eT>& orig_B = X.B.m;
skipping to change at line 301 skipping to change at line 356
} }
else else
{ {
const Cube<eT> processed_A(X.A); const Cube<eT> processed_A(X.A);
const Cube<eT> processed_B(X.B); const Cube<eT> processed_B(X.B);
glue_cube_plus::apply(out, processed_A, processed_B); glue_cube_plus::apply(out, processed_A, processed_B);
} }
} }
template<typename eT>
inline
void
glue_cube_plus::apply_inplace(Cube<eT>& out, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, B, "cube addition");
eT* out_mem = out.memptr();
const eT* B_mem = B.mem;
const u32 n_elem = B.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += B_mem[i];
}
}
template<typename T1, typename op_cube_type>
inline
void
glue_cube_plus::apply_inplace(Cube<typename T1::elem_type>& out, const OpCu
be<T1, op_cube_type>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const Cube<eT> tmp(X);
glue_cube_plus::apply_inplace(out, tmp);
}
template<typename T1> template<typename T1>
inline inline
void void
glue_cube_plus::apply_inplace(Cube<typename T1::elem_type>& out, const OpCu be<T1, op_square>& X) glue_cube_plus::apply_inplace(Cube<typename T1::elem_type>& out, const OpCu be<T1, op_square>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X.m); const unwrap_cube<T1> tmp(X.m);
skipping to change at line 361 skipping to change at line 382
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT tmp_val = B_mem[i]; const eT tmp_val = B_mem[i];
out_mem[i] += tmp_val*tmp_val; out_mem[i] += tmp_val*tmp_val;
} }
} }
template<typename T1, typename T2, typename glue_cube_type> template<typename T1, typename T2>
inline inline
void void
glue_cube_plus::apply_inplace(Cube<typename T1::elem_type>& out, const Glue Cube<T1, T2, glue_cube_type>& X) glue_cube_plus::apply_inplace(Cube<typename T1::elem_type>& out, const Glue Cube<T1, T2, glue_cube_plus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X + out; out = X + out;
} }
// #endif
// cube addition with different element types
template<typename eT1, typename eT2>
inline
void
glue_cube_plus::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& o
ut, const Cube<eT1>& X, const Cube<eT2>& Y)
{
arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "cube addition");
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
}
//! @} //! @}
 End of changes. 6 change blocks. 
140 lines changed or deleted 134 lines changed or added


 glue_cube_plus_proto.hpp   glue_cube_plus_proto.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 glue_cube_plus //! \addtogroup glue_cube_plus
//! @{ //! @{
//! Class which implements the immediate addition of cubes //! Class which implements the immediate addition of cubes
class glue_cube_plus class glue_cube_plus
{ {
public: public:
// cube template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1, T2, glue_cube_plus>& X);
template<typename T1>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
T1& X);
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>, Cube<eT> , glue_cube_plus>& X); inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>, Cube<eT> , glue_cube_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT> ,Cube<eT>,glue_cube_plus>, Cube<eT>, glue_cube_plus>& X); inline static void apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT> ,Cube<eT>,glue_cube_plus>, Cube<eT>, glue_cube_plus>& X);
template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1, T2, glue_cube_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>, subview_ cube<eT>, glue_cube_plus>& X); inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>, subview_ cube<eT>, glue_cube_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube<subview_cube<eT>, Cube<eT>, glue_cube_plus>& X); inline static void apply(Cube<eT>& out, const GlueCube<subview_cube<eT>, Cube<eT>, glue_cube_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube<subview_cube<eT>, subview_cube<eT>, glue_cube_plus>& X); inline static void apply(Cube<eT>& out, const GlueCube<subview_cube<eT>, subview_cube<eT>, glue_cube_plus>& X);
// cube, inplace
template<typename eT>
inline static void apply_inplace(Cube<eT>& out, const Cube<eT>& B);
template<typename T1, typename op_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
OpCube<T1, op_cube_type>& X);
template<typename T1> template<typename T1>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const OpCube<T1, op_square>& X); inline static void apply_inplace(Cube<typename T1::elem_type>& out, const OpCube<T1, op_square>& X);
template<typename T1, typename T2, typename glue_cube_type> template<typename T1, typename T2>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
GlueCube<T1, T2, glue_cube_type>& X); GlueCube<T1, T2, glue_cube_plus>& X);
// cube addition with different element types
template<typename eT1, typename eT2> #endif
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
22 lines changed or deleted 17 lines changed or added


 glue_cube_schur_meat.hpp   glue_cube_schur_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_cube_schur //! \addtogroup glue_cube_schur
//! @{ //! @{
template<typename eT>
inline
void
glue_cube_schur::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube schur product");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] * B_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_schur::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B,
const Cube<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "cube schur product");
arma_debug_assert_same_size(A, C, "cube schur product");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] * B_mem[i] * C_mem[i];
}
}
template<typename eT>
inline
void
glue_cube_schur::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue
_cube_schur>& X)
{
glue_cube_schur::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_cube_schur::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cub
e<eT>,glue_cube_schur>, Cube<eT>,glue_cube_schur>& X)
{
glue_cube_schur::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline
void void
glue_cube_schur::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1 ,T2,glue_cube_schur>& X) glue_cube_schur::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1 ,T2,glue_cube_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_cube = 1 + depth_lhs_cube< glue_cube_schur, GlueCube<T1,T2,gl ue_cube_schur> >::num; const u32 N_cube = 1 + depth_lhs_cube< glue_cube_schur, GlueCube<T1,T2,gl ue_cube_schur> >::num;
arma_extra_debug_print( arma_boost::format("N_cube = %d") % N_cube ); arma_extra_debug_print( arma_boost::format("N_cube = %d") % N_cube );
skipping to change at line 156 skipping to change at line 87
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename eT> template<typename T1>
inline inline
void void
glue_cube_schur::apply_inplace(Cube<eT>& out, const Cube<eT>& B) glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const T1& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X);
const Cube<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "cube schur product"); arma_debug_assert_same_size(out, B, "cube schur product");
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] *= B_mem[i]; out_mem[i] *= B_mem[i];
} }
} }
template<typename T1, typename op_cube_type> //! cube schur product with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const OpC ube<T1, op_cube_type>& X) glue_cube_schur::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& out, const Cube<eT1>& X, const Cube<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "cube schur product");
const Cube<eT> tmp(X); //out.set_size(X.n_rows, X.n_cols, X.n_slices);
glue_cube_schur::apply_inplace(out, tmp); out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) * upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
} }
template<typename T1, typename T2, typename glue_cube_type> template<typename eT>
inline inline
void void
glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const Glu eCube<T1, T2, glue_cube_type>& X) glue_cube_schur::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// out = X % out; arma_debug_assert_same_size(A, B, "cube schur product");
typedef typename T1::elem_type eT; // no aliasing problem
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
const Cube<eT> tmp(X); eT* out_mem = out.memptr();
glue_cube_schur::apply_inplace(out, tmp); const eT* A_mem = A.mem;
} const eT* B_mem = B.mem;
// const u32 n_elem = A.n_elem;
// cube schur product with different element types
template<typename eT1, typename eT2> for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] * B_mem[i];
}
}
template<typename eT>
inline inline
void void
glue_cube_schur::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& out, const Cube<eT1>& X, const Cube<eT2>& Y) glue_cube_schur::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B, const Cube<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; arma_debug_assert_same_size(A, B, "cube schur product");
arma_debug_assert_same_size(A, C, "cube schur product");
arma_debug_assert_same_size(X,Y, "cube schur product");
//out.set_size(X.n_rows, X.n_cols, X.n_slices); // no aliasing problem
out.copy_size(X); //out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out_eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT* A_mem = A.mem;
const eT2* Y_mem = Y.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) * upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = A_mem[i] * B_mem[i] * C_mem[i];
} }
} }
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_cube_schur::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue
_cube_schur>& X)
{
glue_cube_schur::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_cube_schur::apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT>,Cub
e<eT>,glue_cube_schur>, Cube<eT>,glue_cube_schur>& X)
{
glue_cube_schur::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2>
inline
void
glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const Glu
eCube<T1, T2, glue_cube_schur>& X)
{
arma_extra_debug_sigprint();
out = X % out;
}
#endif
//! @} //! @}
 End of changes. 24 change blocks. 
101 lines changed or deleted 92 lines changed or added


 glue_cube_schur_proto.hpp   glue_cube_schur_proto.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 glue_cube_schur //! \addtogroup glue_cube_schur
//! @{ //! @{
//! Class which implements the immediate Schur product (element-wise multip lication) of two or more cubes //! Class which implements the immediate Schur product (element-wise multip lication) of two or more cubes
class glue_cube_schur class glue_cube_schur
{ {
public: public:
// mat template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1,T2,glue_cube_schur>& X);
template<typename T1>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
T1& X);
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C); inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT> & B, const Cube<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>, glue_cube_schur>& X); inline static void apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>, glue_cube_schur>& X);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT> ,Cube<eT>,glue_cube_schur>, Cube<eT>, glue_cube_schur>& X); inline static void apply(Cube<eT>& out, const GlueCube< GlueCube<Cube<eT> ,Cube<eT>,glue_cube_schur>, Cube<eT>, glue_cube_schur>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub e<T1,T2,glue_cube_schur>& X); inline static void apply_inplace(Cube<typename T1::elem_type>& out, const GlueCube<T1, T2, glue_cube_schur>& X);
// mat, inplace #endif
template<typename eT> inline static void apply_inplace(Cube<eT>& out, con
st Cube<eT>& B);
template<typename T1, typename op_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
OpCube<T1, op_cube_type>& X);
template<typename T1, typename T2, typename glue_cube_type>
inline static void apply_inplace(Cube<typename T1::elem_type>& out, const
GlueCube<T1, T2, glue_cube_type>& X);
// matrix schur product with different element types
template<typename eT1, typename eT2>
inline static void apply_mixed(Cube<typename promote_type<eT1,eT2>::resul
t>& out, const Cube<eT1>& X, const Cube<eT2>& Y);
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
20 lines changed or deleted 15 lines changed or added


 glue_div_meat.hpp   glue_div_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_div //! \addtogroup glue_div
//! @{ //! @{
template<typename eT>
inline
void
glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "element-wise matrix division");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const u32 n_elem = A.n_elem;
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] / B_mem[i];
}
}
template<typename eT>
inline
void
glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat
<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "element-wise matrix division");
arma_debug_assert_same_size(B, C, "element-wise matrix division");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const u32 n_elem = A.n_elem;
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] / B_mem[i] / C_mem[i];
}
}
template<typename eT>
inline
void
glue_div::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_div>& X)
{
glue_div::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_div::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_div>, M
at<eT>,glue_div>& X)
{
glue_div::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline
void void
glue_div::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_div >& X) glue_div::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_div >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_mat = 1 + depth_lhs< glue_div, Glue<T1,T2,glue_div> >::num; const u32 N_mat = 1 + depth_lhs< glue_div, Glue<T1,T2,glue_div> >::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 );
if(N_mat == 2) if(N_mat == 2)
{ {
const unwrap<T1> tmp1(X.A); if(is_Mat<T1>::value == false)
const unwrap<T2> tmp2(X.B); {
out = X.A;
glue_div::apply_inplace(out, X.B);
}
else
{
const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
glue_div::apply(out, tmp1.M, tmp2.M); glue_div::apply(out, tmp1.M, tmp2.M);
}
} }
else else
{ {
const Mat<eT>* ptrs[N_mat]; const Mat<eT>* ptrs[N_mat];
bool del[N_mat]; bool del[N_mat];
mat_ptrs<glue_div, Glue<T1,T2,glue_div> >::get_ptrs(ptrs, del, X); mat_ptrs<glue_div, Glue<T1,T2,glue_div> >::get_ptrs(ptrs, del, X);
//mat_ptrs_outcheck<glue_div, Glue<T1,T2,glue_div> >::get_ptrs(ptrs, de l, X, &out); //mat_ptrs_outcheck<glue_div, Glue<T1,T2,glue_div> >::get_ptrs(ptrs, de l, X, &out);
for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] ); for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] );
skipping to change at line 156 skipping to change at line 95
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename eT> template<typename T1>
inline inline
void void
glue_div::apply_inplace(Mat<eT>& out, const Mat<eT>& B) glue_div::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;
const unwrap<T1> tmp(X);
const Mat<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "element-wise matrix division"); arma_debug_assert_same_size(out, B, "element-wise matrix division");
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= B_mem[i]; out_mem[i] /= B_mem[i];
} }
} }
template<typename T1, typename op_type> //! element-wise division with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_div::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_t ype>& X) glue_div::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, con st Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "element-wise matrix division");
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const Mat<eT> tmp(X); const u32 n_elem = out.n_elem;
glue_div::apply_inplace(out, tmp);
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
} }
template<typename T1, typename T2, typename glue_type> template<typename eT>
inline inline
void void
glue_div::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2 , glue_type>& X) glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; arma_debug_assert_same_size(A, B, "element-wise matrix division");
const Mat<eT> tmp(X); // no aliasing problem
glue_div::apply_inplace(out, tmp); //out.set_size(A.n_rows, A.n_cols);
} out.copy_size(A);
const u32 n_elem = A.n_elem;
// eT* out_mem = out.memptr();
// element-wise division with different element types const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
template<typename eT1, typename eT2> for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] / B_mem[i];
}
}
template<typename eT>
inline inline
void void
glue_div::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, con st Mat<eT1>& X, const Mat<eT2>& Y) glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat <eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; arma_debug_assert_same_size(A, B, "element-wise matrix division");
arma_debug_assert_same_size(B, C, "element-wise matrix division");
arma_debug_assert_same_size(X,Y, "element-wise matrix division");
//out.set_size(X.n_rows, X.n_cols); // no aliasing problem
out.copy_size(X); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
out_eT* out_mem = out.memptr(); const u32 n_elem = A.n_elem;
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = A_mem[i] / B_mem[i] / C_mem[i];
} }
}
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_div::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_div>& X)
{
glue_div::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_div::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_div>, M
at<eT>,glue_div>& X)
{
glue_div::apply(out, X.A.A, X.A.B, X.B);
} }
#endif
//! @} //! @}
 End of changes. 25 change blocks. 
102 lines changed or deleted 92 lines changed or added


 glue_div_proto.hpp   glue_div_proto.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 glue_div //! \addtogroup glue_div
//! @{ //! @{
//! Class which implements the immediate element-wise division of two or mo re matrices //! Class which implements the immediate element-wise division of two or mo re matrices
class glue_div class glue_div
{ {
public: public:
template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_div>& X);
template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
T1& X);
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);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B ); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B );
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); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_di v>& X); inline static void apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_di v>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>, glue_div>, Mat<eT>, glue_div>& X); inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>, glue_div>, Mat<eT>, glue_div>& X);
template<typename T1, typename T2> #endif
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_div>& X);
template<typename eT>
inline static void apply_inplace(Mat<eT>& out, const Mat<eT>& B);
template<typename T1, typename op_type>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_type>& X);
template<typename T1, typename T2, typename glue_type>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_type>& X);
// element-wise division with different element types
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);
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
20 lines changed or deleted 15 lines changed or added


 glue_minus_meat.hpp   glue_minus_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_minus //! \addtogroup glue_minus
//! @{ //! @{
//! Immediate out = A-B
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix subtraction");
// no aliasing problem
//out.set_size(A.n_rows,A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i];
}
}
//! Immediate out = A-B-C
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M
at<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix subtraction");
arma_debug_assert_same_size(A, C, "matrix subtraction");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i] - C_mem[i];
}
}
//! Immediate out = A-B (operands obtained from Glue)
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_minus>& X)
{
glue_minus::apply(out, X.A, X.B);
}
//! Immediate out = A-B-C (operands obtained from Glue)
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_minus
>, Mat<eT>, glue_minus> &X)
{
glue_minus::apply(out, X.A.A, X.A.B, X.B);
}
//! Immediate out = A-B-...-Z (operands obtained from Glue) //! Immediate out = A-B-...-Z (operands obtained from Glue)
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_minus::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_m inus>& X) glue_minus::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_m inus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_mat = 1 + depth_lhs< glue_minus, Glue<T1,T2,glue_minus> >::nu m; const u32 N_mat = 1 + depth_lhs< glue_minus, Glue<T1,T2,glue_minus> >::nu m;
arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat ); arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat );
if(N_mat == 2) if(N_mat == 2)
{ {
const unwrap<T1> tmp1(X.A); if(is_Mat<T1>::value == false)
const unwrap<T2> tmp2(X.B); {
out = X.A;
glue_minus::apply_inplace(out, X.B);
}
else
{
const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
glue_minus::apply(out, tmp1.M, tmp2.M); glue_minus::apply(out, tmp1.M, tmp2.M);
}
} }
else else
{ {
const Mat<eT>* ptrs[N_mat]; const Mat<eT>* ptrs[N_mat];
bool del[N_mat]; bool del[N_mat];
mat_ptrs<glue_minus, Glue<T1,T2,glue_minus> >::get_ptrs(ptrs, del, X); mat_ptrs<glue_minus, Glue<T1,T2,glue_minus> >::get_ptrs(ptrs, del, X);
//mat_ptrs_outcheck<glue_minus, Glue<T1,T2,glue_minus> >::get_ptrs(ptrs , del, X, &out); //mat_ptrs_outcheck<glue_minus, Glue<T1,T2,glue_minus> >::get_ptrs(ptrs , del, X, &out);
for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] ); for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] );
skipping to change at line 163 skipping to change at line 97
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
//! Immediate out -= B //! Immediate out -= B
template<typename eT> template<typename T1>
inline inline
void void
glue_minus::apply_inplace(Mat<eT>& out, const Mat<eT>& B) glue_minus::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;
const unwrap<T1> tmp(X);
const Mat<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "matrix subtraction"); arma_debug_assert_same_size(out, B, "matrix subtraction");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] -= B_mem[i]; out_mem[i] -= B_mem[i];
} }
} }
template<typename T1, typename op_type> //! matrix subtraction with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_minus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op _type>& X) glue_minus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix subtraction");
const Mat<eT> tmp(X); //out.set_size(X.n_rows, X.n_cols);
glue_minus::apply_inplace(out, tmp); out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
} }
template<typename T1, typename T2, typename glue_type> //! Immediate out = A-B
template<typename eT>
inline inline
void void
glue_minus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
T2, glue_type>& X) {
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix subtraction");
// no aliasing problem
//out.set_size(A.n_rows,A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i];
}
}
//! Immediate out = A-B-C
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M
at<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix subtraction");
arma_debug_assert_same_size(A, C, "matrix subtraction");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] - B_mem[i] - C_mem[i];
}
}
#if defined(ARMA_GOOD_COMPILER)
template<typename T1>
inline
void
glue_minus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op
_scalar_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
out = out - X; const unwrap<T1> tmp(X.m);
const Mat<eT>& A = tmp.M;
arma_debug_assert_same_size(out, A, "matrix subtraction");
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT k = X.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] -= k * A_mem[i];
}
} }
// template<typename T1>
// matrix subtraction with different element types inline
void
glue_minus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op
_scalar_div_pre>& X)
{
arma_extra_debug_sigprint();
template<typename eT1, typename eT2> typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.m);
const Mat<eT>& A = tmp.M;
arma_debug_assert_same_size(out, A, "matrix subtraction");
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT k = X.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] -= k / A_mem[i];
}
}
template<typename T1>
inline inline
void void
glue_minus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y) glue_minus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op _scalar_div_post>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename T1::elem_type eT;
arma_debug_assert_same_size(X,Y, "matrix subtraction"); const unwrap<T1> tmp(X.m);
const Mat<eT>& A = tmp.M;
//out.set_size(X.n_rows, X.n_cols); arma_debug_assert_same_size(out, A, "matrix subtraction");
out.copy_size(X);
out_eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT* A_mem = A.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; const eT k = X.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] -= A_mem[i] / k;
} }
} }
//! Immediate out = A-B (operands obtained from Glue)
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_minus>& X)
{
glue_minus::apply(out, X.A, X.B);
}
//! Immediate out = A-B-C (operands obtained from Glue)
template<typename eT>
inline
void
glue_minus::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_minus
>, Mat<eT>, glue_minus> &X)
{
glue_minus::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2>
inline
void
glue_minus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_minus>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = out - X;
}
#endif
// //
// glue_minus_diag // glue_minus_diag
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_minus_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, const Op<T2,op_diagmat>& B_orig) glue_minus_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, const Op<T2,op_diagmat>& B_orig)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 23 change blocks. 
103 lines changed or deleted 186 lines changed or added


 glue_minus_proto.hpp   glue_minus_proto.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 glue_minus //! \addtogroup glue_minus
//! @{ //! @{
//! Class for the minus operation, where the result is always a dense matri x //! Class for the minus operation, where the result is always a dense matri x
class glue_minus class glue_minus
{ {
public: public:
// mat template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_minus>& X);
template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
T1& X);
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);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B ); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B );
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); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C);
template<typename eT> #if defined(ARMA_GOOD_COMPILER)
inline static void apply(Mat<eT>& out, const Glue< Mat<eT>, Mat<eT>, glue
_minus>& X);
template<typename eT> template<typename T1>
inline static void apply(Mat<eT>& out, const Glue< Glue< Mat<eT>,Mat<eT>, inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
glue_minus>, Mat<eT>, glue_minus>& X); Op<T1, op_scalar_times>& X);
template<typename T1, typename T2> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
T2,glue_minus>& X); Op<T1, op_scalar_div_pre>& X);
// mat, inplace template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_scalar_div_post>& X);
template<typename eT> //
inline static void apply_inplace(Mat<eT>& out, const Mat<eT>& B);
template<typename T1, typename op_type> template<typename eT>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply(Mat<eT>& out, const Glue< Mat<eT>, Mat<eT>, glue
Op<T1, op_type>& X); _minus>& X);
template<typename T1, typename T2, typename glue_type> template<typename eT>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply(Mat<eT>& out, const Glue< Glue< Mat<eT>,Mat<eT>,
Glue<T1, T2, glue_type>& X); glue_minus>, Mat<eT>, glue_minus>& X);
// matrix subtraction with different element types template<typename T1, typename T2>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_minus>& X);
template<typename eT1, typename eT2> #endif
inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result
>& out, const Mat<eT1>& X, const Mat<eT2>& Y);
}; };
//! Class for the minus operation, where one of the operands is a diagonal matrix //! Class for the minus operation, where one of the operands is a diagonal matrix
class glue_minus_diag class glue_minus_diag
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B); inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B);
 End of changes. 10 change blocks. 
23 lines changed or deleted 32 lines changed or added


 glue_plus_meat.hpp   glue_plus_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_plus //! \addtogroup glue_plus
//! @{ //! @{
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix addition");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i];
}
}
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Ma
t<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_assert_same_size(A, C, "matrix addition");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i] + C_mem[i];
}
}
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_plus>& X)
{
glue_plus::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_plus>,
Mat<eT>, glue_plus>& X)
{
glue_plus::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_plus::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_pl us>& X) glue_plus::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_pl us>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_mat = 1 + depth_lhs< glue_plus, Glue<T1,T2,glue_plus> >::num; const u32 N_mat = 1 + depth_lhs< glue_plus, Glue<T1,T2,glue_plus> >::num;
skipping to change at line 115 skipping to change at line 45
glue_plus::apply_inplace(out, X.A); glue_plus::apply_inplace(out, X.A);
} }
else else
if(is_glue_times<T2>::value == true) if(is_glue_times<T2>::value == true)
{ {
out = X.A; out = X.A;
glue_plus::apply_inplace(out, X.B); glue_plus::apply_inplace(out, X.B);
} }
else else
{ {
const unwrap<T1> tmp1(X.A); if(is_Mat<T1>::value == false)
const unwrap<T2> tmp2(X.B); {
out = X.A;
glue_plus::apply_inplace(out, X.B);
}
else
if(is_Mat<T2>::value == false)
{
out = X.B;
glue_plus::apply_inplace(out, X.A);
}
else
{
// even though the calls to unwrap in this block are logically unne
cessary,
// the compiler ignores the above if statements and overzealously c
hecks
// whether the code in this block can be used during all instances
of
// template expansion
const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
glue_plus::apply(out, tmp1.M, tmp2.M); glue_plus::apply(out, tmp1.M, tmp2.M);
}
} }
} }
else else
{ {
const Mat<eT>* ptrs[N_mat]; const Mat<eT>* ptrs[N_mat];
bool del[N_mat]; bool del[N_mat];
mat_ptrs<glue_plus, Glue<T1,T2,glue_plus> >::get_ptrs(ptrs, del, X); mat_ptrs<glue_plus, Glue<T1,T2,glue_plus> >::get_ptrs(ptrs, del, X);
for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] ); for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] );
skipping to change at line 169 skipping to change at line 118
{ {
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print( arma_boost::format("delete mat_ptr[%d]") % i ); arma_extra_debug_print( arma_boost::format("delete mat_ptr[%d]") % i );
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename T1>
inline
void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X);
const Mat<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "matrix addition");
eT* out_mem = out.memptr();
const eT* B_mem = B.mem;
const u32 n_elem = B.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += B_mem[i];
}
}
//! matrix addition with different element types
template<typename eT1, typename eT2>
inline
void
glue_plus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, co
nst Mat<eT1>& X, const Mat<eT2>& Y)
{
arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix addition");
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
}
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix addition");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i];
}
}
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Ma
t<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_assert_same_size(A, C, "matrix addition");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] + B_mem[i] + C_mem[i];
}
}
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_plus>& X)
{
glue_plus::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_plus::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_plus>,
Mat<eT>, glue_plus>& X)
{
glue_plus::apply(out, X.A.A, X.A.B, X.B);
}
// possible aliasing cases: // possible aliasing cases:
// Q = Q + Q.row(0) -> no problem (aliasing has no effect or incompatible matrix dimensions). // Q = Q + Q.row(0) -> no problem (aliasing has no effect or incompatible matrix dimensions).
// however, the only time the above will work is when Q has the same dimensions as Q.row(0), // however, the only time the above will work is when Q has the same dimensions as Q.row(0),
// meaning that doing this addition operation is prett y silly // meaning that doing this addition operation is prett y silly
// Q = Q + R.row(0) -> no problem // Q = Q + R.row(0) -> no problem
// Q = R + Q.row(0) -> output Q is set to size of R, which may destroy inp ut Q // Q = R + Q.row(0) -> output Q is set to size of R, which may destroy inp ut Q
// //
// strategy: // strategy:
// if the matrix from the second argument is an alias of the output matrix, // if the matrix from the second argument is an alias of the output matrix,
// make a proper matrix out of the second argument // make a proper matrix out of the second argument
skipping to change at line 320 skipping to change at line 394
} }
else else
{ {
const Mat<eT> processed_A(X.A); const Mat<eT> processed_A(X.A);
const Mat<eT> processed_B(X.B); const Mat<eT> processed_B(X.B);
glue_plus::apply(out, processed_A, processed_B); glue_plus::apply(out, processed_A, processed_B);
} }
} }
template<typename eT> template<typename T1>
inline void glue_plus::apply_inplace(Mat<eT>& out, const Mat<eT>& B) inline
void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_
square>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.m);
const Mat<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "matrix addition"); arma_debug_assert_same_size(out, B, "matrix addition");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 n_elem = B.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] += B_mem[i]; const eT tmp_val = B_mem[i];
out_mem[i] += tmp_val*tmp_val;
} }
}
template<typename T1>
inline
void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_
scalar_times>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.m);
const Mat<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "matrix addition");
eT* out_mem = out.memptr();
const eT* B_mem = B.mem;
const eT k = X.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += k * B_mem[i];
}
} }
template<typename T1, typename op_type> template<typename T1>
inline inline
void void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_ type>& X) glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_ scalar_div_pre>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT> tmp(X); const unwrap<T1> tmp(X.m);
glue_plus::apply_inplace(out, tmp); const Mat<eT>& A = tmp.M;
arma_debug_assert_same_size(out, A, "matrix addition");
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT k = X.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += k / A_mem[i];
}
} }
template<typename T1> template<typename T1>
inline inline
void void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_ square>& X) glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_ scalar_div_post>& 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.m); const unwrap<T1> tmp(X.m);
const Mat<eT>& B = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_assert_same_size(out, B, "matrix addition"); arma_debug_assert_same_size(out, A, "matrix addition");
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* A_mem = A.mem;
const eT k = X.aux;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT tmp_val = B_mem[i]; out_mem[i] += A_mem[i] / k;
out_mem[i] += tmp_val*tmp_val;
} }
} }
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2>
inline inline
void void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T 2, glue_type>& X) glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T 2, glue_plus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X + out; out = X + out;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<Op<T1
, op_scalar_times>, Op<T2, op_scalar_times>, glue_plus>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X.A.m);
const unwrap<T2> tmp2(X.B.m);
const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(out, A, "matrix addition");
arma_debug_assert_same_size( A, B, "matrix addition");
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k1 = X.A.aux;
const eT k2 = X.B.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += k1*A_mem[i] + k2*B_mem[i];
}
}
template<typename T1, typename T2, typename T3>
inline
void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue< Glue
< Op<T1, op_scalar_times>, Op<T2, op_scalar_times>, glue_plus>, Op<T3, op_s
calar_times>, glue_plus>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X.A.A.m);
const unwrap<T2> tmp2(X.A.B.m);
const unwrap<T3> tmp3(X.B.m);
const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M;
arma_debug_assert_same_size(out, A, "matrix addition");
arma_debug_assert_same_size( A, B, "matrix addition");
arma_debug_assert_same_size( B, C, "matrix addition");
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const eT k1 = X.A.A.aux;
const eT k2 = X.A.B.aux;
const eT k3 = X.B.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] += k1*A_mem[i] + k2*B_mem[i] + k3*C_mem[i];
}
}
template<typename T1, typename T2>
inline
void
glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T 2, glue_times>& X) glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T 2, glue_times>& 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> tmp1(X.A, out); const unwrap_check<T1> tmp1(X.A, out);
const unwrap_check<T2> tmp2(X.B, out); const unwrap_check<T2> tmp2(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
skipping to change at line 908 skipping to change at line 1099
const u32 local_n_elem = A.n_elem; const u32 local_n_elem = A.n_elem;
for(u32 i=0; i<local_n_elem; ++i) for(u32 i=0; i<local_n_elem; ++i)
{ {
out_mem[i] = A_mem[i]/k1 + B_mem[i]/k2 + C_mem[i]/k3; out_mem[i] = A_mem[i]/k1 + B_mem[i]/k2 + C_mem[i]/k3;
} }
} }
// #endif
// matrix addition with different element types
template<typename eT1, typename eT2>
inline
void
glue_plus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, co
nst Mat<eT1>& X, const Mat<eT2>& Y)
{
arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix addition");
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
}
// //
// glue_plus_diag // glue_plus_diag
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_plus_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, c onst Op<T2,op_diagmat>& B_orig) glue_plus_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, c onst Op<T2,op_diagmat>& B_orig)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 23 change blocks. 
122 lines changed or deleted 294 lines changed or added


 glue_plus_proto.hpp   glue_plus_proto.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 glue_plus //! \addtogroup glue_plus
//! @{ //! @{
//! Class which implements the immediate addition of matrices, with the res ult stored in 'Mat' (dense matrix) //! Class which implements the immediate addition of matrices, with the res ult stored in 'Mat' (dense matrix)
class glue_plus class glue_plus
{ {
public: public:
// mat template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_plus>& X);
template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
T1& X);
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);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B ); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B );
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); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
// mat
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<Mat<eT>, Mat<eT>, glue_ plus>& X); inline static void apply(Mat<eT>& out, const Glue<Mat<eT>, Mat<eT>, glue_ plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,g lue_plus>, Mat<eT>, glue_plus>& X); inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,g lue_plus>, Mat<eT>, glue_plus>& X);
template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<Mat<eT>, subview<eT>, g lue_plus>& X); inline static void apply(Mat<eT>& out, const Glue<Mat<eT>, subview<eT>, g lue_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<subview<eT>, Mat<eT>, g lue_plus>& X); inline static void apply(Mat<eT>& out, const Glue<subview<eT>, Mat<eT>, g lue_plus>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<subview<eT>, subview<eT >, glue_plus>& X); inline static void apply(Mat<eT>& out, const Glue<subview<eT>, subview<eT >, glue_plus>& X);
// mat, inplace // mat, inplace
template<typename eT> template<typename T1>
inline static void apply_inplace(Mat<eT>& out, const Mat<eT>& B); inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_square>& X);
template<typename T1, typename op_type> template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_type>& X); Op<T1, op_scalar_times>& X);
template<typename T1> template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_square>& X); Op<T1, op_scalar_div_pre>& X);
template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_scalar_div_post>& X);
template<typename T1, typename T2>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_plus>& X);
template<typename T1, typename T2>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<Op<T1, op_scalar_times>, Op<T2, op_scalar_times>, glue_plus>& X);
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename T3>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_type>& X); Glue< Glue< Op<T1, op_scalar_times>, Op<T2, op_scalar_times>, glue_plus>, O
p<T3, op_scalar_times>, glue_plus>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times>& X); inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<Op<T1, op_trans>, T2, glue_times>& X); inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<Op<T1, op_trans>, T2, glue_times>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, Op<T2, op_trans>, glue_times>& X); inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, Op<T2, op_trans>, glue_times>& X);
skipping to change at line 111 skipping to change at line 128
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl ue<Op<T1, op_scalar_div_pre>, Op<T2, op_scalar_div_pre>, glue_plus>, Op<T3, op_scalar_div_pre>, glue_plus>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl ue<Op<T1, op_scalar_div_pre>, Op<T2, op_scalar_div_pre>, glue_plus>, Op<T3, op_scalar_div_pre>, glue_plus>& in);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1, op_scalar_div_post>, Op<T2, op_scalar_div_post>, glue_plus>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1, op_scalar_div_post>, Op<T2, op_scalar_div_post>, glue_plus>& in);
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl ue<Op<T1, op_scalar_div_post>, Op<T2, op_scalar_div_post>, glue_plus>, Op<T 3, op_scalar_div_post>, glue_plus>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl ue<Op<T1, op_scalar_div_post>, Op<T2, op_scalar_div_post>, glue_plus>, Op<T 3, op_scalar_div_post>, glue_plus>& in);
// matrix addition with different element types #endif
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);
}; };
class glue_plus_diag class glue_plus_diag
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B); inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B);
 End of changes. 8 change blocks. 
20 lines changed or deleted 40 lines changed or added


 glue_schur_meat.hpp   glue_schur_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_schur //! \addtogroup glue_schur
//! @{ //! @{
template<typename eT>
inline
void
glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix schur product");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] * B_mem[i];
}
}
template<typename eT>
inline
void
glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M
at<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix schur product");
arma_debug_assert_same_size(A, C, "matrix schur product");
// no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] * B_mem[i] * C_mem[i];
}
}
template<typename eT>
inline
void
glue_schur::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_schur>& X)
{
glue_schur::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_schur::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_schur
>, Mat<eT>,glue_schur>& X)
{
glue_schur::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline
void void
glue_schur::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_s chur>& X) glue_schur::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_s chur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 N_mat = 1 + depth_lhs< glue_schur, Glue<T1,T2,glue_schur> >::nu m; const u32 N_mat = 1 + depth_lhs< glue_schur, Glue<T1,T2,glue_schur> >::nu m;
arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat ); arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat );
if(N_mat == 2) if(N_mat == 2)
{ {
const unwrap<T1> tmp1(X.A); if(is_Mat<T1>::value == false)
const unwrap<T2> tmp2(X.B); {
out = X.A;
glue_schur::apply_inplace(out, X.B);
}
else
if(is_Mat<T2>::value == false)
{
out = X.B;
glue_schur::apply_inplace(out, X.A);
}
else
{
const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
glue_schur::apply(out, tmp1.M, tmp2.M); glue_schur::apply(out, tmp1.M, tmp2.M);
}
} }
else else
{ {
const Mat<eT>* ptrs[N_mat]; const Mat<eT>* ptrs[N_mat];
bool del[N_mat]; bool del[N_mat];
mat_ptrs<glue_schur, Glue<T1,T2,glue_schur> >::get_ptrs(ptrs, del, X); mat_ptrs<glue_schur, Glue<T1,T2,glue_schur> >::get_ptrs(ptrs, del, X);
//mat_ptrs_outcheck<glue_schur, Glue<T1,T2,glue_schur> >::get_ptrs(ptrs , del, X, &out); //mat_ptrs_outcheck<glue_schur, Glue<T1,T2,glue_schur> >::get_ptrs(ptrs , del, X, &out);
for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] ); for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format( "ptrs[%d] = %x") % i % ptrs[i] );
skipping to change at line 156 skipping to change at line 101
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ; arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ) ;
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename eT> template<typename T1>
inline inline
void void
glue_schur::apply_inplace(Mat<eT>& out, const Mat<eT>& B) glue_schur::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;
const unwrap<T1> tmp(X);
const Mat<eT>& B = tmp.M;
arma_debug_assert_same_size(out, B, "matrix schur product"); arma_debug_assert_same_size(out, B, "matrix schur product");
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] *= B_mem[i]; out_mem[i] *= B_mem[i];
} }
} }
template<typename T1, typename op_type> //! matrix schur product with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op _type>& X) glue_schur::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix schur product");
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
const Mat<eT> tmp(X); out_eT* out_mem = out.memptr();
glue_schur::apply_inplace(out, tmp); const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) * upgrade_val<eT1,eT
2>::apply(Y_mem[i]);
}
} }
template<typename T1, typename T2, typename glue_type> template<typename eT>
inline inline
void void
glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_type>& X) glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// out = X % out; arma_debug_assert_same_size(A, B, "matrix schur product");
typedef typename T1::elem_type eT; // no aliasing problem
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const Mat<eT> tmp(X); eT* out_mem = out.memptr();
glue_schur::apply_inplace(out, tmp); const eT* A_mem = A.mem;
} const eT* B_mem = B.mem;
// const u32 n_elem = A.n_elem;
// matrix schur product with different element types
template<typename eT1, typename eT2> for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = A_mem[i] * B_mem[i];
}
}
template<typename eT>
inline inline
void void
glue_schur::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y) glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M at<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; arma_debug_assert_same_size(A, B, "matrix schur product");
arma_debug_assert_same_size(A, C, "matrix schur product");
arma_debug_assert_same_size(X,Y, "matrix schur product");
//out.set_size(X.n_rows, X.n_cols); // no aliasing problem
out.copy_size(X); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
out_eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT* A_mem = A.mem;
const eT2* Y_mem = Y.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) * upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = A_mem[i] * B_mem[i] * C_mem[i];
} }
} }
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_schur::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_schur>& X)
{
glue_schur::apply(out, X.A, X.B);
}
template<typename eT>
inline
void
glue_schur::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,glue_schur
>, Mat<eT>,glue_schur>& X)
{
glue_schur::apply(out, X.A.A, X.A.B, X.B);
}
template<typename T1, typename T2>
inline
void
glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_schur>& X)
{
arma_extra_debug_sigprint();
out = X % out;
}
#endif
// //
// glue_schur_diag // glue_schur_diag
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_schur_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, const Op<T2,op_diagmat>& B_orig) glue_schur_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, const Op<T2,op_diagmat>& B_orig)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 26 change blocks. 
103 lines changed or deleted 108 lines changed or added


 glue_schur_proto.hpp   glue_schur_proto.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 glue_schur //! \addtogroup glue_schur
//! @{ //! @{
//! Class which implements the immediate Schur product (element-wise multip lication) of two or more matrices //! Class which implements the immediate Schur product (element-wise multip lication) of two or more matrices
class glue_schur class glue_schur
{ {
public: public:
// mat template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_schur>& X);
template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
T1& X);
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);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B ); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B );
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); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C);
#if defined(ARMA_GOOD_COMPILER)
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_sc hur>& X); inline static void apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_sc hur>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,g lue_schur>, Mat<eT>, glue_schur>& X); inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,g lue_schur>, Mat<eT>, glue_schur>& X);
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_schur>& X); inline static void apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_schur>& X);
// mat, inplace #endif
template<typename eT> inline static void apply_inplace(Mat<eT>& out, cons
t Mat<eT>& B);
template<typename T1, typename op_type>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_type>& X);
template<typename T1, typename T2, typename glue_type>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_type>& X);
// matrix schur product with different element types
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);
}; };
class glue_schur_diag class glue_schur_diag
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B); inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B);
 End of changes. 4 change blocks. 
20 lines changed or deleted 15 lines changed or added


 glue_times_meat.hpp   glue_times_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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<typename eT>
arma_inline
u32 glue_times::mul_storage_cost(const Mat<eT>& X, const Mat<eT>& Y)
{
return X.n_rows * Y.n_cols;
}
//! multiply matrices A and B, storing the result in 'out'
//! assumes that A and B are not aliases of 'out'
template<typename eT>
inline
void
glue_times::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_mul_size(A, B, "matrix multiply");
out.set_size(A.n_rows,B.n_cols);
gemm<>::apply(out,A,B);
}
template<typename eT>
inline
void
glue_times::apply(Mat<eT>& out, const Mat<eT>& A_in, const Mat<eT>& B_in)
{
arma_extra_debug_sigprint();
if( (&out != &A_in) && (&out != &B_in) )
{
glue_times::apply_noalias(out,A_in,B_in);
}
else
{
if( (&out == &A_in) && (&out != &B_in) )
{
Mat<eT> A_copy(A_in);
glue_times::apply_noalias(out,A_copy,B_in);
}
else
if( (&out != &A_in) && (&out == &B_in) )
{
Mat<eT> B_copy(B_in);
glue_times::apply_noalias(out,A_in,B_copy);
}
else
if( (&out == &A_in) && (&out == &B_in) )
{
Mat<eT> tmp(A_in);
glue_times::apply_noalias(out,tmp,tmp);
}
}
}
template<typename eT>
inline
void
glue_times::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M
at<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_mul_size(A, B, "matrix multiply");
arma_debug_assert_mul_size(B, C, "matrix multiply");
if( mul_storage_cost(A,B) <= mul_storage_cost(B,C) )
{
Mat<eT> tmp;
glue_times::apply_noalias(tmp, A, B);
if(&out != &C)
{
glue_times::apply_noalias(out, tmp, C);
}
else
{
Mat<eT> C_copy = C;
glue_times::apply_noalias(out, tmp, C_copy);
}
}
else
{
Mat<eT> tmp;
glue_times::apply_noalias(tmp, B, C);
if(&out != &A)
{
glue_times::apply_noalias(out, A, tmp);
}
else
{
Mat<eT> A_copy = A;
glue_times::apply_noalias(out, A_copy, tmp);
}
}
}
template<typename T1, typename T2> template<typename T1, typename T2>
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 s32 N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >::nu m;
skipping to change at line 350 skipping to change at line 248
{ {
if(del[i] == true) if(del[i] == true)
{ {
arma_extra_debug_print(arma_boost::format("delete mat_ptr[%d]") % i ); arma_extra_debug_print(arma_boost::format("delete mat_ptr[%d]") % i );
delete ptrs[i]; delete ptrs[i];
} }
} }
} }
} }
template<typename eT> template<typename T1>
inline inline
void void
glue_times::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_times>& X) glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X)
{ {
glue_times::apply(out, X.A, X.B); arma_extra_debug_sigprint();
}
template<typename eT> typedef typename T1::elem_type eT;
inline
void
glue_times::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>, glue_time
s>, Mat<eT>, glue_times>& X)
{
glue_times::apply(out, X.A.A, X.A.B, X.B);
}
template<typename eT> const unwrap<T1> tmp(X);
inline const Mat<eT>& B = tmp.M;
void
glue_times::apply_inplace(Mat<eT>& out, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_mul_size(out, B, "matrix multiply"); arma_debug_assert_mul_size(out, B, "matrix multiply");
if(out.n_cols == B.n_cols) if(out.n_cols == B.n_cols)
{ {
podarray<eT> tmp(out.n_cols); podarray<eT> tmp(out.n_cols);
eT* tmp_rowdata = tmp.memptr(); eT* tmp_rowdata = tmp.memptr();
for(u32 out_row=0; out_row < out.n_rows; ++out_row) for(u32 out_row=0; out_row < out.n_rows; ++out_row)
{ {
skipping to change at line 404 skipping to change at line 291
val += tmp_rowdata[i] * B_coldata[i]; val += tmp_rowdata[i] * B_coldata[i];
} }
out.at(out_row,B_col) = val; out.at(out_row,B_col) = val;
} }
} }
} }
else else
{ {
Mat<eT> tmp = out; const Mat<eT> tmp(out);
glue_times::apply(out, tmp, B); glue_times::apply(out, tmp, B);
} }
} }
template<typename T1, typename op_type> //! matrix multiplication with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op _type>& X) glue_times::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_mul_size(X,Y, "matrix multiply");
const Mat<eT> tmp(X); out.set_size(X.n_rows,Y.n_cols);
glue_times::apply(out, out, tmp); gemm_mixed<>::apply(out, X, Y);
} }
template<typename T1, typename T2, typename glue_type> template<typename eT>
arma_inline
u32 glue_times::mul_storage_cost(const Mat<eT>& X, const Mat<eT>& Y)
{
return X.n_rows * Y.n_cols;
}
//! multiply matrices A and B, storing the result in 'out'
//! assumes that A and B are not aliases of 'out'
template<typename eT>
inline
void
glue_times::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_mul_size(A, B, "matrix multiply");
out.set_size(A.n_rows,B.n_cols);
gemm<>::apply(out,A,B);
}
template<typename eT>
inline
void
glue_times::apply(Mat<eT>& out, const Mat<eT>& A_in, const Mat<eT>& B_in)
{
arma_extra_debug_sigprint();
if( (&out != &A_in) && (&out != &B_in) )
{
glue_times::apply_noalias(out,A_in,B_in);
}
else
{
if( (&out == &A_in) && (&out != &B_in) )
{
Mat<eT> A_copy(A_in);
glue_times::apply_noalias(out,A_copy,B_in);
}
else
if( (&out != &A_in) && (&out == &B_in) )
{
Mat<eT> B_copy(B_in);
glue_times::apply_noalias(out,A_in,B_copy);
}
else
if( (&out == &A_in) && (&out == &B_in) )
{
Mat<eT> tmp(A_in);
glue_times::apply_noalias(out,tmp,tmp);
}
}
}
template<typename eT>
inline
void
glue_times::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M
at<eT>& C)
{
arma_extra_debug_sigprint();
arma_debug_assert_mul_size(A, B, "matrix multiply");
arma_debug_assert_mul_size(B, C, "matrix multiply");
if( mul_storage_cost(A,B) <= mul_storage_cost(B,C) )
{
Mat<eT> tmp;
glue_times::apply_noalias(tmp, A, B);
if(&out != &C)
{
glue_times::apply_noalias(out, tmp, C);
}
else
{
Mat<eT> C_copy = C;
glue_times::apply_noalias(out, tmp, C_copy);
}
}
else
{
Mat<eT> tmp;
glue_times::apply_noalias(tmp, B, C);
if(&out != &A)
{
glue_times::apply_noalias(out, A, tmp);
}
else
{
Mat<eT> A_copy = A;
glue_times::apply_noalias(out, A_copy, tmp);
}
}
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_mat_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
const u32 cost_AB = B.n_cols;
const u32 cost_BC = B.n_rows;
if(cost_AB <= cost_BC)
{
podarray<eT> tmp(B.n_cols);
for(u32 col=0; col<B.n_cols; ++col)
{
const eT* B_coldata = B.colptr(col);
eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i)
{
val += A_mem[i] * B_coldata[i];
}
tmp[col] = val;
}
return op_dot::direct_dot(B.n_cols, tmp.mem, C_mem);
}
else
{
podarray<eT> tmp(B.n_rows);
for(u32 row=0; row<B.n_rows; ++row)
{
eT val = eT(0);
for(u32 col=0; col<B.n_cols; ++col)
{
val += B.at(row,col) * C_mem[col];
}
tmp[row] = val;
}
return op_dot::direct_dot(B.n_rows, A_mem, tmp.mem);
}
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_diagmat_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i)
{
val += A_mem[i] * B.at(i,i) * C_mem[i];
}
return val;
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_invdiagmat_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i)
{
val += (A_mem[i] * C_mem[i]) / B.at(i,i);
}
return val;
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_invdiagvec_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
const eT* B_mem = B.mem;
eT val = eT(0);
for(u32 i=0; i<B.n_elem; ++i)
{
val += (A_mem[i] * C_mem[i]) / B_mem[i];
}
return val;
}
#if defined(ARMA_GOOD_COMPILER)
template<typename eT>
inline
void
glue_times::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_times>& X)
{
glue_times::apply(out, X.A, X.B);
}
template<typename eT>
inline inline
void void
glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_type>& X) glue_times::apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>, glue_time s>, Mat<eT>, glue_times>& X)
{ {
arma_extra_debug_sigprint(); glue_times::apply(out, X.A.A, X.A.B, X.B);
out = out * X;
} }
//! out = T1 * trans(T2) //! out = T1 * trans(T2)
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, Op<T2,op _trans>, glue_times>& X) glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1, Op<T2,op _trans>, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 581 skipping to change at line 703
glue_times::apply(out, A, B); glue_times::apply(out, A, B);
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out[i] = -out[i]; out[i] = -out[i];
} }
} }
template<typename eT> template<typename T1, typename T2>
inline
eT
glue_times::direct_rowvec_mat_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
const u32 cost_AB = B.n_cols;
const u32 cost_BC = B.n_rows;
if(cost_AB <= cost_BC)
{
podarray<eT> tmp(B.n_cols);
for(u32 col=0; col<B.n_cols; ++col)
{
const eT* B_coldata = B.colptr(col);
eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i)
{
val += A_mem[i] * B_coldata[i];
}
tmp[col] = val;
}
return op_dot::direct_dot(B.n_cols, tmp.mem, C_mem);
}
else
{
podarray<eT> tmp(B.n_rows);
for(u32 row=0; row<B.n_rows; ++row)
{
eT val = eT(0);
for(u32 col=0; col<B.n_cols; ++col)
{
val += B.at(row,col) * C_mem[col];
}
tmp[row] = val;
}
return op_dot::direct_dot(B.n_rows, A_mem, tmp.mem);
}
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_diagmat_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i)
{
val += A_mem[i] * B.at(i,i) * C_mem[i];
}
return val;
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_invdiagmat_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
eT val = eT(0);
for(u32 i=0; i<B.n_rows; ++i)
{
val += (A_mem[i] * C_mem[i]) / B.at(i,i);
}
return val;
}
template<typename eT>
inline
eT
glue_times::direct_rowvec_invdiagvec_colvec
(
const eT* A_mem,
const Mat<eT>& B,
const eT* C_mem
)
{
arma_extra_debug_sigprint();
const eT* B_mem = B.mem;
eT val = eT(0);
for(u32 i=0; i<B.n_elem; ++i)
{
val += (A_mem[i] * C_mem[i]) / B_mem[i];
}
return val;
}
//
// matrix multiplication with different element types
template<typename eT1, typename eT2>
inline inline
void void
glue_times::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y) glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; out = out * X;
arma_debug_assert_mul_size(X,Y, "matrix multiply");
out.set_size(X.n_rows,Y.n_cols);
gemm_mixed<>::apply(out, X, Y);
} }
#endif
// //
// glue_times_diag // glue_times_diag
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_times_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, const Op<T2,op_diagmat>& B_orig) glue_times_diag::apply(Mat<typename T1::elem_type>& out, const T1& A_orig, const Op<T2,op_diagmat>& B_orig)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 853 skipping to change at line 847
inline inline
void void
glue_times_diag::apply(Mat<typename T1::elem_type>& out, const Glue<Op<T1,o p_diagmat>, Op<T2,op_diagmat>, glue_times_diag>& X) glue_times_diag::apply(Mat<typename T1::elem_type>& out, const Glue<Op<T1,o p_diagmat>, Op<T2,op_diagmat>, glue_times_diag>& X)
{ {
glue_times_diag::apply(out, X.A, X.B); glue_times_diag::apply(out, X.A, X.B);
} }
// //
// glue_times_vec // glue_times_vec
//! at least one of T1 and T2 is a vector (both could be vectors)
template<typename T1, typename T2>
inline
void
glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,
glue_times_vec>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
unwrap_check<T1> tmp1(X.A, out);
unwrap_check<T2> tmp2(X.B, out);
const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A, B, "vector multiply");
// col * row --> outer product
// mat * row --> only makes sense if mat is a col vector, hence equiv to
col * row
// col * mat --> only makes sense if mat is a row vector, hence equiv to
col * row
// row * col --> dot product
// row * mat --> ok
// mat * col --> ok
out.set_size(A.n_rows, B.n_cols);
if(A.n_cols == 1) // A is a column vector
{
glue_times_vec::mul_col_row(out, A.mem, B.mem);
}
else
{
if(A.n_rows == 1) // A is a row vector
{
if(B.n_cols == 1)
{
out[0] = op_dot::direct_dot(A.n_elem, A.mem, B.mem);
}
else
{
gemv<true>::apply(out.memptr(), B, A.mem);
}
}
else // A is a matrix
{
gemv<>::apply(out.memptr(), A, B.mem);
}
}
}
template<typename eT> template<typename eT>
inline inline
void void
glue_times_vec::mul_col_row(Mat<eT>& out, const eT* A, const eT* B) glue_times_vec::mul_col_row(Mat<eT>& out, const eT* A, const eT* B)
{ {
const u32 n_rows = out.n_rows; const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = out.n_cols;
for(u32 col=0; col < n_cols; ++col) for(u32 col=0; col < n_cols; ++col)
{ {
skipping to change at line 897 skipping to change at line 945
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
for(u32 row=0; row < n_rows; ++row) for(u32 row=0; row < n_rows; ++row)
{ {
out_coldata[row] += A[row] * val; out_coldata[row] += A[row] * val;
} }
} }
} }
template<typename T1> #if defined(ARMA_GOOD_COMPILER)
inline
void
glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<T1, Col<
typename T1::elem_type>,glue_times_vec>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
unwrap_check< T1 > tmp1(X.A, out);
unwrap_check< Col<eT> > tmp2(X.B, out);
const Mat<eT>& A = tmp1.M;
const Col<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A, B, "vector multiply");
out.set_size(A.n_rows, 1);
//gemm<>::apply(out,A,B); // NOTE: B is interpreted as a Mat
gemv<>::apply(out.memptr(), A, B.mem);
}
template<typename T1>
inline
void
glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<T1, Row<
typename T1::elem_type>,glue_times_vec>& X)
{
arma_extra_debug_sigprint();
// T1 * rowvec makes sense only if T1 ends up being a matrix with one col
umn (i.e. a column vector)
typedef typename T1::elem_type eT;
unwrap_check< T1 > tmp1(X.A, out);
unwrap_check< Row<eT> > tmp2(X.B, out);
const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; // NOTE: interpretation of a Row as a Mat
arma_debug_assert_mul_size(A, B, "vector multiply");
out.set_size(A.n_rows, B.n_cols);
glue_times_vec::mul_col_row(out, A.mem, B.mem);
}
template<typename T1>
inline
void
glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<Col<type
name T1::elem_type>,T1,glue_times_vec>& X)
{
arma_extra_debug_sigprint();
// colvec * T1 makes sense only if T1 ends up being a matrix with one row
(i.e. a row vector)
typedef typename T1::elem_type eT;
unwrap_check< Col<eT> > tmp1(X.A, out);
unwrap_check< T1 > tmp2(X.B, out);
const Mat<eT>& A = tmp1.M; // NOTE: interpretation of a Col as a Mat
const Mat<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A, B, "vector multiply");
out.set_size(A.n_rows, B.n_cols);
glue_times_vec::mul_col_row(out, A.mem, B.mem);
}
template<typename T1>
inline
void
glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<Row<type
name T1::elem_type>,T1,glue_times_vec>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
unwrap_check< Row<eT> > tmp1(X.A, out);
unwrap_check< T1 > tmp2(X.B, out);
const Row<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A, B, "vector multiply");
out.set_size(A.n_rows, B.n_cols);
// eT* out_mem = out.memptr();
// const eT* A_mem = A.mem;
//
// const u32 A_n_cols = A.n_cols;
// const u32 B_n_cols = B.n_cols;
//
// for(u32 col=0; col<B_n_cols; ++col)
// {
// const eT* B_coldata = B.colptr(col);
//
// eT val = eT(0);
// for(u32 i=0; i<A_n_cols; ++i)
// {
// val += A_mem[i] * B_coldata[i];
// }
//
// out_mem[col] = val;
// }
gemv<true>::apply(out.memptr(), B, A.mem);
}
template<typename eT> template<typename eT>
inline inline
void void
glue_times_vec::apply(Mat<eT>& out, const Glue<Col<eT>,Row<eT>,glue_times_v ec>& X) glue_times_vec::apply(Mat<eT>& out, const Glue<Col<eT>,Row<eT>,glue_times_v ec>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
unwrap_check< Col<eT> > tmp1(X.A, out); unwrap_check< Col<eT> > tmp1(X.A, out);
unwrap_check< Row<eT> > tmp2(X.B, out); unwrap_check< Row<eT> > tmp2(X.B, out);
skipping to change at line 1078 skipping to change at line 1016
template<typename T1> template<typename T1>
inline inline
void void
glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<Op<T1, o p_trans>, Col<typename T1::elem_type>,glue_times_vec>& X) glue_times_vec::apply(Mat<typename T1::elem_type>& out, const Glue<Op<T1, o p_trans>, Col<typename T1::elem_type>,glue_times_vec>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
unwrap_check< T1 > tmp1(X.A.m, out); unwrap_check< T1 > tmp1(X.A.m, out);
unwrap_check< Col<eT> > tmp2(X.B, out); unwrap_check< Col<eT> > tmp2(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Col<eT>& B = tmp2.M; const Col<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A.n_cols, A.n_rows, B.n_rows, B.n_cols, "vecto r multiply"); arma_debug_assert_mul_size(A.n_cols, A.n_rows, B.n_rows, B.n_cols, "vecto r multiply");
out.set_size(A.n_cols, B.n_cols); out.set_size(A.n_cols, B.n_cols);
// eT* out_mem = out.memptr(); // eT* out_mem = out.memptr();
skipping to change at line 1110 skipping to change at line 1048
// { // {
// val += A_col[row] * B_mem[row]; // val += A_col[row] * B_mem[row];
// } // }
// //
// out_mem[col] = val; // out_mem[col] = val;
// } // }
gemv<true>::apply(out.memptr(), A, B.mem); gemv<true>::apply(out.memptr(), A, B.mem);
} }
#endif
//! @} //! @}
 End of changes. 22 change blocks. 
383 lines changed or deleted 319 lines changed or added


 glue_times_proto.hpp   glue_times_proto.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 glue_times //! \addtogroup glue_times
//! @{ //! @{
//! Class which implements the immediate multiplication of two or more matr ices //! Class which implements the immediate multiplication of two or more matr ices
class glue_times class glue_times
{ {
public: public:
template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_times>& X);
template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
T1& X);
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);
template<typename eT> template<typename eT>
arma_inline static u32 mul_storage_cost(const Mat<eT>& X, const Mat<eT>& Y); arma_inline static u32 mul_storage_cost(const Mat<eT>& X, const Mat<eT>& Y);
template<typename eT> template<typename eT>
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Ma t<eT>& B); inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Ma t<eT>& B);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B ); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B );
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); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B , const Mat<eT>& C);
template<typename T1, typename T2> template<typename eT>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, inline static eT direct_rowvec_mat_colvec(const eT* A_mem, const Mat<eT>&
T2,glue_times>& X); B, const eT* C_mem);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_ti mes>& X); inline static eT direct_rowvec_diagmat_colvec(const eT* A_mem, const Mat< eT>& B, const eT* C_mem);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>, glue_times>, Mat<eT>, glue_times>& X); inline static eT direct_rowvec_invdiagmat_colvec(const eT* A_mem, const M at<eT>& B, const eT* C_mem);
template<typename eT> template<typename eT>
inline static void apply_inplace(Mat<eT>& out, const Mat<eT>& B); inline static eT direct_rowvec_invdiagvec_colvec(const eT* A_mem, const M
at<eT>& B, const eT* C_mem);
#if defined(ARMA_GOOD_COMPILER)
template<typename T1, typename op_type> template<typename eT>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_ti
Op<T1, op_type>& X); mes>& X);
template<typename T1, typename T2, typename glue_type> template<typename eT>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const inline static void apply(Mat<eT>& out, const Glue< Glue<Mat<eT>,Mat<eT>,
Glue<T1, T2, glue_type>& X); glue_times>, Mat<eT>, glue_times>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, Op<T2,op_trans>,glue_times >& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, Op<T2,op_trans>,glue_times >& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1,op_trans>,T2,glue_times>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1,op_trans>,T2,glue_times>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1,op_trans>,Op<T2,op_trans>,glue_times>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1,op_trans>,Op<T2,op_trans>,glue_times>& X);
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Op <T1, op_neg>, T2, glue_times>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Op <T1, op_neg>, T2, glue_times>& X);
template<typename eT> template<typename T1, typename T2>
inline static eT direct_rowvec_mat_colvec(const eT* A_mem, const Mat<eT>& inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
B, const eT* C_mem); Glue<T1, T2, glue_times>& X);
template<typename eT>
inline static eT direct_rowvec_diagmat_colvec(const eT* A_mem, const Mat<
eT>& B, const eT* C_mem);
template<typename eT>
inline static eT direct_rowvec_invdiagmat_colvec(const eT* A_mem, const M
at<eT>& B, const eT* C_mem);
template<typename eT>
inline static eT direct_rowvec_invdiagvec_colvec(const eT* A_mem, const M
at<eT>& B, const eT* C_mem);
// matrix multiplication with different element types #endif
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);
}; };
class glue_times_diag class glue_times_diag
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B); inline static void apply(Mat<typename T1::elem_type>& out, const T1& A, c onst Op<T2,op_diagmat>& B);
skipping to change at line 112 skipping to change at line 111
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1,op_diagmat>, Op<T2,op_diagmat>, glue_times_diag>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1,op_diagmat>, Op<T2,op_diagmat>, glue_times_diag>& X);
}; };
class glue_times_vec class glue_times_vec
{ {
public: public:
template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_times_vec>& X);
template<typename eT> template<typename eT>
inline static void mul_col_row(Mat<eT>& out, const eT* A_mem, const eT* B _mem); inline static void mul_col_row(Mat<eT>& out, const eT* A_mem, const eT* B _mem);
template<typename eT> template<typename eT>
inline static void mul_col_row_inplace_add(Mat<eT>& out, const eT* A_mem, const eT* B_mem); inline static void mul_col_row_inplace_add(Mat<eT>& out, const eT* A_mem, const eT* B_mem);
template<typename T1> #if defined(ARMA_GOOD_COMPILER)
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
Col<typename T1::elem_type>, glue_times_vec>& X);
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
Row<typename T1::elem_type>, glue_times_vec>& X);
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Col
<typename T1::elem_type>, T1, glue_times_vec>& X);
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Row
<typename T1::elem_type>, T1, glue_times_vec>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue<Col<eT>, Row<eT>, glue_ times_vec>& X); inline static void apply(Mat<eT>& out, const Glue<Col<eT>, Row<eT>, glue_ times_vec>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue< Op<Row<eT>, op_trans>, Row<eT>, glue_times_vec>& X); inline static void apply(Mat<eT>& out, const Glue< Op<Row<eT>, op_trans>, Row<eT>, glue_times_vec>& X);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Glue< Col<eT>, Op<Col<eT>, o p_trans>, glue_times_vec>& X); inline static void apply(Mat<eT>& out, const Glue< Col<eT>, Op<Col<eT>, o p_trans>, glue_times_vec>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1, op_trans>, Col<typename T1::elem_type>, glue_times_vec>& X); inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op< T1, op_trans>, Col<typename T1::elem_type>, glue_times_vec>& X);
#endif
}; };
//! @} //! @}
 End of changes. 12 change blocks. 
47 lines changed or deleted 38 lines changed or added


 op_cor_meat.hpp   op_cor_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// 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_cor //! \addtogroup op_cor
//! @{ //! @{
template<typename T1> template<typename eT>
inline inline
void void
op_cor::apply(Mat<typename T1::pod_type>& out, const Op<T1,op_cor>& in) op_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a;
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 u32 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 T1> template<typename T>
inline inline
void void
op_cor::apply(Mat< std::complex<typename T1::pod_type> >& out, const Op<T1, op_cor>& in) op_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T;
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a;
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 u32 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);
skipping to change at line 91 skipping to change at line 78
out = trans(conj(A)) * A; out = trans(conj(A)) * A;
out -= (trans(conj(acc)) * acc)/eT(N); out -= (trans(conj(acc)) * acc)/eT(N);
out /= norm_val; out /= norm_val;
//out = out / (trans(sd) * sd); //out = out / (trans(sd) * sd);
out /= conv_to< Mat<eT> >::from(trans(sd) * sd); out /= conv_to< Mat<eT> >::from(trans(sd) * sd);
} }
} }
template<typename T1>
inline
void
op_cor::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cor>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a;
op_cor::direct_cor(out, A, norm_type);
}
//! @} //! @}
 End of changes. 8 change blocks. 
17 lines changed or deleted 21 lines changed or added


 op_cor_proto.hpp   op_cor_proto.hpp 
skipping to change at line 24 skipping to change at line 24
// 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 T1> inline static void apply(Mat<typename T1::pod_type> template<typename eT> inline static void direct_cor(Mat<eT>&
& out, const Op<T1,op_cor>& in); out, const Mat<eT>& X, const u32 norm_type);
template<typename T1> inline static void apply(Mat< std::complex<typename template<typename T> inline static void direct_cor(Mat< std::complex<T>
T1::pod_type> >& out, const Op<T1,op_cor>& in); >& out, const Mat< std::complex<T> >& X, const u32 norm_type);
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 7 lines changed or added


 op_cov_meat.hpp   op_cov_meat.hpp 
skipping to change at line 20 skipping to change at line 20
// 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_cov //! \addtogroup op_cov
//! @{ //! @{
template<typename T1> template<typename eT>
inline inline
void void
op_cov::apply(Mat<typename T1::pod_type>& out, const Op<T1,op_cov>& in) op_cov::direct_cov(Mat<eT>& out, const Mat<eT>& A, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a;
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);
} }
skipping to change at line 58 skipping to change at line 51
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 T1> template<typename T>
inline inline
void void
op_cov::apply(Mat< std::complex<typename T1::pod_type> >& out, const Op<T1, op_cov>& in) op_cov::direct_cov(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T;
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a;
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);
out.set_size(1,1); out.set_size(1,1);
out[0] = tmp_mat[0]; out[0] = tmp_mat[0];
} }
else else
{ {
skipping to change at line 101 skipping to change at line 88
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(conj(A)) * A; out = trans(conj(A)) * A;
out -= (trans(conj(acc)) * acc)/eT(N); out -= (trans(conj(acc)) * acc)/eT(N);
out /= norm_val; out /= norm_val;
} }
} }
template<typename T1>
inline
void
op_cov::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cov>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
const u32 norm_type = in.aux_u32_a;
op_cov::direct_cov(out, A, norm_type);
}
//! @} //! @}
 End of changes. 8 change blocks. 
17 lines changed or deleted 21 lines changed or added


 op_cov_proto.hpp   op_cov_proto.hpp 
skipping to change at line 24 skipping to change at line 24
// 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 T1> inline static void apply(Mat<typename T1::pod_type> template<typename eT> inline static void direct_cov(Mat<eT>&
& out, const Op<T1,op_cov>& in); out, const Mat<eT>& X, const u32 norm_type);
template<typename T1> inline static void apply(Mat< std::complex<typename template<typename T> inline static void direct_cov(Mat< std::complex<T>
T1::pod_type> >& out, const Op<T1,op_cov>& in); >& out, const Mat< std::complex<T> >& X, const u32 norm_type);
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 7 lines changed or added


 op_max_meat.hpp   op_max_meat.hpp 
skipping to change at line 103 skipping to change at line 103
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;
arma_debug_check( (X.n_elem == 0), "op_max::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_max::apply(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" );
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_max::apply(), dim = 0"); arma_extra_debug_print("op_max::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_max::direct_max( X.colptr(col), X.n_rows ); out[col] = op_max::direct_max( X.colptr(col), X.n_rows );
skipping to change at line 235 skipping to change at line 235
inline void op_max::apply(Mat< std::complex<T> >& out, const Op<T1,op_max>& in) inline void op_max::apply(Mat< std::complex<T> >& out, const Op<T1,op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
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;
arma_debug_check( (X.n_elem == 0), "op_max::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_max::apply(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" );
if(dim == 0) // column-wise max if(dim == 0) // column-wise max
{ {
arma_extra_debug_print("op_max::apply(), dim = 0"); arma_extra_debug_print("op_max::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_max::direct_max( X.colptr(col), X.n_rows ); out[col] = op_max::direct_max( X.colptr(col), X.n_rows );
 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 88 skipping to change at line 88
void void
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;
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;
arma_debug_check( (X.n_elem == 0), "op_mean::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_mean::apply(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1 ");
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(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_mean::direct_mean( X.colptr(col), X.n_rows ); out[col] = op_mean::direct_mean( X.colptr(col), X.n_rows );
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 op_median_meat.hpp   op_median_meat.hpp 
skipping to change at line 102 skipping to change at line 102
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;
arma_debug_check( (X.n_elem == 0), "op_median::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "median(): given matrix has no element s" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_median::apply(): incorrect usage. dim mu st be 0 or 1"); arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // column-wise if(dim == 0) // column-wise
{ {
arma_extra_debug_print("op_median::apply(), dim = 0"); arma_extra_debug_print("op_median::apply(), dim = 0");
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(u32 col=0; col<X.n_cols; ++col)
skipping to change at line 246 skipping to change at line 246
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;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
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;
arma_debug_check( (X.n_elem == 0), "op_median::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "median(): given matrix has no element s" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_median::apply(): incorrect usage. dim mu st be 0 or 1"); arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // column-wise if(dim == 0) // column-wise
{ {
arma_extra_debug_print("op_median::apply(), dim = 0"); arma_extra_debug_print("op_median::apply(), dim = 0");
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(u32 col=0; col<X.n_cols; ++col)
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_min_meat.hpp   op_min_meat.hpp 
skipping to change at line 101 skipping to change at line 101
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;
arma_debug_check( (X.n_elem == 0), "op_min::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_min::apply(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" );
if(dim == 0) // column-wise min if(dim == 0) // column-wise min
{ {
arma_extra_debug_print("op_min::apply(), dim = 0"); arma_extra_debug_print("op_min::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_min::direct_min( X.colptr(col), X.n_rows ); out[col] = op_min::direct_min( X.colptr(col), X.n_rows );
skipping to change at line 233 skipping to change at line 233
inline void op_min::apply(Mat< std::complex<T> >& out, const Op<T1,op_min>& in) inline void op_min::apply(Mat< std::complex<T> >& out, const Op<T1,op_min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
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;
arma_debug_check( (X.n_elem == 0), "op_min::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_min::apply(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" );
if(dim == 0) // column-wise min if(dim == 0) // column-wise min
{ {
arma_extra_debug_print("op_min::apply(), dim = 0"); arma_extra_debug_print("op_min::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_min::direct_min( X.colptr(col), X.n_rows ); out[col] = op_min::direct_min( X.colptr(col), X.n_rows );
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_misc_meat.hpp   op_misc_meat.hpp 
skipping to change at line 27 skipping to change at line 27
template<typename T1> template<typename T1>
inline inline
void void
op_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log>& in) op_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::log(A.mem[i]); out_mem[i] = std::log(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_log::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_log>& i n) op_log::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_log>& i n)
{ {
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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::log(A.mem[i]); out_mem[i] = std::log(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_trunc_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ log>& in) op_trunc_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ log>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = trunc_log(A.mem[i]); out_mem[i] = trunc_log(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_trunc_log::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_t runc_log>& in) op_trunc_log::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_t runc_log>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = trunc_log(A.mem[i]); out_mem[i] = trunc_log(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_log10::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log10>& in ) op_log10::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log10>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::log10(A.mem[i]); out_mem[i] = std::log10(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_log10::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_log10 >& in) op_log10::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_log10 >& 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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::log10(A.mem[i]); out_mem[i] = std::log10(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_exp::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_exp>& in) op_exp::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_exp>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::exp(A.mem[i]); out_mem[i] = std::exp(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_exp::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_exp>& i n) op_exp::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_exp>& i n)
{ {
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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::exp(A.mem[i]); out_mem[i] = std::exp(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_trunc_exp::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ exp>& in) op_trunc_exp::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ exp>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = trunc_exp(A.mem[i]); out_mem[i] = trunc_exp(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_trunc_exp::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_t runc_exp>& in) op_trunc_exp::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_t runc_exp>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = trunc_exp(A.mem[i]); out_mem[i] = trunc_exp(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_sqrt::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sqrt>& in) op_sqrt::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sqrt>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::sqrt(A.mem[i]); out_mem[i] = std::sqrt(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_sqrt::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sqrt>& in) op_sqrt::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sqrt>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::sqrt(A.mem[i]); out_mem[i] = std::sqrt(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_square::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_square>& in) op_square::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_square>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT tmp_val = A.mem[i]; const eT val = A_mem[i];
out_ptr[i] = tmp_val*tmp_val; out_mem[i] = val*val;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_square::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_squa re>& in) op_square::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_squa re>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT tmp_val = A.mem[i]; const eT val = A_mem[i];
out_ptr[i] = tmp_val*tmp_val; out_mem[i] = val*val;
} }
}
template<typename T1, typename T2>
inline
T1
op_pow::internal_pow(const T1 base, const T2 exponent)
{
return std::pow(base, exponent);
}
template<typename T2>
inline
char
op_pow::internal_pow(const char base, const T2 exponent)
{
typedef char out_type;
return out_type( std::pow(double(base), exponent) );
}
template<typename T2>
inline
unsigned char
op_pow::internal_pow(const unsigned char base, const T2 exponent)
{
typedef unsigned char out_type;
return out_type( std::pow(double(base), exponent) );
}
template<typename T2>
inline
int
op_pow::internal_pow(const int base, const T2 exponent)
{
typedef int out_type;
return out_type( std::pow(double(base), exponent) );
}
template<typename T2>
inline
unsigned int
op_pow::internal_pow(const unsigned int base, const T2 exponent)
{
typedef unsigned int out_type;
return out_type( std::pow(double(base), exponent) );
} }
template<typename T1> template<typename T1>
inline inline
void void
op_pow::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow>& in) op_pow::apply(Mat<typename T1::pod_type>& out, const Op<T1,op_pow>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols); eT* out_mem = out.memptr();
out.copy_size(A); const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::pow(A.mem[i], in.aux); //out_mem[i] = std::pow(A_mem[i], in.aux);
out_mem[i] = op_pow::internal_pow(A_mem[i], in.aux);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_pow::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_pow>& i n) op_pow::apply(Cube<typename T1::pod_type>& out, const OpCube<T1,op_pow>& 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_write<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices); eT* out_mem = out.memptr();
out.copy_size(A); const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::pow(A.mem[i], in.aux); //out_mem[i] = std::pow(A_mem[i], in.aux);
out_mem[i] = op_pow::internal_pow(A_mem[i], in.aux);
} }
} }
template<typename T, typename T1> template<typename T1>
inline inline
void void
op_pow::apply(Mat< std::complex<T> >& out, const Op<T1,op_pow>& in) op_pow::apply(Mat< std::complex<typename T1::pod_type> >& out, const Op<T1, op_pow>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef typename T1::pod_type T;
typedef std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
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 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A); out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
if(in.aux.imag() == T(0)) if(in.aux.imag() == T(0))
{ {
const T in_aux_real = in.aux.real(); const T in_aux_real = in.aux.real();
skipping to change at line 475 skipping to change at line 460
} }
else else
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::pow(A.mem[i], in.aux); out_ptr[i] = std::pow(A.mem[i], in.aux);
} }
} }
} }
template<typename T, typename T1> template<typename T1>
inline inline
void void
op_pow::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_pow>& in) op_pow::apply(Cube< std::complex<typename T1::pod_type> >& out, const OpCub e<T1,op_pow>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef typename T1::pod_type T;
typedef std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
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 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices); //out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A); out.copy_size(A);
skipping to change at line 563 skipping to change at line 549
template<typename T1> template<typename T1>
inline inline
void void
op_pow_s32::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow_s32> & in) op_pow_s32::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow_s32> & 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_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const Mat<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a; const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
//out_ptr[i] = std::pow(A.mem[i], exponent); // causes problems with g //out_mem[i] = std::pow(A_mem[i], exponent); // causes problems with g
cc 4.1/4.2 for base that has an integer type cc 4.1/4.2 for base that has an integer type
out_ptr[i] = op_pow_s32::internal_pow(A.mem[i], exponent); out_mem[i] = op_pow_s32::internal_pow(A_mem[i], exponent);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_pow_s32::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_pow _s32>& in) op_pow_s32::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_pow _s32>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const Cube<eT>& A = tmp.M; eT* out_mem = out.memptr();
const u32 n_elem = A.n_elem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a; const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
//out_ptr[i] = std::pow(A.mem[i], exponent); // causes problems with g //out_mem[i] = std::pow(A_mem[i], exponent); // causes problems with g
cc 4.1/4.2 for base that has an integer type cc 4.1/4.2 for base that has an integer type
out_ptr[i] = op_pow_s32::internal_pow(A.mem[i], exponent); out_mem[i] = op_pow_s32::internal_pow(A_mem[i], exponent);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_conj::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_conj>& in) op_conj::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_conj>& in)
{ {
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<T1>::value == true >::apply(); const unwrap_write<T1> tmp(out, in.m);
const Mat<eT>& A = tmp.M;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::conj(A.mem[i]); out_mem[i] = std::conj(A_mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_conj::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_conj>& in) op_conj::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_conj>& in)
{ {
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<T1>::value == true >::apply(); const unwrap_cube_write<T1> tmp(out, in.m);
const Cube<eT>& A = tmp.M;
const unwrap_cube<T1> tmp(in.m); eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const Cube<eT>& A = tmp.M; const u32 n_elem = out.n_elem;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::conj(A.mem[i]); out_mem[i] = std::conj(A_mem[i]);
} }
} }
//! @} //! @}
 End of changes. 86 change blocks. 
214 lines changed or deleted 182 lines changed or added


 op_misc_proto.hpp   op_misc_proto.hpp 
skipping to change at line 78 skipping to change at line 78
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_square>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_square>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_square>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_square>& in);
}; };
class op_pow class op_pow
{ {
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ template<typename T1, typename T2> static inline T1 internal_pow(const T1
e>& out, const Op<T1,op_pow>& in); base, const T2 exponent);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_pow>& in);
template<typename T, typename T1> inline static void apply( Mat< std::com template<typename T2> static inline char internal_pow(const
plex<T> >& out, const Op<T1,op_pow>& in); char base, const T2 exponent);
template<typename T, typename T1> inline static void apply(Cube< std::com template<typename T2> static inline unsigned char internal_pow(const unsi
plex<T> >& out, const OpCube<T1,op_pow>& in); gned char base, const T2 exponent);
template<typename T2> static inline int internal_pow(const
int base, const T2 exponent);
template<typename T2> static inline unsigned int internal_pow(const unsi
gned int base, const T2 exponent);
template<typename T1> inline static void apply( Mat<typename T1::pod_type
>& out, const Op<T1,op_pow>& in);
template<typename T1> inline static void apply(Cube<typename T1::pod_type
>& out, const OpCube<T1,op_pow>& in);
template<typename T1> inline static void apply( Mat< std::complex<typenam
e T1::pod_type> >& out, const Op<T1,op_pow>& in);
template<typename T1> inline static void apply(Cube< std::complex<typenam
e T1::pod_type> >& out, const OpCube<T1,op_pow>& in);
}; };
class op_pow_s32 class op_pow_s32
{ {
public: public:
template<typename T1> static inline T1 internal_pow(const T1 base, const int exponent); template<typename T1> static inline T1 internal_pow(const T1 base, const int exponent);
static inline char internal_pow(const char base, const int exponent); static inline char internal_pow(const char base, const int exponent);
static inline unsigned char internal_pow(const unsigned char base, const int exponent); static inline unsigned char internal_pow(const unsigned char base, const int exponent);
 End of changes. 2 change blocks. 
8 lines changed or deleted 21 lines changed or added


 op_neg_meat.hpp   op_neg_meat.hpp 
skipping to change at line 28 skipping to change at line 28
//! Negate all elements of a dense matrix //! Negate all elements of a dense matrix
template<typename T1> template<typename T1>
inline inline
void void
op_neg::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_neg> &in) op_neg::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_neg> &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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// no alias problems eT* out_mem = out.memptr();
//out.set_size(X.n_rows, X.n_cols); const eT* A_mem = A.memptr();
out.copy_size(X); const u32 n_elem = out.n_elem;
const eT* X_mem = X.mem; for(u32 i=0; i<n_elem; ++i)
eT* out_mem = out.memptr();
for(u32 i=0; i<X.n_elem; ++i)
{ {
out_mem[i] = -X_mem[i]; out_mem[i] = -A_mem[i];
} }
} }
//! Negate all elements of a dense cube //! Negate all elements of a dense cube
template<typename T1> template<typename T1>
inline inline
void void
op_neg::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_neg> &i n) op_neg::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_neg> &i n)
{ {
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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// no alias problems eT* out_mem = out.memptr();
//out.set_size(X.n_rows, X.n_cols, X.n_slices); const eT* A_mem = A.memptr();
out.copy_size(X); const u32 n_elem = out.n_elem;
const eT* X_mem = X.mem; for(u32 i=0; i<n_elem; ++i)
eT* out_mem = out.memptr();
for(u32 i=0; i<X.n_elem; ++i)
{ {
out_mem[i] = -X_mem[i]; out_mem[i] = -A_mem[i];
} }
} }
//! @} //! @}
 End of changes. 10 change blocks. 
22 lines changed or deleted 14 lines changed or added


 op_ones_meat.hpp   op_ones_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_ones //! \addtogroup op_ones
//! @{ //! @{
template<typename eT> template<typename T1>
inline
void
op_ones_full::apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_full>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, in.aux_u32_b);
out.fill(eT(1));
}
template<typename eT>
inline
void
op_ones_full::apply(Mat<eT>& out, const Op<Col<eT>,op_ones_full>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, 1);
out.fill(eT(1));
}
template<typename eT>
inline
void
op_ones_full::apply(Mat<eT>& out, const Op<Row<eT>,op_ones_full>& in)
{
arma_extra_debug_sigprint();
out.set_size(1, in.aux_u32_a);
out.fill(eT(1));
}
template<typename eT>
inline
void
op_ones_full::apply(Col<eT>& out, const Op<Col<eT>,op_ones_full>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a);
out.fill(eT(1));
}
template<typename eT>
inline inline
void void
op_ones_full::apply(Row<eT>& out, const Op<Row<eT>,op_ones_full>& in) op_ones_full::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ones_f ull>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a); out.ones(in.aux_u32_a, in.aux_u32_b);
out.fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void void
op_ones_full::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_ones_full>& in) op_ones_full::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_ones_full>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c); out.ones(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
out.fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void void
op_ones_diag::apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in) op_ones_diag::apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a, in.aux_u32_b); out.zeros(in.aux_u32_a, in.aux_u32_b);
 End of changes. 4 change blocks. 
50 lines changed or deleted 4 lines changed or added


 op_ones_proto.hpp   op_ones_proto.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 op_ones //! \addtogroup op_ones
//! @{ //! @{
//! Class for creation of a dense matrix/vector/cube with all elements set to one //! Class for creation of a dense matrix/vector/cube with all elements set to one
class op_ones_full class op_ones_full
{ {
public: public:
template<typename eT> template<typename T1>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_full>& in inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
); _ones_full>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_ones_full>& in
);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_ones_full>& in
);
template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_ones_full>& in
);
template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_ones_full>& in
);
//
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_ones_ful l>& in); inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_ones_ful l>& in);
}; };
class op_ones_diag class op_ones_diag
{ {
public: public:
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in ); inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in );
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
21 lines changed or deleted 4 lines changed or added


 op_rand_meat.hpp   op_rand_meat.hpp 
skipping to change at line 50 skipping to change at line 50
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const T a = T(std::rand()) / T(RAND_MAX); const T a = T(std::rand()) / T(RAND_MAX);
const T b = T(std::rand()) / T(RAND_MAX); const T b = T(std::rand()) / T(RAND_MAX);
x[i] = std::complex<T>(a,b); x[i] = std::complex<T>(a,b);
} }
} }
template<typename eT> template<typename T1>
inline
void
op_rand::apply(Mat<eT>& out, const Op<Mat<eT>,op_rand>& in)
{
arma_extra_debug_sigprint();
const u32 n_rows = in.aux_u32_a;
const u32 n_cols = (in.aux_u32_b > 0) ? in.aux_u32_b : 1;
out.set_size(n_rows, n_cols);
op_rand::direct_rand(out.memptr(), out.n_elem);
}
template<typename eT>
inline
void
op_rand::apply(Mat<eT>& out, const Op<Col<eT>,op_rand>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, 1);
op_rand::direct_rand(out.memptr(), out.n_elem);
}
template<typename eT>
inline
void
op_rand::apply(Mat<eT>& out, const Op<Row<eT>,op_rand>& in)
{
arma_extra_debug_sigprint();
out.set_size(1, in.aux_u32_a);
op_rand::direct_rand(out.memptr(), out.n_elem);
}
template<typename eT>
inline
void
op_rand::apply(Col<eT>& out, const Op<Col<eT>,op_rand>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a);
op_rand::direct_rand(out.memptr(), out.n_elem);
}
template<typename eT>
inline inline
void void
op_rand::apply(Row<eT>& out, const Op<Row<eT>,op_rand>& in) op_rand::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_rand>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a); out.set_size(in.aux_u32_a, in.aux_u32_b);
op_rand::direct_rand(out.memptr(), out.n_elem); op_rand::direct_rand(out.memptr(), out.n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
op_rand::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& in) op_rand::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 3 change blocks. 
54 lines changed or deleted 3 lines changed or added


 op_rand_proto.hpp   op_rand_proto.hpp 
skipping to change at line 32 skipping to change at line 32
private: private:
template<typename eT> template<typename eT>
inline static void direct_rand(eT* x, const u32 n_elem); inline static void direct_rand(eT* x, const u32 n_elem);
template<typename T> template<typename T>
inline static void direct_rand(std::complex<T>* x, const u32 n_elem); inline static void direct_rand(std::complex<T>* x, const u32 n_elem);
public: public:
template<typename eT> template<typename T1>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_rand>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_rand>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_rand>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_rand>& in);
template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_rand>& in);
template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_rand>& in);
//
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& i n); inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& i n);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
16 lines changed or deleted 3 lines changed or added


 op_randn_meat.hpp   op_randn_meat.hpp 
skipping to change at line 58 skipping to change at line 58
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
x[i] = eT(op_randn::randn<eT>()); x[i] = eT(op_randn::randn<eT>());
} }
} }
template<typename eT> template<typename T>
inline inline
void void
op_randn::apply(Mat<eT>& out, const Op<Mat<eT>,op_randn>& in) op_randn::direct_randn(std::complex<T>* x, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_rows = in.aux_u32_a; for(u32 i=0; i<n_elem; ++i)
const u32 n_cols = (in.aux_u32_b > 0) ? in.aux_u32_b : 1; {
const T a = op_randn::randn<T>();
out.set_size(n_rows, n_cols); const T b = op_randn::randn<T>();
op_randn::direct_randn(out.memptr(), out.n_elem);
}
template<typename eT>
inline
void
op_randn::apply(Mat<eT>& out, const Op<Col<eT>,op_randn>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, 1);
op_randn::direct_randn(out.memptr(), out.n_elem);
}
template<typename eT>
inline
void
op_randn::apply(Mat<eT>& out, const Op<Row<eT>,op_randn>& in)
{
arma_extra_debug_sigprint();
out.set_size(1, in.aux_u32_a);
op_randn::direct_randn(out.memptr(), out.n_elem);
}
template<typename eT>
inline
void
op_randn::apply(Col<eT>& out, const Op<Col<eT>,op_randn>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a);
op_randn::direct_randn(out.memptr(), out.n_elem); x[i] = std::complex<T>(a,b);
}
} }
template<typename eT> template<typename T1>
inline inline
void void
op_randn::apply(Row<eT>& out, const Op<Row<eT>,op_randn>& in) op_randn::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_randn>& in )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a); out.set_size(in.aux_u32_a, in.aux_u32_b);
op_randn::direct_randn(out.memptr(), out.n_elem); op_randn::direct_randn(out.memptr(), out.n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
op_randn::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_randn>& in) op_randn::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_randn>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 7 change blocks. 
46 lines changed or deleted 11 lines changed or added


 op_randn_proto.hpp   op_randn_proto.hpp 
skipping to change at line 30 skipping to change at line 30
class op_randn class op_randn
{ {
private: private:
template<typename eT> template<typename eT>
inline static eT randn(); inline static eT randn();
template<typename eT> template<typename eT>
inline static void direct_randn(eT* x, const u32 n_elem); inline static void direct_randn(eT* x, const u32 n_elem);
public: template<typename T>
inline static void direct_randn(std::complex<T>* x, const u32 n_elem);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_randn>& in);
template<typename eT> public:
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_randn>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_randn>& in);
template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_randn>& in);
template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_randn>& in);
// template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_randn>& in);
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_randn>& in); inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_randn>& in);
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
16 lines changed or deleted 6 lines changed or added


 op_reshape_meat.hpp   op_reshape_meat.hpp 
skipping to change at line 35 skipping to change at line 35
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 u32 in_n_rows = in.aux_u32_a;
const u32 in_n_cols = in.aux_u32_b; const u32 in_n_cols = in.aux_u32_b;
const u32 in_n_elem = in_n_rows * in_n_cols; const u32 in_n_elem = in_n_rows * in_n_cols;
arma_debug_check( (A.n_elem != in_n_elem), "op_reshape::apply(): incompat ible dimensions"); arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen sions");
if(in.aux == eT(0)) if(in.aux == eT(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);
syslib::copy_elem( out.memptr(), A.memptr(), out.n_elem ); syslib::copy_elem( out.memptr(), A.memptr(), out.n_elem );
} }
else else
{ {
skipping to change at line 91 skipping to change at line 91
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 u32 in_n_rows = in.aux_u32_a;
const u32 in_n_cols = in.aux_u32_b; const u32 in_n_cols = in.aux_u32_b;
const u32 in_n_slices = in.aux_u32_c; const u32 in_n_slices = in.aux_u32_c;
const u32 in_n_elem = in_n_rows * in_n_cols * in_n_slices; const u32 in_n_elem = in_n_rows * in_n_cols * in_n_slices;
arma_debug_check( (A.n_elem != in_n_elem), "op_reshape()::apply(): incomp atible dimensions"); arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen sions");
if(in.aux == eT(0)) if(in.aux == eT(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);
syslib::copy_elem( out.memptr(), A.memptr(), out.n_elem ); syslib::copy_elem( out.memptr(), A.memptr(), out.n_elem );
} }
else else
{ {
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 op_scalar_misc_meat.hpp   op_scalar_misc_meat.hpp 
skipping to change at line 28 skipping to change at line 28
//! Add a scalar to all elements of a matrix //! Add a scalar to all elements of a matrix
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_plus::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_scal ar_plus>& in) op_scalar_plus::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_scal ar_plus>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = X_mem[i] + k; out_mem[i] = A_mem[i] + k;
} }
} }
//! Add a scalar to all elements of a cube //! Add a scalar to all elements of a cube
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_plus::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op _scalar_plus>& in) op_scalar_plus::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op _scalar_plus>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = X_mem[i] + k; out_mem[i] = A_mem[i] + k;
} }
} }
//! For each element of a matrix, subtract it from a scalar //! For each element of a matrix, subtract it from a scalar
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_minus_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op _scalar_minus_pre>& in) op_scalar_minus_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op _scalar_minus_pre>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = k - X_mem[i]; out_mem[i] = k - A_mem[i];
} }
} }
//! For each element of a cube, subtract it from a scalar //! For each element of a cube, subtract it from a scalar
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_minus_pre::apply(Cube<typename T1::elem_type>& out, const OpCube< T1,op_scalar_minus_pre>& in) op_scalar_minus_pre::apply(Cube<typename T1::elem_type>& out, const OpCube< T1,op_scalar_minus_pre>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = k - X_mem[i]; out_mem[i] = k - A_mem[i];
} }
} }
//! subtract a scalar from each element of a matrix //! subtract a scalar from each element of a matrix
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_minus_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,o p_scalar_minus_post>& in) op_scalar_minus_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,o p_scalar_minus_post>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = X_mem[i] - k; out_mem[i] = A_mem[i] - k;
} }
} }
//! subtract a scalar from each element of a cube //! subtract a scalar from each element of a cube
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_minus_post::apply(Cube<typename T1::elem_type>& out, const OpCube <T1,op_scalar_minus_post>& in) op_scalar_minus_post::apply(Cube<typename T1::elem_type>& out, const OpCube <T1,op_scalar_minus_post>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = X_mem[i] - k; out_mem[i] = A_mem[i] - k ;
} }
} }
//! Multiply all elements of a matrix by a scalar //! Multiply all elements of a matrix by a scalar
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sca lar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sca lar_times>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = X_mem[i] * k; out_mem[i] = A_mem[i] * k;
} }
} }
//! Multiply all elements of a cube by a scalar //! Multiply all elements of a cube by a scalar
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,o p_scalar_times>& in) op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,o p_scalar_times>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] * k;
}
}
//! Evaluate Glue<T1,T2,glue_type>, and then multiply each element of the r
esult by a scalar.
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<Glue<T1,T
2,glue_type>, op_scalar_times>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Mat<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
const eT k = in.aux;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] *= k; out_mem[i] = A_mem[i] * k;
} }
} }
//! Evaluate GlueCube<T1,T2,glue_type>, and then multiply each element of t #if defined(ARMA_GOOD_COMPILER)
he result by a scalar.
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube<Glue
Cube<T1,T2,glue_type>, op_scalar_times>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Cube<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] *= k;
}
}
//! Evaluate A + B, and then multiply each element of the result by a scala r. //! Evaluate A + B, and then multiply each element of the result by a scala r.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_plus>, op_scalar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_plus>, op_scalar_times>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp1(in.m.A); const unwrap<T1> tmp1(in.m.A);
skipping to change at line 502 skipping to change at line 428
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = (A_mem[i] * B_mem[i]) * k; out_mem[i] = (A_mem[i] * B_mem[i]) * k;
} }
} }
#endif
// //
// //
// //
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_s calar_div_pre>& in) op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_s calar_div_pre>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// TODO: analyse effects of aliasing
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = k / X_mem[i]; out_mem[i] = k / A_mem[i];
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube<T1 ,op_scalar_div_pre>& in) op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube<T1 ,op_scalar_div_pre>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// TODO: analyse effects of aliasing
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = k / X_mem[i];
}
}
template<typename eT>
inline
void
op_scalar_div_pre::apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_pre>&
in)
{
arma_extra_debug_sigprint();
const Mat<eT>& X = in.m;
if(&out != &X)
{
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = k / X_mem[i];
}
}
else
{
eT* out_mem = out.memptr();
const eT k = in.aux;
for(u32 i=0; i < out.n_elem; ++i)
{
out_mem[i] = k / out_mem[i];
}
}
}
template<typename eT>
inline
void
op_scalar_div_pre::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_scalar_div
_pre>& in)
{
arma_extra_debug_sigprint();
const Cube<eT>& X = in.m;
if(&out != &X)
{
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = k / X_mem[i];
}
}
else
{
eT* out_mem = out.memptr();
const eT k = in.aux;
for(u32 i=0; i < out.n_elem; ++i)
{
out_mem[i] = k / out_mem[i];
}
}
}
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op<Glue<T1
,T2,glue_type>, op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Mat<eT>'
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT k = in.aux; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = k / out_mem[i];
}
}
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube<Gl
ueCube<T1,T2,glue_type>, op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Cube<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = k / out_mem[i]; out_mem[i] = k / A_mem[i];
} }
} }
#if defined(ARMA_GOOD_COMPILER)
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T 1,T2,glue_plus>, op_scalar_div_pre>& in) op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T 1,T2,glue_plus>, op_scalar_div_pre>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
unwrap<T1> tmp1(in.m.A); unwrap<T1> tmp1(in.m.A);
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
skipping to change at line 886 skipping to change at line 692
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = k / (A_mem[i] * B_mem[i]); out_mem[i] = k / (A_mem[i] * B_mem[i]);
} }
} }
#endif
// //
// //
// //
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ scalar_div_post>& in) op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ scalar_div_post>& 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_write<T1> tmp(out, in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& A = tmp.M;
// TODO: analyse effects of aliasing
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const u32 n_elem = out.n_elem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = X_mem[i] / k; out_mem[i] = A_mem[i] / k;
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<T 1,op_scalar_div_post>& in) op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<T 1,op_scalar_div_post>& 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_write<T1> tmp(out, in.m);
const Cube<eT>& X = tmp.M; const Cube<eT>& A = tmp.M;
// TODO: analyse effects of aliasing
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* A_mem = A.memptr();
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] / k;
}
}
template<typename eT>
inline
void
op_scalar_div_post::apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_post
>& in)
{
arma_extra_debug_sigprint();
const Mat<eT>& X = in.m;
if(&out != &X)
{
//out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] / k;
}
}
else
{
eT* out_mem = out.memptr();
const eT k = in.aux;
for(u32 i=0; i < out.n_elem; ++i)
{
out_mem[i] /= k;
}
}
}
template<typename eT>
inline
void
op_scalar_div_post::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_scalar_di
v_post>& in)
{
arma_extra_debug_sigprint();
const Cube<eT>& X = in.m;
if(&out != &X)
{
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] / k;
}
}
else
{
eT* out_mem = out.memptr();
const eT k = in.aux;
for(u32 i=0; i < out.n_elem; ++i)
{
out_mem[i] /= k;
}
}
}
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op<Glue<T
1,T2,glue_type>, op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Mat<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] /= k;
}
}
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<G
lueCube<T1,T2,glue_type>, op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Cube<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= k; out_mem[i] = A_mem[i] / k;
} }
} }
#if defined(ARMA_GOOD_COMPILER)
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op< Glue< T1,T2,glue_plus>, op_scalar_div_post>& in) op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op< Glue< T1,T2,glue_plus>, op_scalar_div_post>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
unwrap<T1> tmp1(in.m.A); unwrap<T1> tmp1(in.m.A);
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
skipping to change at line 1270 skipping to change at line 956
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = (A_mem[i] * B_mem[i]) / k; out_mem[i] = (A_mem[i] * B_mem[i]) / k;
} }
} }
#endif
//! @} //! @}
 End of changes. 65 change blocks. 
402 lines changed or deleted 78 lines changed or added


 op_scalar_misc_proto.hpp   op_scalar_misc_proto.hpp 
skipping to change at line 53 skipping to change at line 53
}; };
//! 'multiply matrix/cube by a scalar' operation //! 'multiply matrix/cube by a scalar' operation
class op_scalar_times class op_scalar_times
{ {
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_scalar_times>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_scalar_times>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_scalar_times>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_scalar_times>& in);
template<typename T1, typename T2, typename glue_type> inline static void #if defined(ARMA_GOOD_COMPILER)
apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_
type>, op_scalar_times>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_
type>, op_scalar_times>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal ar_times>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal ar_times>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal ar_times>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal ar_times>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal ar_times>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal ar_times>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal ar_times>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal ar_times>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal ar_times>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal ar_times>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal ar_times>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal ar_times>& in);
#endif
}; };
//! 'divide scalar by a matrix/cube' operation //! 'divide scalar by a matrix/cube' operation
class op_scalar_div_pre class op_scalar_div_pre
{ {
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_scalar_div_pre>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_scalar_div_pre>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_scalar_div_pre>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_scalar_div_pre>& in);
template<typename eT> inline static void apply( Mat<eT>& out, const O #if defined(ARMA_GOOD_COMPILER)
p< Mat<eT>,op_scalar_div_pre>& in);
template<typename eT> inline static void apply(Cube<eT>& out, const OpCub
e<Cube<eT>,op_scalar_div_pre>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_
type>, op_scalar_div_pre>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_
type>, op_scalar_div_pre>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal ar_div_pre>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal ar_div_pre>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal ar_div_pre>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal ar_div_pre>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal ar_div_pre>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal ar_div_pre>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal ar_div_pre>& in);
#endif
}; };
//! 'divide matrix/cube by a scalar' operation //! 'divide matrix/cube by a scalar' operation
class op_scalar_div_post class op_scalar_div_post
{ {
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_scalar_div_post>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_scalar_div_post>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_scalar_div_post>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ e>& out, const OpCube<T1,op_scalar_div_post>& in);
template<typename eT> inline static void apply( Mat<eT>& out, const O #if defined(ARMA_GOOD_COMPILER)
p< Mat<eT>,op_scalar_div_post>& in);
template<typename eT> inline static void apply(Cube<eT>& out, const OpCub
e<Cube<eT>,op_scalar_div_post>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_
type>, op_scalar_div_post>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_
type>, op_scalar_div_post>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal ar_div_post>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal ar_div_post>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal ar_div_post>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal ar_div_post>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal ar_div_post>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal ar_div_post>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal ar_div_post>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal ar_div_post>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal ar_div_post>& in); template<typename T1, typename T2> inline static void apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal ar_div_post>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal ar_div_post>& in); template<typename T1, typename T2> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal ar_div_post>& in);
#endif
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
28 lines changed or deleted 9 lines changed or added


 op_sort_meat.hpp   op_sort_meat.hpp 
skipping to change at line 19 skipping to change at line 19
// 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_sort //! \addtogroup op_sort
//! @{ //! @{
// using qsort() rather than std::sort() for now. // using qsort() rather than std::sort() for now.
// std::sort() will be used when a Random Access Iterator wrapper for plain // std::sort() will be used when a Random Access Iterator wrapper for plain
arrays is ready arrays is ready,
// otherwise using std::sort() now would entail copying elements to/from st // otherwise using std::sort() would currently entail copying elements to/f
d::vector rom std::vector
template<typename eT> template<typename eT>
class arma_qsort_helper class arma_qsort_helper
{ {
public: public:
static static
int int
ascend_compare(const void* A_orig, const void* B_orig) ascend_compare(const void* A_orig, const void* B_orig)
{ {
skipping to change at line 159 skipping to change at line 159
template<typename T1> template<typename T1>
inline inline
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;
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 u32 sort_type = in.aux_u32_a;
const u32 dim = in.aux_u32_b; const u32 dim = in.aux_u32_b;
arma_debug_check( (X.is_finite() == false), "op_sort::apply(): given obje arma_debug_check( (X.is_finite() == false), "sort(): given object has non
ct has non-finite elements" ); -finite elements" );
arma_debug_check( (sort_type > 1), "op_sort::apply(): incorrect arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor
usage. sort_type must be 0 or 1"); t_type must be 0 or 1");
arma_debug_check( (dim > 1), "op_sort::apply(): incorrect arma_debug_check( (dim > 1), "sort(): incorrect usage. dim
usage. dim must be 0 or 1" ); must be 0 or 1" );
if(dim == 0) // column-wise if(dim == 0) // column-wise
{ {
arma_extra_debug_print("op_sort::apply(), dim = 0"); arma_extra_debug_print("op_sort::apply(), dim = 0");
out = X; out = X;
for(u32 col=0; col<out.n_cols; ++col) for(u32 col=0; col<out.n_cols; ++col)
{ {
op_sort::direct_sort( out.colptr(col), out.n_rows, sort_type ); op_sort::direct_sort( out.colptr(col), out.n_rows, sort_type );
 End of changes. 3 change blocks. 
11 lines changed or deleted 11 lines changed or added


 op_stddev_meat.hpp   op_stddev_meat.hpp 
skipping to change at line 29 skipping to change at line 29
//! For each row or for each column, find the standard deviation. //! For each row or for each column, find the standard deviation.
//! 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.
//! The dimension for which the standard deviations are found is set via th e stddev() function. //! The dimension for which the standard deviations are found is set via th e stddev() function.
template<typename eT> template<typename eT>
inline inline
void void
op_stddev::apply(Mat<eT>& out, const Mat<eT>& X, const u32 norm_type, const u32 dim) op_stddev::apply(Mat<eT>& out, const Mat<eT>& X, const u32 norm_type, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.n_elem == 0), "op_stddev::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "stddev(): given matrix has no element s" );
arma_debug_check( (norm_type > 1), "op_stddev::apply(): incorrect usage. arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type
norm_type must be 0 or 1"); must be 0 or 1");
arma_debug_check( (dim > 1), "op_stddev::apply(): incorrect usage. arma_debug_check( (dim > 1), "stddev(): incorrect usage. dim must b
dim must be 0 or 1" ); e 0 or 1" );
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 0"); arma_extra_debug_print("op_stddev::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = std::sqrt( op_var::direct_var( X.colptr(col), X.n_rows, no rm_type ) ); out[col] = std::sqrt( op_var::direct_var( X.colptr(col), X.n_rows, no rm_type ) );
skipping to change at line 85 skipping to change at line 85
//! implementation for complex numbers //! implementation for complex numbers
template<typename T> template<typename T>
inline inline
void void
op_stddev::apply(Mat<T>& out, const Mat< std::complex<T> >& X, const u32 no rm_type, const u32 dim) op_stddev::apply(Mat<T>& out, const Mat< std::complex<T> >& X, const u32 no rm_type, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
arma_debug_check( (X.n_elem == 0), "op_stddev::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "stddev(): given matrix has no element s" );
arma_debug_check( (norm_type > 1), "op_stddev::apply(): incorrect usage. arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type
norm_type must be 0 or 1"); must be 0 or 1");
arma_debug_check( (dim > 1), "op_stddev::apply(): incorrect usage. arma_debug_check( (dim > 1), "stddev(): incorrect usage. dim must b
dim must be 0 or 1" ); e 0 or 1" );
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 0"); arma_extra_debug_print("op_stddev::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = std::sqrt( op_var::direct_var( X.colptr(col), X.n_rows, no rm_type ) ); out[col] = std::sqrt( op_var::direct_var( X.colptr(col), X.n_rows, no rm_type ) );
 End of changes. 4 change blocks. 
10 lines changed or deleted 10 lines changed or added


 op_sum_meat.hpp   op_sum_meat.hpp 
skipping to change at line 30 skipping to change at line 30
//! 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 u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "op_sum::apply(): 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;
if(dim == 0) // column-wise sum arma_debug_check( (X.n_elem < 1), "sum(): given object has no elements");
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);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col < X.n_cols; ++col)
{ {
eT tmp_val = eT(0); const eT* X_colptr = X.colptr(col);
for(u32 row=0; row<X.n_rows; ++row)
eT val = eT(0);
for(u32 row=0; row < X.n_rows; ++row)
{ {
tmp_val += X.at(row,col); val += X_colptr[row];
} }
out.at(0,col) = tmp_val; out.at(0,col) = val;
} }
} }
else else // traverse across columns (i.e. find the sum in each rows)
if(dim == 1) // row-wise sum
{ {
out.set_size(X.n_rows, 1); out.set_size(X.n_rows, 1);
for(u32 row=0; row<X.n_rows; ++row) for(u32 row=0; row < X.n_rows; ++row)
{ {
eT tmp_val = eT(0); eT val = eT(0);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
tmp_val += X.at(row,col); val += X.at(row,col);
} }
out.at(row,0) = tmp_val; out.at(row,0) = val;
} }
} }
} }
//! @} //! @}
 End of changes. 12 change blocks. 
14 lines changed or deleted 19 lines changed or added


 op_trans_meat.hpp   op_trans_meat.hpp 
skipping to change at line 66 skipping to change at line 66
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(&out != &A) if(&out != &A)
{ {
op_trans::apply_noalias(out, A); op_trans::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 transpose of a square matrix") ; arma_extra_debug_print("op_trans::apply(): doing in-place transpose o f a square matrix");
const u32 n_rows = out.n_rows; const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = out.n_cols;
for(u32 col=0; col<n_cols; ++col) for(u32 col=0; col<n_cols; ++col)
{ {
eT* coldata = out.colptr(col); eT* coldata = out.colptr(col);
for(u32 row=(col+1); row<n_rows; ++row) for(u32 row=(col+1); row<n_rows; ++row)
{ {
skipping to change at line 109 skipping to change at line 109
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
if(&out != &A) if(&out != &A)
{ {
op_trans::apply_noalias(out, A); op_trans::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 transpose of a square matrix") ; arma_extra_debug_print("op_trans::apply(): doing in-place transpose o f a square matrix");
const u32 n_rows = out.n_rows; const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = out.n_cols;
for(u32 col=0; col<n_cols; ++col) for(u32 col=0; col<n_cols; ++col)
{ {
eT* coldata = out.colptr(col); eT* coldata = out.colptr(col);
for(u32 row=(col+1); row<n_rows; ++row) for(u32 row=(col+1); row<n_rows; ++row)
{ {
skipping to change at line 133 skipping to change at line 133
} }
else else
{ {
const Mat<eT> A_copy = A; const Mat<eT> A_copy = A;
op_trans::apply_noalias(out, A_copy); op_trans::apply_noalias(out, A_copy);
} }
} }
} }
#if defined(ARMA_GOOD_COMPILER)
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_trans::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue _plus>, op_trans>& in) op_trans::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue _plus>, op_trans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
isnt_same_type<eT, typename T2::elem_type>::check(); isnt_same_type<eT, typename T2::elem_type>::check();
skipping to change at line 181 skipping to change at line 183
const u32 out_col = row; const u32 out_col = row;
out.at(out_row, out_col) = A.at(row,col) + B.at(row,col); out.at(out_row, out_col) = A.at(row,col) + B.at(row,col);
} }
} }
} }
} }
#endif
// inline void op_trans::apply_inplace(mat &X) // inline void op_trans::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 u32 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;
// } // }
 End of changes. 4 change blocks. 
2 lines changed or deleted 6 lines changed or added


 op_trans_proto.hpp   op_trans_proto.hpp 
skipping to change at line 33 skipping to change at line 33
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);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _trans>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _trans>& in);
#if defined(ARMA_GOOD_COMPILER)
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1,T2,glue_plus>,op_trans>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1,T2,glue_plus>,op_trans>& in);
#endif
// inline static void apply_inplace(mat &out); // inline static void apply_inplace(mat &out);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 4 lines changed or added


 op_trig_meat.hpp   op_trig_meat.hpp 
skipping to change at line 159 skipping to change at line 159
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::acos(A.mem[i]); out_ptr[i] = boost::math::acos(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_acos::apply(): need Boost libraries"); arma_stop("acos(): need Boost libraries");
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_acos::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_acos>& in) op_acos::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_acos>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 193 skipping to change at line 193
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::acos(A.mem[i]); out_ptr[i] = boost::math::acos(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_acos::apply(): need Boost libraries"); arma_stop("acos(): need Boost libraries");
} }
#endif #endif
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cosh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cosh>& in) op_cosh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cosh>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 278 skipping to change at line 278
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::acosh(A.mem[i]); out_ptr[i] = boost::math::acosh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_acosh::apply(): need Boost libraries"); arma_stop("acosh(): need Boost libraries");
} }
#endif #endif
} }
template<typename T1> template<typename T1>
inline inline
void void
op_acosh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_acosh >& in) op_acosh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_acosh >& in)
{ {
skipping to change at line 312 skipping to change at line 312
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::acosh(A.mem[i]); out_ptr[i] = boost::math::acosh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_acosh::apply(): need Boost libraries"); arma_stop("acosh(): need Boost libraries");
} }
#endif #endif
} }
// sin family // sin family
template<typename T1> template<typename T1>
inline inline
void void
skipping to change at line 393 skipping to change at line 393
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A); out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::acos(A.mem[i]); out_ptr[i] = std::asin(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_asin::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asin>& in) op_asin::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asin>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 419 skipping to change at line 419
const Cube<eT>& A = tmp.M; const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices); //out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A); out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::acos(A.mem[i]); out_ptr[i] = std::asin(A.mem[i]);
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_asin::apply(Mat< std::complex<T> >& out, const Op<T1,op_asin>& in) op_asin::apply(Mat< std::complex<T> >& out, const Op<T1,op_asin>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 453 skipping to change at line 453
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::asin(A.mem[i]); out_ptr[i] = boost::math::asin(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asin::apply(): need Boost libraries"); arma_stop("asin(): need Boost libraries");
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_asin::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_asin>& in) op_asin::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_asin>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 487 skipping to change at line 487
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::asin(A.mem[i]); out_ptr[i] = boost::math::asin(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asin::apply(): need Boost libraries"); arma_stop("asin(): need Boost libraries");
} }
#endif #endif
} }
template<typename T1> template<typename T1>
inline inline
void void
op_sinh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sinh>& in) op_sinh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sinh>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 572 skipping to change at line 572
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::asinh(A.mem[i]); out_ptr[i] = boost::math::asinh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asinh::apply(): need Boost libraries"); arma_stop("asinh(): need Boost libraries");
} }
#endif #endif
} }
template<typename T1> template<typename T1>
inline inline
void void
op_asinh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asinh >& in) op_asinh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asinh >& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 605 skipping to change at line 605
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::asinh(A.mem[i]); out_ptr[i] = boost::math::asinh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asinh::apply(): need Boost libraries"); arma_stop("asinh(): need Boost libraries");
} }
#endif #endif
} }
// tan family // tan family
template<typename T1> template<typename T1>
inline inline
void void
op_tan::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_tan>& in) op_tan::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_tan>& in)
skipping to change at line 745 skipping to change at line 745
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::atan(A.mem[i]); out_ptr[i] = boost::math::atan(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asin::apply(): need Boost libraries"); arma_stop("atan(): need Boost libraries");
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_atan::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_atan>& in) op_atan::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_atan>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 779 skipping to change at line 779
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::atan(A.mem[i]); out_ptr[i] = boost::math::atan(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asin::apply(): need Boost libraries"); arma_stop("atan(): need Boost libraries");
} }
#endif #endif
} }
template<typename T1> template<typename T1>
inline inline
void void
op_tanh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_tanh>& in) op_tanh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_tanh>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 864 skipping to change at line 864
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::atanh(A.mem[i]); out_ptr[i] = boost::math::atanh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_atanh::apply(): need Boost libraries"); arma_stop("atanh(): need Boost libraries");
} }
#endif #endif
} }
template<typename T1> template<typename T1>
inline inline
void void
op_atanh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_atanh >& in) op_atanh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_atanh >& in)
{ {
skipping to change at line 898 skipping to change at line 898
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::atanh(A.mem[i]); out_ptr[i] = boost::math::atanh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_atanh::apply(): need Boost libraries"); arma_stop("atanh(): need Boost libraries");
} }
#endif #endif
} }
//! @} //! @}
 End of changes. 14 change blocks. 
14 lines changed or deleted 14 lines changed or added


 op_var_meat.hpp   op_var_meat.hpp 
skipping to change at line 78 skipping to change at line 78
//! 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.
//! The dimension, for which the variances are found, is set via the var() function. //! The dimension, for which the variances are found, is set via the var() function.
template<typename eT> template<typename eT>
inline inline
void void
op_var::apply(Mat<eT>& out, const Mat<eT>& X, const u32 norm_type, const u3 2 dim) op_var::apply(Mat<eT>& out, const Mat<eT>& X, const u32 norm_type, const u3 2 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.n_elem == 0), "op_var::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "var(): given matrix has no elements" );
arma_debug_check( (norm_type > 1), "op_var::apply(): incorrect usage. nor arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus
m_type must be 0 or 1"); t be 0 or 1");
arma_debug_check( (dim > 1), "op_var::apply(): incorrect usage. dim arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0
must be 0 or 1" ); or 1" );
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_var::apply(), dim = 0"); arma_extra_debug_print("op_var::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type ); out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type );
skipping to change at line 134 skipping to change at line 134
//! implementation for complex numbers //! implementation for complex numbers
template<typename T> template<typename T>
inline inline
void void
op_var::apply(Mat<T>& out, const Mat< std::complex<T> >& X, const u32 norm_ type, const u32 dim) op_var::apply(Mat<T>& out, const Mat< std::complex<T> >& X, const u32 norm_ type, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
arma_debug_check( (X.n_elem == 0), "op_var::apply(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "var(): given matrix has no elements" );
arma_debug_check( (norm_type > 1), "op_var::apply(): incorrect usage. nor arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus
m_type must be 0 or 1"); t be 0 or 1");
arma_debug_check( (dim > 1), "op_var::apply(): incorrect usage. dim arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0
must be 0 or 1" ); or 1" );
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_var::apply(), dim = 0"); arma_extra_debug_print("op_var::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X.n_cols; ++col)
{ {
out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type ); out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type );
 End of changes. 4 change blocks. 
10 lines changed or deleted 10 lines changed or added


 op_zeros_meat.hpp   op_zeros_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// 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_zeros //! \addtogroup op_zeros
//! @{ //! @{
template<typename eT> template<typename T1>
inline
void
op_zeros::apply(Mat<eT>& out, const Op<Mat<eT>,op_zeros>& in)
{
arma_extra_debug_sigprint();
const u32 n_rows = in.aux_u32_a;
const u32 n_cols = (in.aux_u32_b > 0) ? in.aux_u32_b : 1;
out.zeros(n_rows, n_cols);
}
template<typename eT>
inline
void
op_zeros::apply(Mat<eT>& out, const Op<Col<eT>,op_zeros>& in)
{
arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a, 1);
}
template<typename eT>
inline
void
op_zeros::apply(Mat<eT>& out, const Op<Row<eT>,op_zeros>& in)
{
arma_extra_debug_sigprint();
out.zeros(1, in.aux_u32_a);
}
template<typename eT>
inline
void
op_zeros::apply(Col<eT>& out, const Op<Col<eT>,op_zeros>& in)
{
arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a);
}
template<typename eT>
inline inline
void void
op_zeros::apply(Row<eT>& out, const Op<Row<eT>,op_zeros>& in) op_zeros::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_zeros>& in )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a); out.zeros(in.aux_u32_a, in.aux_u32_b);
} }
template<typename eT> template<typename eT>
inline inline
void void
op_zeros::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_zeros>& in) op_zeros::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_zeros>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c); out.zeros(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
 End of changes. 3 change blocks. 
46 lines changed or deleted 3 lines changed or added


 op_zeros_proto.hpp   op_zeros_proto.hpp 
skipping to change at line 24 skipping to change at line 24
//! \addtogroup op_zeros //! \addtogroup op_zeros
//! @{ //! @{
//! generate matrix/vector with all elements set to zero //! generate matrix/vector with all elements set to zero
class op_zeros class op_zeros
{ {
public: public:
template<typename eT> template<typename T1>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_zeros>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_zeros>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_zeros>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_zeros>& in);
template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_zeros>& in);
template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_zeros>& in);
//
template<typename eT> template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_zeros>& in); inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_zeros>& in);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
16 lines changed or deleted 3 lines changed or added


 operator_relational.hpp   operator_relational.hpp 
skipping to change at line 161 skipping to change at line 161
umat out(A.n_rows, A.n_cols); umat out(A.n_rows, A.n_cols);
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
typedef typename umat::elem_type umat_elem_type; typedef typename umat::elem_type umat_elem_type;
umat_elem_type* out_mem = out.memptr(); umat_elem_type* out_mem = out.memptr();
for(u32 i=0; i<A.n_elem; ++i) for(u32 i=0; i<A.n_elem; ++i)
{ {
if(A_mem[i] == B_mem[i]) if(A_mem[i] <= B_mem[i])
{ {
out_mem[i] = umat_elem_type(1); out_mem[i] = umat_elem_type(1);
} }
else else
{ {
out_mem[i] = umat_elem_type(0); out_mem[i] = umat_elem_type(0);
} }
} }
return out; return out;
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 running_stat_meat.hpp   running_stat_meat.hpp 
skipping to change at line 19 skipping to change at line 19
// 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 running_stat //! \addtogroup running_stat
//! @{ //! @{
template<typename eT> template<typename eT>
inline
arma_counter<eT>::~arma_counter()
{
arma_extra_debug_sigprint_this(this);
}
template<typename eT>
inline
arma_counter<eT>::arma_counter()
: d_count( eT(0))
, i_count(u32(0))
{
arma_extra_debug_sigprint_this(this);
}
template<typename eT>
inline
const arma_counter<eT>&
arma_counter<eT>::operator++()
{
const u32 max_val = 0xffffffff;
if(i_count < max_val)
{
i_count++;
}
else
{
d_count += eT(max_val);
i_count = 1;
}
return *this;
}
template<typename eT>
inline
void
arma_counter<eT>::operator++(int)
{
operator++();
}
template<typename eT>
inline
void
arma_counter<eT>::reset()
{
d_count = eT(0);
i_count = u32(0);
}
template<typename eT>
inline
eT
arma_counter<eT>::value()
const
{
return d_count + eT(i_count);
}
template<typename eT>
inline
eT
arma_counter<eT>::value_plus_1()
const
{
const u32 max_val = 0xffffffff;
if(i_count < max_val)
{
return d_count + eT(i_count + 1);
}
else
{
return d_count + eT(max_val) + eT(1);
}
}
template<typename eT>
inline
eT
arma_counter<eT>::value_minus_1()
const
{
if(i_count > 0)
{
return d_count + eT(i_count - 1);
}
else
{
return d_count - eT(1);
}
}
//
template<typename eT>
running_stat<eT>::~running_stat()
{
arma_extra_debug_sigprint_this(this);
}
template<typename eT>
running_stat<eT>::running_stat() running_stat<eT>::running_stat()
: N (typename running_stat<eT>::T(0)) : r_mean ( eT(0))
, acc1 ( eT(0)) , r_var (typename running_stat<eT>::T(0))
, acc2 (typename running_stat<eT>::T(0))
, min_val ( eT(0)) , min_val ( eT(0))
, max_val ( eT(0)) , max_val ( eT(0))
, min_val_norm(typename running_stat<eT>::T(0)) , min_val_norm(typename running_stat<eT>::T(0))
, max_val_norm(typename running_stat<eT>::T(0)) , max_val_norm(typename running_stat<eT>::T(0))
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
//! update statistics to reflect new sample //! update statistics to reflect new sample
template<typename eT> template<typename eT>
inline inline
void void
running_stat<eT>::operator() (const typename running_stat<eT>::T sample) running_stat<eT>::operator() (const typename running_stat<eT>::T sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_check( (arma_isfinite(sample) == false), "running_stat: non-finite s
ample given" );
running_stat_aux::update_stats(*this, sample); running_stat_aux::update_stats(*this, sample);
} }
//! 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();
isnt_same_type<eT, std::complex< typename running_stat<eT>::T > >::check( ); isnt_same_type<eT, std::complex< typename running_stat<eT>::T > >::check( );
arma_check( (arma_isfinite(sample) == false), "running_stat: non-finite s
ample given" );
running_stat_aux::update_stats(*this, sample); running_stat_aux::update_stats(*this, sample);
} }
//! set all statistics to zero //! set all statistics to zero
template<typename eT> template<typename eT>
inline inline
void void
running_stat<eT>::reset() running_stat<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename running_stat<eT>::T T; typedef typename running_stat<eT>::T T;
N = T(0); counter.reset();
acc1 = eT(0); r_mean = eT(0);
acc2 = T(0); r_var = T(0);
min_val = eT(0); min_val = eT(0);
max_val = eT(0); max_val = eT(0);
min_val_norm = T(0); min_val_norm = T(0);
max_val_norm = T(0); max_val_norm = T(0);
} }
//! mean or average value //! mean or average value
template<typename eT> template<typename eT>
inline inline
eT eT
running_stat<eT>::mean() const running_stat<eT>::mean()
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename running_stat<eT>::T T; return r_mean;
if(N > T(0))
{
return acc1 / N;
}
else
{
return eT(0);
}
} }
//! 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 u32 norm_type)
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return running_stat_aux::var(*this, norm_type); const T N = counter.value();
if(N > T(1))
{
if(norm_type == 0)
{
return r_var;
}
else
{
const T N_minus_1 = counter.value_minus_1();
return (N_minus_1/N) * r_var;
}
}
else
{
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 u32 norm_type)
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return std::sqrt( running_stat_aux::var(*this, norm_type) ); return std::sqrt( (*this).var(norm_type) );
} }
//! minimum value //! minimum value
template<typename eT> template<typename eT>
inline inline
eT eT
running_stat<eT>::min() const running_stat<eT>::min()
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return min_val; return min_val;
} }
//! maximum value //! maximum value
template<typename eT> template<typename eT>
inline inline
eT eT
running_stat<eT>::max() const running_stat<eT>::max()
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return max_val; return max_val;
} }
//! update statistics to reflect new sample //! update statistics to reflect new sample
template<typename eT> template<typename eT>
inline inline
void void
running_stat_aux::update_stats(running_stat<eT>& x, const eT sample) running_stat_aux::update_stats(running_stat<eT>& x, const eT sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(x.N > eT(0)) typedef typename running_stat<eT>::T T;
const T N = x.counter.value();
if(N > T(0))
{ {
if(sample < x.min_val) if(sample < x.min_val)
{ {
x.min_val = sample; x.min_val = sample;
} }
if(sample > x.max_val) if(sample > x.max_val)
{ {
x.max_val = sample; x.max_val = sample;
} }
const T N_plus_1 = x.counter.value_plus_1();
const T N_minus_1 = x.counter.value_minus_1();
// note: variance has to be updated before the mean
const eT tmp = sample - x.r_mean;
x.r_var = N_minus_1/N * x.r_var + (tmp*tmp)/N_plus_1;
x.r_mean = x.r_mean + (sample - x.r_mean)/N_plus_1;
//x.r_mean = (N/N_plus_1)*x.r_mean + sample/N_plus_1;
//x.r_mean = (x.r_mean + sample/N) * N/N_plus_1;
} }
else else
{ {
x.r_mean = sample;
x.min_val = sample; x.min_val = sample;
x.max_val = sample; x.max_val = sample;
}
x.N++; // r_var is initialised to zero
// in the constructor and reset()
}
x.acc1 += sample; x.counter++;
x.acc2 += sample*sample;
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for complex numbers)
template<typename T> template<typename T>
inline inline
void void
running_stat_aux::update_stats(running_stat< std::complex<T> >& x, const T sample) running_stat_aux::update_stats(running_stat< std::complex<T> >& x, const T sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 192 skipping to change at line 330
} }
//! alter statistics to reflect new sample (version for complex numbers) //! alter statistics to reflect new sample (version for complex numbers)
template<typename T> template<typename T>
inline inline
void void
running_stat_aux::update_stats(running_stat< std::complex<T> >& x, const st d::complex<T>& sample) running_stat_aux::update_stats(running_stat< std::complex<T> >& x, const st d::complex<T>& sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const T sample_norm = std::norm(sample); const T sample_norm = std::norm(sample);
const T N = x.counter.value();
if(x.N > T(0)) if(N > T(0))
{ {
if(sample_norm < x.min_val_norm) if(sample_norm < x.min_val_norm)
{ {
x.min_val_norm = sample_norm; x.min_val_norm = sample_norm;
x.min_val = sample; x.min_val = sample;
} }
if(sample_norm > x.max_val_norm) if(sample_norm > x.max_val_norm)
{ {
x.max_val_norm = sample_norm; x.max_val_norm = sample_norm;
x.max_val = sample; x.max_val = sample;
} }
const T N_plus_1 = x.counter.value_plus_1();
const T N_minus_1 = x.counter.value_minus_1();
x.r_var = N_minus_1/N * x.r_var + std::norm(sample - x.r_mean)/N_plus_1
;
x.r_mean = x.r_mean + (sample - x.r_mean)/N_plus_1;
//x.r_mean = (N/N_plus_1)*x.r_mean + sample/N_plus_1;
//x.r_mean = (x.r_mean + sample/N) * N/N_plus_1;
} }
else else
{ {
x.r_mean = sample;
x.min_val = sample; x.min_val = sample;
x.max_val = sample; x.max_val = sample;
x.min_val_norm = sample_norm; x.min_val_norm = sample_norm;
x.max_val_norm = sample_norm; x.max_val_norm = sample_norm;
}
x.N++;
x.acc1 += sample;
x.acc2 += sample_norm;
}
//! variance
template<typename eT>
inline
eT
running_stat_aux::var(const running_stat<eT>& x, const u32 norm_type)
{
arma_extra_debug_sigprint();
if(x.N > eT(1)) // r_var is initialised to zero
{ // in the constructor and reset()
const eT norm_val = (norm_type == 0) ? (x.N-eT(1)) : x.N;
const eT var_val = (x.acc2 - x.acc1*x.acc1/x.N) / norm_val;
return var_val;
}
else
{
return eT(0);
} }
}
//! variance (version for complex numbers)
template<typename T>
inline
T
running_stat_aux::var(const running_stat< std::complex<T> >& x, const u32 n
orm_type)
{
arma_extra_debug_sigprint();
if(x.N > T(1)) x.counter++;
{
const T norm_val = (norm_type == 0) ? (x.N-T(1)) : x.N;
const T var_val = (x.acc2 - std::norm(x.acc1)/x.N) / norm_val;
return var_val;
}
else
{
return T(0);
}
} }
//! @} //! @}
 End of changes. 29 change blocks. 
73 lines changed or deleted 186 lines changed or added


 running_stat_proto.hpp   running_stat_proto.hpp 
skipping to change at line 18 skipping to change at line 18
// 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 running_stat //! \addtogroup running_stat
//! @{ //! @{
template<typename eT>
class arma_counter
{
public:
inline ~arma_counter();
inline arma_counter();
inline const arma_counter& operator++();
inline void operator++(int);
inline void reset();
inline eT value() const;
inline eT value_plus_1() const;
inline eT value_minus_1() const;
private:
arma_aligned eT d_count;
arma_aligned u32 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:
typedef typename get_pod_type<eT>::pod_type T; typedef typename get_pod_type<eT>::pod_type T;
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 u32 norm_type = 0) const;
inline T stddev(const u32 norm_type = 0) const; inline T stddev(const u32 norm_type = 0) const;
inline eT min() const; inline eT min() const;
inline eT max() const; inline eT max() const;
// //
// //
private: private:
arma_aligned T N; arma_aligned arma_counter<T> counter;
arma_aligned eT acc1; arma_aligned eT r_mean;
arma_aligned T acc2; arma_aligned T r_var;
arma_aligned eT min_val; arma_aligned eT min_val;
arma_aligned eT max_val; arma_aligned eT max_val;
arma_aligned T min_val_norm; arma_aligned T min_val_norm;
arma_aligned T max_val_norm; arma_aligned T max_val_norm;
friend class running_stat_aux; friend class running_stat_aux;
}; };
class running_stat_aux class running_stat_aux
{ {
public: public:
template<typename eT> template<typename eT>
inline static void update_stats(running_stat<eT>& x, const eT sample); inline static void update_stats(running_stat<eT>& x, const eT sample);
template<typename T> template<typename T>
inline static void update_stats(running_stat< std::complex<T> >& x, const T sample); inline static void update_stats(running_stat< std::complex<T> >& x, const T sample);
template<typename T> template<typename T>
inline static void update_stats(running_stat< std::complex<T> >& x, const std::complex<T>& sample); inline static void update_stats(running_stat< std::complex<T> >& x, const std::complex<T>& sample);
//
template<typename eT>
inline static eT var(const running_stat<eT>& x, const u32
norm_type = 0);
template<typename T>
inline static T var(const running_stat< std::complex<T> >& x, const u32
norm_type = 0);
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
18 lines changed or deleted 31 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 68 skipping to change at line 68
inline inline
void void
subview<eT>::fill(const eT val) subview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
eT* coldata = colptr(col); eT* coldata = colptr(col);
for(u32 row = 0; row != n_rows; ++row) for(u32 row = 0; row<n_rows; ++row)
{ {
coldata[row] = val; coldata[row] = val;
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
skipping to change at line 166 skipping to change at line 166
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 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<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");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
skipping to change at line 194 skipping to change at line 194
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 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<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "matrix addition"); arma_debug_assert_same_size(t, x, "matrix addition");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
skipping to change at line 222 skipping to change at line 222
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 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<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "matrix subtraction"); arma_debug_assert_same_size(t, x, "matrix subtraction");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
skipping to change at line 250 skipping to change at line 250
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 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<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "matrix schur product"); arma_debug_assert_same_size(t, x, "matrix schur product");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
skipping to change at line 278 skipping to change at line 278
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 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<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise matrix division"); arma_debug_assert_same_size(t, x, "element-wise matrix division");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
skipping to change at line 306 skipping to change at line 306
//! x.submat(...) = y.submat(...) //! x.submat(...) = y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator= (const subview<eT>& x_in) subview<eT>::operator= (const subview<eT>& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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.aux_row2, x_in.aux_col2) : 0; const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 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");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
skipping to change at line 343 skipping to change at line 343
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator+= (const subview<eT>& x_in) subview<eT>::operator+= (const subview<eT>& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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.aux_row2, x_in.aux_col2) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 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, "matrix addition"); arma_debug_assert_same_size(t, x, "matrix addition");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
skipping to change at line 642 skipping to change at line 642
( (
( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) ) ( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) )
|| ||
( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) ) ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) )
); );
return (row_overlap & col_overlap); return (row_overlap & col_overlap);
} }
} }
template<typename eT>
inline
bool
subview<eT>::is_vec() const
{
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>& actual_out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// //
const bool alias = (&actual_out == &in.m); const bool alias = (&actual_out == &in.m);
Mat<eT>* tmp = (alias) ? new Mat<eT> : 0; Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
Mat<eT>& out = (alias) ? (*tmp) : actual_out; Mat<eT>& out = (alias) ? (*tmp) : actual_out;
// //
const u32 n_rows = in.n_rows; const u32 n_rows = in.n_rows; // number of rows in the subview
const u32 n_cols = in.n_cols; const u32 n_cols = in.n_cols; // number of columns in the subview
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. 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((n_rows == 1) && (n_cols != 1)) if(in.is_vec() == true)
{ {
arma_extra_debug_print("subview::apply(): copying row (going across col if(n_cols == 1) // a column vector
umns)");
for(u32 col = 0; col<n_cols; ++col)
{ {
out[col] = in.m.at(in.aux_row1, col); arma_extra_debug_print("subview::extract(): copying col (going across
} rows)");
}
else
if((n_rows != 1) && (n_cols == 1))
{
arma_extra_debug_print("subview::apply(): copying col (going across n_r
ows)");
const eT* in_coldata = in.colptr(0); eT* out_mem = out.memptr();
const eT* in_coldata = in.colptr(0); // the first column of the subv
iew, taking into account any row offset
for(u32 row = 0; row<n_rows; ++row) for(u32 row=0; row<n_rows; ++row)
{ {
out[row] = in_coldata[row]; out_mem[row] = in_coldata[row];
}
} }
else // a row vector
{
arma_extra_debug_print("subview::extract(): copying row (going across
columns)");
const Mat<eT>& X = in.m;
eT* out_mem = out.memptr();
const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1;
for(u32 i=0; i<n_cols; ++i)
{
out_mem[i] = X.at(row, i+start_col);
}
}
} }
else else // general submatrix
for(u32 col = 0; col<n_cols; ++col)
{ {
eT* out_coldata = out.colptr(col); arma_extra_debug_print("subview::extract(): general submatrix");
const eT* in_coldata = in.colptr(col);
for(u32 row = 0; row<n_rows; ++row) for(u32 col = 0; col<n_cols; ++col)
{ {
out_coldata[row] = in_coldata[row]; eT* out_coldata = out.colptr(col);
} const eT* in_coldata = in.colptr(col);
for(u32 row = 0; row<n_rows; ++row)
{
out_coldata[row] = in_coldata[row];
}
}
} }
if(alias) if(alias)
{ {
actual_out = out; actual_out = out;
delete tmp; delete tmp;
} }
} }
skipping to change at line 902 skipping to change at line 921
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col) subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col) : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col, const u
32 in_row1, const u32 in_row2)
: subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
{
arma_extra_debug_sigprint();
}
template<typename eT>
arma_inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col, const u32 in_
row1, const u32 in_row2)
: subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline inline
void void
subview_col<eT>::operator=(const subview<eT>& X) subview_col<eT>::operator=(const subview<eT>& X)
{ {
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" );
} }
skipping to change at line 956 skipping to change at line 991
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row) subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row)
: subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1) : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row, const u
32 in_col1, const u32 in_col2)
: subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
{
arma_extra_debug_sigprint();
}
template<typename eT>
arma_inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row, const u32 in_
col1, const u32 in_col2)
: subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline inline
void void
subview_row<eT>::operator=(const subview<eT>& X) subview_row<eT>::operator=(const subview<eT>& X)
{ {
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" );
} }
 End of changes. 24 change blocks. 
39 lines changed or deleted 95 lines changed or added


 subview_proto.hpp   subview_proto.hpp 
skipping to change at line 96 skipping to change at line 96
arma_inline eT operator()(const u32 in_row, const u32 in_col) const; arma_inline eT operator()(const u32 in_row, const u32 in_col) const;
arma_inline eT& at(const u32 in_row, const u32 in_col); arma_inline eT& at(const u32 in_row, const u32 in_col);
arma_inline eT at(const u32 in_row, const u32 in_col) const; arma_inline eT at(const u32 in_row, const u32 in_col) const;
arma_inline eT* colptr(const u32 in_col); arma_inline eT* colptr(const u32 in_col);
arma_inline const eT* colptr(const u32 in_col) const; arma_inline const eT* colptr(const u32 in_col) const;
inline bool check_overlap(const subview& x) const; inline bool check_overlap(const subview& x) const;
inline bool is_vec() const;
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>
{ {
public: public:
skipping to change at line 121 skipping to change at line 123
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);
protected: protected:
arma_inline subview_col(const Mat<eT>& in_m, const u32 in_col); arma_inline subview_col(const Mat<eT>& in_m, const u32 in_col);
arma_inline subview_col( Mat<eT>& in_m, const u32 in_col); arma_inline subview_col( Mat<eT>& in_m, const u32 in_col);
arma_inline subview_col(const Mat<eT>& in_m, const u32 in_col, const u32
in_row1, const u32 in_row2);
arma_inline subview_col( Mat<eT>& in_m, const u32 in_col, const u32
in_row1, const u32 in_row2);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Col<eT>;
subview_col(); subview_col();
}; };
template<typename eT> template<typename eT>
class subview_row : public subview<eT> class subview_row : public subview<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
skipping to change at line 146 skipping to change at line 153
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);
protected: protected:
arma_inline subview_row(const Mat<eT>& in_m, const u32 in_row); arma_inline subview_row(const Mat<eT>& in_m, const u32 in_row);
arma_inline subview_row( Mat<eT>& in_m, const u32 in_row); arma_inline subview_row( Mat<eT>& in_m, const u32 in_row);
arma_inline subview_row(const Mat<eT>& in_m, const u32 in_row, const u32
in_col1, const u32 in_col2);
arma_inline subview_row( Mat<eT>& in_m, const u32 in_row, const u32
in_col1, const u32 in_col2);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Row<eT>;
subview_row(); subview_row();
}; };
//! @} //! @}
 End of changes. 5 change blocks. 
0 lines changed or deleted 16 lines changed or added


 unwrap.hpp   unwrap.hpp 
skipping to change at line 647 skipping to change at line 647
inline unwrap_check(const diagview<eT> & A, const T2& junk) inline unwrap_check(const diagview<eT> & A, const T2& junk)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<eT> M; const Mat<eT> M;
}; };
//! if the given object in not a matrix, unwrap it into the given 'out' mat
rix (i.e. do not create another matrix)
//! and provide a reference to the 'out' matrix.
//! if the given object is a matrix, set the size of the 'out' matrix to be
the same as the given object
//! and provide a reference to the given object.
template<typename T1>
class unwrap_write
{
private:
template<typename eT> inline unwrap_write(Mat<eT>& out, const T1& in
);
template<typename eT> inline unwrap_write(Row<eT>& out, const T1& in
);
template<typename eT> inline unwrap_write(Col<eT>& out, const T1& in
);
template<typename eT> inline unwrap_write(subview<eT>& out, const T1& in
);
template<typename eT> inline unwrap_write(diagview<eT>& out, const T1& in
);
};
//template <>
template<typename eT>
class unwrap_write< Mat<eT> >
{
public:
inline
unwrap_write(Mat<eT>& out, const Mat<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
unwrap_write(Row<eT>& out, const Mat<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
unwrap_write(Col<eT>& out, const Mat<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
~unwrap_write()
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
};
//template <>
template<typename eT>
class unwrap_write< Row<eT> >
{
public:
inline
unwrap_write(Mat<eT>& out, const Row<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
unwrap_write(Row<eT>& out, const Row<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
unwrap_write(Col<eT>& out, const Row<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
~unwrap_write()
{
}
const Row<eT>& M;
};
//template <>
template<typename eT>
class unwrap_write< Col<eT> >
{
public:
inline
unwrap_write(Mat<eT>& out, const Col<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
unwrap_write(Row<eT>& out, const Col<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
unwrap_write(Col<eT>& out, const Col<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
~unwrap_write()
{
}
const Col<eT>& M;
};
template<typename T1, typename op_type>
class unwrap_write< Op<T1, op_type> >
{
public:
typedef typename T1::elem_type eT;
//template<typename eT>
inline
unwrap_write(Mat<eT>& out, const Op<T1,op_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
//template<typename eT>
inline
unwrap_write(Row<eT>& out, const Op<T1,op_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
//template<typename eT>
inline
unwrap_write(Col<eT>& out, const Op<T1,op_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_write()
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
};
template<typename T1, typename T2, typename glue_type>
class unwrap_write< Glue<T1, T2, glue_type> >
{
public:
typedef typename T1::elem_type eT;
inline
unwrap_write(Mat<eT>& out, const Glue<T1, T2, glue_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
unwrap_write(Row<eT>& out, const Glue<T1, T2, glue_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
unwrap_write(Col<eT>& out, const Glue<T1, T2, glue_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_write()
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
};
//template<>
template<typename eT>
class unwrap_write< subview<eT> >
{
public:
inline
unwrap_write(Mat<eT>& out, const subview<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
unwrap_write(Row<eT>& out, const subview<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
unwrap_write(Col<eT>& out, const subview<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_write()
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
};
//template<>
template<typename eT>
class unwrap_write< diagview<eT> >
{
public:
inline
unwrap_write(Mat<eT>& out, const diagview<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
unwrap_write(Row<eT>& out, const diagview<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
unwrap_write(Col<eT>& out, const diagview<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_write()
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
};
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 297 lines changed or added


 unwrap_cube.hpp   unwrap_cube.hpp 
skipping to change at line 202 skipping to change at line 202
inline unwrap_cube_check(const subview_cube<eT>& A, const T2& junk) inline unwrap_cube_check(const subview_cube<eT>& A, const T2& junk)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Cube<eT> M; const Cube<eT> M;
}; };
//! if the given object in not a cube, unwrap it into the given 'out' cube
(i.e. do not create another cube)
//! and provide a reference to the 'out' cube.
//! if the given object is a cube, set the size of the 'out' cube to be the
same as the given object
//! and provide a reference to the given object.
template<typename T1>
class unwrap_cube_write
{
private:
template<typename eT> inline unwrap_cube_write(Cube<eT>& out, const T1& i
n);
};
//template <>
template<typename eT>
class unwrap_cube_write< Cube<eT> >
{
public:
inline
unwrap_cube_write(Cube<eT>& out, const Cube<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
out.copy_size(A);
}
inline
~unwrap_cube_write()
{
arma_extra_debug_sigprint();
}
const Cube<eT>& M;
};
template<typename T1, typename op_type>
class unwrap_cube_write< OpCube<T1, op_type> >
{
public:
typedef typename T1::elem_type eT;
//template<typename eT>
inline
unwrap_cube_write(Cube<eT>& out, const OpCube<T1,op_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_cube_write()
{
arma_extra_debug_sigprint();
}
const Cube<eT>& M;
};
template<typename T1, typename T2, typename glue_type>
class unwrap_cube_write< GlueCube<T1, T2, glue_type> >
{
public:
typedef typename T1::elem_type eT;
inline
unwrap_cube_write(Cube<eT>& out, const GlueCube<T1, T2, glue_type>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_cube_write()
{
arma_extra_debug_sigprint();
}
const Cube<eT>& M;
};
//template<>
template<typename eT>
class unwrap_cube_write< subview_cube<eT> >
{
public:
inline
unwrap_cube_write(Cube<eT>& out, const subview_cube<eT>& A)
: M(out)
{
arma_extra_debug_sigprint();
out = A;
}
inline
~unwrap_cube_write()
{
arma_extra_debug_sigprint();
}
const Cube<eT>& M;
};
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 108 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/