Col_meat.hpp   Col_meat.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Col //! \addtogroup Col
//! @{ //! @{
//! construct an empty column vector //! construct an empty column vector
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col() Col<eT>::Col()
: Mat<eT>()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
} }
//! construct a column vector with the specified number of n_elem //! construct a column vector with the specified number of n_elem
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const u32 in_n_elem) Col<eT>::Col(const u32 in_n_elem)
: Mat<eT>(in_n_elem, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
Mat<eT>::init(in_n_elem, 1);
} }
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols)
: Mat<eT>(in_n_rows, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 1;
);
Mat<eT>::init(in_n_rows, in_n_cols);
} }
//! construct a column vector from specified text //! construct a column vector from specified text
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const char* text) Col<eT>::Col(const char* text)
: Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
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" ); access::rw(Mat<eT>::vec_state) = 1;
} }
//! 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();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); access::rw(Mat<eT>::vec_state) = 1;
return *this; return *this;
} }
//! 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 std::string& text) Col<eT>::Col(const std::string& text)
: Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
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" ); access::rw(Mat<eT>::vec_state) = 1;
} }
//! 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 std::string& text) Col<eT>::operator=(const std::string& text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); access::rw(Mat<eT>::vec_state) = 1;
return *this; return *this;
} }
//! construct a column vector from a given column vector
template<typename eT>
inline
Col<eT>::Col(const Col<eT>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
}
//! 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 eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(val);
return *this; return *this;
} }
//! construct a column vector from a given matrix; the matrix must have exa ctly one column
template<typename eT> template<typename eT>
template<typename T1>
inline inline
Col<eT>::Col(const Mat<eT>& X) Col<eT>::Col(const Base<eT,T1>& X)
: Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 1;
);
}
//! construct a column vector from a given matrix; the matrix must have exa Mat<eT>::operator=(X.get_ref());
ctly one column
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator=(const Mat<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> template<typename eT>
template<typename T1>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator*=(const Mat<eT>& X) Col<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator=(X.get_ref());
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 Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co
bool copy_aux_mem) nst bool strict)
: Mat<eT>(aux_mem, aux_n_rows, aux_n_cols, copy_aux_mem) : Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem, strict)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! construct a column vector from a given auxiliary array of eTs
template<typename eT>
inline
Col<eT>::Col(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols)
: Mat<eT>(aux_mem, aux_n_rows, aux_n_cols)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! construct a column vector from a given auxiliary array of eTs
template<typename eT>
inline
Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem)
: Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// set_size(aux_length, 1); access::rw(Mat<eT>::vec_state) = 1;
//
// arma_check( (Mat<eT>::n_elem != aux_length), "Col::Col(): don't know h
ow to handle the given array" );
//
// syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem );
} }
//! construct a column vector from a given auxiliary array of eTs //! construct a column vector from a given auxiliary array of eTs
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const eT* aux_mem, const u32 aux_length) Col<eT>::Col(const eT* aux_mem, const u32 aux_length)
: Mat<eT>(aux_mem, aux_length, 1) : Mat<eT>(aux_mem, aux_length, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// set_size(aux_length, 1); access::rw(Mat<eT>::vec_state) = 1;
//
// arma_check( (Mat<eT>::n_elem != aux_length), "Col::Col(): don't know h
ow to handle the given array" );
//
// syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem );
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Col<eT>::Col Col<eT>::Col
( (
const Base<typename Col<eT>::pod_type, T1>& A, const Base<typename Col<eT>::pod_type, T1>& A,
const Base<typename Col<eT>::pod_type, T2>& B const Base<typename Col<eT>::pod_type, T2>& B
) )
: Mat<eT>(A,B)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! construct a column vector from given a submatrix; the submatrix must ha
ve exactly one column
template<typename eT>
inline
Col<eT>::Col(const subview<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 submatrix; the submatrix must ha
ve exactly one column
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); access::rw(Mat<eT>::vec_state) = 1;
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
return *this; Mat<eT>::init(A,B);
}
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator*=(const subview<eT>& X)
{
arma_extra_debug_sigprint();
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 //! construct a column vector from given a subcube; the subcube must have e xactly one column
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const subview_cube<eT>& X) Col<eT>::Col(const subview_cube<eT>& X)
: Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 1;
);
}
//! 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); 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"
);
return *this;
}
//! construct a column vector from given a diagview
template<typename eT>
inline
Col<eT>::Col(const diagview<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 diagview //! construct a column vector from given a subcube; the subcube must have e xactly one column
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 subview_cube<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;
}
template<typename eT>
inline
const Col<eT>&
Col<eT>::operator*=(const diagview<eT>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
mat_injector< Col<eT> > mat_injector< Col<eT> >
Col<eT>::operator<<(const eT val) Col<eT>::operator<<(const eT val)
{ {
return mat_injector< Col<eT> >(*this, val); return mat_injector< Col<eT> >(*this, val);
} }
skipping to change at line 406 skipping to change at line 272
arma_inline arma_inline
const subview_col<eT> const subview_col<eT>
Col<eT>::rows(const u32 in_row1, const u32 in_row2) Col<eT>::rows(const u32 in_row1, const u32 in_row2)
const const
{ {
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used");
return subview_col<eT>(*this, 0, in_row1, in_row2); 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
template<typename eT>
template<typename T1, typename op_type>
inline
Col<eT>::Col(const Op<T1, op_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! 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 T1, typename op_type>
inline
const Col<eT>&
Col<eT>::operator=(const Op<T1, op_type>& 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>
template<typename T1, typename op_type>
inline
const Col<eT>&
Col<eT>::operator*=(const Op<T1, op_type>& 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>
template<typename T1, typename eop_type>
inline
Col<eT>::Col(const eOp<T1, eop_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename eop_type>
inline
const Col<eT>&
Col<eT>::operator=(const eOp<T1, eop_type>& 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>
template<typename T1, typename eop_type>
inline
const Col<eT>&
Col<eT>::operator*=(const eOp<T1, eop_type>& 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>
template<typename T1, typename op_type>
inline
Col<eT>::Col(const mtOp<eT, T1, op_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename op_type>
inline
const Col<eT>&
Col<eT>::operator=(const mtOp<eT, T1, op_type>& 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>
template<typename T1, typename op_type>
inline
const Col<eT>&
Col<eT>::operator*=(const mtOp<eT, T1, op_type>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
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
template<typename eT>
template<typename T1, typename T2, typename glue_type>
inline
Col<eT>::Col(const Glue<T1, T2, glue_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! 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 T1, typename T2, typename glue_type>
inline
const Col<eT>&
Col<eT>::operator=(const Glue<T1, T2, glue_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
const Col<eT>&
Col<eT>::operator*=(const Glue<T1, T2, glue_type>& 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>
template<typename T1, typename T2, typename eglue_type>
inline
Col<eT>::Col(const eGlue<T1, T2, eglue_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename T2, typename eglue_type>
inline
const Col<eT>&
Col<eT>::operator=(const eGlue<T1, T2, eglue_type>& 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>
template<typename T1, typename T2, typename eglue_type>
inline
const Col<eT>&
Col<eT>::operator*=(const eGlue<T1, T2, eglue_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
Col<eT>::Col(const mtGlue<eT, T1, T2, glue_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename T2, typename glue_type>
inline
const Col<eT>&
Col<eT>::operator=(const mtGlue<eT, T1, T2, glue_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
const Col<eT>&
Col<eT>::operator*=(const mtGlue<eT, T1, T2, glue_type>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
return *this;
}
//! change the number of rows
template<typename eT>
inline
void
Col<eT>::set_size(const u32 in_n_elem)
{
arma_extra_debug_sigprint();
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)
template<typename eT>
inline
void
Col<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
{
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 ) );
arma_debug_check( (in_n_cols > 1), "Col::set_size(): incompatible dimensi
ons" );
}
template<typename eT>
inline
void
Col<eT>::reshape(const u32 in_rows, const u32 in_cols, const u32 dim)
{
arma_extra_debug_sigprint();
Mat<eT>::reshape(in_rows, in_cols, dim);
arma_debug_check( (in_cols > 1), "Col::set_size(): incompatible dimension
s" );
}
//! change the number of n_rows (this function re-implements mat::copy_siz
e() in order to check the number of columns)
template<typename eT>
template<typename eT2>
inline
void
Col<eT>::copy_size(const Mat<eT2>& x)
{
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 ) );
arma_debug_check( (x.n_cols > 1), "Col::copy_size(): incompatible dimensi
ons" );
}
template<typename eT>
inline
void
Col<eT>::zeros()
{
arma_extra_debug_sigprint();
Mat<eT>::zeros();
}
template<typename eT>
inline
void
Col<eT>::zeros(const u32 in_n_elem)
{
arma_extra_debug_sigprint();
Mat<eT>::zeros(in_n_elem, 1);
}
template<typename eT>
inline
void
Col<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
{
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 ) );
arma_debug_check( (in_n_cols > 1), "Col::zeros(): incompatible dimensions
" );
}
template<typename eT>
inline
void
Col<eT>::ones()
{
arma_extra_debug_sigprint();
Mat<eT>::ones();
}
template<typename eT>
inline
void
Col<eT>::ones(const u32 in_n_elem)
{
arma_extra_debug_sigprint();
Mat<eT>::ones(in_n_elem, 1);
}
template<typename eT>
inline
void
Col<eT>::ones(const u32 in_n_rows, const u32 in_n_cols)
{
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 ) );
arma_debug_check( (in_n_cols > 1), "Col::ones(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Col<eT>::load(const std::string name, const file_type type, const bool prin
t_status)
{
arma_extra_debug_sigprint();
Mat<eT>::load(name, type, print_status);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Col<eT>::load(std::istream& is, const file_type type, const bool print_stat
us)
{
arma_extra_debug_sigprint();
Mat<eT>::load(is, type, print_status);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Col<eT>::quiet_load(const std::string name, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(name, type);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Col<eT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(is, type);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT> template<typename eT>
inline inline
typename Col<eT>::row_iterator typename Col<eT>::row_iterator
Col<eT>::begin_row(const u32 row_num) Col<eT>::begin_row(const u32 row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds");
return Mat<eT>::memptr() + row_num; return Mat<eT>::memptr() + row_num;
skipping to change at line 864 skipping to change at line 320
typename Col<eT>::const_row_iterator typename Col<eT>::const_row_iterator
Col<eT>::end_row(const u32 row_num) const Col<eT>::end_row(const u32 row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
return Mat<eT>::memptr() + row_num + 1; return Mat<eT>::memptr() + row_num + 1;
} }
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
void
Col<eT>::fixed<fixed_n_elem>::mem_setup()
{
arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0)
{
access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (fixed_n_elem > Mat_prealloc::mem_n_el
em) ? mem_local_extra : Mat<eT>::mem_local;
}
else
{
access::rw(Mat<eT>::n_rows) = 0;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0;
}
}
#ifdef ARMA_EXTRA_COL_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT)
#endif
//! @} //! @}
 End of changes. 41 change blocks. 
645 lines changed or deleted 77 lines changed or added


 Col_proto.hpp   Col_proto.hpp 
skipping to change at line 29 skipping to change at line 29
//! Class for column vectors (matrices with only column) //! Class for column vectors (matrices with only column)
template<typename eT> template<typename eT>
class Col : public Mat<eT>, public BaseVec< eT, Col<eT> > class Col : public Mat<eT>, public BaseVec< eT, Col<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
inline Col(); inline Col();
inline explicit Col(const u32 n_elem); inline explicit Col(const 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 const Col& operator=(const char* text);
inline Col(const std::string& text);
inline const Col& operator=(const std::string& text);
inline Col(const Col& X);
inline const Col& operator=(const Col& X);
//inline explicit 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 Col( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, inline Col(const char* text);
const bool copy_aux_mem = true); inline const Col& operator=(const char* text);
inline Col(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) inline Col(const std::string& text);
; inline const Col& operator=(const std::string& text);
inline Col( eT* aux_mem, const u32 aux_length, const bool copy_aux_m inline const Col& operator=(const eT val);
em = true);
template<typename T1> inline Col(const Base<eT,T1>& X);
template<typename T1> inline const Col& operator=(const Base<eT,T1>& X);
inline Col( eT* aux_mem, const u32 aux_length, const bool copy_aux_m
em = true, const bool strict = 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_cube<eT>& X);
inline const Col& operator=(const subview<eT>& X); inline const Col& operator=(const subview_cube<eT>& X);
inline const Col& operator*=(const subview<eT>& X);
inline Col(const subview_cube<eT>& X);
inline const Col& operator=(const subview_cube<eT>& X);
inline const Col& operator*=(const subview_cube<eT>& X);
inline Col(const diagview<eT>& X);
inline const Col& operator=(const diagview<eT>& X);
inline const Col& operator*=(const diagview<eT>& X);
inline mat_injector<Col> operator<<(const eT val); inline mat_injector<Col> operator<<(const eT val);
arma_inline eT& row(const u32 row_num); arma_inline eT& row(const u32 row_num);
arma_inline eT row(const u32 row_num) const; 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 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; 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 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 eop_type> inline Col(con
st eOp<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Col& operator=(con
st eOp<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Col& operator*=(con
st eOp<T1, eop_type>& X);
template<typename T1, typename op_type> inline Col(cons
t mtOp<eT, T1, op_type>& X);
template<typename T1, typename op_type> inline const Col& operator=(cons
t mtOp<eT, T1, op_type>& X);
template<typename T1, typename op_type> inline const Col& operator*=(cons
t mtOp<eT, 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 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 eglue_type> inline
Col(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename eglue_type> inline const Col&
operator=(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename eglue_type> inline const Col&
operator*=(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename glue_type> inline
Col(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Col&
operator=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Col&
operator*=(const mtGlue<eT, T1, T2, glue_type>& X);
inline void set_size(const u32 n_elem);
inline void set_size(const u32 n_rows, const u32 n_cols);
inline void reshape(const u32 n_rows, const u32 n_cols, const u32 dim =
0);
template<typename eT2>
inline void copy_size(const Mat<eT2>& m);
inline void zeros();
inline void zeros(const u32 n_elem);
inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones();
inline void ones(const u32 n_elem);
inline void ones(const u32 n_rows, const u32 n_cols);
inline void load(const std::string name, const file_type type = auto_de
tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de
tect, const bool print_status = true);
inline void quiet_load(const std::string name, const file_type type = a
uto_detect);
inline void quiet_load( std::istream& is, const file_type type = a
uto_detect);
typedef eT* row_iterator; typedef eT* row_iterator;
typedef const eT* const_row_iterator; typedef const eT* const_row_iterator;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const u32 row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const u32 row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const u32 row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const u32 row_num) const;
template<u32 fixed_n_elem>
class fixed : public Col<eT>
{
private:
arma_aligned eT mem_local_extra[ ( fixed_n_elem > Mat_prealloc::mem_n_e
lem ) ? fixed_n_elem : 1 ];
arma_inline void mem_setup();
arma_inline void swap_rows_cols() { access::rw(Mat<eT>::n_cols) = fixed
_n_elem; access::rw(Mat<eT>::n_rows) = 1; }
public:
inline fixed() { mem_setup(); }
inline fixed(const char* text) { mem_setup(); swa
p_rows_cols(); Col<eT>::operator=(text); }
inline const Col& operator=(const char* text) { swa
p_rows_cols(); Col<eT>::operator=(text); return *this; }
inline fixed(const std::string& text) { mem_setup(); swa
p_rows_cols(); Col<eT>::operator=(text); }
inline const Col& operator=(const std::string& text) { swa
p_rows_cols(); Col<eT>::operator=(text); return *this; }
inline const Col& operator=(const eT val) { Col<eT>::operator=(val); re
turn *this; }
template<typename T1>
inline fixed(const Base<eT,T1>& A) { mem_setup(); Col<eT>::operator=(A.
get_ref()); }
template<typename T1>
inline const Col& operator=(const Base<eT,T1>& A) { Col<eT>::operator=(
A.get_ref()); return *this; }
template<typename T1, typename T2>
inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T
2>& B) { mem_setup(); Col<eT>::init(A,B); }
inline fixed(const subview_cube<eT>& X) { mem_setup(); C
ol<eT>::operator=(X); }
inline const Col& operator=(const subview_cube<eT>& X) { C
ol<eT>::operator=(X); return *this; }
};
#ifdef ARMA_EXTRA_COL_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO)
#endif
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
101 lines changed or deleted 67 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 27 skipping to change at line 27
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
Cube<eT>::~Cube() Cube<eT>::~Cube()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
delete_mat(); delete_mat();
if(use_aux_mem == false) if(mem_state == 0)
{ {
if(n_elem > sizeof(mem_local)/sizeof(eT) ) if(n_elem > Cube_prealloc::mem_n_elem)
{ {
delete [] mem; delete [] mem;
} }
} }
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
// try to expose buggy user code that accesses deleted objects // try to expose buggy user code that accesses deleted objects
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
skipping to change at line 58 skipping to change at line 58
} }
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube() Cube<eT>::Cube()
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
//! construct the cube to have user specified dimensions //! construct the cube to have user specified dimensions
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces) Cube<eT>::Cube(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces)
: 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) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(in_n_rows, in_n_cols, in_n_slices); init(in_n_rows, in_n_cols, in_n_slices);
} }
//! internal cube construction; if the requested size is small enough, memo ry from the stack is used. //! internal cube construction; if the requested size is small enough, memo ry from the stack is used.
//! otherwise memory is allocated via 'new' //! otherwise memory is allocated via 'new'
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::init(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces) Cube<eT>::init(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d, in_n_slices = %d") % in_n_rows % in_n_cols % in_n_slices ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d, in_n_slices = %d") % in_n_rows % in_n_cols % in_n_slices );
const u32 new_n_elem = in_n_rows * in_n_cols * in_n_slices; const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) & & (n_slices == in_n_slices) );
if(n_elem == new_n_elem) if(same_size == false)
{ {
if( (n_rows != in_n_rows) || (n_cols != in_n_cols) || (n_slices != in_n arma_debug_check( (mem_state == 3), "Cube::init(): size can't be change
_slices) ) d as template based size specification is in use" );
{
delete_mat();
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices;
create_mat(); const u32 old_n_elem = n_elem;
} const u32 new_n_elem = in_n_rows * in_n_cols * in_n_slices;
}
else
{
arma_debug_check
(
(use_aux_mem == true),
"Cube::init(): can't change the amount of memory as auxiliary memory
is in use"
);
delete_mat();
if(n_elem > sizeof(mem_local)/sizeof(eT) )
{
delete [] mem;
}
if(new_n_elem <= sizeof(mem_local)/sizeof(eT) ) if(old_n_elem == new_n_elem)
{ {
access::rw(mem) = mem_local; if(same_size == false)
{
delete_mat();
if(new_n_elem > 0)
{
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices;
create_mat();
}
}
} }
else else
{ {
access::rw(mem) = new(std::nothrow) eT[new_n_elem]; arma_debug_check( (mem_state == 2), "Cube::init(): requested size is
arma_check( (mem == 0), "Cube::init(): out of memory" ); not compatible with the size of auxiliary memory" );
}
delete_mat();
if(mem_state == 0)
{
if(n_elem > Cube_prealloc::mem_n_elem )
{
arma_extra_debug_print("Cube::init(): freeing memory");
delete [] mem;
}
}
access::rw(mem_state) = 0;
if(new_n_elem <= Cube_prealloc::mem_n_elem)
{
access::rw(mem) = mem_local;
}
else
{
arma_extra_debug_print("Cube::init(): allocating memory");
access::rw(mem) = new(std::nothrow) eT[new_n_elem];
arma_check( (mem == 0), "Cube::init(): out of memory" );
}
if(new_n_elem > 0)
{
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices;
access::rw(n_elem) = new_n_elem;
access::rw(n_elem) = new_n_elem; create_mat();
}
}
if(new_n_elem == 0) if(new_n_elem == 0)
{ {
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
access::rw(n_elem_slice) = 0; access::rw(n_elem_slice) = 0;
access::rw(n_slices) = 0; access::rw(n_slices) = 0;
access::rw(n_elem) = 0;
} }
else }
{ }
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices;
}
create_mat(); //! for constructing a complex cube out of two non-complex cubes
template<typename eT>
template<typename T1, typename T2>
inline
void
Cube<eT>::init
(
const BaseCube<typename Cube<eT>::pod_type,T1>& A,
const BaseCube<typename Cube<eT>::pod_type,T2>& B
)
{
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil
e-time abort if eT isn't std::complex
typedef typename T1::elem_type T;
arma_type_check< is_complex<T>::value == true >::apply(); //!< compile-
time abort if T is std::complex
isnt_same_type<std::complex<T>, eT>::check(); //!< compile-time abort i
f types are not compatible
const unwrap_cube<T1> tmp_A(A.get_ref());
const unwrap_cube<T2> tmp_B(B.get_ref());
const Cube<T>& X = tmp_A.M;
const Cube<T>& Y = tmp_B.M;
arma_assert_same_size(X, Y, "Cube()");
init(X.n_rows, X.n_cols, X.n_slices);
const T* X_mem = X.mem;
const T* Y_mem = Y.mem;
for(u32 i=0; i<n_elem; ++i)
{
access::rw(mem[i]) = std::complex<T>(X_mem[i], Y_mem[i]);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::delete_mat() Cube<eT>::delete_mat()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) for(u32 slice = 0; slice < n_slices; ++slice)
{ {
delete access::rw(mat_ptrs[slice]); delete access::rw(mat_ptrs[slice]);
} }
if(n_slices > sizeof(mat_ptrs_local)/sizeof(Mat<eT>*) ) if(mem_state <= 2)
{ {
delete [] mat_ptrs; if(n_slices > Cube_prealloc::mat_ptrs_size)
{
delete [] mat_ptrs;
}
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::create_mat() Cube<eT>::create_mat()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if( n_slices <= sizeof(mat_ptrs_local)/sizeof(Mat<eT>*) ) if(mem_state <= 2)
{
access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local);
}
else
{ {
access::rw(mat_ptrs) = new(std::nothrow) const Mat<eT>*[n_slices]; if(n_slices <= Cube_prealloc::mat_ptrs_size)
arma_check( (mat_ptrs == 0), "Cube::create_mat(): out of memory" ); {
access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local);
}
else
{
access::rw(mat_ptrs) = new(std::nothrow) const Mat<eT>*[n_slices];
arma_check( (mat_ptrs == 0), "Cube::create_mat(): out of memory" );
}
} }
for(u32 slice = 0; slice < n_slices; ++slice) for(u32 slice = 0; slice < n_slices; ++slice)
{ {
mat_ptrs[slice] = new Mat<eT>('j', slice_memptr(slice), n_rows, n_cols) ; mat_ptrs[slice] = new Mat<eT>('j', slice_memptr(slice), n_rows, n_cols) ;
} }
} }
//! Set the cube to be equal to the specified scalar. //! Set the cube to be equal to the specified scalar.
//! NOTE: the size of the cube will be 1x1x1 //! NOTE: the size of the cube will be 1x1x1
skipping to change at line 217 skipping to change at line 279
} }
//! In-place addition of a scalar to all elements of the cube //! In-place addition of a scalar to all elements of the cube
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const eT val) Cube<eT>::operator+=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_plus( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] += val;
local_ptr[j] += val;
}
if(i < local_n_elem)
{
local_ptr[i] += val;
}
return *this; return *this;
} }
//! In-place subtraction of a scalar from all elements of the cube //! In-place subtraction of a scalar from all elements of the cube
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const eT val) Cube<eT>::operator-=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_minus( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] -= val;
local_ptr[j] -= val;
}
if(i < local_n_elem)
{
local_ptr[i] -= val;
}
return *this; return *this;
} }
//! In-place multiplication of all elements of the cube with a scalar //! In-place multiplication of all elements of the cube with a scalar
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator*=(const eT val) Cube<eT>::operator*=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_mul( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] *= val;
local_ptr[j] *= val;
}
if(i < local_n_elem)
{
local_ptr[i] *= val;
}
return *this; return *this;
} }
//! In-place division of all elements of the cube with a scalar //! In-place division of all elements of the cube with a scalar
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const eT val) Cube<eT>::operator/=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_div( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] /= val;
local_ptr[j] /= val;
}
if(i < local_n_elem)
{
local_ptr[i] /= val;
}
return *this; return *this;
} }
//! construct a cube from a given cube //! construct a cube from a given cube
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const Cube<eT>& in_cube) Cube<eT>::Cube(const Cube<eT>& in_cube)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint(arma_boost::format("this = %x in_cube = %x") % this % &in_cube); arma_extra_debug_sigprint(arma_boost::format("this = %x in_cube = %x") % this % &in_cube);
init(in_cube); init(in_cube);
} }
//! construct a cube from a given cube //! construct a cube from a given cube
template<typename eT> template<typename eT>
skipping to change at line 370 skipping to change at line 376
} }
//! construct a cube from a given auxiliary array of eTs. //! construct a cube from a given auxiliary array of eTs.
//! if copy_aux_mem is true, new memory is allocated and the array is copie d. //! if copy_aux_mem is true, new memory is allocated and the array is copie d.
//! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying). //! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying).
//! note that in the latter case //! note that in the latter case
//! the default is to copy the array. //! the default is to copy the array.
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, con Cube<eT>::Cube(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, con
st u32 aux_n_slices, const bool copy_aux_mem) st u32 aux_n_slices, const bool copy_aux_mem, const bool strict)
: n_rows (copy_aux_mem ? 0 : aux_n_rows ) : n_rows (copy_aux_mem ? 0 : aux_n_rows )
, n_cols (copy_aux_mem ? 0 : aux_n_cols ) , n_cols (copy_aux_mem ? 0 : aux_n_cols )
, n_elem_slice(copy_aux_mem ? 0 : aux_n_rows*aux_n_cols ) , n_elem_slice(copy_aux_mem ? 0 : aux_n_rows*aux_n_cols )
, n_slices (copy_aux_mem ? 0 : aux_n_slices ) , n_slices (copy_aux_mem ? 0 : aux_n_slices )
, n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols*aux_n_slices) , n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols*aux_n_slices)
, use_aux_mem (copy_aux_mem ? false : true ) , mem_state (copy_aux_mem ? 0 : (strict ? 2 : 1) )
, mat_ptrs (mat_ptrs ) , mat_ptrs (mat_ptrs )
, mem (copy_aux_mem ? mem : aux_mem ) , mem (copy_aux_mem ? mem : aux_mem )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(copy_aux_mem == true) if(copy_aux_mem == true)
{ {
init(aux_n_rows, aux_n_cols, aux_n_slices); init(aux_n_rows, aux_n_cols, aux_n_slices);
syslib::copy_elem( memptr(), aux_mem, n_elem ); syslib::copy_elem( memptr(), aux_mem, n_elem );
} }
else else
{ {
create_mat(); create_mat();
} }
} }
//! construct a cube from a given auxiliary read-only array of eTs. //! construct a cube from a given auxiliary read-only array of eTs.
//! the array is copied. //! the array is copied.
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_col s, const u32 aux_n_slices) Cube<eT>::Cube(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_col s, const u32 aux_n_slices)
: 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) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(aux_n_rows, aux_n_cols, aux_n_slices); init(aux_n_rows, aux_n_cols, aux_n_slices);
syslib::copy_elem( memptr(), aux_mem, n_elem ); syslib::copy_elem( memptr(), aux_mem, n_elem );
} }
//! in-place cube addition //! in-place cube addition
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const Cube<eT>& m) Cube<eT>::operator+=(const Cube<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "cube addition"); arma_debug_assert_same_size(*this, m, "cube addition");
const u32 local_n_elem = m.n_elem; arrayops::inplace_plus( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] += m_mem[i];
out_mem[j] += m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] += m_mem[i];
}
return *this; return *this;
} }
//! in-place cube subtraction //! in-place cube subtraction
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const Cube<eT>& m) Cube<eT>::operator-=(const Cube<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "cube subtraction"); arma_debug_assert_same_size(*this, m, "cube subtraction");
const u32 local_n_elem = m.n_elem; arrayops::inplace_minus( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] -= m_mem[i];
out_mem[j] -= m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] -= m_mem[i];
}
return *this; return *this;
} }
//! in-place element-wise cube multiplication //! in-place element-wise cube multiplication
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const Cube<eT>& m) Cube<eT>::operator%=(const Cube<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "element-wise cube multiplication") ; arma_debug_assert_same_size(*this, m, "element-wise cube multiplication") ;
const u32 local_n_elem = m.n_elem; arrayops::inplace_mul( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] *= m_mem[i];
out_mem[j] *= m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] *= m_mem[i];
}
return *this; return *this;
} }
//! in-place element-wise cube division //! in-place element-wise cube division
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const Cube<eT>& m) Cube<eT>::operator/=(const Cube<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "element-wise cube division"); arma_debug_assert_same_size(*this, m, "element-wise cube division");
const u32 local_n_elem = m.n_elem; arrayops::inplace_div( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] /= m_mem[i];
out_mem[j] /= m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] /= m_mem[i];
}
return *this; return *this;
} }
//! for constructing a complex cube out of two non-complex cubes //! for constructing a complex cube out of two non-complex cubes
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Cube<eT>::Cube Cube<eT>::Cube
( (
const BaseCube<typename Cube<eT>::pod_type,T1>& A, const BaseCube<typename Cube<eT>::pod_type,T1>& A,
const BaseCube<typename Cube<eT>::pod_type,T2>& B const BaseCube<typename Cube<eT>::pod_type,T2>& B
) )
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil init(A,B);
e-time abort if eT isn't std::complex
typedef typename T1::elem_type T;
arma_type_check< is_complex<T>::value == true >::apply(); //!< compile-
time abort if T is std::complex
isnt_same_type<std::complex<T>, eT>::check(); //!< compile-time abort i
f types are not compatible
const unwrap_cube<T1> tmp_A(A.get_ref());
const unwrap_cube<T2> tmp_B(B.get_ref());
const Cube<T>& X = tmp_A.M;
const Cube<T>& Y = tmp_B.M;
arma_assert_same_size(X, Y, "Cube()");
init(X.n_rows, X.n_cols, X.n_slices);
const T* X_mem = X.mem;
const T* Y_mem = Y.mem;
for(u32 i=0; i<n_elem; ++i)
{
access::rw(mem[i]) = std::complex<T>(X_mem[i], Y_mem[i]);
}
} }
//! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation) //! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation)
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube(const subview_cube<eT>& X) Cube<eT>::Cube(const subview_cube<eT>& X)
: n_rows(0) : n_rows(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) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
//! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation) //! construct a cube from a subview_cube instance (e.g. construct a cube fr om a delayed subcube operation)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const subview_cube<eT>& X) Cube<eT>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::extract(*this, X); subview_cube<eT>::extract(*this, X);
return *this; return *this;
} }
//! in-place cube addition (using a subcube on the right-hand-side) //! in-place cube addition (using a subcube on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const subview_cube<eT>& X) Cube<eT>::operator+=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::plus_inplace(*this, X); subview_cube<eT>::plus_inplace(*this, X);
return *this; return *this;
} }
//! in-place cube subtraction (using a subcube on the right-hand-side) //! in-place cube subtraction (using a subcube on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const subview_cube<eT>& X) Cube<eT>::operator-=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::minus_inplace(*this, X); subview_cube<eT>::minus_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise cube mutiplication (using a subcube on the right- hand-side) //! in-place element-wise cube mutiplication (using a subcube on the right- hand-side)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const subview_cube<eT>& X) Cube<eT>::operator%=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::schur_inplace(*this, X); subview_cube<eT>::schur_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise cube division (using a subcube on the right-hand- side) //! in-place element-wise cube division (using a subcube on the right-hand- side)
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const subview_cube<eT>& X) Cube<eT>::operator/=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::div_inplace(*this, X); subview_cube<eT>::div_inplace(*this, X);
return *this; return *this;
} }
//! provide the reference to the matrix representing a single slice //! provide the reference to the matrix representing a single slice
template<typename eT> template<typename eT>
arma_inline arma_inline
Mat<eT>& Mat<eT>&
Cube<eT>::slice(const u32 in_slice) Cube<eT>::slice(const u32 in_slice)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 765 skipping to change at line 690
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);
} }
//! creation of subview_cube (generic subcube)
template<typename eT>
arma_inline
subview_cube<eT>
Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s
lice_span)
{
arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a;
const u32 in_row2 = row_span.b;
const u32 in_col1 = col_span.a;
const u32 in_col2 = col_span.b;
const u32 in_slice1 = slice_span.a;
const u32 in_slice2 = slice_span.b;
arma_debug_check
(
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_slice1 > in_slice2
) ||
(in_row2 >= n_rows) || (in_col2 >= n_cols) || (in_slice2 >= n_slices)
,
"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);
}
//! creation of subview_cube (generic subcube)
template<typename eT>
arma_inline
const subview_cube<eT>
Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s
lice_span) const
{
arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a;
const u32 in_row2 = row_span.b;
const u32 in_col1 = col_span.a;
const u32 in_col2 = col_span.b;
const u32 in_slice1 = slice_span.a;
const u32 in_slice2 = slice_span.b;
arma_debug_check
(
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_slice1 > in_slice2
) ||
(in_row2 >= n_rows) || (in_col2 >= n_cols) || (in_slice2 >= n_slices)
,
"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);
}
//! create a cube from OpCube, i.e. run the previously delayed unary operat ions //! create a cube from OpCube, i.e. run the previously delayed unary operat ions
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Cube<eT>::Cube(const OpCube<T1, op_type>& X) Cube<eT>::Cube(const OpCube<T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
op_type::apply(*this, X); op_type::apply(*this, X);
} }
skipping to change at line 876 skipping to change at line 855
//! create a cube from eOpCube, i.e. run the previously delayed unary opera tions //! create a cube from eOpCube, i.e. run the previously delayed unary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
Cube<eT>::Cube(const eOpCube<T1, eop_type>& X) Cube<eT>::Cube(const eOpCube<T1, eop_type>& X)
: n_rows(0) : n_rows(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) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
skipping to change at line 977 skipping to change at line 956
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Cube<eT>::Cube(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::Cube(const GlueCube<T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
skipping to change at line 1080 skipping to change at line 1059
//! create a cube from eGlue, i.e. run the previously delayed binary operat ions //! create a cube from eGlue, i.e. run the previously delayed binary operat ions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
Cube<eT>::Cube(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::Cube(const eGlueCube<T1, T2, eglue_type>& X)
: n_rows(0) : n_rows(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) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
skipping to change at line 1320 skipping to change at line 1299
{ {
if(arma_isfinite(mem[i]) == false) if(arma_isfinite(mem[i]) == false)
{ {
return false; return false;
} }
} }
return true; return true;
} }
//! returns true if the cube has no elements
template<typename eT>
arma_inline
bool
Cube<eT>::is_empty() const
{
return (n_elem == 0);
}
//! returns true if the given index is currently in range
template<typename eT>
arma_inline
bool
Cube<eT>::in_range(const u32 i) const
{
return (i < n_elem);
}
//! returns true if the given location is currently in range
template<typename eT>
arma_inline
bool
Cube<eT>::in_range(const u32 in_row, const u32 in_col, const u32 in_slice)
const
{
return ( (in_row < n_rows) && (in_col < n_cols) && (in_slice < n_slices)
);
}
//! returns a pointer to array of eTs used by the cube //! returns a pointer to array of eTs used by the cube
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
Cube<eT>::memptr() Cube<eT>::memptr()
{ {
return const_cast<eT*>(mem); return const_cast<eT*>(mem);
} }
//! returns a pointer to array of eTs used by the cube //! returns a pointer to array of eTs used by the cube
skipping to change at line 1377 skipping to change at line 1383
arma_inline arma_inline
const eT* const eT*
Cube<eT>::slice_colptr(const u32 slice, const u32 col) const Cube<eT>::slice_colptr(const u32 slice, const u32 col) const
{ {
return &mem[ slice*n_elem_slice + col*n_rows ]; return &mem[ slice*n_elem_slice + col*n_rows ];
} }
//! print contents of the cube (to the cout stream), //! print contents of the cube (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::print(const std::string extra_text) const Cube<eT>::print(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
cout << extra_text << '\n'; cout << extra_text << '\n';
} }
arma_ostream::print(cout, *this, true); arma_ostream::print(cout, *this, true);
} }
//! print contents of the cube to a user specified stream, //! print contents of the cube to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::print(std::ostream& user_stream, const std::string extra_text) co nst Cube<eT>::print(std::ostream& user_stream, const std::string extra_text) co nst
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
} }
arma_ostream::print(user_stream, *this, true); arma_ostream::print(user_stream, *this, true);
} }
//! print contents of the cube (to the cout stream), //! print contents of the cube (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's flags are used as is and are not modified //! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::raw_print(const std::string extra_text) const Cube<eT>::raw_print(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
cout << extra_text << '\n'; cout << extra_text << '\n';
} }
arma_ostream::print(cout, *this, false); arma_ostream::print(cout, *this, false);
} }
//! print contents of the cube to a user specified stream, //! print contents of the cube to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's flags are used as is and are not modified. //! the stream's state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::raw_print(std::ostream& user_stream, const std::string extra_text ) const Cube<eT>::raw_print(std::ostream& user_stream, const std::string extra_text ) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
skipping to change at line 1492 skipping to change at line 1498
} }
//! fill the cube with the specified value //! fill the cube with the specified value
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::fill(const eT val) Cube<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_set( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] = val;
local_ptr[j] = val;
}
if(i < local_n_elem)
{
local_ptr[i] = val;
}
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::zeros() Cube<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::zeros(const u32 in_rows, const u32 in_cols, const u32 in_slices) Cube<eT>::zeros(const u32 in_rows, const u32 in_cols, const u32 in_slices)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d , in_slices = %d") % in_rows % in_cols % in_slices ); arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d , in_slices = %d") % in_rows % in_cols % in_slices );
set_size(in_rows, in_cols, in_slices); set_size(in_rows, in_cols, in_slices);
fill(eT(0)); fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::ones() Cube<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1548 skipping to change at line 1541
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::ones(const u32 in_rows, const u32 in_cols, const u32 in_slices) Cube<eT>::ones(const u32 in_rows, const u32 in_cols, const u32 in_slices)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d , in_slices = %d") % in_rows % in_cols % in_slices ); arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d , in_slices = %d") % in_rows % in_cols % in_slices );
set_size(in_rows, in_cols, in_slices); set_size(in_rows, in_cols, in_slices);
fill(eT(1)); fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::reset() Cube<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0,0); init(0,0,0);
} }
template<typename eT>
template<typename T1>
inline
void
Cube<eT>::set_real(const BaseCube<typename Cube<eT>::pod_type,T1>& X)
{
arma_extra_debug_sigprint();
Cube_aux::set_real(*this, X);
}
template<typename eT>
template<typename T1>
inline
void
Cube<eT>::set_imag(const BaseCube<typename Cube<eT>::pod_type,T1>& X)
{
arma_extra_debug_sigprint();
Cube_aux::set_imag(*this, X);
}
//! save the cube to a file //! save the cube to a file
template<typename eT> template<typename eT>
inline inline
bool bool
Cube<eT>::save(const std::string name, const file_type type, const bool pri nt_status) const Cube<eT>::save(const std::string name, const file_type type, const bool pri nt_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool save_okay; bool save_okay;
skipping to change at line 1885 skipping to change at line 1901
typename Cube<eT>::const_slice_iterator typename Cube<eT>::const_slice_iterator
Cube<eT>::end_slice(const u32 slice_num) const Cube<eT>::end_slice(const u32 slice_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (slice_num >= n_slices), "end_slice(): index out of bou nds"); arma_debug_check( (slice_num >= n_slices), "end_slice(): index out of bou nds");
return slice_memptr(slice_num) + n_elem_slice; return slice_memptr(slice_num) + n_elem_slice;
} }
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols, u32 fixed_n_slices>
arma_inline
void
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::mem_setup()
{
arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0)
{
access::rw(Cube<eT>::n_rows) = fixed_n_rows;
access::rw(Cube<eT>::n_cols) = fixed_n_cols;
access::rw(Cube<eT>::n_elem_slice) = fixed_n_rows * fixed_n_cols;
access::rw(Cube<eT>::n_slices) = fixed_n_slices;
access::rw(Cube<eT>::n_elem) = fixed_n_elem;
access::rw(Cube<eT>::mem_state) = 3;
access::rw(Cube<eT>::mat_ptrs) = const_cast< const Mat<eT>** >( \
(fixed_n_slices > Cube_prealloc::m
at_ptrs_size) ? mat_ptrs_local_extra : mat_ptrs_local );
access::rw(Cube<eT>::mem) = (fixed_n_elem > Cube_prealloc::m
em_n_elem) ? mem_local_extra : mem_local;
create_mat();
}
else
{
access::rw(Cube<eT>::n_rows) = 0;
access::rw(Cube<eT>::n_cols) = 0;
access::rw(Cube<eT>::n_elem_slice) = 0;
access::rw(Cube<eT>::n_slices) = 0;
access::rw(Cube<eT>::n_elem) = 0;
access::rw(Cube<eT>::mem_state) = 3;
access::rw(Cube<eT>::mat_ptrs) = 0;
access::rw(Cube<eT>::mem) = 0;
}
}
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Cube_aux::prefix_pp(Cube<eT>& x) Cube_aux::prefix_pp(Cube<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const u32 n_elem = x.n_elem;
u32 i,j; u32 i,j;
skipping to change at line 2013 skipping to change at line 2064
//! postfix ++ for complex numbers (work around for limitations of the std: :complex class) //! postfix ++ for complex numbers (work around for limitations of the std: :complex class)
template<typename T> template<typename T>
arma_inline arma_inline
void void
Cube_aux::postfix_mm(Cube< std::complex<T> >& x) Cube_aux::postfix_mm(Cube< std::complex<T> >& x)
{ {
x -= T(1); x -= T(1);
} }
template<typename eT, typename T1>
inline
void
Cube_aux::set_real(Cube<eT>& out, const BaseCube<eT,T1>& X)
{
arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& A = tmp.M;
arma_debug_assert_same_size( out, A, "Cube::set_real()" );
out = A;
}
template<typename T, typename T1>
inline
void
Cube_aux::set_real(Cube< std::complex<T> >& out, const BaseCube<T,T1>& X)
{
arma_extra_debug_sigprint();
(is_Cube<T1>::value == true) ? Cube_aux::set_real_via_unwrap(out, X) : Cu
be_aux::set_real_via_proxy(out, X);
}
template<typename eT, typename T1>
inline
void
Cube_aux::set_imag(Cube<eT>& out, const BaseCube<eT,T1>& X)
{
arma_extra_debug_sigprint();
}
template<typename T, typename T1>
inline
void
Cube_aux::set_imag(Cube< std::complex<T> >& out, const BaseCube<T,T1>& X)
{
arma_extra_debug_sigprint();
(is_Cube<T1>::value == true) ? Cube_aux::set_imag_via_unwrap(out, X) : Cu
be_aux::set_imag_via_proxy(out, X);
}
template<typename T, typename T1>
inline
void
Cube_aux::set_real_via_unwrap(Cube< std::complex<T> >& out, const BaseCube<
T,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const unwrap_cube<T1> tmp(X.get_ref());
const Cube<T>& A = tmp.M;
arma_debug_assert_same_size( out, A, "Cube::set_real()" );
const u32 n_elem = out.n_elem;
const T* A_mem = A.memptr();
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
//out_mem[i].real() = A_mem[i];
out_mem[i] = std::complex<T>( A_mem[i], out_mem[i].imag() );
}
}
template<typename T, typename T1>
inline
void
Cube_aux::set_imag_via_unwrap(Cube< std::complex<T> >& out, const BaseCube<
T,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const unwrap_cube<T1> tmp(X.get_ref());
const Cube<T>& A = tmp.M;
arma_debug_assert_same_size( out, A, "Cube::set_imag()" );
const u32 n_elem = out.n_elem;
const T* A_mem = A.memptr();
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
// out_mem[i].imag() = A_mem[i];
out_mem[i] = std::complex<T>(out_mem[i].real(), A_mem[i]);
}
}
template<typename T, typename T1>
inline
void
Cube_aux::set_real_via_proxy(Cube< std::complex<T> >& out, const BaseCube<T
,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const ProxyCube<T1> P(X.get_ref());
arma_debug_assert_same_size( out.n_rows, out.n_cols, out.n_slices, P.n_ro
ws, P.n_cols, P.n_slices, "Cube::set_real()" );
const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
//out_mem[i].real() = P[i];
out_mem[i] = std::complex<T>( P[i], out_mem[i].imag() );
}
}
template<typename T, typename T1>
inline
void
Cube_aux::set_imag_via_proxy(Cube< std::complex<T> >& out, const BaseCube<T
,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const ProxyCube<T1> P(X.get_ref());
arma_debug_assert_same_size( out.n_rows, out.n_cols, out.n_slices, P.n_ro
ws, P.n_cols, P.n_slices, "Cube::set_imag()" );
const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
//out_mem[i].imag() = P[i];
out_mem[i] = std::complex<T>( out_mem[i].real(), P[i] );
}
}
#ifdef ARMA_EXTRA_CUBE_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_MEAT)
#endif
//! @} //! @}
 End of changes. 55 change blocks. 
248 lines changed or deleted 464 lines changed or added


 Cube_proto.hpp   Cube_proto.hpp 
skipping to change at line 19 skipping to change at line 19
// 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 Cube //! \addtogroup Cube
//! @{ //! @{
struct Cube_prealloc
{
static const u32 mat_ptrs_size = 4;
static const u32 mem_n_elem = 64;
};
//! Dense cube class //! Dense cube class
template<typename eT> template<typename eT>
class Cube : public BaseCube< eT, Cube<eT> > class Cube : public BaseCube< eT, Cube<eT> >
{ {
public: public:
typedef eT elem_type; //!< the type of ele ments stored in the cube typedef eT elem_type; //!< the type of ele ments stored in the cube
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-co mplex, pod_type is same as eT. otherwise, pod_type is the underlying type u sed by std::complex typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-co mplex, pod_type is same as eT. otherwise, pod_type is the underlying type u sed by std::complex
const u32 n_rows; //!< number of rows in each slice (read-only) const u32 n_rows; //!< number of rows in each slice (read-only)
const u32 n_cols; //!< number of columns in each slice (read-only) const u32 n_cols; //!< number of columns in each slice (read-only)
const u32 n_elem_slice; //!< number of elements in each slice (read-only ) const u32 n_elem_slice; //!< number of elements in each slice (read-only )
const u32 n_slices; //!< number of slices in the cube (read-only) const u32 n_slices; //!< number of slices in the cube (read-only)
const u32 n_elem; //!< number of elements in the cube (read-only) const u32 n_elem; //!< number of elements in the cube (read-only)
const bool use_aux_mem; //!< true if externally managed memory is being const u32 mem_state;
used (read-only)
// mem_state = 0: normal cube that can be resized;
// mem_state = 1: use auxiliary memory until change in the number of elem
ents is requested;
// mem_state = 2: use auxiliary memory and don't allow the number of elem
ents to be changed;
// mem_state = 3: fixed size via template based size specification.
arma_aligned const Mat<eT>** const mat_ptrs; //!< pointer to an array con taining pointers to Mat instances (one for each slice) arma_aligned const Mat<eT>** const mat_ptrs; //!< pointer to an array con taining pointers to Mat instances (one for each slice)
arma_aligned const eT* const mem; //!< pointer to the memory u sed by the cube (memory is read-only) arma_aligned const eT* const mem; //!< pointer to the memory u sed by the cube (memory is read-only)
protected: protected:
arma_aligned Mat<eT>* mat_ptrs_local[ 16 ]; arma_aligned Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ];
arma_aligned eT mem_local[ 64 ]; arma_aligned eT mem_local[ Cube_prealloc::mem_n_elem ];
public: public:
inline ~Cube(); inline ~Cube();
inline Cube(); inline Cube();
inline Cube(const u32 in_rows, const u32 in_cols, const u32 in_slices); inline Cube(const u32 in_rows, const u32 in_cols, const u32 in_slices);
inline Cube( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols , const u32 aux_n_slices, const bool copy_aux_mem = true); inline Cube( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols , const u32 aux_n_slices, const bool copy_aux_mem = true, const bool strict = true);
inline Cube(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols , const u32 aux_n_slices); inline Cube(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols , const u32 aux_n_slices);
arma_inline const Cube& operator=(const eT val); arma_inline const Cube& operator=(const eT val);
arma_inline const Cube& operator+=(const eT val); arma_inline const Cube& operator+=(const eT val);
arma_inline const Cube& operator-=(const eT val); arma_inline const Cube& operator-=(const eT val);
arma_inline const Cube& operator*=(const eT val); arma_inline const Cube& operator*=(const eT val);
arma_inline const Cube& operator/=(const eT val); arma_inline const Cube& operator/=(const eT val);
inline Cube(const Cube& m); inline Cube(const Cube& m);
inline const Cube& operator=(const Cube& m); inline const Cube& operator=(const Cube& m);
skipping to change at line 85 skipping to change at line 96
arma_inline Mat<eT>& slice(const u32 in_slice); arma_inline Mat<eT>& slice(const u32 in_slice);
arma_inline const Mat<eT>& slice(const u32 in_slice) const; arma_inline const Mat<eT>& slice(const u32 in_slice) const;
arma_inline subview_cube<eT> slices(const u32 in_slice1, const u32 in_slice2); arma_inline subview_cube<eT> slices(const u32 in_slice1, const u32 in_slice2);
arma_inline const subview_cube<eT> slices(const u32 in_slice1, const u32 in_slice2) const; arma_inline const subview_cube<eT> slices(const u32 in_slice1, const u32 in_slice2) const;
arma_inline subview_cube<eT> subcube(const u32 in_row1, const u32 i n_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u3 2 in_slice2); arma_inline subview_cube<eT> subcube(const u32 in_row1, const u32 i n_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u3 2 in_slice2);
arma_inline const subview_cube<eT> subcube(const u32 in_row1, const u32 i n_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u3 2 in_slice2) const; arma_inline const subview_cube<eT> subcube(const u32 in_row1, const u32 i n_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u3 2 in_slice2) const;
arma_inline subview_cube<eT> subcube(const span& row_span, const sp
an& col_span, const span& slice_span);
arma_inline const subview_cube<eT> subcube(const span& row_span, const sp
an& col_span, const span& slice_span) const;
template<typename T1, typename op_type> inline Cube(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline Cube(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator+=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator+=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator-=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator-=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator%=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator%=(con st OpCube<T1, op_type>& X);
template<typename T1, typename op_type> inline const Cube& operator/=(con st OpCube<T1, op_type>& X); template<typename T1, typename op_type> inline const Cube& operator/=(con st OpCube<T1, op_type>& X);
template<typename T1, typename eop_type> inline Cube(co nst eOpCube<T1, eop_type>& X); template<typename T1, typename eop_type> inline Cube(co nst eOpCube<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Cube& operator=(co nst eOpCube<T1, eop_type>& X); template<typename T1, typename eop_type> inline const Cube& operator=(co nst eOpCube<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Cube& operator+=(co nst eOpCube<T1, eop_type>& X); template<typename T1, typename eop_type> inline const Cube& operator+=(co nst eOpCube<T1, eop_type>& X);
skipping to change at line 130 skipping to change at line 144
arma_inline eT& operator() (const u32 in_row, const u32 in_col, const u32 in_slice); arma_inline eT& operator() (const u32 in_row, const u32 in_col, const u32 in_slice);
arma_inline eT operator() (const u32 in_row, const u32 in_col, const u32 in_slice) const; arma_inline eT operator() (const u32 in_row, const u32 in_col, const u32 in_slice) const;
arma_inline const Cube& operator++(); arma_inline const Cube& operator++();
arma_inline void operator++(int); arma_inline void operator++(int);
arma_inline const Cube& operator--(); arma_inline const Cube& operator--();
arma_inline void operator--(int); arma_inline void operator--(int);
arma_inline bool is_finite() const; arma_inline bool is_finite() const;
arma_inline bool is_empty() const;
arma_inline bool in_range(const u32 i) const;
arma_inline bool in_range(const u32 in_row, const u32 in_col, const u32 i
n_slice) const;
arma_inline eT* memptr(); arma_inline eT* memptr();
arma_inline const eT* memptr() const; arma_inline const eT* memptr() const;
arma_inline eT* slice_memptr(const u32 slice); arma_inline eT* slice_memptr(const u32 slice);
arma_inline const eT* slice_memptr(const u32 slice) const; arma_inline const eT* slice_memptr(const u32 slice) const;
arma_inline eT* slice_colptr(const u32 in_slice, const u32 in_col); arma_inline eT* slice_colptr(const u32 in_slice, const u32 in_col);
arma_inline const eT* slice_colptr(const u32 in_slice, const u32 in_col) const; arma_inline const eT* slice_colptr(const u32 in_slice, const u32 in_col) const;
skipping to change at line 161 skipping to change at line 179
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, const u32 in_slic es); inline void zeros(const u32 in_rows, const u32 in_cols, const u32 in_slic es);
inline void ones(); inline void ones();
inline void ones(const u32 in_rows, const u32 in_cols, const u32 in_slice s); inline void ones(const u32 in_rows, const u32 in_cols, const u32 in_slice s);
inline void reset(); inline void reset();
template<typename T1> inline void set_real(const BaseCube<pod_type,T1>& X
);
template<typename T1> inline void set_imag(const BaseCube<pod_type,T1>& X
);
inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true); inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true);
inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true); inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const; inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const; inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a uto_detect); inline bool quiet_load(const std::string name, const file_type type = a uto_detect);
skipping to change at line 193 skipping to change at line 214
inline iterator end(); inline iterator end();
inline const_iterator end() const; inline const_iterator end() const;
inline slice_iterator begin_slice(const u32 slice_num); inline slice_iterator begin_slice(const u32 slice_num);
inline const_slice_iterator begin_slice(const u32 slice_num) const; inline const_slice_iterator begin_slice(const u32 slice_num) const;
inline slice_iterator end_slice(const u32 slice_num); inline slice_iterator end_slice(const u32 slice_num);
inline const_slice_iterator end_slice(const u32 slice_num) const; inline const_slice_iterator end_slice(const u32 slice_num) const;
template<u32 fixed_n_rows, u32 fixed_n_cols, u32 fixed_n_slices>
class fixed : public Cube<eT>
{
private:
static const u32 fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n_s
lices;
arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_prea
lloc::mat_ptrs_size) ? fixed_n_slices : 1 ];
arma_aligned eT mem_local_extra [ (fixed_n_elem > Cube_prea
lloc::mem_n_elem) ? fixed_n_elem : 1 ];
arma_inline void mem_setup();
public:
inline fixed() { mem_setup(); }
inline const Cube& operator=(const eT val) { mem_setup(); Cube<eT>::ope
rator=(val); return *this; }
template<typename T1>
inline fixed(const BaseCube<eT,T1>& A) { mem_setup(); Cube<eT>::operato
r=(A.get_ref()); }
template<typename T1>
inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::oper
ator=(A.get_ref()); return *this; }
template<typename T1, typename T2>
inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<po
d_type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); }
};
#ifdef ARMA_EXTRA_CUBE_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_PROTO)
#endif
protected: protected:
inline void init(const u32 in_rows, const u32 in_cols, const u32 in_slice s); inline void init(const u32 in_rows, const u32 in_cols, const u32 in_slice s);
inline void init(const Cube& x); inline void init(const Cube& x);
template<typename T1, typename T2>
inline void init(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type,
T2>& B);
inline void delete_mat(); inline void delete_mat();
inline void create_mat(); inline void create_mat();
friend class op_reshape;
}; };
class Cube_aux class Cube_aux
{ {
public: public:
template<typename eT> arma_inline static void prefix_pp(Cube<eT>& x); template<typename eT> arma_inline static void prefix_pp(Cube<eT>& x);
template<typename T> arma_inline static void prefix_pp(Cube< std::comple x<T> >& x); template<typename T> arma_inline static void prefix_pp(Cube< std::comple x<T> >& x);
template<typename eT> arma_inline static void postfix_pp(Cube<eT>& x); template<typename eT> arma_inline static void postfix_pp(Cube<eT>& x);
template<typename T> arma_inline static void postfix_pp(Cube< std::compl ex<T> >& x); template<typename T> arma_inline static void postfix_pp(Cube< std::compl ex<T> >& x);
template<typename eT> arma_inline static void prefix_mm(Cube<eT>& x); template<typename eT> arma_inline static void prefix_mm(Cube<eT>& x);
template<typename T> arma_inline static void prefix_mm(Cube< std::comple x<T> >& x); template<typename T> arma_inline static void prefix_mm(Cube< std::comple x<T> >& x);
template<typename eT> arma_inline static void postfix_mm(Cube<eT>& x); template<typename eT> arma_inline static void postfix_mm(Cube<eT>& x);
template<typename T> arma_inline static void postfix_mm(Cube< std::compl ex<T> >& x); template<typename T> arma_inline static void postfix_mm(Cube< std::compl ex<T> >& x);
template<typename eT, typename T1> inline static void set_real(Cube<eT>&
out, const BaseCube<eT,T1>& X);
template<typename T, typename T1> inline static void set_real(Cube< std:
:complex<T> >& out, const BaseCube< T,T1>& X);
template<typename eT, typename T1> inline static void set_imag(Cube<eT>&
out, const BaseCube<eT,T1>& X);
template<typename T, typename T1> inline static void set_imag(Cube< std:
:complex<T> >& out, const BaseCube< T,T1>& X);
template<typename T, typename T1> inline static void set_real_via_unwrap
(Cube< std::complex<T> >& out, const BaseCube< T,T1>& X);
template<typename T, typename T1> inline static void set_imag_via_unwrap
(Cube< std::complex<T> >& out, const BaseCube< T,T1>& X);
template<typename T, typename T1> inline static void set_real_via_proxy(
Cube< std::complex<T> >& out, const BaseCube< T,T1>& X);
template<typename T, typename T1> inline static void set_imag_via_proxy(
Cube< std::complex<T> >& out, const BaseCube< T,T1>& X);
}; };
//! @} //! @}
 End of changes. 11 change blocks. 
5 lines changed or deleted 97 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 25 skipping to change at line 25
//! \addtogroup Mat //! \addtogroup Mat
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
Mat<eT>::~Mat() Mat<eT>::~Mat()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(use_aux_mem == false) if(mem_state == 0)
{ {
if(n_elem > sizeof(mem_local)/sizeof(eT) ) if(n_elem > Mat_prealloc::mem_n_elem)
{ {
delete [] mem; delete [] mem;
} }
} }
if(arma_config::debug == true) if(arma_config::debug == true)
{ {
// try to expose buggy user code that accesses deleted objects // try to expose buggy user code that accesses deleted objects
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
skipping to change at line 51 skipping to change at line 51
isnt_supported_elem_type<eT>::check(); isnt_supported_elem_type<eT>::check();
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat() Mat<eT>::Mat()
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
//! construct the matrix to have user specified dimensions //! construct the matrix to have user specified dimensions
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const u32 in_n_rows, const u32 in_n_cols) Mat<eT>::Mat(const u32 in_n_rows, const u32 in_n_cols)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(in_n_rows, in_n_cols); init(in_n_rows, in_n_cols);
} }
//! internal matrix construction; if the requested size is small enough, me mory from the stack is used. otherwise memory is allocated via 'new' //! internal matrix construction; if the requested size is small enough, me mory from the stack is used. otherwise memory is allocated via 'new'
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init(const u32 in_n_rows, const u32 in_n_cols) Mat<eT>::init(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols );
const u32 new_n_elem = in_n_rows * in_n_cols; const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) ) ;
if(n_elem == new_n_elem) if(same_size == false)
{
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
}
else
{ {
const u32 t_vec_state = vec_state;
const u32 t_mem_state = mem_state;
arma_debug_check arma_debug_check
( (
(use_aux_mem == true), (t_mem_state == 3),
"Mat::init(): can't change the amount of memory as auxiliary memory i "Mat::init(): size is fixed and hence cannot be changed"
s in use"
); );
if(n_elem > sizeof(mem_local)/sizeof(eT) ) arma_debug_check
{ (
delete [] mem; (
} (t_vec_state > 0) &&
(
((t_vec_state == 1) && (in_n_cols > 1)) ||
((t_vec_state == 2) && (in_n_rows > 1))
)
),
"Mat::init(): object is a row or column vector; requested size is not
compatible"
);
if(new_n_elem <= sizeof(mem_local)/sizeof(eT) ) const u32 old_n_elem = n_elem;
const u32 new_n_elem = in_n_rows * in_n_cols;
if(old_n_elem == new_n_elem)
{ {
access::rw(mem) = mem_local; arma_extra_debug_print("Mat::init(): reusing memory");
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
} }
else else
{ {
access::rw(mem) = new(std::nothrow) eT[new_n_elem]; arma_debug_check
arma_check( (mem == 0), "Mat::init(): out of memory" ); (
} (t_mem_state == 2),
"Mat::init(): requested size is not compatible with the size of aux
iliary memory"
);
if(t_mem_state == 0)
{
if(old_n_elem > Mat_prealloc::mem_n_elem )
{
arma_extra_debug_print("Mat::init(): freeing memory");
access::rw(n_elem) = new_n_elem; delete [] mem;
}
}
if(new_n_elem <= Mat_prealloc::mem_n_elem )
{
access::rw(mem) = mem_local;
}
else
{
arma_extra_debug_print("Mat::init(): allocating memory");
access::rw(mem) = new(std::nothrow) eT[new_n_elem];
arma_check( (mem == 0), "Mat::init(): out of memory" );
}
access::rw(n_elem) = new_n_elem;
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(mem_state) = 0;
}
if(new_n_elem == 0) if(new_n_elem == 0)
{ {
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
} }
else
{
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
}
} }
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const char* text) Mat<eT>::Mat(const char* text)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init( std::string(text) ); init( std::string(text) );
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
skipping to change at line 163 skipping to change at line 200
return *this; return *this;
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const std::string& text) Mat<eT>::Mat(const std::string& text)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(text); init(text);
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
skipping to change at line 300 skipping to change at line 338
} }
//! In-place addition of a scalar to all elements of the matrix //! In-place addition of a scalar to all elements of the matrix
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const eT val) Mat<eT>::operator+=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_plus( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] += val;
local_ptr[j] += val;
}
if(i < local_n_elem)
{
local_ptr[i] += val;
}
return *this; return *this;
} }
//! In-place subtraction of a scalar from all elements of the matrix //! In-place subtraction of a scalar from all elements of the matrix
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const eT val) Mat<eT>::operator-=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_minus( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] -= val;
local_ptr[j] -= val;
}
if(i < local_n_elem)
{
local_ptr[i] -= val;
}
return *this; return *this;
} }
//! In-place multiplication of all elements of the matrix with a scalar //! In-place multiplication of all elements of the matrix with a scalar
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const eT val) Mat<eT>::operator*=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_mul( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] *= val;
local_ptr[j] *= val;
}
if(i < local_n_elem)
{
local_ptr[i] *= val;
}
return *this; return *this;
} }
//! In-place division of all elements of the matrix with a scalar //! In-place division of all elements of the matrix with a scalar
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const eT val) Mat<eT>::operator/=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_div( memptr(), val, n_elem );
const u32 local_n_elem = n_elem;
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
local_ptr[i] /= val;
local_ptr[j] /= val;
}
if(i < local_n_elem)
{
local_ptr[i] /= val;
}
return *this; return *this;
} }
//! construct a matrix from a given matrix //! construct a matrix from a given matrix
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const Mat<eT>& in_mat) Mat<eT>::Mat(const Mat<eT>& in_mat)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") % this % &in_mat); arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") % this % &in_mat);
init(in_mat); init(in_mat);
} }
//! construct a matrix from a given matrix //! construct a matrix from a given matrix
template<typename eT> template<typename eT>
skipping to change at line 439 skipping to change at line 422
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init(const Mat<eT>& x) Mat<eT>::init(const Mat<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
init(x.n_rows, x.n_cols); init(x.n_rows, x.n_cols);
syslib::copy_elem( memptr(), x.mem, n_elem ); syslib::copy_elem( memptr(), x.mem, x.n_elem );
}
}
//! for constructing a complex matrix out of two non-complex matrices
template<typename eT>
template<typename T1, typename T2>
inline
void
Mat<eT>::init
(
const Base<typename Mat<eT>::pod_type,T1>& A,
const Base<typename Mat<eT>::pod_type,T2>& B
)
{
arma_extra_debug_sigprint();
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil
e-time abort if eT isn't std::complex
typedef typename T1::elem_type T;
arma_type_check< is_complex<T>::value == true >::apply(); //!< compile-
time abort if T is std::complex
isnt_same_type<std::complex<T>, eT>::check(); //!< compile-time abort i
f types are not compatible
const unwrap<T1> tmp_A(A.get_ref());
const unwrap<T2> tmp_B(B.get_ref());
const Mat<T>& X = tmp_A.M;
const Mat<T>& Y = tmp_B.M;
arma_assert_same_size(X, Y, "Mat()");
init(X.n_rows, Y.n_cols);
const T* X_mem = X.mem;
const T* Y_mem = Y.mem;
for(u32 i=0; i<n_elem; ++i)
{
access::rw(mem[i]) = std::complex<T>(X_mem[i], Y_mem[i]);
}
}
//! try to steal the memory from a given matrix;
//! if memory can't be stolen, copy the given matrix
template<typename eT>
inline
void
Mat<eT>::steal_mem(Mat<eT>& x)
{
arma_extra_debug_sigprint();
if(this != &x)
{
const u32 x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols;
const u32 x_n_elem = x.n_elem;
const u32 x_vec_state = x.vec_state;
const u32 x_mem_state = x.mem_state;
const u32 t_vec_state = vec_state;
bool layout_ok = false;
if(t_vec_state == x_vec_state)
{
layout_ok = true;
}
else
{
if( (t_vec_state == 1) && ( x_n_cols <= 1) )
{
layout_ok = true;
}
if( (t_vec_state == 2) && ( x_n_rows <= 1) )
{
layout_ok = true;
}
}
if( (x_mem_state == 0) && (x_n_elem > Mat_prealloc::mem_n_elem) && (lay
out_ok == true) )
{
reset();
access::rw(n_rows) = x_n_rows;
access::rw(n_cols) = x_n_cols;
access::rw(n_elem) = x_n_elem;
access::rw(mem) = x.mem;
access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0;
access::rw(x.n_elem) = 0;
access::rw(x.mem) = 0;
}
else
{
init(x);
}
} }
} }
//! construct a matrix from a given auxiliary array of eTs. //! construct a matrix from a given auxiliary array of eTs.
//! if copy_aux_mem is true, new memory is allocated and the array is copie d. //! if copy_aux_mem is true, new memory is allocated and the array is copie d.
//! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying). //! if copy_aux_mem is false, the auxiliary array is used directly (without allocating memory and copying).
//! the default is to copy the array. //! the default is to copy the array.
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const Mat<eT>::Mat(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const
bool copy_aux_mem) bool copy_aux_mem, const bool strict)
: n_rows (copy_aux_mem ? 0 : aux_n_rows ) : n_rows (copy_aux_mem ? 0 : aux_n_rows )
, n_cols (copy_aux_mem ? 0 : aux_n_cols ) , n_cols (copy_aux_mem ? 0 : aux_n_cols )
, n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols) , n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols)
, use_aux_mem(copy_aux_mem ? false : true ) , vec_state( 0 )
, mem (copy_aux_mem ? mem : aux_mem ) , mem_state(copy_aux_mem ? 0 : ( strict ? 2 : 1 ) )
, mem (copy_aux_mem ? mem : aux_mem )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(copy_aux_mem == true) if(copy_aux_mem == true)
{ {
init(aux_n_rows, aux_n_cols); init(aux_n_rows, aux_n_cols);
syslib::copy_elem( memptr(), aux_mem, n_elem ); syslib::copy_elem( memptr(), aux_mem, n_elem );
} }
} }
//! construct a matrix from a given auxiliary read-only array of eTs. //! construct a matrix from a given auxiliary read-only array of eTs.
//! the array is copied. //! the array is copied.
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) Mat<eT>::Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(aux_n_rows, aux_n_cols); init(aux_n_rows, aux_n_cols);
syslib::copy_elem( memptr(), aux_mem, n_elem ); syslib::copy_elem( memptr(), aux_mem, n_elem );
} }
//! DANGEROUS! Construct a temporary matrix, using auxiliary memory. //! DANGEROUS! Construct a temporary matrix, using auxiliary memory.
//! This constructor is NOT intended for usage by user code. //! This constructor is NOT intended for usage by user code.
//! Its sole purpose is to be used by the Cube class. //! Its sole purpose is to be used by the Cube class.
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons t u32 aux_n_cols) Mat<eT>::Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons t u32 aux_n_cols)
: n_rows (aux_n_rows ) : n_rows (aux_n_rows )
, n_cols (aux_n_cols ) , n_cols (aux_n_cols )
, n_elem (aux_n_rows*aux_n_cols) , n_elem (aux_n_rows*aux_n_cols)
, use_aux_mem(true ) , vec_state(0 )
, mem (aux_mem ) , mem_state(3 )
, mem (aux_mem )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
//! in-place matrix addition //! in-place matrix addition
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Mat<eT>& m) Mat<eT>::operator+=(const Mat<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "matrix addition"); arma_debug_assert_same_size(*this, m, "matrix addition");
const u32 local_n_elem = m.n_elem; arrayops::inplace_plus( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] += m_mem[i];
out_mem[j] += m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] += m_mem[i];
}
return *this; return *this;
} }
//! in-place matrix subtraction //! in-place matrix subtraction
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Mat<eT>& m) Mat<eT>::operator-=(const Mat<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "matrix subtraction"); arma_debug_assert_same_size(*this, m, "matrix subtraction");
const u32 local_n_elem = m.n_elem; arrayops::inplace_minus( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] -= m_mem[i];
out_mem[j] -= m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] -= m_mem[i];
}
return *this; return *this;
} }
//! in-place matrix multiplication //! in-place matrix multiplication
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const Mat<eT>& m) Mat<eT>::operator*=(const Mat<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
glue_times::apply_inplace(*this, m); glue_times::apply_inplace(*this, m);
return *this; return *this;
} }
//! in-place element-wise matrix multiplication //! in-place element-wise matrix multiplication
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const Mat<eT>& m) Mat<eT>::operator%=(const Mat<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "element-wise matrix multplication" ); arma_debug_assert_same_size(*this, m, "element-wise matrix multplication" );
const u32 local_n_elem = m.n_elem; arrayops::inplace_mul( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] *= m_mem[i];
out_mem[j] *= m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] *= m_mem[i];
}
return *this; return *this;
} }
//! in-place element-wise matrix division //! in-place element-wise matrix division
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const Mat<eT>& m) Mat<eT>::operator/=(const Mat<eT>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(*this, m, "element-wise matrix division"); arma_debug_assert_same_size(*this, m, "element-wise matrix division");
const u32 local_n_elem = m.n_elem; arrayops::inplace_div( memptr(), m.memptr(), n_elem );
eT* out_mem = (*this).memptr();
const eT* m_mem = m.memptr();
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2)
{
out_mem[i] /= m_mem[i];
out_mem[j] /= m_mem[j];
}
if(i < local_n_elem)
{
out_mem[i] /= m_mem[i];
}
return *this; return *this;
} }
//! for constructing a complex matrix out of two non-complex matrices //! for constructing a complex matrix out of two non-complex matrices
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Mat<eT>::Mat Mat<eT>::Mat
( (
const Base<typename Mat<eT>::pod_type,T1>& A, const Base<typename Mat<eT>::pod_type,T1>& A,
const Base<typename Mat<eT>::pod_type,T2>& B const Base<typename Mat<eT>::pod_type,T2>& B
) )
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil init(A,B);
e-time abort if eT isn't std::complex
typedef typename T1::elem_type T;
arma_type_check< is_complex<T>::value == true >::apply(); //!< compile-
time abort if T is std::complex
isnt_same_type<std::complex<T>, eT>::check(); //!< compile-time abort i
f types are not compatible
const unwrap<T1> tmp_A(A.get_ref());
const unwrap<T2> tmp_B(B.get_ref());
const Mat<T>& X = tmp_A.M;
const Mat<T>& Y = tmp_B.M;
arma_assert_same_size(X, Y, "Mat()");
init(X.n_rows, Y.n_cols);
const T* X_mem = X.mem;
const T* Y_mem = Y.mem;
for(u32 i=0; i<n_elem; ++i)
{
access::rw(mem[i]) = std::complex<T>(X_mem[i], Y_mem[i]);
}
} }
//! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation) //! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation)
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const subview<eT>& X) Mat<eT>::Mat(const subview<eT>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
//! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation) //! construct a matrix from subview (e.g. construct a matrix from a delayed submatrix operation)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const subview<eT>& X) Mat<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::extract(*this, X); subview<eT>::extract(*this, X);
return *this; return *this;
} }
//! in-place matrix addition (using a submatrix on the right-hand-side) //! in-place matrix addition (using a submatrix on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const subview<eT>& X) Mat<eT>::operator+=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::plus_inplace(*this, X); subview<eT>::plus_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix subtraction (using a submatrix on the right-hand-side) //! in-place matrix subtraction (using a submatrix on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const subview<eT>& X) Mat<eT>::operator-=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::minus_inplace(*this, X); subview<eT>::minus_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix mutiplication (using a submatrix on the right-hand-side ) //! in-place matrix mutiplication (using a submatrix on the right-hand-side )
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const subview<eT>& X) Mat<eT>::operator*=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise matrix mutiplication (using a submatrix on the ri ght-hand-side) //! in-place element-wise matrix mutiplication (using a submatrix on the ri ght-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const subview<eT>& X) Mat<eT>::operator%=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::schur_inplace(*this, X); subview<eT>::schur_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise matrix division (using a submatrix on the right-h and-side) //! in-place element-wise matrix division (using a submatrix on the right-h and-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const subview<eT>& X) Mat<eT>::operator/=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::div_inplace(*this, X); subview<eT>::div_inplace(*this, X);
return *this; return *this;
} }
//! construct a matrix from a subview_cube instance //! construct a matrix from a subview_cube instance
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const subview_cube<eT>& x) Mat<eT>::Mat(const subview_cube<eT>& x)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(x); this->operator=(x);
} }
//! construct a matrix from a subview_cube instance //! construct a matrix from a subview_cube instance
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const subview_cube<eT>& X) Mat<eT>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::extract(*this, X); subview_cube<eT>::extract(*this, X);
return *this; return *this;
} }
//! in-place matrix addition (using a single-slice subcube on the right-han d-side) //! in-place matrix addition (using a single-slice subcube on the right-han d-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const subview_cube<eT>& X) Mat<eT>::operator+=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::plus_inplace(*this, X); subview_cube<eT>::plus_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix subtraction (using a single-slice subcube on the right- hand-side) //! in-place matrix subtraction (using a single-slice subcube on the right- hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const subview_cube<eT>& X) Mat<eT>::operator-=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::minus_inplace(*this, X); subview_cube<eT>::minus_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix mutiplication (using a single-slice subcube on the righ t-hand-side) //! in-place matrix mutiplication (using a single-slice subcube on the righ t-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const subview_cube<eT>& X) Mat<eT>::operator*=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> tmp(X); const Mat<eT> tmp(X);
glue_times::apply_inplace(*this, tmp); glue_times::apply_inplace(*this, tmp);
return *this; return *this;
} }
//! in-place element-wise matrix mutiplication (using a single-slice subcub e on the right-hand-side) //! in-place element-wise matrix mutiplication (using a single-slice subcub e on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const subview_cube<eT>& X) Mat<eT>::operator%=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::schur_inplace(*this, X); subview_cube<eT>::schur_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise matrix division (using a single-slice subcube on the right-hand-side) //! in-place element-wise matrix division (using a single-slice subcube on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const subview_cube<eT>& X) Mat<eT>::operator/=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_cube<eT>::div_inplace(*this, X); subview_cube<eT>::div_inplace(*this, X);
return *this; return *this;
} }
//! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation) //! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation)
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const diagview<eT>& X) Mat<eT>::Mat(const diagview<eT>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
this->operator=(X); this->operator=(X);
} }
//! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation) //! construct a matrix from diagview (e.g. construct a matrix from a delaye d diag operation)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const diagview<eT>& X) Mat<eT>::operator=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>::extract(*this, X); diagview<eT>::extract(*this, X);
return *this; return *this;
} }
//! in-place matrix addition (using a diagview on the right-hand-side) //! in-place matrix addition (using a diagview on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const diagview<eT>& X) Mat<eT>::operator+=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>::plus_inplace(*this, X); diagview<eT>::plus_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix subtraction (using a diagview on the right-hand-side) //! in-place matrix subtraction (using a diagview on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const diagview<eT>& X) Mat<eT>::operator-=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>::minus_inplace(*this, X); diagview<eT>::minus_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix mutiplication (using a diagview on the right-hand-side) //! in-place matrix mutiplication (using a diagview on the right-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const diagview<eT>& X) Mat<eT>::operator*=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise matrix mutiplication (using a diagview on the rig ht-hand-side) //! in-place element-wise matrix mutiplication (using a diagview on the rig ht-hand-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const diagview<eT>& X) Mat<eT>::operator%=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>::schur_inplace(*this, X); diagview<eT>::schur_inplace(*this, X);
return *this; return *this;
} }
//! in-place element-wise matrix division (using a diagview on the right-ha nd-side) //! in-place element-wise matrix division (using a diagview on the right-ha nd-side)
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const diagview<eT>& X) Mat<eT>::operator/=(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>::div_inplace(*this, X); diagview<eT>::div_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
mat_injector< Mat<eT> > mat_injector< Mat<eT> >
Mat<eT>::operator<<(const eT val) Mat<eT>::operator<<(const eT val)
{ {
return mat_injector< Mat<eT> >(*this, val); return mat_injector< Mat<eT> >(*this, val);
} }
skipping to change at line 1115 skipping to change at line 1137
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols),
"Mat::submat(): indices out of bounds or incorrectly used" "Mat::submat(): indices out of bounds or incorrectly used"
); );
return subview<eT>(*this, in_row1, in_col1, in_row2, in_col2); return subview<eT>(*this, in_row1, in_col1, in_row2, in_col2);
} }
//! creation of subview (submatrix)
template<typename eT>
arma_inline
subview<eT>
Mat<eT>::submat(const span& row_span, const span& col_span)
{
arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a;
const u32 in_row2 = row_span.b;
const u32 in_col1 = col_span.a;
const u32 in_col2 = col_span.b;
arma_debug_check
(
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (
in_col2 >= n_cols),
"Mat::submat(): indices out of bounds or incorrectly used"
);
return subview<eT>(*this, in_row1, in_col1, in_row2, in_col2);
}
//! creation of subview (generic submatrix)
template<typename eT>
arma_inline
const subview<eT>
Mat<eT>::submat(const span& row_span, const span& col_span) const
{
arma_extra_debug_sigprint();
const u32 in_row1 = row_span.a;
const u32 in_row2 = row_span.b;
const u32 in_col1 = col_span.a;
const u32 in_col2 = col_span.b;
arma_debug_check
(
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (
in_col2 >= n_cols),
"Mat::submat(): indices out of bounds or incorrectly used"
);
return subview<eT>(*this, in_row1, in_col1, in_row2, in_col2);
}
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT> diagview<eT>
Mat<eT>::diag(const s32 in_id) Mat<eT>::diag(const s32 in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0; const u32 row_offset = (in_id < 0) ? -in_id : 0;
const u32 col_offset = (in_id > 0) ? in_id : 0; const u32 col_offset = (in_id > 0) ? in_id : 0;
skipping to change at line 1137 skipping to change at line 1205
( (
(row_offset >= n_rows) || (col_offset >= n_cols), (row_offset >= n_rows) || (col_offset >= n_cols),
"Mat::diag(): requested diagonal out of bounds" "Mat::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
return diagview<eT>(*this, row_offset, col_offset, len); return diagview<eT>(*this, row_offset, col_offset, len);
} }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT>
arma_inline
const diagview<eT>
Mat<eT>::diag(const s32 in_id) const
{
arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0;
const u32 col_offset = (in_id > 0) ? in_id : 0;
arma_debug_check
(
(row_offset >= n_rows) || (col_offset >= n_cols),
"Mat::diag(): requested diagonal out of bounds"
);
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
return diagview<eT>(*this, row_offset, col_offset, len);
}
template<typename eT>
inline
void
Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 >= n_rows) || (in_row2 >= n_rows),
"Mat::swap_rows(): out of bounds"
);
for(u32 col=0; col<n_cols; ++col)
{
const u32 offset = col*n_rows;
const u32 pos1 = in_row1 + offset;
const u32 pos2 = in_row2 + offset;
const eT tmp = mem[pos1];
access::rw(mem[pos1]) = mem[pos2];
access::rw(mem[pos2]) = tmp;
}
}
template<typename eT>
inline
void
Mat<eT>::swap_cols(const u32 in_col1, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_col1 >= n_cols) || (in_col2 >= n_cols),
"Mat::swap_cols(): out of bounds"
);
eT* ptr1 = colptr(in_col1);
eT* ptr2 = colptr(in_col2);
for(u32 row=0; row<n_rows; ++row)
{
const eT tmp = ptr1[row];
ptr1[row] = ptr2[row];
ptr2[row] = tmp;
}
}
//! remove specified row
template<typename eT>
inline
void
Mat<eT>::shed_row(const u32 row_num)
{
arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "Mat::shed_row(): out of bounds");
shed_rows(row_num, row_num);
}
//! remove specified column
template<typename eT>
inline
void
Mat<eT>::shed_col(const u32 col_num)
{
arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "Mat::shed_col(): out of bounds");
shed_cols(col_num, col_num);
}
//! remove specified rows
template<typename eT>
inline
void
Mat<eT>::shed_rows(const u32 in_row1, const u32 in_row2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 > in_row2) || (in_row2 >= n_rows),
"Mat::shed_rows(): indices out of bounds or incorrectly used"
);
const u32 n_keep_front = in_row1;
const u32 n_keep_back = n_rows - (in_row2 + 1);
Mat<eT> X(n_keep_front + n_keep_back, n_cols);
if(n_keep_front > 0)
{
X.rows( 0, (n_keep_front-1) ) = rows( 0, (in_row1-1) );
}
if(n_keep_back > 0)
{
X.rows( n_keep_front, (n_keep_front+n_keep_back-1) ) = rows( (in_row2+
1), (n_rows-1) );
}
steal_mem(X);
}
//! remove specified columns
template<typename eT>
inline
void
Mat<eT>::shed_cols(const u32 in_col1, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_col1 > in_col2) || (in_col2 >= n_cols),
"Mat::shed_cols(): indices out of bounds or incorrectly used"
);
const u32 n_keep_front = in_col1;
const u32 n_keep_back = n_cols - (in_col2 + 1);
Mat<eT> X(n_rows, n_keep_front + n_keep_back);
if(n_keep_front > 0)
{
X.cols( 0, (n_keep_front-1) ) = cols( 0, (in_col1-1) );
}
if(n_keep_back > 0)
{
X.cols( n_keep_front, (n_keep_front+n_keep_back-1) ) = cols( (in_col2+
1), (n_cols-1) );
}
steal_mem(X);
}
//! insert N rows at the specified row position,
//! optionally setting the elements of the inserted rows to zero
template<typename eT>
inline
void
Mat<eT>::insert_rows(const u32 row_num, const u32 N, const bool set_to_zero
)
{
arma_extra_debug_sigprint();
const u32 t_n_rows = n_rows;
const u32 t_n_cols = n_cols;
const u32 A_n_rows = row_num;
const u32 B_n_rows = t_n_rows - row_num;
// insertion at row_num == n_rows is in effect an append operation
arma_debug_check( (row_num > t_n_rows), "Mat::insert_rows(): out of bound
s");
if(N > 0)
{
Mat<eT> out(t_n_rows + N, t_n_cols);
if(A_n_rows > 0)
{
out.rows(0, A_n_rows-1) = rows(0, A_n_rows-1);
}
if(B_n_rows > 0)
{
out.rows(row_num + N, t_n_rows + N - 1) = rows(row_num, t_n_rows-1);
}
if(set_to_zero == true)
{
out.rows(row_num, row_num + N - 1).zeros();
}
steal_mem(out);
}
}
//! insert N columns at the specified column position,
//! optionally setting the elements of the inserted columns to zero
template<typename eT> template<typename eT>
arma_inline inline
const diagview<eT> void
Mat<eT>::diag(const s32 in_id) const Mat<eT>::insert_cols(const u32 col_num, const u32 N, const bool set_to_zero
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0; const u32 t_n_rows = n_rows;
const u32 col_offset = (in_id > 0) ? in_id : 0; const u32 t_n_cols = n_cols;
arma_debug_check const u32 A_n_cols = col_num;
( const u32 B_n_cols = t_n_cols - col_num;
(row_offset >= n_rows) || (col_offset >= n_cols),
"Mat::diag(): requested diagonal out of bounds"
);
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); // insertion at col_num == n_cols is in effect an append operation
arma_debug_check( (col_num > t_n_cols), "Mat::insert_cols(): out of bound
s");
return diagview<eT>(*this, row_offset, col_offset, len); if(N > 0)
{
Mat<eT> out(t_n_rows, t_n_cols + N);
if(A_n_cols > 0)
{
out.cols(0, A_n_cols-1) = cols(0, A_n_cols-1);
}
if(B_n_cols > 0)
{
out.cols(col_num + N, t_n_cols + N - 1) = cols(col_num, t_n_cols-1);
}
if(set_to_zero == true)
{
out.cols(col_num, col_num + N - 1).zeros();
}
steal_mem(out);
}
} }
//! insert the given object at the specified row position;
//! the given object must have the same number of columns as the matrix
template<typename eT> template<typename eT>
template<typename T1>
inline inline
void void
Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2) Mat<eT>::insert_rows(const u32 row_num, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check const unwrap<T1> tmp(X.get_ref());
( const Mat<eT>& C = tmp.M;
(in_row1 >= n_rows) || (in_row2 >= n_rows),
"Mat::swap_rows(): out of bounds"
);
for(u32 col=0; col<n_cols; ++col) const u32 N = C.n_rows;
const u32 t_n_rows = n_rows;
const u32 t_n_cols = n_cols;
const u32 A_n_rows = row_num;
const u32 B_n_rows = t_n_rows - row_num;
// insertion at row_num == n_rows is in effect an append operation
arma_debug_check( (row_num > t_n_rows), "Mat::insert_rows(): out of bou
nds");
arma_debug_check( (C.n_cols != t_n_cols), "Mat::insert_rows(): given obje
ct has an incompatible number of columns");
if(N > 0)
{ {
const u32 offset = col*n_rows; Mat<eT> out(t_n_rows + N, t_n_cols);
const u32 pos1 = in_row1 + offset;
const u32 pos2 = in_row2 + offset;
const eT tmp = mem[pos1]; if(A_n_rows > 0)
access::rw(mem[pos1]) = mem[pos2]; {
access::rw(mem[pos2]) = tmp; out.rows(0, A_n_rows-1) = rows(0, A_n_rows-1);
} }
if(B_n_rows > 0)
{
out.rows(row_num + N, t_n_rows + N - 1) = rows(row_num, t_n_rows - 1)
;
}
out.rows(row_num, row_num + N - 1) = C;
steal_mem(out);
}
} }
//! insert the given object at the specified column position;
//! the given object must have the same number of rows as the matrix
template<typename eT> template<typename eT>
template<typename T1>
inline inline
void void
Mat<eT>::swap_cols(const u32 in_col1, const u32 in_col2) Mat<eT>::insert_cols(const u32 col_num, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check const unwrap<T1> tmp(X.get_ref());
( const Mat<eT>& C = tmp.M;
(in_col1 >= n_cols) || (in_col2 >= n_cols),
"Mat::swap_cols(): out of bounds"
);
eT* ptr1 = colptr(in_col1); const u32 N = C.n_cols;
eT* ptr2 = colptr(in_col2);
for(u32 row=0; row<n_rows; ++row) const u32 t_n_rows = n_rows;
const u32 t_n_cols = n_cols;
const u32 A_n_cols = col_num;
const u32 B_n_cols = t_n_cols - col_num;
// insertion at col_num == n_cols is in effect an append operation
arma_debug_check( (col_num > t_n_cols), "Mat::insert_cols(): out of bou
nds");
arma_debug_check( (C.n_rows != t_n_rows), "Mat::insert_cols(): given obje
ct has an incompatible number of rows");
if(N > 0)
{ {
const eT tmp = ptr1[row]; Mat<eT> out(t_n_rows, t_n_cols + N);
ptr1[row] = ptr2[row];
ptr2[row] = tmp; if(A_n_cols > 0)
} {
out.cols(0, A_n_cols-1) = cols(0, A_n_cols-1);
}
if(B_n_cols > 0)
{
out.cols(col_num + N, t_n_cols + N - 1) = cols(col_num, t_n_cols - 1)
;
}
out.cols(col_num, col_num + N - 1) = C;
steal_mem(out);
}
} }
//! create a matrix from Op, i.e. run the previously delayed unary operatio ns //! create a matrix from Op, i.e. run the previously delayed unary operatio ns
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Mat<eT>::Mat(const Op<T1, op_type>& X) Mat<eT>::Mat(const Op<T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
op_type::apply(*this, X); op_type::apply(*this, X);
} }
skipping to change at line 1333 skipping to change at line 1664
} }
//! create a matrix from eOp, i.e. run the previously delayed unary operati ons //! create a matrix from eOp, i.e. run the previously delayed unary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
Mat<eT>::Mat(const eOp<T1, eop_type>& X) Mat<eT>::Mat(const eOp<T1, eop_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
skipping to change at line 1443 skipping to change at line 1775
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Mat<eT>::Mat(const mtOp<eT, T1, op_type>& X) Mat<eT>::Mat(const mtOp<eT, T1, op_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
skipping to change at line 1544 skipping to change at line 1877
} }
//! create a matrix from Glue, i.e. run the previously delayed binary opera tions //! create a matrix from Glue, i.e. run the previously delayed binary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Mat<eT>::Mat(const Glue<T1, T2, glue_type>& X) Mat<eT>::Mat(const Glue<T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
isnt_same_type<eT, typename T2::elem_type>::check(); isnt_same_type<eT, typename T2::elem_type>::check();
glue_type::apply(*this, X); glue_type::apply(*this, X);
} }
skipping to change at line 1692 skipping to change at line 2026
} }
//! create a matrix from eGlue, i.e. run the previously delayed binary oper ations //! create a matrix from eGlue, i.e. run the previously delayed binary oper ations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
Mat<eT>::Mat(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::Mat(const eGlue<T1, T2, eglue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
isnt_same_type<eT, typename T2::elem_type>::check(); isnt_same_type<eT, typename T2::elem_type>::check();
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
} }
skipping to change at line 1808 skipping to change at line 2143
} }
//! EXPERIMENTAL: create a matrix from mtGlue, i.e. run the previously dela yed binary operations //! EXPERIMENTAL: create a matrix from mtGlue, i.e. run the previously dela yed binary operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X) Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, use_aux_mem(false) , vec_state(0)
, mem_state(0)
//, mem(0) //, mem(0)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
glue_type::apply(*this, X); glue_type::apply(*this, X);
} }
//! EXPERIMENTAL: create a matrix from Glue, i.e. run the previously delaye d binary operations //! EXPERIMENTAL: create a matrix from Glue, i.e. run the previously delaye d binary operations
template<typename eT> template<typename eT>
skipping to change at line 2052 skipping to change at line 2388
{ {
if(arma_isfinite(mem[i]) == false) if(arma_isfinite(mem[i]) == false)
{ {
return false; return false;
} }
} }
return true; return true;
} }
//! returns true if the matrix has no elements
template<typename eT>
arma_inline
bool
Mat<eT>::is_empty() const
{
return (n_elem == 0);
}
//! returns true if the given index is currently in range
template<typename eT>
arma_inline
bool
Mat<eT>::in_range(const u32 i) const
{
return (i < n_elem);
}
//! returns true if the given location is currently in range
template<typename eT>
arma_inline
bool
Mat<eT>::in_range(const u32 in_row, const u32 in_col) const
{
return ( (in_row < n_rows) && (in_col < n_cols) );
}
//! returns a pointer to array of eTs for a specified column; no bounds che ck //! returns a pointer to array of eTs for a specified column; no bounds che ck
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
Mat<eT>::colptr(const u32 in_col) Mat<eT>::colptr(const u32 in_col)
{ {
return & access::rw(mem[in_col*n_rows]); return & access::rw(mem[in_col*n_rows]);
} }
//! returns a pointer to array of eTs for a specified column; no bounds che ck //! returns a pointer to array of eTs for a specified column; no bounds che ck
skipping to change at line 2091 skipping to change at line 2454
arma_inline arma_inline
const eT* const eT*
Mat<eT>::memptr() const Mat<eT>::memptr() const
{ {
return mem; return mem;
} }
//! print contents of the matrix (to the cout stream), //! print contents of the matrix (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print(const std::string extra_text) const Mat<eT>::print(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = cout.width(); const std::streamsize orig_width = cout.width();
skipping to change at line 2114 skipping to change at line 2477
cout.width(orig_width); cout.width(orig_width);
} }
arma_ostream::print(cout, *this, true); arma_ostream::print(cout, *this, true);
} }
//! print contents of the matrix to a user specified stream, //! print contents of the matrix to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print(std::ostream& user_stream, const std::string extra_text) con st Mat<eT>::print(std::ostream& user_stream, const std::string extra_text) con st
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = user_stream.width(); const std::streamsize orig_width = user_stream.width();
skipping to change at line 2137 skipping to change at line 2500
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), //! print contents of the transposed version of the matrix (to the cout str eam),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print_trans(const std::string extra_text) const Mat<eT>::print_trans(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_trans::apply_noalias(tmp, *this);
tmp.print(extra_text); tmp.print(extra_text);
} }
//! print contents of the transposed version of matrix to a user specified stream, //! print contents of the transposed version of matrix to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's flags are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print_trans(std::ostream& user_stream, const std::string extra_tex t) const Mat<eT>::print_trans(std::ostream& user_stream, const std::string extra_tex t) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_trans::apply_noalias(tmp, *this);
tmp.print(user_stream, extra_text); 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 state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print(const std::string extra_text) const Mat<eT>::raw_print(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
skipping to change at line 2193 skipping to change at line 2556
cout << extra_text << '\n'; cout << extra_text << '\n';
cout.width(orig_width); cout.width(orig_width);
} }
arma_ostream::print(cout, *this, false); arma_ostream::print(cout, *this, false);
} }
//! print contents of the matrix to a user specified stream, //! print contents of the matrix to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's flags are used as is and are not modified. //! the stream's state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print(std::ostream& user_stream, const std::string extra_text) const Mat<eT>::raw_print(std::ostream& user_stream, const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
skipping to change at line 2216 skipping to change at line 2579
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), //! print contents of the transposed version of the matrix (to the cout str eam),
//! 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 state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print_trans(const std::string extra_text) const Mat<eT>::raw_print_trans(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_trans::apply_noalias(tmp, *this);
tmp.raw_print(extra_text); tmp.raw_print(extra_text);
} }
//! print contents of the transposed version of the matrix to a user specif ied stream, //! print contents of the transposed version of the matrix to a user specif ied 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 state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print_trans(std::ostream& user_stream, const std::string extra _text) const Mat<eT>::raw_print_trans(std::ostream& user_stream, const std::string extra _text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_trans::apply_noalias(tmp, *this);
tmp.raw_print(user_stream, extra_text); 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_elem)
{
arma_extra_debug_sigprint();
switch(vec_state)
{
case 0:
case 1:
init(in_elem, 1);
break;
case 2:
init(1, in_elem);
break;
default:
;
}
}
//! change the matrix to have user specified dimensions (data is not preser
ved)
template<typename eT>
inline
void
Mat<eT>::set_size(const u32 in_rows, const u32 in_cols) Mat<eT>::set_size(const u32 in_rows, const u32 in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(in_rows, in_cols); init(in_rows, in_cols);
} }
//! change the matrix to have user specified dimensions (data is preserved) //! change the matrix to have user specified dimensions (data is preserved)
template<typename eT> template<typename eT>
inline inline
skipping to change at line 2291 skipping to change at line 2678
//! fill the matrix with the specified value //! fill the matrix with the specified value
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
Mat<eT>::fill(const eT val) Mat<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT* local_ptr = memptr(); arrayops::inplace_set( memptr(), val, n_elem );
const u32 local_n_elem = n_elem; }
u32 i,j;
for(i=0, j=1; j<local_n_elem; i+=2, j+=2) template<typename eT>
{ inline
local_ptr[i] = val; void
local_ptr[j] = val; Mat<eT>::zeros()
} {
arma_extra_debug_sigprint();
if(i < local_n_elem) fill(eT(0));
{
local_ptr[i] = val;
}
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::zeros() Mat<eT>::zeros(const u32 in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
set_size(in_elem);
fill(eT(0)); fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::zeros(const u32 in_rows, const u32 in_cols) Mat<eT>::zeros(const u32 in_rows, const u32 in_cols)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d ") % in_rows % in_cols ); arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d ") % in_rows % in_cols );
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
fill(eT(0)); fill(eT(0));
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::ones() Mat<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(1)); fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::ones(const u32 in_elem)
{
arma_extra_debug_sigprint();
set_size(in_elem);
fill(eT(1));
}
template<typename eT>
inline
void
Mat<eT>::ones(const u32 in_rows, const u32 in_cols) Mat<eT>::ones(const u32 in_rows, const u32 in_cols)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d ") % in_rows % in_cols ); arma_extra_debug_sigprint( arma_boost::format("in_rows = %d, in_cols = %d ") % in_rows % in_cols );
set_size(in_rows, in_cols); set_size(in_rows, in_cols);
fill(eT(1)); fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::reset() Mat<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0); init(0,0);
} }
template<typename eT>
template<typename T1>
inline
void
Mat<eT>::set_real(const Base<typename Mat<eT>::pod_type,T1>& X)
{
arma_extra_debug_sigprint();
Mat_aux::set_real(*this, X);
}
template<typename eT>
template<typename T1>
inline
void
Mat<eT>::set_imag(const Base<typename Mat<eT>::pod_type,T1>& X)
{
arma_extra_debug_sigprint();
Mat_aux::set_imag(*this, X);
}
//! save the matrix to a file //! save the matrix to a file
template<typename eT> template<typename eT>
inline inline
bool bool
Mat<eT>::save(const std::string name, const file_type type, const bool prin t_status) const Mat<eT>::save(const std::string name, const file_type type, const bool prin t_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool save_okay; bool save_okay;
skipping to change at line 2916 skipping to change at line 3337
typename Mat<eT>::const_row_iterator typename Mat<eT>::const_row_iterator
Mat<eT>::end_row(const u32 row_num) const Mat<eT>::end_row(const u32 row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= n_rows), "Mat::end_row(): index out of boun ds" ); arma_debug_check( (row_num >= n_rows), "Mat::end_row(): index out of boun ds" );
return typename Mat<eT>::const_row_iterator(*this, row_num + 1); return typename Mat<eT>::const_row_iterator(*this, row_num + 1);
} }
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
void
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::mem_setup()
{
arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0)
{
access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (fixed_n_elem > Mat_prealloc::mem_n_el
em) ? mem_local_extra : mem_local;
}
else
{
access::rw(Mat<eT>::n_rows) = 0;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0;
}
}
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::prefix_pp(Mat<eT>& x) Mat_aux::prefix_pp(Mat<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const u32 n_elem = x.n_elem;
u32 i,j; u32 i,j;
skipping to change at line 3044 skipping to change at line 3493
//! postfix ++ for complex numbers (work around for limitations of the std: :complex class) //! postfix ++ for complex numbers (work around for limitations of the std: :complex class)
template<typename T> template<typename T>
arma_inline arma_inline
void void
Mat_aux::postfix_mm(Mat< std::complex<T> >& x) Mat_aux::postfix_mm(Mat< std::complex<T> >& x)
{ {
x -= T(1); x -= T(1);
} }
template<typename eT, typename T1>
inline
void
Mat_aux::set_real(Mat<eT>& out, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
arma_debug_assert_same_size( out, A, "Mat::set_real()" );
out = A;
}
template<typename T, typename T1>
inline
void
Mat_aux::set_real(Mat< std::complex<T> >& out, const Base<T,T1>& X)
{
arma_extra_debug_sigprint();
(is_Mat<T1>::value == true) ? Mat_aux::set_real_via_unwrap(out, X) : Mat_
aux::set_real_via_proxy(out, X);
}
template<typename eT, typename T1>
inline
void
Mat_aux::set_imag(Mat<eT>& out, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
}
template<typename T, typename T1>
inline
void
Mat_aux::set_imag(Mat< std::complex<T> >& out, const Base<T,T1>& X)
{
arma_extra_debug_sigprint();
(is_Mat<T1>::value == true) ? Mat_aux::set_imag_via_unwrap(out, X) : Mat_
aux::set_imag_via_proxy(out, X);
}
template<typename T, typename T1>
inline
void
Mat_aux::set_real_via_unwrap(Mat< std::complex<T> >& out, const Base<T,T1>&
X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const unwrap<T1> tmp(X.get_ref());
const Mat<T>& A = tmp.M;
arma_debug_assert_same_size( out, A, "Mat::set_real()" );
const u32 n_elem = out.n_elem;
const T* A_mem = A.memptr();
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
//out_mem[i].real() = A_mem[i];
out_mem[i] = std::complex<T>( A_mem[i], out_mem[i].imag() );
}
}
template<typename T, typename T1>
inline
void
Mat_aux::set_imag_via_unwrap(Mat< std::complex<T> >& out, const Base<T,T1>&
X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const unwrap<T1> tmp(X.get_ref());
const Mat<T>& A = tmp.M;
arma_debug_assert_same_size( out, A, "Mat::set_imag()" );
const u32 n_elem = out.n_elem;
const T* A_mem = A.memptr();
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
// out_mem[i].imag() = A_mem[i];
out_mem[i] = std::complex<T>(out_mem[i].real(), A_mem[i]);
}
}
template<typename T, typename T1>
inline
void
Mat_aux::set_real_via_proxy(Mat< std::complex<T> >& out, const Base<T,T1>&
X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const Proxy<T1> P(X.get_ref());
arma_debug_assert_same_size( out.n_rows, out.n_cols, P.n_rows, P.n_cols,
"Mat::set_real()" );
const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
//out_mem[i].real() = P[i];
out_mem[i] = std::complex<T>( P[i], out_mem[i].imag() );
}
}
template<typename T, typename T1>
inline
void
Mat_aux::set_imag_via_proxy(Mat< std::complex<T> >& out, const Base<T,T1>&
X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const Proxy<T1> P(X.get_ref());
arma_debug_assert_same_size( out.n_rows, out.n_cols, P.n_rows, P.n_cols,
"Mat::set_imag()" );
const u32 n_elem = out.n_elem;
eT* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
//out_mem[i].imag() = P[i];
out_mem[i] = std::complex<T>( out_mem[i].real(), P[i] );
}
}
#ifdef ARMA_EXTRA_MAT_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_MEAT)
#endif
//! @} //! @}
 End of changes. 105 change blocks. 
274 lines changed or deleted 894 lines changed or added


 Mat_proto.hpp   Mat_proto.hpp 
skipping to change at line 19 skipping to change at line 19
// 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 Mat //! \addtogroup Mat
//! @{ //! @{
struct Mat_prealloc
{
static const u32 mem_n_elem = 16;
};
//! Dense matrix class //! Dense matrix class
template<typename eT> template<typename eT>
class Mat : public Base< eT, Mat<eT> > class Mat : public Base< eT, Mat<eT> >
{ {
public: public:
typedef eT elem_type; //!< the type of el ements stored in the matrix typedef eT elem_type; //!< the type of el ements stored in the matrix
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-c omplex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-c omplex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex
const u32 n_rows; //!< number of rows in the matrix (read-only) const u32 n_rows; //!< number of rows in the matrix (read-only)
const u32 n_cols; //!< number of columns in the matrix (read-only) const u32 n_cols; //!< number of columns in the matrix (read-only)
const u32 n_elem; //!< number of elements in the matrix (read-only) const u32 n_elem; //!< number of elements in the matrix (read-only)
const bool use_aux_mem; //!< true if externally managed memory is being u const u16 vec_state; //!< 0: matrix layout; 1: column vector layout; 2: r
sed (read-only) ow vector layout
const u16 mem_state;
// mem_state = 0: normal matrix that can be resized;
// mem_state = 1: use auxiliary memory until change in the number of elem
ents is requested;
// mem_state = 2: use auxiliary memory and don't allow the number of elem
ents to be changed;
// mem_state = 3: fixed size via template based size specification.
arma_aligned const eT* const mem; //!< pointer to the memory used by the matrix (memory is read-only) arma_aligned const eT* const mem; //!< pointer to the memory used by the matrix (memory is read-only)
protected: protected:
arma_aligned eT mem_local[ 16 ]; arma_aligned eT mem_local[ Mat_prealloc::mem_n_elem ];
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, const bool strict = 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);
arma_inline const Mat& operator/=(const eT val); arma_inline const Mat& operator/=(const eT val);
inline Mat(const Mat& m); inline Mat(const Mat& m);
inline const Mat& operator=(const Mat& m); inline const Mat& operator=(const Mat& m);
skipping to change at line 115 skipping to change at line 126
arma_inline subview<eT> rows(const u32 in_row1, const u32 in_row2); arma_inline subview<eT> rows(const u32 in_row1, const u32 in_row2);
arma_inline const subview<eT> rows(const u32 in_row1, const u32 in_row2) const; arma_inline const subview<eT> rows(const u32 in_row1, const u32 in_row2) const;
arma_inline subview<eT> cols(const u32 in_col1, const u32 in_col2); arma_inline subview<eT> cols(const u32 in_col1, const u32 in_col2);
arma_inline const subview<eT> cols(const u32 in_col1, const u32 in_col2) const; arma_inline const subview<eT> cols(const u32 in_col1, const u32 in_col2) const;
arma_inline subview<eT> submat(const u32 in_row1, const u32 in_col1 , const u32 in_row2, const u32 in_col2); arma_inline subview<eT> submat(const u32 in_row1, const u32 in_col1 , const u32 in_row2, const u32 in_col2);
arma_inline const subview<eT> submat(const u32 in_row1, const u32 in_col1 , const u32 in_row2, const u32 in_col2) const; arma_inline const subview<eT> submat(const u32 in_row1, const u32 in_col1 , const u32 in_row2, const u32 in_col2) const;
arma_inline subview<eT> submat(const span& row_span, const span& co
l_span);
arma_inline const subview<eT> submat(const span& row_span, const span& co
l_span) const;
arma_inline diagview<eT> diag(const s32 in_id = 0); arma_inline diagview<eT> diag(const s32 in_id = 0);
arma_inline const diagview<eT> diag(const s32 in_id = 0) const; arma_inline const diagview<eT> diag(const s32 in_id = 0) const;
inline void swap_rows(const u32 in_row1, const u32 in_row2); inline void swap_rows(const u32 in_row1, const u32 in_row2);
inline void swap_cols(const u32 in_col1, const u32 in_col2); inline void swap_cols(const u32 in_col1, const u32 in_col2);
inline void shed_row(const u32 row_num);
inline void shed_col(const u32 col_num);
inline void shed_rows(const u32 in_row1, const u32 in_row2);
inline void shed_cols(const u32 in_col1, const u32 in_col2);
inline void insert_rows(const u32 row_num, const u32 N, const bool set_to
_zero = true);
inline void insert_cols(const u32 col_num, const u32 N, const bool set_to
_zero = true);
template<typename T1> inline void insert_rows(const u32 row_num, const Ba
se<eT,T1>& X);
template<typename T1> inline void insert_cols(const u32 col_num, const Ba
se<eT,T1>& X);
template<typename T1, typename op_type> inline Mat(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline Mat(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator+=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator+=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator-=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator-=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator*=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator*=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator%=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator%=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator/=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator/=(cons t Op<T1, op_type>& X);
template<typename T1, typename eop_type> inline Mat(con st eOp<T1, eop_type>& X); template<typename T1, typename eop_type> inline Mat(con st eOp<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Mat& operator=(con st eOp<T1, eop_type>& X); template<typename T1, typename eop_type> inline const Mat& operator=(con st eOp<T1, eop_type>& X);
skipping to change at line 188 skipping to change at line 214
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& operator() (const u32 in_row, const u32 in_col); arma_inline eT& operator() (const u32 in_row, const u32 in_col);
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 const Mat& operator++(); arma_inline const Mat& operator++();
arma_inline void operator++(int); arma_inline void operator++(int);
arma_inline const Mat& operator--(); arma_inline const Mat& operator--();
arma_inline void operator--(int); arma_inline void operator--(int);
arma_inline bool is_vec() const; arma_inline bool is_vec() const;
arma_inline bool is_square() const; arma_inline bool is_square() const;
arma_inline bool is_finite() const; arma_inline bool is_finite() const;
arma_inline bool is_empty() const;
arma_inline bool in_range(const u32 i) const;
arma_inline bool in_range(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;
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;
skipping to change at line 213 skipping to change at line 243
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 raw_print_trans(const std::string extra_text = "") const; inline void raw_print_trans(const std::string extra_text = "") const;
inline void raw_print_trans(std::ostream& user_stream, const std::string extra_text = "") const; inline void raw_print_trans(std::ostream& user_stream, const std::string extra_text = "") const;
template<typename eT2> template<typename eT2>
inline void copy_size(const Mat<eT2>& m); inline void copy_size(const Mat<eT2>& m);
inline void set_size(const u32 in_elem);
inline void set_size(const u32 in_rows, const u32 in_cols); inline void set_size(const u32 in_rows, const u32 in_cols);
inline void reshape(const u32 in_rows, const u32 in_cols, const u32 dim = 0); inline void reshape(const u32 in_rows, const u32 in_cols, const u32 dim = 0);
arma_hot inline void fill(const eT val); arma_hot inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const u32 in_elem);
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_elem);
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();
template<typename T1> inline void set_real(const Base<pod_type,T1>& X);
template<typename T1> inline void set_imag(const Base<pod_type,T1>& X);
inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true); inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true);
inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true); inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const; inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const; inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a uto_detect); inline bool quiet_load(const std::string name, const file_type type = a uto_detect);
inline bool quiet_load( std::istream& is, const file_type type = a uto_detect); inline bool quiet_load( std::istream& is, const file_type type = a uto_detect);
// iterators // for container-like functionality
typedef eT value_type;
typedef u32 size_type;
typedef eT* iterator; typedef eT* iterator;
typedef const eT* const_iterator; typedef const eT* const_iterator;
typedef eT* col_iterator; typedef eT* col_iterator;
typedef const eT* const_col_iterator; typedef const eT* const_col_iterator;
class row_iterator class row_iterator
{ {
public: public:
skipping to change at line 309 skipping to change at line 348
inline col_iterator end_col (const u32 col_num); inline col_iterator end_col (const u32 col_num);
inline const_col_iterator end_col (const u32 col_num) const; inline const_col_iterator end_col (const u32 col_num) const;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const u32 row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const u32 row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const u32 row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const u32 row_num) const;
// inline void clear();
// inline void resize(const u32 in_n_elem);
// arma_inline bool empty() const;
// arma_inline u32 size() const;
template<u32 fixed_n_rows, u32 fixed_n_cols>
class fixed : public Mat<eT>
{
private:
static const u32 fixed_n_elem = fixed_n_rows * fixed_n_cols;
arma_aligned eT mem_local_extra[ ( fixed_n_elem > Mat_prealloc::mem_n_e
lem ) ? fixed_n_elem : 1 ];
arma_inline void mem_setup();
public:
inline fixed() { mem_setup(); }
inline fixed(const char* text) { mem_setup(); Mat
<eT>::operator=(text); }
inline const Mat& operator=(const char* text) { Mat
<eT>::operator=(text); return *this; }
inline fixed(const std::string& text) { mem_setup(); Mat
<eT>::operator=(text); }
inline const Mat& operator=(const std::string& text) { Mat
<eT>::operator=(text); return *this; }
inline const Mat& operator=(const eT val) { Mat<eT>::operator=(val); re
turn *this; }
template<typename T1>
inline fixed(const Base<eT,T1>& A) { mem_setup(); Mat<eT>::operator=(A.
get_ref()); }
template<typename T1>
inline const Mat& operator=(const Base<eT,T1>& A) { Mat<eT>::operator=(
A.get_ref()); return *this; }
template<typename T1, typename T2>
inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T
2>& B) { mem_setup(); Mat<eT>::init(A,B); }
};
#ifdef ARMA_EXTRA_MAT_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO)
#endif
protected: protected:
inline void init(const u32 in_rows, const u32 in_cols); inline void init(const u32 in_rows, const u32 in_cols);
inline void init(const std::string& text); inline void init(const std::string& text);
inline void init(const Mat& x); inline void init(const Mat& x);
template<typename T1, typename T2>
inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
inline void steal_mem(Mat& X);
inline Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons t u32 aux_n_cols); inline Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons t u32 aux_n_cols);
friend class Cube<eT>; friend class Cube<eT>;
friend class glue_join; friend class glue_join;
}; };
class Mat_aux class Mat_aux
{ {
public: public:
skipping to change at line 336 skipping to change at line 421
template<typename T> arma_inline static void prefix_pp(Mat< std::complex <T> >& x); template<typename T> arma_inline static void prefix_pp(Mat< std::complex <T> >& x);
template<typename eT> arma_inline static void postfix_pp(Mat<eT>& x); template<typename eT> arma_inline static void postfix_pp(Mat<eT>& x);
template<typename T> arma_inline static void postfix_pp(Mat< std::comple x<T> >& x); template<typename T> arma_inline static void postfix_pp(Mat< std::comple x<T> >& x);
template<typename eT> arma_inline static void prefix_mm(Mat<eT>& x); template<typename eT> arma_inline static void prefix_mm(Mat<eT>& x);
template<typename T> arma_inline static void prefix_mm(Mat< std::complex <T> >& x); template<typename T> arma_inline static void prefix_mm(Mat< std::complex <T> >& x);
template<typename eT> arma_inline static void postfix_mm(Mat<eT>& x); template<typename eT> arma_inline static void postfix_mm(Mat<eT>& x);
template<typename T> arma_inline static void postfix_mm(Mat< std::comple x<T> >& x); template<typename T> arma_inline static void postfix_mm(Mat< std::comple x<T> >& x);
template<typename eT, typename T1> inline static void set_real(Mat<eT>&
out, const Base<eT,T1>& X);
template<typename T, typename T1> inline static void set_real(Mat< std::
complex<T> >& out, const Base< T,T1>& X);
template<typename eT, typename T1> inline static void set_imag(Mat<eT>&
out, const Base<eT,T1>& X);
template<typename T, typename T1> inline static void set_imag(Mat< std::
complex<T> >& out, const Base< T,T1>& X);
template<typename T, typename T1> inline static void set_real_via_unwrap
(Mat< std::complex<T> >& out, const Base< T,T1>& X);
template<typename T, typename T1> inline static void set_imag_via_unwrap
(Mat< std::complex<T> >& out, const Base< T,T1>& X);
template<typename T, typename T1> inline static void set_real_via_proxy(
Mat< std::complex<T> >& out, const Base< T,T1>& X);
template<typename T, typename T1> inline static void set_imag_via_proxy(
Mat< std::complex<T> >& out, const Base< T,T1>& X);
}; };
//! @} //! @}
 End of changes. 16 change blocks. 
9 lines changed or deleted 131 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 22 skipping to change at line 22
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Row //! \addtogroup Row
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row() Row<eT>::Row()
: Mat<eT>()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const u32 in_n_elem) Row<eT>::Row(const u32 in_n_elem)
: Mat<eT>(1,in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::init(1, in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols)
: Mat<eT>(in_n_rows, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 2;
);
Mat<eT>::init(in_n_rows, in_n_cols);
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const char* text) Row<eT>::Row(const char* text)
: Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 2;
);
Mat<eT>::operator=(text);
} }
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; return *this;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const std::string& text) Row<eT>::Row(const std::string& text)
: Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 2;
);
Mat<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const std::string& text) Row<eT>::operator=(const std::string& text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
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)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const Row<eT>& X) Row<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(val);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1>
inline inline
Row<eT>::Row(const Mat<eT>& X) Row<eT>::Row(const Base<eT,T1>& X)
: Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 2;
);
}
template<typename eT> Mat<eT>::operator=(X.get_ref());
inline
const Row<eT>&
Row<eT>::operator=(const Mat<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> template<typename eT>
template<typename T1>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator*=(const Mat<eT>& X) Row<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator=(X.get_ref());
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
return *this;
}
//! construct a row vector from a given auxiliary array
template<typename eT>
inline
Row<eT>::Row(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)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
//! construct a row vector from a given auxiliary array
template<typename eT>
inline
Row<eT>::Row(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols)
: Mat<eT>(aux_mem, aux_n_rows, aux_n_cols)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); return *this;
} }
//! construct a row vector from a given auxiliary array //! construct a row vector from a given auxiliary array
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem) Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co
: Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem) nst bool strict)
: Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// Mat<eT>::set_size(1, aux_length); access::rw(Mat<eT>::vec_state) = 2;
// arma_check( (Mat<eT>::n_elem != aux_length), "Row(): don't know how to
handle the given array" );
//
// syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem );
} }
//! construct a row vector from a given auxiliary array //! construct a row vector from a given auxiliary array
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const eT* aux_mem, const u32 aux_length) Row<eT>::Row(const eT* aux_mem, const u32 aux_length)
: Mat<eT>(aux_mem, 1, aux_length) : Mat<eT>(aux_mem, 1, aux_length)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// Mat<eT>::set_size(1, aux_length); access::rw(Mat<eT>::vec_state) = 2;
// arma_check( (Mat<eT>::n_elem != aux_length), "Row(): don't know how to
handle the given array" );
//
// syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem );
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Row<eT>::Row Row<eT>::Row
( (
const Base<typename Row<eT>::pod_type, T1>& A, const Base<typename Row<eT>::pod_type, T1>& A,
const Base<typename Row<eT>::pod_type, T2>& B const Base<typename Row<eT>::pod_type, T2>& B
) )
: Mat<eT>(A,B)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
Row<eT>::Row(const subview<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<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); access::rw(Mat<eT>::vec_state) = 2;
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
return *this; Mat<eT>::init(A,B);
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator*=(const subview<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> template<typename eT>
inline inline
Row<eT>::Row(const subview_cube<eT>& X) Row<eT>::Row(const subview_cube<eT>& X)
: Mat<eT>(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" access::rw(Mat<eT>::vec_state) = 2;
);
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator=(const subview_cube<eT>& X)
{
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
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;
} }
//! construct a row vector from given a diagview
template<typename eT>
inline
Row<eT>::Row(const diagview<eT>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
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"
);
}
//! 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 subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(X); Mat<eT>::operator=(X);
//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"
);
return *this;
}
template<typename eT>
inline
const Row<eT>&
Row<eT>::operator*=(const diagview<eT>& X)
{
arma_extra_debug_sigprint();
Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
mat_injector< Row<eT> > mat_injector< Row<eT> >
Row<eT>::operator<<(const eT val) Row<eT>::operator<<(const eT val)
{ {
return mat_injector< Row<eT> >(*this, val); return mat_injector< Row<eT> >(*this, val);
} }
skipping to change at line 381 skipping to change at line 245
const subview_row<eT> const subview_row<eT>
Row<eT>::cols(const u32 in_col1, const u32 in_col2) Row<eT>::cols(const u32 in_col1, const u32 in_col2)
const const
{ {
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used");
return subview_row<eT>(*this, 0, in_col1, in_col2); return subview_row<eT>(*this, 0, in_col1, in_col2);
} }
template<typename eT> template<typename eT>
template<typename T1, typename op_type>
inline
Row<eT>::Row(const Op<T1, op_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename op_type>
inline
const Row<eT>&
Row<eT>::operator=(const Op<T1, op_type>& 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>
template<typename T1, typename op_type>
inline
const Row<eT>&
Row<eT>::operator*=(const Op<T1, op_type>& 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>
template<typename T1, typename eop_type>
inline
Row<eT>::Row(const eOp<T1, eop_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename eop_type>
inline
const Row<eT>&
Row<eT>::operator=(const eOp<T1, eop_type>& 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>
template<typename T1, typename eop_type>
inline
const Row<eT>&
Row<eT>::operator*=(const eOp<T1, eop_type>& 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>
template<typename T1, typename op_type>
inline
Row<eT>::Row(const mtOp<eT, T1, op_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename op_type>
inline
const Row<eT>&
Row<eT>::operator=(const mtOp<eT, T1, op_type>& 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>
template<typename T1, typename op_type>
inline
const Row<eT>&
Row<eT>::operator*=(const mtOp<eT, T1, op_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
Row<eT>::Row(const Glue<T1, T2, glue_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename T2, typename glue_type>
inline
const Row<eT>&
Row<eT>::operator=(const Glue<T1, T2, glue_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
const Row<eT>&
Row<eT>::operator*=(const Glue<T1, T2, glue_type>& 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>
template<typename T1, typename T2, typename eglue_type>
inline
Row<eT>::Row(const eGlue<T1, T2, eglue_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename T2, typename eglue_type>
inline
const Row<eT>&
Row<eT>::operator=(const eGlue<T1, T2, eglue_type>& 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>
template<typename T1, typename T2, typename eglue_type>
inline
const Row<eT>&
Row<eT>::operator*=(const eGlue<T1, T2, eglue_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
Row<eT>::Row(const mtGlue<eT, T1, T2, glue_type>& X)
: Mat<eT>(X)
{
arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
template<typename T1, typename T2, typename glue_type>
inline
const Row<eT>&
Row<eT>::operator=(const mtGlue<eT, T1, T2, glue_type>& 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>
template<typename T1, typename T2, typename glue_type>
inline
const Row<eT>&
Row<eT>::operator*=(const mtGlue<eT, T1, T2, glue_type>& 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
void
Row<eT>::set_size(const u32 in_n_elem)
{
arma_extra_debug_sigprint();
Mat<eT>::set_size(1,in_n_elem);
}
template<typename eT>
inline
void
Row<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
{
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 );
arma_debug_check( (in_n_rows > 1), "Row::set_size(): incompatible dimensi
ons" );
}
template<typename eT>
inline
void
Row<eT>::reshape(const u32 in_rows, const u32 in_cols, const u32 dim)
{
arma_extra_debug_sigprint();
Mat<eT>::reshape(in_rows, in_cols, dim);
arma_debug_check( (in_rows > 1), "Row::set_size(): incompatible dimension
s" );
}
template<typename eT>
template<typename eT2>
inline
void
Row<eT>::copy_size(const Mat<eT2>& x)
{
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 );
arma_debug_check( (x.n_rows > 1), "Row::copy_size(): incompatible dimensi
ons" );
}
template<typename eT>
inline
void
Row<eT>::zeros()
{
arma_extra_debug_sigprint();
Mat<eT>::zeros();
}
template<typename eT>
inline
void
Row<eT>::zeros(const u32 in_n_elem)
{
arma_extra_debug_sigprint();
Mat<eT>::zeros(1, in_n_elem);
}
template<typename eT>
inline
void
Row<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
{
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 );
arma_debug_check( (in_n_rows > 1), "Row<eT>::zeros(): incompatible dimens
ions" );
}
template<typename eT>
inline
void
Row<eT>::ones()
{
arma_extra_debug_sigprint();
Mat<eT>::ones();
}
template<typename eT>
inline
void
Row<eT>::ones(const u32 in_n_elem)
{
arma_extra_debug_sigprint();
Mat<eT>::ones(1, in_n_elem);
}
template<typename eT>
inline
void
Row<eT>::ones(const u32 in_n_rows, const u32 in_n_cols)
{
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 );
arma_debug_check( (in_n_rows > 1), "Row<eT>::ones(): incompatible dimensi
ons" );
}
template<typename eT>
inline
void
Row<eT>::load(const std::string name, const file_type type, const bool prin
t_status)
{
arma_extra_debug_sigprint();
Mat<eT>::load(name, type, print_status);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Row<eT>::load(std::istream& is, const file_type type, const bool print_stat
us)
{
arma_extra_debug_sigprint();
Mat<eT>::load(is, type, print_status);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Row<eT>::quiet_load(const std::string name, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(name, type);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Row<eT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(is, type);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline inline
typename Row<eT>::row_iterator typename Row<eT>::row_iterator
Row<eT>::begin_row(const u32 row_num) Row<eT>::begin_row(const u32 row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out o f bounds");
return Mat<eT>::memptr(); return Mat<eT>::memptr();
} }
skipping to change at line 837 skipping to change at line 292
typename Row<eT>::const_row_iterator typename Row<eT>::const_row_iterator
Row<eT>::end_row(const u32 row_num) const Row<eT>::end_row(const u32 row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
return Mat<eT>::memptr() + Mat<eT>::n_cols; return Mat<eT>::memptr() + Mat<eT>::n_cols;
} }
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
void
Row<eT>::fixed<fixed_n_elem>::mem_setup()
{
arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0)
{
access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (fixed_n_elem > Mat_prealloc::mem_n_el
em) ? mem_local_extra : Mat<eT>::mem_local;
}
else
{
access::rw(Mat<eT>::n_rows) = 0;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0;
}
}
#ifdef ARMA_EXTRA_ROW_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT)
#endif
//! @} //! @}
 End of changes. 37 change blocks. 
630 lines changed or deleted 68 lines changed or added


 Row_proto.hpp   Row_proto.hpp 
skipping to change at line 26 skipping to change at line 26
//! \addtogroup Row //! \addtogroup Row
//! @{ //! @{
//! Class for row vectors (matrices with only one row) //! Class for row vectors (matrices with only one row)
template<typename eT> template<typename eT>
class Row : public Mat<eT>, public BaseVec< eT, Row<eT> > class Row : public Mat<eT>, public BaseVec< eT, Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<eT>::result 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 const Row& operator=(const char* text);
inline Row(const std::string& text);
inline const Row& operator=(const std::string& text);
inline Row(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 Row(const Mat<eT>& X);
inline const Row& operator=(const Mat<eT>& X);
inline const Row& operator*=(const Mat<eT>& X);
inline Row( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, inline Row(const char* text);
const bool copy_aux_mem = true); inline const Row& operator=(const char* text);
inline Row(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) inline Row(const std::string& text);
; inline const Row& operator=(const std::string& text);
inline Row( eT* aux_mem, const u32 aux_length, const bool copy_aux_m inline const Row& operator=(const eT val);
em = true);
template<typename T1> inline Row(const Base<eT,T1>& X);
template<typename T1> inline const Row& operator=(const Base<eT,T1>& X);
inline Row( eT* aux_mem, const u32 aux_length, const bool copy_aux_m
em = true, const bool strict = 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_cube<eT>& X);
inline const Row& operator=(const subview<eT>& X); inline const Row& operator=(const subview_cube<eT>& X);
inline const Row& operator*=(const subview<eT>& X);
inline Row(const subview_cube<eT>& X);
inline const Row& operator=(const subview_cube<eT>& X);
inline const Row& operator*=(const subview_cube<eT>& X);
inline explicit Row(const diagview<eT>& X);
inline const Row& operator=(const diagview<eT>& X);
inline const Row& operator*=(const diagview<eT>& X);
inline mat_injector<Row> operator<<(const eT val); inline mat_injector<Row> operator<<(const eT val);
arma_inline eT& col(const u32 col_num); arma_inline eT& col(const u32 col_num);
arma_inline eT col(const u32 col_num) const; 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 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; 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 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 eop_type> inline Row(con
st eOp<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Row& operator=(con
st eOp<T1, eop_type>& X);
template<typename T1, typename eop_type> inline const Row& operator*=(con
st eOp<T1, eop_type>& X);
template<typename T1, typename op_type> inline Row(cons
t mtOp<eT, T1, op_type>& X);
template<typename T1, typename op_type> inline const Row& operator=(cons
t mtOp<eT, T1, op_type>& X);
template<typename T1, typename op_type> inline const Row& operator*=(cons
t mtOp<eT, 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 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 eglue_type> inline
Row(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename eglue_type> inline const Row&
operator=(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename eglue_type> inline const Row&
operator*=(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename glue_type> inline
Row(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Row&
operator=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Row&
operator*=(const mtGlue<eT, T1, T2, glue_type>& X);
inline void set_size(const u32 N);
inline void set_size(const u32 n_rows, const u32 n_cols);
inline void reshape(const u32 n_rows, const u32 n_cols, const u32 dim =
0);
template<typename eT2>
inline void copy_size(const Mat<eT2>& m);
inline void zeros();
inline void zeros(const u32 N);
inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones();
inline void ones(const u32 N);
inline void ones(const u32 n_rows, const u32 n_cols);
inline void load(const std::string name, const file_type type = auto_de
tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de
tect, const bool print_status = true);
inline void quiet_load(const std::string name, const file_type type = a
uto_detect);
inline void quiet_load( std::istream& is, const file_type type = a
uto_detect);
typedef eT* row_iterator; typedef eT* row_iterator;
typedef const eT* const_row_iterator; typedef const eT* const_row_iterator;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const u32 row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const u32 row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const u32 row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const u32 row_num) const;
template<u32 fixed_n_elem>
class fixed : public Row<eT>
{
private:
arma_aligned eT mem_local_extra[ ( fixed_n_elem > Mat_prealloc::mem_n_e
lem ) ? fixed_n_elem : 1 ];
arma_inline void mem_setup();
public:
inline fixed() { mem_setup(); }
inline fixed(const char* text) { mem_setup(); Row
<eT>::operator=(text); }
inline const Row& operator=(const char* text) { Row
<eT>::operator=(text); return *this; }
inline fixed(const std::string& text) { mem_setup(); Row
<eT>::operator=(text); }
inline const Row& operator=(const std::string& text) { Row
<eT>::operator=(text); return *this; }
inline const Row& operator=(const eT val) { Row<eT>::operator=(val); re
turn *this; }
template<typename T1>
inline fixed(const Base<eT,T1>& A) { mem_setup(); Row<eT>::operator=(A.
get_ref()); }
template<typename T1>
inline const Row& operator=(const Base<eT,T1>& A) { Row<eT>::operator=(
A.get_ref()); return *this; }
template<typename T1, typename T2>
inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T
2>& B) { mem_setup(); Row<eT>::init(A,B); }
inline fixed(const subview_cube<eT>& X) { mem_setup(); R
ow<eT>::operator=(X); }
inline const Row& operator=(const subview_cube<eT>& X) { R
ow<eT>::operator=(X); return *this; }
};
#ifdef ARMA_EXTRA_ROW_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_PROTO)
#endif
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
104 lines changed or deleted 67 lines changed or added


 access.hpp   access.hpp 
skipping to change at line 29 skipping to change at line 29
class access class access
{ {
public: public:
//! internal function to allow modification of data declared as read-only //! internal function to allow modification of data declared as read-only
template<typename T1> arma_inline static T1& rw(const T1& x) { return con st_cast<T1&>(x); } template<typename T1> arma_inline static T1& rw(const T1& x) { return con st_cast<T1&>(x); }
//! internal function to obtain the real part of either a plain number or a complex number //! internal function to obtain the real part of either a plain number or a complex number
template<typename eT> arma_inline static const eT& tmp_real(const eT& X) { return X; } template<typename eT> arma_inline static const eT& tmp_real(const eT& X) { return X; }
template<typename T> arma_inline static const T tmp_real(const std::co mplex<T>& X) { return X.real(); } template<typename T> arma_inline static const T tmp_real(const std::co mplex<T>& X) { return X.real(); }
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 0 lines changed or added


 arma_config.hpp   arma_config.hpp 
skipping to change at line 68 skipping to change at line 68
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) #if defined(ARMA_GOOD_COMPILER)
static const bool good_comp = true; static const bool good_comp = true;
#else #else
static const bool good_comp = false; static const bool good_comp = false;
#endif #endif
#if ( \
defined(ARMA_EXTRA_MAT_PROTO) || defined(ARMA_EXTRA_MAT_MEAT)
\
|| defined(ARMA_EXTRA_COL_PROTO) || defined(ARMA_EXTRA_COL_MEAT)
\
|| defined(ARMA_EXTRA_ROW_PROTO) || defined(ARMA_EXTRA_ROW_MEAT)
\
|| defined(ARMA_EXTRA_CUBE_PROTO) || defined(ARMA_EXTRA_CUBE_MEAT)
\
|| defined(ARMA_EXTRA_FIELD_PROTO) || defined(ARMA_EXTRA_FIELD_MEAT)
\
)
static const bool extra_code = true;
#else
static const bool extra_code = false;
#endif
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 17 lines changed or added


 arma_version.hpp   arma_version.hpp 
skipping to change at line 21 skipping to change at line 21
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 0 #define ARMA_VERSION_MAJOR 0
#define ARMA_VERSION_MINOR 9 #define ARMA_VERSION_MINOR 9
#define ARMA_VERSION_PATCH 60 #define ARMA_VERSION_PATCH 70
#define ARMA_VERSION_NAME "Killer Bush Turkey" #define ARMA_VERSION_NAME "Subtropical Winter Safari"
// http://en.wikipedia.org/wiki/Australian_Brush-turkey
struct arma_version struct arma_version
{ {
static const unsigned int major = ARMA_VERSION_MAJOR; static const unsigned int major = ARMA_VERSION_MAJOR;
static const unsigned int minor = ARMA_VERSION_MINOR; static const unsigned int minor = ARMA_VERSION_MINOR;
static const unsigned int patch = ARMA_VERSION_PATCH; static const unsigned int patch = ARMA_VERSION_PATCH;
static static
inline inline
std::string std::string
 End of changes. 1 change blocks. 
3 lines changed or deleted 2 lines changed or added


 armadillo   armadillo 
skipping to change at line 63 skipping to change at line 63
#endif #endif
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/current_function.hpp> #include <boost/current_function.hpp>
#define ARMA_USE_BOOST_FORMAT #define ARMA_USE_BOOST_FORMAT
#endif #endif
#endif #endif
#if defined(ARMA_USE_ATLAS) #define ARMA_INCFILE_WRAP(x) <x>
#if defined(ARMA_USE_ATLAS)
#if !defined(ARMA_ATLAS_INCLUDE_DIR) #if !defined(ARMA_ATLAS_INCLUDE_DIR)
extern "C" extern "C"
{ {
#include <cblas.h> #include <cblas.h>
#include <clapack.h> #include <clapack.h>
} }
#else #else
#define ARMA_STR1(x) x #define ARMA_STR1(x) x
#define ARMA_STR2(x) ARMA_STR1(x) #define ARMA_STR2(x) ARMA_STR1(x)
#define ARMA_STR3(x) <x>
#define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h ) #define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h )
#define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack .h) #define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack .h)
extern "C" extern "C"
{ {
#include ARMA_STR3(ARMA_CBLAS) #include ARMA_INCFILE_WRAP(ARMA_CBLAS)
#include ARMA_STR3(ARMA_CLAPACK) #include ARMA_INCFILE_WRAP(ARMA_CLAPACK)
} }
#undef ARMA_STR1 #undef ARMA_STR1
#undef ARMA_STR2 #undef ARMA_STR2
#undef ARMA_STR3
#undef ARMA_CBLAS #undef ARMA_CBLAS
#undef ARMA_CLAPACK #undef ARMA_CLAPACK
#endif #endif
#endif #endif
#include "armadillo_bits/itpp_wrap.hpp" #include "armadillo_bits/itpp_wrap.hpp"
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
skipping to change at line 114 skipping to change at line 112
#include "armadillo_bits/typedef.hpp" #include "armadillo_bits/typedef.hpp"
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/format_wrap.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
#include "armadillo_bits/span.hpp"
// //
// class prototypes // class prototypes
#include "armadillo_bits/syslib_proto.hpp" #include "armadillo_bits/syslib_proto.hpp"
#include "armadillo_bits/arrayops_proto.hpp"
#include "armadillo_bits/podarray_proto.hpp" #include "armadillo_bits/podarray_proto.hpp"
#include "armadillo_bits/blas_proto.hpp" #include "armadillo_bits/blas_proto.hpp"
#include "armadillo_bits/lapack_proto.hpp" #include "armadillo_bits/lapack_proto.hpp"
#include "armadillo_bits/atlas_proto.hpp" #include "armadillo_bits/atlas_proto.hpp"
#include "armadillo_bits/auxlib_proto.hpp" #include "armadillo_bits/auxlib_proto.hpp"
#include "armadillo_bits/Base.hpp" #include "armadillo_bits/Base.hpp"
#include "armadillo_bits/BaseCube.hpp" #include "armadillo_bits/BaseCube.hpp"
 End of changes. 8 change blocks. 
6 lines changed or deleted 6 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 615 skipping to change at line 615
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 << "@ arma_config::good_comp = " << arma_config::good_co mp << '\n';
std::cout << "@ arma_config::extra_code = " << arma_config::extra_c ode << '\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


 eglue_cube_core_meat.hpp   eglue_cube_core_meat.hpp 
skipping to change at line 61 skipping to change at line 61
else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) { retu rn x.P1.at(row,col,slice) * x.P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) { retu rn x.P1.at(row,col,slice) * x.P2.at(row,col,slice); }
else else
{ {
arma_stop("eglue_cube_core::get_elem(): unhandled eglue_type"); arma_stop("eglue_cube_core::get_elem(): unhandled eglue_type");
return eT(0); return eT(0);
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline
void
eglue_cube_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const
eGlueCube<T1, T2, eglue_type>& x)
{
arma_extra_debug_sigprint();
if( (is_Cube<T1>::value == true) && (is_Cube<T2>::value == true) )
{
eglue_cube_core<eglue_type>::apply_unwrap(out, x);
}
else
{
eglue_cube_core<eglue_type>::apply_proxy(out, x);
}
}
template<typename eglue_type>
template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_cube_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x) eglue_cube_core<eglue_type>::apply_proxy(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// eglue_type::apply() function is not allowed to unwrap things // eglue_type::apply_proxy() function is not allowed to unwrap things
// (in order to get the input into a common format). // (in order to get the input into a common format).
// the proxy class is already providing objects with element access // the proxy class is already providing objects with element access
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const ProxyCube<T1>& P1 = x.P1; const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2; const ProxyCube<T2>& P2 = x.P2;
out.set_size(P1.n_rows, P1.n_cols, P1.n_slices); out.set_size(P1.n_rows, P1.n_cols, P1.n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = P1.n_elem; const u32 n_elem = P1.n_elem;
if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; } if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; }
else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; } else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; }
else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; } else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; }
else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; } else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3 2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; }
else else
{ {
arma_stop("eglue_cube_core::apply(): unhandled eglue_type"); arma_stop("eglue_cube_core::apply_proxy(): unhandled eglue_type");
}
}
template<typename eglue_type>
template<typename T1, typename T2>
arma_hot
inline
void
eglue_cube_core<eglue_type>::apply_unwrap(Cube<typename T1::elem_type>& out
, const eGlueCube<T1, T2, eglue_type>& x)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp1(x.P1.Q);
const unwrap_cube<typename ProxyCube<T2>::stored_type> tmp2(x.P2.Q);
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
out.set_size(A.n_rows, A.n_cols, A.n_slices);
eT* out_mem = out.memptr();
const eT* A_mem = A.memptr();
const eT* B_mem = B.memptr();
const u32 n_elem = A.n_elem;
if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] + B_mem[i]; }
else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] - B_mem[i]; }
else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] / B_mem[i]; }
else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] * B_mem[i]; }
else
{
arma_stop("eglue_cube_core::apply_unwrap(): unhandled eglue_type");
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_cube_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type >& out, const eGlueCube<T1, T2, eglue_type>& x) eglue_cube_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type >& out, const eGlueCube<T1, T2, eglue_type>& x)
{ {
 End of changes. 4 change blocks. 
3 lines changed or deleted 61 lines changed or added


 eglue_cube_core_proto.hpp   eglue_cube_core_proto.hpp 
skipping to change at line 28 skipping to change at line 28
template<typename eglue_type> template<typename eglue_type>
struct eglue_cube_core struct eglue_cube_core
{ {
template<typename T1, typename T2> arma_inline static typename T1::elem_t ype get_elem(const eGlueCube<T1, T2, eglue_type>& x, const u32 i); template<typename T1, typename T2> arma_inline static typename T1::elem_t ype get_elem(const eGlueCube<T1, T2, eglue_type>& x, const u32 i);
template<typename T1, typename T2> arma_inline static typename T1::elem_t ype get_elem(const eGlueCube<T1, T2, eglue_type>& x, const u32 row, const u 32 col, const u32 slice); template<typename T1, typename T2> arma_inline static typename T1::elem_t ype get_elem(const eGlueCube<T1, T2, eglue_type>& x, const u32 row, const u 32 col, const u32 slice);
template<typename T1, typename T2> arma_hot inline static void apply(Cube <typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x); template<typename T1, typename T2> arma_hot inline static void apply(Cube <typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x);
template<typename T1, typename T2> arma_hot inline static void apply_prox
y (Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>&
x);
template<typename T1, typename T2> arma_hot inline static void apply_unwr
ap(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>&
x);
template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_plus (Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x); template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_plus (Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x);
template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_minus(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x); template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_minus(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x);
template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_schur(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x); template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_schur(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x);
template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_div (Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x); template<typename T1, typename T2> arma_hot inline static void apply_inpl ace_div (Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_ type>& x);
}; };
class eglue_cube_plus; class eglue_cube_plus;
class eglue_cube_minus; class eglue_cube_minus;
class eglue_cube_div; class eglue_cube_div;
 End of changes. 1 change blocks. 
0 lines changed or deleted 7 lines changed or added


 eop_core_meat.hpp   eop_core_meat.hpp 
skipping to change at line 144 skipping to change at line 144
const Proxy<T1>& P = x.P; const Proxy<T1>& P = x.P;
out.set_size(P.n_rows, P.n_cols); out.set_size(P.n_rows, P.n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = P.n_elem; const u32 n_elem = P.n_elem;
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
for(u32 i=0; i<n_elem; ++i) u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
out_mem[i] = eop_aux::generate<eT,eop_type>();
out_mem[j] = eop_aux::generate<eT,eop_type>();
}
if(i < n_elem)
{ {
out_mem[i] = eop_aux::generate<eT,eop_type>(); out_mem[i] = eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) if(is_same_type<eop_type, eop_ones_diag>::value == true)
{ {
for(u32 col=0; col<P.n_rows; ++col) for(u32 col=0; col<P.n_rows; ++col)
{ {
for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); } for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); }
out.at(col,col) = eT(1); out.at(col,col) = eT(1);
for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); } for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); }
} }
} }
else else
{ {
for(u32 i=0; i<n_elem; ++i) u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
out_mem[i] = eop_core<eop_type>::process(x, P[i]);
out_mem[j] = eop_core<eop_type>::process(x, P[j]);
}
if(i < n_elem)
{ {
out_mem[i] = eop_core<eop_type>::process(x, P[i]); out_mem[i] = eop_core<eop_type>::process(x, P[i]);
} }
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
skipping to change at line 198 skipping to change at line 214
out.set_size(P.n_rows, P.n_cols); out.set_size(P.n_rows, P.n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 n_elem = P.n_elem; const u32 n_elem = P.n_elem;
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
for(u32 i=0; i<n_elem; ++i) u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
out_mem[i] = eop_aux::generate<eT,eop_type>();
out_mem[j] = eop_aux::generate<eT,eop_type>();
}
if(i < n_elem)
{ {
out_mem[i] = eop_aux::generate<eT,eop_type>(); out_mem[i] = eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) if(is_same_type<eop_type, eop_ones_diag>::value == true)
{ {
for(u32 col=0; col<P.n_rows; ++col) for(u32 col=0; col<P.n_rows; ++col)
{ {
skipping to change at line 220 skipping to change at line 244
out.at(col,col) = eT(1); out.at(col,col) = eT(1);
for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); } for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); }
} }
} }
else else
{ {
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
for(u32 i=0; i<n_elem; ++i) u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
out_mem[i] = eop_core<eop_type>::process(x, A_mem[i]);
out_mem[j] = eop_core<eop_type>::process(x, A_mem[j]);
}
if(i < n_elem)
{ {
out_mem[i] = eop_core<eop_type>::process(x, A_mem[i]); out_mem[i] = eop_core<eop_type>::process(x, A_mem[i]);
} }
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
skipping to change at line 392 skipping to change at line 424
{ {
out_mem[i] /= eop_aux::generate<eT,eop_type>(); out_mem[i] /= eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) if(is_same_type<eop_type, eop_ones_diag>::value == true)
{ {
for(u32 col=0; col<P.n_rows; ++col) for(u32 col=0; col<P.n_rows; ++col)
{ {
for(u32 row=0; row<col; ++row) { out.at(row,col) /= eT(0); const eT zero = eT(0);
}
for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) /= eT(0); for(u32 row=0; row<col; ++row) { out.at(row,col) /= zero;
} }
for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) /= zero;
}
} }
} }
else else
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= eop_core<eop_type>::process(x, P[i]); out_mem[i] /= eop_core<eop_type>::process(x, P[i]);
} }
} }
} }
 End of changes. 5 change blocks. 
8 lines changed or deleted 42 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 484 skipping to change at line 484
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field<oT>& t = *this; field<oT>& t = *this;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
t[i] = x; t[i] = x;
} }
} }
//! reset the field to an empty state (i.e. the field will have no objects)
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::reset() field<oT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0); init(0,0);
} }
//! reset each object
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::reset_objects() field<oT>::reset_objects()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field_aux::reset_objects(*this); field_aux::reset_objects(*this);
} }
//! returns true if the field has no objects
template<typename oT>
arma_inline
bool
field<oT>::is_empty() const
{
return (n_elem == 0);
}
//! returns true if the given index is currently in range
template<typename oT>
arma_inline
bool
field<oT>::in_range(const u32 i) const
{
return (i < n_elem);
}
//! returns true if the given location is currently in range
template<typename oT>
arma_inline
bool
field<oT>::in_range(const u32 in_row, const u32 in_col) const
{
return ( (in_row < n_rows) && (in_col < n_cols) );
}
template<typename oT> template<typename oT>
inline inline
bool bool
field<oT>::save(const std::string name, const file_type type, const bool pr int_status) const field<oT>::save(const std::string name, const file_type type, const bool pr int_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::string err_msg; std::string err_msg;
const bool save_okay = field_aux::save(*this, name, type, err_msg); const bool save_okay = field_aux::save(*this, name, type, err_msg);
skipping to change at line 1528 skipping to change at line 1557
inline inline
bool bool
field_aux::load(field< std::string >& x, std::istream& is, const file_type type, std::string& err_msg) field_aux::load(field< std::string >& x, std::istream& is, const file_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return diskio::load_std_string(x, is, err_msg); return diskio::load_std_string(x, is, err_msg);
} }
#ifdef ARMA_EXTRA_FIELD_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_FIELD_MEAT)
#endif
//! @} //! @}
 End of changes. 4 change blocks. 
0 lines changed or deleted 33 lines changed or added


 field_proto.hpp   field_proto.hpp 
skipping to change at line 103 skipping to change at line 103
inline const subview_field<oT> subfield(const u32 in_row1, const u32 in_c ol1, const u32 in_row2, const u32 in_col2) const; inline const subview_field<oT> subfield(const u32 in_row1, const u32 in_c ol1, const u32 in_row2, const u32 in_col2) const;
inline void print(const std::string extra_text = "") const; inline void print(const std::string extra_text = "") const;
inline void print(std::ostream& user_stream, const std::string extra_text = "") const; inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
inline void fill(const oT& x); inline void fill(const oT& x);
inline void reset(); inline void reset();
inline void reset_objects(); inline void reset_objects();
arma_inline bool is_empty() const;
arma_inline bool in_range(const u32 i) const;
arma_inline bool in_range(const u32 in_row, const u32 in_col) const;
inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true); inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true);
inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true); inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const; inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const; inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a uto_detect); inline bool quiet_load(const std::string name, const file_type type = a uto_detect);
skipping to change at line 166 skipping to change at line 171
arma_aligned const field<oT>& M; arma_aligned const field<oT>& M;
arma_aligned u32 i; arma_aligned u32 i;
}; };
inline iterator begin(); inline iterator begin();
inline const_iterator begin() const; inline const_iterator begin() const;
inline iterator end(); inline iterator end();
inline const_iterator end() const; inline const_iterator end() const;
#ifdef ARMA_EXTRA_FIELD_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_FIELD_PROTO)
#endif
private: private:
inline void init(const field<oT>& x); inline void init(const field<oT>& x);
inline void init(const u32 n_rows_in, const u32 n_cols_in); inline void init(const u32 n_rows_in, const u32 n_cols_in);
inline void delete_objects(); inline void delete_objects();
inline void create_objects(); inline void create_objects();
friend class field_aux; friend class field_aux;
friend class subview_field<oT>; friend class subview_field<oT>;
 End of changes. 2 change blocks. 
0 lines changed or deleted 9 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
skipping to change at line 32 skipping to change at line 32
typename T1::elem_type typename T1::elem_type
accu_unwrap(const Base<typename T1::elem_type,T1>& X) accu_unwrap(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const eT* A_mem = A.memptr(); return arrayops::accumulate( A.memptr(), A.n_elem );
const u32 N = A.n_elem;
eT val1 = eT(0);
eT val2 = eT(0);
u32 i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
val1 += A_mem[i];
val2 += A_mem[j];
}
if(i < N)
{
val1 += A_mem[i];
}
return val1 + val2;
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::elem_type typename T1::elem_type
accu_proxy(const Base<typename T1::elem_type,T1>& X) accu_proxy(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 175 skipping to change at line 156
//! accumulate the elements of a subview (submatrix) //! accumulate the elements of a subview (submatrix)
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview<eT>& S) accu(const subview<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 S_n_rows = S.n_rows;
const u32 S_n_cols = S.n_cols;
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<S.n_cols; ++col) for(u32 col=0; col<S_n_cols; ++col)
{ {
const eT* coldata = S.colptr(col); val += arrayops::accumulate( S.colptr(col), S_n_rows );
for(u32 row=0; row<S.n_rows; ++row)
{
val += coldata[row];
}
} }
return val; return val;
} }
//! accumulate the elements of a subview_row //! accumulate the elements of a subview_row
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
skipping to change at line 227 skipping to change at line 205
//! accumulate the elements of a subview_col //! accumulate the elements of a subview_col
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview_col<eT>& S) accu(const subview_col<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const eT* S_colptr = S.colptr(0); return arrayops::accumulate( S.colptr(0), S.n_rows );
const u32 n_rows = S.n_rows;
eT val = eT(0);
for(u32 row=0; row<n_rows; ++row)
{
val += S_colptr[row];
}
return val;
} }
//! @} //! @}
 End of changes. 5 change blocks. 
39 lines changed or deleted 7 lines changed or added


 fn_norm.hpp   fn_norm.hpp 
skipping to change at line 23 skipping to change at line 23
// 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_norm //! \addtogroup fn_norm
//! @{ //! @{
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
norm_unwrap(const Base<typename T1::elem_type,T1>& X, const u32 k) norm_unwrap(const Base<typename T1::elem_type, T1>& X, const u32 k)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.n_elem == 0), "norm(): given object has no elements" ); arma_debug_check( (A.n_elem == 0), "norm(): given object has no elements" );
arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given object must be a vector" ); arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given object must be a vector" );
arma_debug_check( (k == 0), "norm(): k mus t be greater than zero" );
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
const u32 N = A.n_elem; const u32 N = A.n_elem;
if(k==1) switch(k)
{ {
T acc = T(0); case 1:
return arrayops::norm_1( A_mem, N );
for(u32 i=0; i<N; ++i) break;
{
acc += std::abs(A_mem[i]); case 2:
} return arrayops::norm_2( A_mem, N );
break;
return acc;
} default:
else arma_debug_check( (k == 0), "norm(): k must be greater than zero" );
if(k==2) return arrayops::norm_k( A_mem, N, int(k) );
{
if(is_complex<eT>::value == false)
{
eT acc = eT(0);
for(u32 i=0; i<N; ++i)
{
const eT tmp = A_mem[i];
acc += tmp*tmp;
}
return std::sqrt(access::tmp_real(acc));
}
else
{
T acc = T(0);
for(u32 i=0; i<N; ++i)
{
const T tmp = std::abs(A_mem[i]);
acc += tmp*tmp;
}
return std::sqrt(acc);
}
}
else
{
T acc = T(0);
for(u32 i=0; i<N; ++i)
{
acc += std::pow(std::abs(A_mem[i]), int(k));
}
return std::pow(acc, T(1)/T(k));
} }
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
norm_unwrap(const Base<typename T1::elem_type,T1>& X, const char* method) norm_unwrap(const Base<typename T1::elem_type, T1>& X, const char* method)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.n_elem == 0), "norm(): given object has no elements" ); arma_debug_check( (A.n_elem == 0), "norm(): given object has no elements" );
arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given object must be a vector" ); arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given object must be a vector" );
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
const u32 N = A.n_elem; const u32 N = A.n_elem;
const char sig = method[0]; const char sig = method[0];
if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm
{ {
T max_val = std::abs(A_mem[0]); return arrayops::norm_max(A_mem, N);
for(u32 i=1; i<N; ++i)
{
const T tmp_val = std::abs(A_mem[i]);
if(tmp_val > max_val)
{
max_val = tmp_val;
}
}
return max_val;
} }
else else
if(sig == '-') // min norm if(sig == '-') // min norm
{ {
T min_val = std::abs(A_mem[0]); return arrayops::norm_min(A_mem, N);
for(u32 i=1; i<N; ++i)
{
const T tmp_val = std::abs(A_mem[i]);
if(tmp_val < min_val)
{
min_val = tmp_val;
}
}
return min_val;
} }
else else
{ {
arma_stop("norm(): unknown norm type"); arma_stop("norm(): unknown norm type");
return T(0); return T(0);
} }
}
template<typename T1>
arma_hot
arma_inline
typename T1::pod_type
norm_1_proxy(const Proxy<T1>& A)
{
typedef typename T1::pod_type T;
T acc = T(0);
const u32 N = A.n_elem;
u32 i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
acc += std::abs(A[i]);
acc += std::abs(A[j]);
}
if(i < N)
{
acc += std::abs(A[i]);
}
return acc;
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline arma_inline
typename T1::pod_type typename T1::pod_type
norm_proxy(const Base<typename T1::elem_type,T1>& X, const u32 k) norm_2_proxy(const Proxy<T1>& A, const typename arma_not_cx<typename T1::el em_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); typedef typename T1::pod_type T;
typedef typename T1::elem_type eT; T acc = T(0);
typedef typename T1::pod_type T;
const Proxy<T1> A(X.get_ref()); const u32 N = A.n_elem;
arma_debug_check( (A.n_elem == 0), "norm(): given u32 i,j;
object has no elements" );
arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given for(i=0, j=1; j<N; i+=2, j+=2)
object must be a vector" ); {
arma_debug_check( (k == 0), "norm(): k mus const T tmp_i = A[i];
t be greater than zero" ); const T tmp_j = A[j];
acc += tmp_i * tmp_i;
acc += tmp_j * tmp_j;
}
if(i < N)
{
const T tmp_i = A[i];
acc += tmp_i * tmp_i;
}
return std::sqrt(acc);
}
template<typename T1>
arma_hot
arma_inline
typename T1::pod_type
norm_2_proxy(const Proxy<T1>& A, const typename arma_cx_only<typename T1::e
lem_type>::result* junk = 0)
{
typedef typename T1::pod_type T;
T acc = T(0);
const u32 N = A.n_elem; const u32 N = A.n_elem;
if(k==1) for(u32 i=0; i<N; ++i)
{ {
T acc = T(0); const T tmp = std::abs(A[i]);
acc += tmp*tmp;
}
for(u32 i=0; i<N; ++i) return std::sqrt(acc);
{ }
acc += std::abs(A[i]);
}
return acc; template<typename T1>
arma_hot
arma_inline
typename T1::pod_type
norm_k_proxy(const Proxy<T1>& A, const int k)
{
typedef typename T1::pod_type T;
T acc = T(0);
const u32 N = A.n_elem;
u32 i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
acc += std::pow(std::abs(A[i]), k);
acc += std::pow(std::abs(A[j]), k);
} }
else
if(k==2) if(i < N)
{ {
if(is_complex<eT>::value == false) acc += std::pow(std::abs(A[i]), k);
{ }
eT acc = eT(0);
for(u32 i=0; i<N; ++i) return std::pow(acc, T(1)/T(k));
{ }
const eT tmp = A[i];
acc += tmp*tmp;
}
return std::sqrt(access::tmp_real(acc)); template<typename T1>
} arma_hot
else arma_inline
{ typename T1::pod_type
T acc = T(0); norm_max_proxy(const Proxy<T1>& A)
{
typedef typename T1::pod_type T;
for(u32 i=0; i<N; ++i) const u32 N = A.n_elem;
{
const T tmp = std::abs(A[i]);
acc += tmp*tmp;
}
return std::sqrt(acc); T max_val = std::abs(A[0]);
}
u32 i,j;
for(i=1, j=2; j<N; i+=2, j+=2)
{
const T tmp_i = std::abs(A[i]);
const T tmp_j = std::abs(A[j]);
if(max_val < tmp_i) { max_val = tmp_i; }
if(max_val < tmp_j) { max_val = tmp_j; }
} }
else
if(i < N)
{ {
T acc = T(0); const T tmp_i = std::abs(A[i]);
for(u32 i=0; i<N; ++i) if(max_val < tmp_i) { max_val = tmp_i; }
{ }
acc += std::pow(std::abs(A[i]), int(k));
} return max_val;
}
template<typename T1>
arma_hot
arma_inline
typename T1::pod_type
norm_min_proxy(const Proxy<T1>& A)
{
typedef typename T1::pod_type T;
const u32 N = A.n_elem;
T min_val = std::abs(A[0]);
u32 i,j;
return std::pow(acc, T(1)/T(k)); for(i=1, j=2; j<N; i+=2, j+=2)
{
const T tmp_i = std::abs(A[i]);
const T tmp_j = std::abs(A[j]);
if(min_val > tmp_i) { min_val = tmp_i; }
if(min_val > tmp_j) { min_val = tmp_j; }
} }
if(i < N)
{
const T tmp_i = std::abs(A[i]);
if(min_val > tmp_i) { min_val = tmp_i; }
}
return min_val;
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
norm_proxy(const Base<typename T1::elem_type,T1>& X, const char* method) norm_proxy(const Base<typename T1::elem_type, T1>& X, const u32 k)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
arma_debug_check( (A.n_elem == 0), "norm(): given object has no elements" ); arma_debug_check( (A.n_elem == 0), "norm(): given object has no elements" );
arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given object must be a vector" ); arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given object must be a vector" );
const u32 N = A.n_elem; switch(k)
const char sig = method[0];
if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm
{ {
T max_val = std::abs(A[0]); case 1:
return norm_1_proxy(A);
break;
for(u32 i=1; i<N; ++i) case 2:
return norm_2_proxy(A);
break;
default:
{ {
const T tmp_val = std::abs(A[i]); arma_debug_check( (k == 0), "norm(): k must be greater than zero" ) ;
if(tmp_val > max_val) return norm_k_proxy(A, k);
{
max_val = tmp_val;
}
} }
}
}
return max_val; template<typename T1>
arma_hot
inline
typename T1::pod_type
norm_proxy(const Base<typename T1::elem_type, T1>& X, const char* method)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
const Proxy<T1> A(X.get_ref());
arma_debug_check( (A.n_elem == 0), "norm(): given
object has no elements" );
arma_debug_check( !( (A.n_rows == 1) || (A.n_cols == 1) ), "norm(): given
object must be a vector" );
const char sig = method[0];
if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm
{
return norm_max_proxy(A);
} }
else else
if(sig == '-') // min norm if(sig == '-') // min norm
{ {
T min_val = std::abs(A[0]); return norm_min_proxy(A);
for(u32 i=1; i<N; ++i)
{
const T tmp_val = std::abs(A[i]);
if(tmp_val < min_val)
{
min_val = tmp_val;
}
}
return min_val;
} }
else else
{ {
arma_stop("norm(): unknown norm type"); arma_stop("norm(): unknown norm type");
return T(0); return T(0);
} }
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
typename T1::pod_type typename T1::pod_type
norm(const Base<typename T1::elem_type,T1>& X, const u32 k) norm
(
const Base<typename T1::elem_type,T1>& X,
const u32 k,
const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun
k = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (is_Mat<T1>::value == true) ? norm_unwrap(X, k) : norm_proxy(X, k) ; return (is_Mat<T1>::value == true) ? norm_unwrap(X, k) : norm_proxy(X, k) ;
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
typename T1::pod_type typename T1::pod_type
norm(const Base<typename T1::elem_type,T1>& X, const char* method) norm
(
const Base<typename T1::elem_type,T1>& X,
const char* method,
const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun
k = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (is_Mat<T1>::value == true) ? norm_unwrap(X, method) : norm_proxy( X, method); return (is_Mat<T1>::value == true) ? norm_unwrap(X, method) : norm_proxy( X, method);
} }
//! @} //! @}
 End of changes. 43 change blocks. 
156 lines changed or deleted 217 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
skipping to change at line 22 skipping to change at line 22
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_ones //! \addtogroup fn_ones
//! @{ //! @{
//! Generate a vector with all elements set to one //! Generate a vector with all elements set to one
arma_inline arma_inline
const eOp<colvec, eop_ones_full> const eOp<colvec, eop_ones_full>
ones(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk = 0) ones(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_ones_full>(n_elem, 1); return eOp<colvec, eop_ones_full>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_ones_full> const eOp<vec_type, eop_ones_full>
ones(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::resu lt* junk = 0) ones(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::resu lt* junk = 0)
skipping to change at line 49 skipping to change at line 49
} }
else else
{ {
return eOp<vec_type, eop_ones_full>(n_elem, 1); return eOp<vec_type, eop_ones_full>(n_elem, 1);
} }
} }
//! Delayed generation of a dense matrix with all elements set to one //! Delayed generation of a dense matrix with all elements set to one
arma_inline arma_inline
const eOp<mat, eop_ones_full> const eOp<mat, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>:: result* junk = 0) ones(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_full>(n_rows, n_cols); return eOp<mat, eop_ones_full>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_ones_full> const eOp<mat_type, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_on ly<mat_type>::result* junk = 0) ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_on ly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<mat_type>::value == false>::apply(); arma_type_check<is_Mat<mat_type>::value == false>::apply();
return eOp<mat_type, eop_ones_full>(n_rows, n_cols); return eOp<mat_type, eop_ones_full>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_cube_ones_full> const eOpCube<cube, eop_cube_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cub e_only<cube>::result* junk = 0) ones(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_ones_full>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_cube_ones_full>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_ones_full> const eOpCube<cube_type, eop_cube_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0) ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0)
skipping to change at line 92 skipping to change at line 92
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Cube<cube_type>::value == false>::apply(); arma_type_check<is_Cube<cube_type>::value == false>::apply();
return eOpCube<cube_type, eop_cube_ones_full>(n_rows, n_cols, n_slices); return eOpCube<cube_type, eop_cube_ones_full>(n_rows, n_cols, n_slices);
} }
//! 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
arma_inline arma_inline
const eOp<mat, eop_ones_diag> const eOp<mat, eop_ones_diag>
eye(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>::r esult* junk = 0) eye(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_diag>(n_rows, n_cols); return eOp<mat, eop_ones_diag>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_ones_diag> const eOp<mat_type, eop_ones_diag>
eye(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_onl y<mat_type>::result* junk = 0) eye(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_onl y<mat_type>::result* junk = 0)
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
skipping to change at line 37 skipping to change at line 37
inline inline
typename arma_scalar_only<eT>::result typename arma_scalar_only<eT>::result
randn() randn()
{ {
return eT(eop_aux_randn<eT>()); return eT(eop_aux_randn<eT>());
} }
//! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance) //! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<colvec, eop_randn> const eOp<colvec, eop_randn>
randn(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk = 0) randn(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randn>(n_elem, 1); return eOp<colvec, eop_randn>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_randn> const eOp<vec_type, eop_randn>
randn(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0) randn(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0)
skipping to change at line 64 skipping to change at line 64
} }
else else
{ {
return eOp<vec_type, eop_randn>(n_elem, 1); return eOp<vec_type, eop_randn>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance) //! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<mat, eop_randn> const eOp<mat, eop_randn>
randn(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>: :result* junk = 0) randn(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_randn>(n_rows, n_cols); return eOp<mat, eop_randn>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_randn> const eOp<mat_type, eop_randn>
randn(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0) randn(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat_type, eop_randn>(n_rows, n_cols); return eOp<mat_type, eop_randn>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_cube_randn> const eOpCube<cube, eop_cube_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cu be_only<cube>::result* junk = 0) randn(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_randn>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_cube_randn>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_randn> const eOpCube<cube_type, eop_cube_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0) randn(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0)
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 fn_randu.hpp   fn_randu.hpp 
skipping to change at line 37 skipping to change at line 37
inline inline
typename arma_scalar_only<eT>::result typename arma_scalar_only<eT>::result
randu() randu()
{ {
return eT(eop_aux_randu<eT>()); return eT(eop_aux_randu<eT>());
} }
//! Generate a vector with all elements set to random values in the [0,1] i nterval (uniform distribution) //! Generate a vector with all elements set to random values in the [0,1] i nterval (uniform distribution)
arma_inline arma_inline
const eOp<colvec, eop_randu> const eOp<colvec, eop_randu>
randu(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk = 0) randu(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randu>(n_elem, 1); return eOp<colvec, eop_randu>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_randu> const eOp<vec_type, eop_randu>
randu(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0) randu(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0)
skipping to change at line 64 skipping to change at line 64
} }
else else
{ {
return eOp<vec_type, eop_randu>(n_elem, 1); return eOp<vec_type, eop_randu>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to random values in the [ 0,1] interval (uniform distribution) //! Generate a dense matrix with all elements set to random values in the [ 0,1] interval (uniform distribution)
arma_inline arma_inline
const eOp<mat, eop_randu> const eOp<mat, eop_randu>
randu(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>: :result* junk = 0) randu(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_randu>(n_rows, n_cols); return eOp<mat, eop_randu>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_randu> const eOp<mat_type, eop_randu>
randu(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0) randu(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat_type, eop_randu>(n_rows, n_cols); return eOp<mat_type, eop_randu>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_cube_randu> const eOpCube<cube, eop_cube_randu>
randu(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cu be_only<cube>::result* junk = 0) randu(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_randu>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_cube_randu>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_randu> const eOpCube<cube_type, eop_cube_randu>
randu(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0) randu(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0)
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
skipping to change at line 22 skipping to change at line 22
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_zeros //! \addtogroup fn_zeros
//! @{ //! @{
//! Generate a vector with all elements set to zero //! Generate a vector with all elements set to zero
arma_inline arma_inline
const eOp<colvec, eop_zeros> const eOp<colvec, eop_zeros>
zeros(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk = 0) zeros(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_zeros>(n_elem, 1); return eOp<colvec, eop_zeros>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_zeros> const eOp<vec_type, eop_zeros>
zeros(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0) zeros(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0)
skipping to change at line 49 skipping to change at line 49
} }
else else
{ {
return eOp<vec_type, eop_zeros>(n_elem, 1); return eOp<vec_type, eop_zeros>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to zero //! Generate a dense matrix with all elements set to zero
arma_inline arma_inline
const eOp<mat, eop_zeros> const eOp<mat, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>: :result* junk = 0) zeros(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_zeros>(n_rows, n_cols); return eOp<mat, eop_zeros>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_zeros> const eOp<mat_type, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0) zeros(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<mat_type>::value == false>::apply(); arma_type_check<is_Mat<mat_type>::value == false>::apply();
return eOp<mat_type, eop_zeros>(n_rows, n_cols); return eOp<mat_type, eop_zeros>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_cube_zeros> const eOpCube<cube, eop_cube_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cu be_only<cube>::result* junk = 0) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_zeros>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_cube_zeros>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_zeros> const eOpCube<cube_type, eop_cube_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0)
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 gemm.hpp   gemm.hpp 
skipping to change at line 65 skipping to change at line 65
for(u32 row_A=0; row_A < A_n_rows; ++row_A) for(u32 row_A=0; row_A < A_n_rows; ++row_A)
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{ {
A_rowdata[col_A] = A.at(row_A,col_A); A_rowdata[col_A] = A.at(row_A,col_A);
} }
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{ {
const eT* B_coldata = B.colptr(col_B); // const eT* B_coldata = B.colptr(col_B);
//
// eT acc = eT(0);
// for(u32 i=0; i < B_n_rows; ++i)
// {
// acc += A_rowdata[i] * B_coldata[i];
// }
eT acc = eT(0); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col
for(u32 i=0; i < B_n_rows; ++i) ptr(col_B));
{
acc += A_rowdata[i] * B_coldata[i];
}
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,col_B) = acc; C.at(row_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
C.at(row_A,col_B) = alpha * acc; C.at(row_A,col_B) = alpha * acc;
} }
skipping to change at line 107 skipping to change at line 109
if( (do_trans_A == true) && (do_trans_B == false) ) if( (do_trans_A == true) && (do_trans_B == false) )
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{ {
// col_A is interpreted as row_A when storing the results in matrix C // col_A is interpreted as row_A when storing the results in matrix C
const eT* A_coldata = A.colptr(col_A); const eT* A_coldata = A.colptr(col_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{ {
const eT* B_coldata = B.colptr(col_B); // const eT* B_coldata = B.colptr(col_B);
//
// eT acc = eT(0);
// for(u32 i=0; i < B_n_rows; ++i)
// {
// acc += A_coldata[i] * B_coldata[i];
// }
eT acc = eT(0); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_coldata, B.col
for(u32 i=0; i < B_n_rows; ++i) ptr(col_B));
{
acc += A_coldata[i] * B_coldata[i];
}
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,col_B) = acc; C.at(col_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
C.at(col_A,col_B) = alpha * acc; C.at(col_A,col_B) = alpha * acc;
} }
skipping to change at line 166 skipping to change at line 170
for(u32 row_B=0; row_B < B_n_rows; ++row_B) for(u32 row_B=0; row_B < B_n_rows; ++row_B)
{ {
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{ {
B_rowdata[col_B] = B.at(row_B,col_B); B_rowdata[col_B] = B.at(row_B,col_B);
} }
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{ {
const eT* A_coldata = A.colptr(col_A); // const eT* A_coldata = A.colptr(col_A);
//
// eT acc = eT(0);
// for(u32 i=0; i < A_n_rows; ++i)
// {
// acc += B_rowdata[i] * A_coldata[i];
// }
eT acc = eT(0); const eT acc = op_dot::direct_dot_arma(A_n_rows, B_rowdata, A.col
for(u32 i=0; i < A_n_rows; ++i) ptr(col_A));
{
acc += B_rowdata[i] * A_coldata[i];
}
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,row_B) = acc; C.at(col_A,row_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
C.at(col_A,row_B) = alpha * acc; C.at(col_A,row_B) = alpha * acc;
} }
 End of changes. 6 change blocks. 
18 lines changed or deleted 27 lines changed or added


 gemv.hpp   gemv.hpp 
skipping to change at line 79 skipping to change at line 79
} }
} }
} }
else else
if(do_trans_A == true) if(do_trans_A == true)
{ {
for(u32 col=0; col < A_n_cols; ++col) for(u32 col=0; col < A_n_cols; ++col)
{ {
// col is interpreted as row when storing the results in 'y' // col is interpreted as row when storing the results in 'y'
const eT* A_coldata = A.colptr(col); // const eT* A_coldata = A.colptr(col);
//
// eT acc = eT(0);
// for(u32 row=0; row < A_n_rows; ++row)
// {
// acc += A_coldata[row] * x[row];
// }
eT acc = eT(0); const eT acc = op_dot::direct_dot_arma(A_n_rows, A.colptr(col), x);
for(u32 row=0; row < A_n_rows; ++row)
{
acc += A_coldata[row] * x[row];
}
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
y[col] = acc; y[col] = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
y[col] = alpha * acc; y[col] = alpha * acc;
} }
 End of changes. 2 change blocks. 
6 lines changed or deleted 8 lines changed or added


 glue_join_meat.hpp   glue_join_meat.hpp 
skipping to change at line 93 skipping to change at line 93
C.submat(A.n_rows, 0, C.n_rows-1, C.n_cols-1) = B; C.submat(A.n_rows, 0, C.n_rows-1, C.n_cols-1) = B;
} }
else else
{ {
C.set_size(A.n_rows, A.n_cols + B.n_cols); C.set_size(A.n_rows, A.n_cols + B.n_cols);
C.submat(0, 0, C.n_rows-1, A.n_cols-1) = A; C.submat(0, 0, C.n_rows-1, A.n_cols-1) = A;
C.submat(0, A.n_cols, C.n_rows-1, C.n_cols-1) = B; C.submat(0, A.n_cols, C.n_rows-1, C.n_cols-1) = B;
} }
if(C.n_elem > sizeof(C.mem_local)/sizeof(eT)) out.steal_mem(C);
{
out.reset();
access::rw(out.n_elem) = C.n_elem;
access::rw(out.n_rows) = C.n_rows;
access::rw(out.n_cols) = C.n_cols;
access::rw(out.mem ) = C.mem;
access::rw(C.n_elem) = 0;
access::rw(C.n_rows) = 0;
access::rw(C.n_cols) = 0;
}
else
{
out = C;
}
} }
} }
//! @} //! @}
 End of changes. 1 change blocks. 
17 lines changed or deleted 1 lines changed or added


 op_max_meat.hpp   op_max_meat.hpp 
skipping to change at line 21 skipping to change at line 21
// 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_max //! \addtogroup op_max
//! @{ //! @{
//! find the maximum value in an array //! find the maximum value in an array
template<typename eT> template<typename eT>
arma_pure
inline inline
eT eT
op_max::direct_max(const eT* const X, const u32 n_elem) op_max::direct_max(const eT* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = X[0]; eT max_val = X[0];
for(u32 i=1; i<n_elem; ++i) u32 i,j;
for(i=1, j=2; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_val = X[i]; const eT X_i = X[i];
if(tmp_val > max_val) if(X_i > max_val)
{ {
max_val = tmp_val; max_val = X_i;
}
const eT X_j = X[j];
if(X_j > max_val)
{
max_val = X_j;
}
}
if(i < n_elem)
{
const eT X_i = X[i];
if(X_i > max_val)
{
max_val = X_i;
} }
} }
return max_val; return max_val;
} }
//! find the maximum value in a subview //! find the maximum value in a subview
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const subview<eT>& X) op_max::direct_max(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = X[0]; const u32 X_n_elem = X.n_elem;
eT max_val = X[0];
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
} }
//! find the maximum value in a diagview //! find the maximum value in a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const diagview<eT>& X) op_max::direct_max(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = X[0]; const u32 X_n_elem = X.n_elem;
eT max_val = X[0];
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
skipping to change at line 109 skipping to change at line 131
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), "max(): 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), "max(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_max::apply(), dim = 0"); arma_extra_debug_print("op_max::apply(), dim = 0");
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 );
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_max::apply(), dim = 1"); arma_extra_debug_print("op_max::apply(), dim = 1");
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 max_val = X.at(row,0); eT max_val = X.at(row,0);
for(u32 col=1; col<X.n_cols; ++col) for(u32 col=1; col<X_n_cols; ++col)
{ {
const eT tmp_val = X.at(row,col); const eT tmp_val = X.at(row,col);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
out[row] = max_val; out[row] = max_val;
skipping to change at line 182 skipping to change at line 207
} }
//! Find the maximum value in a subview (version for complex numbers) //! Find the maximum value in a subview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const subview< std::complex<T> >& X) op_max::direct_max(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; const u32 X_n_elem = X.n_elem;
T max_val = std::abs(X[index]); u32 index = 0;
T max_val = std::abs(X[index]);
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
skipping to change at line 207 skipping to change at line 233
} }
//! Find the maximum value in a diagview (version for complex numbers) //! Find the maximum value in a diagview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const diagview< std::complex<T> >& X) op_max::direct_max(const diagview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; const u32 X_n_elem = X.n_elem;
T max_val = std::abs(X[index]); u32 index = 0;
T max_val = std::abs(X[index]);
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
skipping to change at line 241 skipping to change at line 268
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), "max(): 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), "max(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
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 );
} }
} }
else else
if(dim == 1) // row-wise max if(dim == 1) // row-wise max
{ {
arma_extra_debug_print("op_max::apply(), dim = 1"); arma_extra_debug_print("op_max::apply(), dim = 1");
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)
{ {
u32 index = 0; u32 index = 0;
T max_val = std::abs(X.at(row,index)); T max_val = std::abs(X.at(row,index));
for(u32 col=1; col<X.n_cols; ++col) for(u32 col=1; col<X.n_cols; ++col)
{ {
const T tmp_val = std::abs(X.at(row,col)); const T tmp_val = std::abs(X.at(row,col));
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
 End of changes. 26 change blocks. 
25 lines changed or deleted 55 lines changed or added


 op_mean_meat.hpp   op_mean_meat.hpp 
skipping to change at line 21 skipping to change at line 21
// 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_mean //! \addtogroup op_mean
//! @{ //! @{
//! find the mean value of an array //! find the mean value of an array
template<typename eT> template<typename eT>
arma_pure
inline inline
eT eT
op_mean::direct_mean(const eT* const X, const u32 n_elem) op_mean::direct_mean(const eT* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
val += X[i];
val += X[j];
}
if(i < n_elem)
{ {
val += X[i]; val += X[i];
} }
return val / eT(n_elem); return val / eT(n_elem);
} }
//! find the mean value of a subview //! find the mean value of a subview
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const subview<eT>& X) op_mean::direct_mean(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); const u32 X_n_elem = X.n_elem;
eT val = eT(0);
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
return val / eT(X.n_elem); return val / eT(X_n_elem);
} }
//! find the mean value of a diagview //! find the mean value of a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const diagview<eT>& X) op_mean::direct_mean(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); const u32 X_n_elem = X.n_elem;
eT val = eT(0);
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
return val / eT(X.n_elem); return val / eT(X_n_elem);
} }
//! \brief //! \brief
//! For each row or for each column, find the mean value. //! For each row or for each column, find the mean value.
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! The dimension, for which the means are found, is set via the mean() fun ction. //! The dimension, for which the means are found, is set via the mean() fun ction.
template<typename T1> template<typename T1>
inline inline
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)
skipping to change at line 94 skipping to change at line 105
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), "mean(): 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), "mean(): incorrect usage. dim must be 0 or 1 "); arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1 ");
const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 0"); arma_extra_debug_print("op_mean::apply(), dim = 0");
out.set_size(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 );
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 1"); arma_extra_debug_print("op_mean::apply(), dim = 1");
out.set_size(X.n_rows, 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 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)
{ {
val += X.at(row,col); val += X.at(row,col);
} }
out[row] = val / eT(X.n_cols); out[row] = val / eT(X_n_cols);
} }
} }
} }
//! @} //! @}
 End of changes. 16 change blocks. 
14 lines changed or deleted 28 lines changed or added


 op_min_meat.hpp   op_min_meat.hpp 
skipping to change at line 21 skipping to change at line 21
// 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_min //! \addtogroup op_min
//! @{ //! @{
//! Find the minimum value in an array //! Find the minimum value in an array
template<typename eT> template<typename eT>
arma_pure
inline inline
eT eT
op_min::direct_min(const eT* const X, const u32 n_elem) op_min::direct_min(const eT* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = X[0]; eT min_val = X[0];
for(u32 i=1; i<n_elem; ++i) u32 i,j;
for(i=1, j=2; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_val = X[i]; const eT X_i = X[i];
if(tmp_val < min_val) if(X_i < min_val)
{ {
min_val = tmp_val; min_val = X_i;
}
const eT X_j = X[j];
if(X_j < min_val)
{
min_val = X_j;
}
}
if(i < n_elem)
{
const eT X_i = X[i];
if(X_i < min_val)
{
min_val = X_i;
} }
} }
return min_val; return min_val;
} }
//! find the minimum value in a subview //! find the minimum value in a subview
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const subview<eT>& X) op_min::direct_min(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = X[0]; const u32 X_n_elem = X.n_elem;
eT min_val = X[0];
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
} }
//! find the minimum value in a diagview //! find the minimum value in a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const diagview<eT>& X) op_min::direct_min(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = X[0]; const u32 X_n_elem = X.n_elem;
eT min_val = X[0];
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
skipping to change at line 107 skipping to change at line 129
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), "min(): 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), "min(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
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 );
} }
} }
else else
if(dim == 1) // row-wise min if(dim == 1) // row-wise min
{ {
arma_extra_debug_print("op_min::apply(), dim = 1"); arma_extra_debug_print("op_min::apply(), dim = 1");
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 min_val = X.at(row,0); eT min_val = X.at(row,0);
for(u32 col=1; col<X.n_cols; ++col) for(u32 col=1; col<X_n_cols; ++col)
{ {
const eT tmp_val = X.at(row,col); const eT tmp_val = X.at(row,col);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
out[row] = min_val; out[row] = min_val;
skipping to change at line 180 skipping to change at line 205
} }
//! Find the minimum value in a subview (version for complex numbers) //! Find the minimum value in a subview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const subview< std::complex<T> >& X) op_min::direct_min(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; const u32 X_n_elem = X.n_elem;
T min_val = std::abs(X[index]); u32 index = 0;
T min_val = std::abs(X[index]);
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
skipping to change at line 205 skipping to change at line 231
} }
//! Find the minimum value in a diagview (version for complex numbers) //! Find the minimum value in a diagview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const diagview< std::complex<T> >& X) op_min::direct_min(const diagview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; const u32 X_n_elem = X.n_elem;
T min_val = std::abs(X[index]); u32 index = 0;
T min_val = std::abs(X[index]);
for(u32 i=1; i<X.n_elem; ++i) for(u32 i=1; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
skipping to change at line 239 skipping to change at line 266
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), "min(): 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), "min(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
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 );
} }
} }
else else
if(dim == 1) // row-wise min if(dim == 1) // row-wise min
{ {
arma_extra_debug_print("op_min::apply(), dim = 1"); arma_extra_debug_print("op_min::apply(), dim = 1");
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)
{ {
u32 index = 0; u32 index = 0;
T min_val = std::abs(X.at(row,index)); T min_val = std::abs(X.at(row,index));
for(u32 col=1; col<X.n_cols; ++col) for(u32 col=1; col<X.n_cols; ++col)
{ {
const T tmp_val = std::abs(X.at(row,col)); const T tmp_val = std::abs(X.at(row,col));
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
 End of changes. 26 change blocks. 
25 lines changed or deleted 55 lines changed or added


 op_reshape_meat.hpp   op_reshape_meat.hpp 
skipping to change at line 45 skipping to change at line 45
if(A.n_elem == in_n_elem) if(A.n_elem == in_n_elem)
{ {
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 // &out == &A, i.e. inplace resize
{ {
access::rw(out.n_rows) = in_n_rows; const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols =
access::rw(out.n_cols) = in_n_cols; = in_n_cols) );
if(same_size == false)
{
arma_debug_check
(
(out.mem_state == 3),
"reshape(): size can't be changed as template based size specif
ication is in use"
);
access::rw(out.n_rows) = in_n_rows;
access::rw(out.n_cols) = in_n_cols;
}
} }
} }
else else
{ {
unwrap_check< Mat<eT> > tmp(A, out); unwrap_check< Mat<eT> > tmp(A, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
skipping to change at line 141 skipping to change at line 152
if(A.n_elem == in_n_elem) if(A.n_elem == in_n_elem)
{ {
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 // &out == &A, i.e. inplace resize
{ {
access::rw(out.n_rows) = in_n_rows; const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols =
access::rw(out.n_cols) = in_n_cols; = in_n_cols) && (out.n_slices == in_n_slices) );
access::rw(out.n_slices) = in_n_slices;
if(same_size == false)
{
arma_debug_check
(
(out.mem_state == 3),
"reshape(): size can't be changed as template based size specif
ication is in use"
);
out.delete_mat();
access::rw(out.n_rows) = in_n_rows;
access::rw(out.n_cols) = in_n_cols;
access::rw(out.n_elem_slice) = in_n_rows * in_n_cols;
access::rw(out.n_slices) = in_n_slices;
out.create_mat();
}
} }
} }
else else
{ {
unwrap_cube_check< Cube<eT> > tmp(A, out); unwrap_cube_check< Cube<eT> > tmp(A, out);
const Cube<eT>& B = tmp.M; const Cube<eT>& B = tmp.M;
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
 End of changes. 4 change blocks. 
7 lines changed or deleted 38 lines changed or added


 op_sum_meat.hpp   op_sum_meat.hpp 
skipping to change at line 40 skipping to change at line 40
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" );
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem < 1), "sum(): given object has no elements"); arma_debug_check( (X.n_elem < 1), "sum(): given object has no elements");
const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the sum in each column) if(dim == 0) // traverse across rows (i.e. find the sum in each column)
{ {
out.set_size(1, X.n_cols); out.set_size(1, X_n_cols);
for(u32 col=0; col < X.n_cols; ++col) for(u32 col=0; col<X_n_cols; ++col)
{ {
const eT* X_colptr = X.colptr(col); out.at(0,col) = arrayops::accumulate( X.colptr(col), X_n_rows );
eT val = eT(0);
for(u32 row=0; row < X.n_rows; ++row)
{
val += X_colptr[row];
}
out.at(0,col) = val;
} }
} }
else // traverse across columns (i.e. find the sum in each row) else // traverse across columns (i.e. find the sum in each row)
{ {
out.set_size(X.n_rows, 1); out.set_size(X_n_rows, 1);
for(u32 row=0; row < X.n_rows; ++row) for(u32 row=0; row<X_n_rows; ++row)
{ {
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<X.n_cols; ++col) for(u32 col=0; col<X_n_cols; ++col)
{ {
val += X.at(row,col); val += X.at(row,col);
} }
out.at(row,0) = val; out.at(row,0) = val;
} }
} }
} }
 End of changes. 7 change blocks. 
15 lines changed or deleted 9 lines changed or added


 subview_cube_meat.hpp   subview_cube_meat.hpp 
skipping to change at line 91 skipping to change at line 91
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator+= (const eT val) subview_cube<eT>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < n_cols; ++col) for(u32 col = 0; col < local_n_cols; ++col)
{ {
eT* coldata = slice_colptr(slice,col); arrayops::inplace_plus( slice_colptr(slice,col), val, local_n_rows );
for(u32 row = 0; row < n_rows; ++row)
{
coldata[row] += val;
}
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator-= (const eT val) subview_cube<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col < local_n_cols; ++col)
{ {
eT* coldata = slice_colptr(slice,col); arrayops::inplace_minus( slice_colptr(slice,col), val, local_n_rows )
;
for(u32 row = 0; row<n_rows; ++row)
{
coldata[row] -= val;
}
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator*= (const eT val) subview_cube<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col < local_n_cols; ++col)
{ {
eT* coldata = slice_colptr(slice,col); arrayops::inplace_mul( slice_colptr(slice,col), val, local_n_rows );
for(u32 row = 0; row<n_rows; ++row)
{
coldata[row] *= val;
}
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator/= (const eT val) subview_cube<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col < local_n_cols; ++col)
{ {
eT* coldata = slice_colptr(slice,col); arrayops::inplace_div( slice_colptr(slice,col), val, local_n_rows );
for(u32 row = 0; row<n_rows; ++row)
{
coldata[row] /= val;
}
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator= (const BaseCube<eT,T1>& in) subview_cube<eT>::operator= (const BaseCube<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "copy into subcube"); arma_debug_assert_same_size(t, x, "copy into subcube");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); syslib::copy_elem( t.slice_colptr(slice,col), x.slice_colptr(slice,co
const eT* x_coldata = x.slice_colptr(slice,col); l), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] = x_coldata[row];
}
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator+= (const BaseCube<eT,T1>& in) subview_cube<eT>::operator+= (const BaseCube<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube addition"); arma_debug_assert_same_size(t, x, "cube addition");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli
const eT* x_coldata = x.slice_colptr(slice,col); ce,col), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] += x_coldata[row];
}
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator-= (const BaseCube<eT,T1>& in) subview_cube<eT>::operator-= (const BaseCube<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube subtraction"); arma_debug_assert_same_size(t, x, "cube subtraction");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl
const eT* x_coldata = x.slice_colptr(slice,col); ice,col), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] -= x_coldata[row];
}
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator%= (const BaseCube<eT,T1>& in) subview_cube<eT>::operator%= (const BaseCube<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube schur product"); arma_debug_assert_same_size(t, x, "cube schur product");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic
const eT* x_coldata = x.slice_colptr(slice,col); e,col), t_n_rows );
for(u32 row = 0; row<t.n_rows; ++row)
{
t_coldata[row] *= x_coldata[row];
}
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator/= (const BaseCube<eT,T1>& in) subview_cube<eT>::operator/= (const BaseCube<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<eT>& x = tmp.M; const Cube<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise cube division"); arma_debug_assert_same_size(t, x, "element-wise cube division");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic
const eT* x_coldata = x.slice_colptr(slice,col); e,col), t_n_rows );
for(u32 row = 0; row<t.n_rows; ++row)
{
t_coldata[row] /= x_coldata[row];
}
} }
} }
} }
//! x.subcube(...) = y.subcube(...) //! x.subcube(...) = y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::operator= (const subview_cube<eT>& x_in) subview_cube<eT>::operator= (const subview_cube<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);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "copy into subcube"); arma_debug_assert_same_size(t, x, "copy into subcube");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); syslib::copy_elem( t.slice_colptr(slice,col), x.slice_colptr(slice,co
const eT* x_coldata = x.slice_colptr(slice,col); l), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] = x_coldata[row];
}
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
} }
skipping to change at line 384 skipping to change at line 359
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube addition"); arma_debug_assert_same_size(t, x, "cube addition");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli
const eT* x_coldata = x.slice_colptr(slice,col); ce,col), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] += x_coldata[row];
}
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
} }
skipping to change at line 423 skipping to change at line 396
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube subtraction"); arma_debug_assert_same_size(t, x, "cube subtraction");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl
const eT* x_coldata = x.slice_colptr(slice,col); ice,col), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] -= x_coldata[row];
}
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
} }
skipping to change at line 462 skipping to change at line 433
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise cube multiplication"); arma_debug_assert_same_size(t, x, "element-wise cube multiplication");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic
const eT* x_coldata = x.slice_colptr(slice,col); e,col), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] *= x_coldata[row];
}
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
} }
skipping to change at line 501 skipping to change at line 470
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT> (*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x _in.aux_col2, x_in.aux_slice2) : 0;
const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise cube division"); arma_debug_assert_same_size(t, x, "element-wise cube division");
for(u32 slice = 0; slice < t.n_slices; ++slice) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
const u32 t_n_slices = t.n_slices;
for(u32 slice = 0; slice < t_n_slices; ++slice)
{ {
for(u32 col = 0; col < t.n_cols; ++col) for(u32 col = 0; col < t_n_cols; ++col)
{ {
eT* t_coldata = t.slice_colptr(slice,col); arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic
const eT* x_coldata = x.slice_colptr(slice,col); e,col), t_n_rows );
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] /= x_coldata[row];
}
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview_cube; delete tmp_subview_cube;
delete tmp_cube; delete tmp_cube;
} }
} }
skipping to change at line 538 skipping to change at line 505
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "copy into subcube"); arma_debug_assert_same_size(t, x, "copy into subcube");
for(u32 col = 0; col < t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.slice_colptr(t.aux_slice1, col); const u32 t_aux_slice1 = t.aux_slice1;
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row < t.n_rows; ++row)
{
t_coldata[row] = x_coldata[row];
}
for(u32 col = 0; col < t_n_cols; ++col)
{
syslib:copy_elem( t.slice_colptr(t_aux_slice1, col), x.colptr(col), t_n
_rows );
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator+= (const Base<eT,T1>& in) subview_cube<eT>::operator+= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube addition"); arma_debug_assert_same_size(t, x, "cube addition");
for(u32 col = 0; col < t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.slice_colptr(t.aux_slice1, col); const u32 t_aux_slice1 = t.aux_slice1;
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row < t.n_rows; ++row) for(u32 col = 0; col < t_n_cols; ++col)
{ {
t_coldata[row] += x_coldata[row]; arrayops::inplace_plus( t.slice_colptr(t_aux_slice1, col), x.colptr(col
} ), t_n_rows );
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator-= (const Base<eT,T1>& in) subview_cube<eT>::operator-= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube subtraction"); arma_debug_assert_same_size(t, x, "cube subtraction");
for(u32 col = 0; col < t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.slice_colptr(t.aux_slice1, col); const u32 t_aux_slice1 = t.aux_slice1;
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row < t.n_rows; ++row) for(u32 col = 0; col < t_n_cols; ++col)
{ {
t_coldata[row] -= x_coldata[row]; arrayops::inplace_minus( t.slice_colptr(t_aux_slice1, col), x.colptr(co
} l), t_n_rows );
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator%= (const Base<eT,T1>& in) subview_cube<eT>::operator%= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "cube schur product"); arma_debug_assert_same_size(t, x, "cube schur product");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.slice_colptr(t.aux_slice1, col); const u32 t_aux_slice1 = t.aux_slice1;
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 col = 0; col < t_n_cols; ++col)
{ {
t_coldata[row] *= x_coldata[row]; arrayops::inplace_mul( t.slice_colptr(t_aux_slice1, col), x.colptr(col)
} , t_n_rows );
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview_cube<eT>::operator/= (const Base<eT,T1>& in) subview_cube<eT>::operator/= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
subview_cube<eT>& t = *this; subview_cube<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise cube division"); arma_debug_assert_same_size(t, x, "element-wise cube division");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.slice_colptr(t.aux_slice1, col); const u32 t_aux_slice1 = t.aux_slice1;
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 col = 0; col < t_n_cols; ++col)
{ {
t_coldata[row] /= x_coldata[row]; arrayops::inplace_div( t.slice_colptr(t_aux_slice1, col), x.colptr(col)
} , t_n_rows );
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::fill(const eT val) subview_cube<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 slice = 0; slice < n_slices; ++slice) const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 local_n_slices = n_slices;
for(u32 slice = 0; slice < local_n_slices; ++slice)
{ {
for(u32 col = 0; col < n_cols; ++col) for(u32 col = 0; col < local_n_cols; ++col)
{ {
eT* coldata = slice_colptr(slice,col); arrayops::inplace_set( slice_colptr(slice,col), val, local_n_rows );
for(u32 row = 0; row < n_rows; ++row)
{
coldata[row] = val;
}
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::zeros() subview_cube<eT>::zeros()
{ {
skipping to change at line 706 skipping to change at line 661
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(1)); fill(eT(1));
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::operator[](const u32 i) subview_cube<eT>::operator[](const u32 i)
{ {
arma_check( (m_ptr == 0), "subview_cube::operator[]: cube is read-only");
const u32 in_slice = i / n_elem_slice; const u32 in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const u32 offset = in_slice * n_elem_slice;
const u32 j = i - offset; const u32 j = i - offset;
const u32 in_col = j / n_rows; const u32 in_col = j / n_rows;
const u32 in_row = j % n_rows; const u32 in_row = j % n_rows;
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
skipping to change at line 740 skipping to change at line 693
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::operator()(const u32 i) subview_cube<eT>::operator()(const u32 i)
{ {
arma_check( (m_ptr == 0), "subview_cube::operator(): matrix is read-only" );
arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
const u32 in_slice = i / n_elem_slice; const u32 in_slice = i / n_elem_slice;
const u32 offset = in_slice * n_elem_slice; const u32 offset = in_slice * n_elem_slice;
const u32 j = i - offset; const u32 j = i - offset;
const u32 in_col = j / n_rows; const u32 in_col = j / n_rows;
const u32 in_row = j % n_rows; const u32 in_row = j % n_rows;
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
skipping to change at line 777 skipping to change at line 729
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice) subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice)
{ {
arma_check( (m_ptr == 0), "subview_cube::operator(): matrix is read-only" );
arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds"); arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice) const subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice) const
skipping to change at line 800 skipping to change at line 751
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice ) subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice )
{ {
arma_check( (m_ptr == 0), "subview_cube::at(): cube is read-only");
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice ) const subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice ) const
{ {
const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_ col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col) subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col)
{ {
arma_check( (m_ptr == 0), "subview_cube::slice_colptr(): cube is read-onl
y");
return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]); return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col) const subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col) const
{ {
return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_co l1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_co l1)*m.n_rows + aux_row1 ];
} }
skipping to change at line 867 skipping to change at line 814
( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) ) ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) )
); );
const bool slice_overlap = const bool slice_overlap =
( (
( (x.aux_slice1 >= t.aux_slice1) && (x.aux_slice1 <= t.aux_slice2) ) ( (x.aux_slice1 >= t.aux_slice1) && (x.aux_slice1 <= t.aux_slice2) )
|| ||
( (x.aux_slice2 >= t.aux_slice1) && (x.aux_slice2 <= t.aux_slice2) ) ( (x.aux_slice2 >= t.aux_slice1) && (x.aux_slice2 <= t.aux_slice2) )
); );
return (row_overlap & col_overlap & slice_overlap); const bool overlap = ( (row_overlap == true) && (col_overlap == true) &
& (slice_overlap == true) );
return overlap;
} }
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview_cube<eT>::check_overlap(const Mat<eT>& x) const subview_cube<eT>::check_overlap(const Mat<eT>& x) const
{ {
const subview_cube<eT>& t = *this; const subview_cube<eT>& t = *this;
skipping to change at line 915 skipping to change at line 864
// //
const u32 n_rows = in.n_rows; const u32 n_rows = in.n_rows;
const u32 n_cols = in.n_cols; const u32 n_cols = in.n_cols;
const u32 n_slices = in.n_slices; const u32 n_slices = in.n_slices;
out.set_size(n_rows, n_cols, n_slices); out.set_size(n_rows, n_cols, n_slices);
arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_sl ices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n _cols % in.m.n_slices); arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_sl ices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n _cols % in.m.n_slices);
for(u32 slice = 0; slice<n_slices; ++slice) for(u32 slice = 0; slice < n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col < n_cols; ++col)
{ {
eT* out_coldata = out.slice_colptr(slice,col); syslib::copy_elem( out.slice_colptr(slice,col), in.slice_colptr(slice
const eT* in_coldata = in.slice_colptr(slice,col); ,col), n_rows );
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 948 skipping to change at line 890
//! mat X = Y.subcube(...) //! mat X = Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (in.n_slices != 1), "subview_cube::extract(): given sub cube doesn't have exactly one slice" ); arma_debug_check( (in.n_slices != 1), "subview_cube::extract(): given sub cube doesn't have exactly one slice" );
out.set_size(in.n_rows, in.n_cols); const u32 n_rows = in.n_rows;
const u32 n_cols = in.n_cols;
const u32 aux_slice1 = in.aux_slice1;
for(u32 col = 0; col < in.n_cols; ++col) out.set_size(n_rows, n_cols);
{
const eT* in_coldata = in.slice_colptr(in.aux_slice1, col);
eT* out_coldata = out.colptr(col);
for(u32 row = 0; row < in.n_rows; ++row) for(u32 col = 0; col < n_cols; ++col)
{ {
out_coldata[row] = in_coldata[row]; syslib::copy_elem( out.colptr(col), in.slice_colptr(aux_slice1, col), n
} _rows );
} }
} }
//! cube X += Y.subcube(...) //! cube X += Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 980 skipping to change at line 920
arma_debug_assert_same_size(out, in, "cube addition"); arma_debug_assert_same_size(out, in, "cube addition");
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;
const u32 n_slices = out.n_slices; const u32 n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(u32 slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
eT* out_coldata = out.slice_colptr(slice,col); arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr(
const eT* in_coldata = in.slice_colptr(slice,col); slice,col), n_rows );
for(u32 row = 0; row<n_rows; ++row)
{
out_coldata[row] += in_coldata[row];
}
} }
} }
} }
//! cube X -= Y.subcube(...) //! cube X -= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
skipping to change at line 1009 skipping to change at line 943
arma_debug_assert_same_size(out, in, "cube subtraction"); arma_debug_assert_same_size(out, in, "cube subtraction");
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;
const u32 n_slices = out.n_slices; const u32 n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(u32 slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
eT* out_coldata = out.slice_colptr(slice,col); arrayops::inplace_minus( out.slice_colptr(slice,col), in.slice_colptr
const eT* in_coldata = in.slice_colptr(slice,col); (slice,col), n_rows );
for(u32 row = 0; row<n_rows; ++row)
{
out_coldata[row] -= in_coldata[row];
}
} }
} }
} }
//! cube X %= Y.subcube(...) //! cube X %= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
skipping to change at line 1038 skipping to change at line 966
arma_debug_assert_same_size(out, in, "cube schur product"); arma_debug_assert_same_size(out, in, "cube schur product");
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;
const u32 n_slices = out.n_slices; const u32 n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(u32 slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
eT* out_coldata = out.slice_colptr(slice,col); arrayops::inplace_mul( out.slice_colptr(slice,col), in.slice_colptr(s
const eT* in_coldata = in.slice_colptr(slice,col); lice,col), n_rows );
for(u32 row = 0; row<n_rows; ++row)
{
out_coldata[row] *= in_coldata[row];
}
} }
} }
} }
//! cube X /= Y.subcube(...) //! cube X /= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in)
{ {
skipping to change at line 1067 skipping to change at line 989
arma_debug_assert_same_size(out, in, "element-wise cube division"); arma_debug_assert_same_size(out, in, "element-wise cube division");
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;
const u32 n_slices = out.n_slices; const u32 n_slices = out.n_slices;
for(u32 slice = 0; slice<n_slices; ++slice) for(u32 slice = 0; slice<n_slices; ++slice)
{ {
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
eT* out_coldata = out.slice_colptr(slice,col); arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(s
const eT* in_coldata = in.slice_colptr(slice,col); lice,col), n_rows );
for(u32 row = 0; row<n_rows; ++row)
{
out_coldata[row] /= in_coldata[row];
}
} }
} }
} }
//! mat X += Y.subcube(...) //! mat X += Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix addition"); arma_debug_assert_same_size(out, in, "matrix addition");
for(u32 col = 0; col < in.n_cols; ++col) const u32 in_n_rows = in.n_rows;
{ const u32 in_n_cols = in.n_cols;
const eT* in_coldata = in.slice_colptr(in.aux_slice1, col); const u32 in_aux_slice1 = in.aux_slice1;
eT* out_coldata = out.colptr(col);
for(u32 row = 0; row < in.n_rows; ++row) for(u32 col = 0; col < in_n_cols; ++col)
{ {
out_coldata[row] += in_coldata[row]; arrayops::inplace_plus( out.colptr(col), in.slice_colptr(in_aux_slice1,
} col), in_n_rows );
} }
} }
//! mat X -= Y.subcube(...) //! mat X -= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix subtraction"); arma_debug_assert_same_size(out, in, "matrix subtraction");
for(u32 col = 0; col < in.n_cols; ++col) const u32 in_n_rows = in.n_rows;
{ const u32 in_n_cols = in.n_cols;
const eT* in_coldata = in.slice_colptr(in.aux_slice1, col); const u32 in_aux_slice1 = in.aux_slice1;
eT* out_coldata = out.colptr(col);
for(u32 row = 0; row < in.n_rows; ++row) for(u32 col = 0; col < in_n_cols; ++col)
{ {
out_coldata[row] -= in_coldata[row]; arrayops::inplace_minus( out.colptr(col), in.slice_colptr(in_aux_slice1
} , col), in_n_rows );
} }
} }
//! mat X %= Y.subcube(...) //! mat X %= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix schur product"); arma_debug_assert_same_size(out, in, "matrix schur product");
for(u32 col = 0; col < in.n_cols; ++col) const u32 in_n_rows = in.n_rows;
{ const u32 in_n_cols = in.n_cols;
const eT* in_coldata = in.slice_colptr(in.aux_slice1, col); const u32 in_aux_slice1 = in.aux_slice1;
eT* out_coldata = out.colptr(col);
for(u32 row = 0; row < in.n_rows; ++row) for(u32 col = 0; col < in_n_cols; ++col)
{ {
out_coldata[row] *= in_coldata[row]; arrayops::inplace_mul( out.colptr(col), in.slice_colptr(in_aux_slice1,
} col), in_n_rows );
} }
} }
//! mat X /= Y.subcube(...) //! mat X /= Y.subcube(...)
template<typename eT> template<typename eT>
inline inline
void void
subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix element-wise division"); arma_debug_assert_same_size(out, in, "matrix element-wise division");
for(u32 col = 0; col < in.n_cols; ++col) const u32 in_n_rows = in.n_rows;
{ const u32 in_n_cols = in.n_cols;
const eT* in_coldata = in.slice_colptr(in.aux_slice1, col); const u32 in_aux_slice1 = in.aux_slice1;
eT* out_coldata = out.colptr(col);
for(u32 row = 0; row < in.n_rows; ++row) for(u32 col = 0; col < in_n_cols; ++col)
{ {
out_coldata[row] /= in_coldata[row]; arrayops::inplace_div( out.colptr(col), in.slice_colptr(in_aux_slice1,
} col), in_n_rows );
} }
} }
//! @} //! @}
 End of changes. 87 change blocks. 
273 lines changed or deleted 203 lines changed or added


 subview_field_meat.hpp   subview_field_meat.hpp 
skipping to change at line 262 skipping to change at line 262
( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) ) ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) )
); );
const bool col_overlap = const bool col_overlap =
( (
( (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); const bool overlap = ( (row_overlap == true) && (col_overlap == true) )
;
return overlap;
} }
} }
//! X = Y.subfield(...) //! X = Y.subfield(...)
template<typename oT> template<typename oT>
inline inline
void void
subview_field<oT>::extract(field<oT>& actual_out, const subview_field<oT>& in) subview_field<oT>::extract(field<oT>& actual_out, const subview_field<oT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 1 change blocks. 
1 lines changed or deleted 4 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 61 skipping to change at line 61
, n_rows(1 + in_row2 - in_row1) , n_rows(1 + in_row2 - in_row1)
, n_cols(1 + in_col2 - in_col1) , n_cols(1 + in_col2 - in_col1)
, n_elem(n_rows*n_cols) , n_elem(n_rows*n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::fill(const eT val) subview<eT>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 col = 0; col<n_cols; ++col) const u32 local_n_cols = n_cols;
{ const u32 local_n_rows = n_rows;
eT* coldata = colptr(col);
for(u32 row = 0; row<n_rows; ++row) if(local_n_rows == 1)
{
for(u32 col=0; col<local_n_cols; ++col)
{ {
coldata[row] = val; at(0, col) += val;
} }
} }
else
}
template<typename eT>
inline
void
subview<eT>::operator+= (const eT val)
{
arma_extra_debug_sigprint();
for(u32 col = 0; col<n_cols; ++col)
{ {
eT* coldata = colptr(col); for(u32 col=0; col<local_n_cols; ++col)
for(u32 row = 0; row<n_rows; ++row)
{ {
coldata[row] += val; arrayops::inplace_plus( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator-= (const eT val) subview<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 col = 0; col<n_cols; ++col) const u32 local_n_cols = n_cols;
{ const u32 local_n_rows = n_rows;
eT* coldata = colptr(col);
for(u32 row = 0; row<n_rows; ++row) if(local_n_rows == 1)
{
for(u32 col=0; col<local_n_cols; ++col)
{ {
coldata[row] -= val; at(0, col) -= val;
}
}
else
{
for(u32 col=0; col<local_n_cols; ++col)
{
arrayops::inplace_minus( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator*= (const eT val) subview<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 col = 0; col<n_cols; ++col) const u32 local_n_cols = n_cols;
{ const u32 local_n_rows = n_rows;
eT* coldata = colptr(col);
for(u32 row = 0; row<n_rows; ++row) if(local_n_rows == 1)
{
for(u32 col=0; col<local_n_cols; ++col)
{ {
coldata[row] *= val; at(0, col) *= val;
}
}
else
{
for(u32 col=0; col<local_n_cols; ++col)
{
arrayops::inplace_mul( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator/= (const eT val) subview<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 col = 0; col<n_cols; ++col) const u32 local_n_cols = n_cols;
{ const u32 local_n_rows = n_rows;
eT* coldata = colptr(col);
for(u32 row = 0; row<n_rows; ++row) if(local_n_rows == 1)
{
for(u32 col=0; col<local_n_cols; ++col)
{ {
coldata[row] /= val; at(0, col) /= val;
}
}
else
{
for(u32 col=0; col<local_n_cols; ++col)
{
arrayops::inplace_div( colptr(col), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline arma_inline
void void
subview<eT>::operator_equ_mat(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");
const u32 t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
for(u32 col=0; col<t_n_cols; ++col)
{
syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
}
}
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator_equ_proxy(const Base<eT,T1>& in)
{
arma_extra_debug_sigprint();
const Proxy<T1> x(in.get_ref());
subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix");
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows;
for(u32 col = 0; col<t_n_cols; ++col) if(t_n_rows == 1)
{ {
eT* t_coldata = t.colptr(col); const eT* x_mem = x.memptr();
for(u32 row = 0; row<t_n_rows; ++row) for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] = x.at(row,col); at(0,col) = x_mem[col];
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
}
template<typename eT>
template<typename T1>
arma_inline
void
subview<eT>::operator= (const Base<eT,T1>& in)
{
arma_extra_debug_sigprint();
(is_Mat<T1>::value == true) ? operator_equ_mat(in) : operator_equ_proxy(i
n);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator+= (const Base<eT,T1>& in) subview<eT>::operator+= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> x(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
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) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1)
{ {
eT* t_coldata = t.colptr(col); const eT* x_mem = x.memptr();
for(u32 row = 0; row<t.n_rows; ++row) for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] += x.at(row,col); at(0,col) += x_mem[col];
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator-= (const Base<eT,T1>& in) subview<eT>::operator-= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> x(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
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) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1)
{ {
eT* t_coldata = t.colptr(col); const eT* x_mem = x.memptr();
for(u32 row = 0; row<t.n_rows; ++row) for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] -= x.at(row,col); at(0,col) -= x_mem[col];
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator%= (const Base<eT,T1>& in) subview<eT>::operator%= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> x(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
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) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1)
{ {
eT* t_coldata = t.colptr(col); const eT* x_mem = x.memptr();
for(u32 row = 0; row<t.n_rows; ++row) for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] *= x.at(row,col); at(0,col) *= x_mem[col];
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator/= (const Base<eT,T1>& in) subview<eT>::operator/= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> x(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
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) const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1)
{ {
eT* t_coldata = t.colptr(col); const eT* x_mem = x.memptr();
for(u32 row = 0; row<t.n_rows; ++row) for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] /= x.at(row,col); at(0,col) /= x_mem[col];
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
//! 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();
skipping to change at line 346 skipping to change at line 363
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");
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
for(u32 col = 0; col<t_n_cols; ++col) if(t_n_rows == 1)
{
for(u32 col=0; col<t_n_cols; ++col)
{
t.at(0,col) = x.at(0,col);
}
}
else
{ {
syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows ); for(u32 col=0; col<t_n_cols; ++col)
{
syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
}
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::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) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) if(t_n_rows == 1)
{
for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] += x_coldata[row]; t.at(0,col) += x.at(0,col);
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap)
{
delete tmp_subview;
delete tmp_mat;
}
} }
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 subtraction"); arma_debug_assert_same_size(t, x, "matrix subtraction");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) if(t_n_rows == 1)
{
for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] -= x_coldata[row]; t.at(0,col) -= x.at(0,col);
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 443 skipping to change at line 487
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 schur product"); arma_debug_assert_same_size(t, x, "matrix schur product");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) if(t_n_rows == 1)
{
for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] *= x_coldata[row]; t.at(0,col) *= x.at(0,col);
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 479 skipping to change at line 530
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, "element-wise matrix division"); arma_debug_assert_same_size(t, x, "element-wise matrix division");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_rows = t.n_rows;
{ const u32 t_n_cols = t.n_cols;
eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) if(t_n_rows == 1)
{
for(u32 col=0; col<t_n_cols; ++col)
{
t.at(0,col) /= x.at(0,col);
}
}
else
{
for(u32 col=0; col<t_n_cols; ++col)
{ {
t_coldata[row] /= x_coldata[row]; arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::zeros() subview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>& t = *this; const u32 local_n_cols = n_cols;
const u32 local_n_rows = n_rows;
for(u32 col = 0; col<t.n_cols; ++col) if(local_n_rows == 1)
{ {
eT* t_coldata = t.colptr(col); for(u32 col=0; col<local_n_cols; ++col)
for(u32 row = 0; row<t.n_rows; ++row)
{ {
t_coldata[row] = eT(0); at(0,col) = val;
} }
} }
else
{
for(u32 col=0; col<local_n_cols; ++col)
{
arrayops::inplace_set( colptr(col), val, local_n_rows );
}
}
}
template<typename eT>
inline
void
subview<eT>::zeros()
{
arma_extra_debug_sigprint();
(*this).fill(eT(0));
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview<eT>::operator[](const u32 i) subview<eT>::operator[](const u32 i)
{ {
arma_check( (m_ptr == 0), "subview::operator[]: matrix is read-only");
const u32 in_col = i / n_rows; const u32 in_col = i / n_rows;
const u32 in_row = i % n_rows; const u32 in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
skipping to change at line 551 skipping to change at line 621
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview<eT>::operator()(const u32 i) subview<eT>::operator()(const u32 i)
{ {
arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const u32 in_col = i / n_rows; const u32 in_col = i / n_rows;
const u32 in_row = i % n_rows; const u32 in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
skipping to change at line 580 skipping to change at line 649
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview<eT>::operator()(const u32 in_row, const u32 in_col) subview<eT>::operator()(const u32 in_row, const u32 in_col)
{ {
arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview<eT>::operator()(const u32 in_row, const u32 in_col) const subview<eT>::operator()(const u32 in_row, const u32 in_col) const
skipping to change at line 603 skipping to change at line 671
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview<eT>::at(const u32 in_row, const u32 in_col) subview<eT>::at(const u32 in_row, const u32 in_col)
{ {
arma_check( (m_ptr == 0), "subview::at(): matrix is read-only");
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview<eT>::at(const u32 in_row, const u32 in_col) const subview<eT>::at(const u32 in_row, const u32 in_col) const
{ {
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
subview<eT>::colptr(const u32 in_col) subview<eT>::colptr(const u32 in_col)
{ {
arma_check( (m_ptr == 0), "subview::colptr(): matrix is read-only");
return & access::rw((*m_ptr).mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]); return & access::rw((*m_ptr).mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
subview<eT>::colptr(const u32 in_col) const subview<eT>::colptr(const u32 in_col) const
{ {
return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
} }
skipping to change at line 663 skipping to change at line 727
( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) ) ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) )
); );
const bool col_overlap = const bool col_overlap =
( (
( (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); const bool overlap = ( (row_overlap == true) && (col_overlap == true) )
;
return overlap;
} }
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview<eT>::is_vec() const subview<eT>::is_vec() const
{ {
return ( (n_rows == 1) || (n_cols == 1) ); return ( (n_rows == 1) || (n_cols == 1) );
} }
skipping to change at line 704 skipping to change at line 770
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(in.is_vec() == true) if(in.is_vec() == true)
{ {
if(n_cols == 1) // a column vector if(n_cols == 1) // a column vector
{ {
arma_extra_debug_print("subview::extract(): copying col (going across rows)"); arma_extra_debug_print("subview::extract(): copying col (going across rows)");
eT* out_mem = out.memptr(); // in.colptr(0) the first column of the subview, taking into account
const eT* in_coldata = in.colptr(0); // the first column of the subv any row offset
iew, taking into account any row offset syslib::copy_elem( out.memptr(), in.colptr(0), n_rows );
for(u32 row=0; row<n_rows; ++row)
{
out_mem[row] = in_coldata[row];
}
} }
else // a row vector else // a row vector
{ {
arma_extra_debug_print("subview::extract(): copying row (going across columns)"); arma_extra_debug_print("subview::extract(): copying row (going across columns)");
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 row = in.aux_row1; const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1; const u32 start_col = in.aux_col1;
skipping to change at line 759 skipping to change at line 820
void void
subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix addition"); arma_debug_assert_same_size(out, in, "matrix addition");
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) if(n_rows == 1)
{ {
eT* out_coldata = out.colptr(col); eT* out_mem = out.memptr();
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]; out_mem[col] += in.at(0,col);
}
}
else
{
for(u32 col=0; col<n_cols; ++col)
{
arrayops::inplace_plus(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! X -= Y.submat(...) //! X -= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix subtraction"); arma_debug_assert_same_size(out, in, "matrix subtraction");
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) if(n_rows == 1)
{ {
eT* out_coldata = out.colptr(col); eT* out_mem = out.memptr();
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]; out_mem[col] -= in.at(0,col);
}
}
else
{
for(u32 col=0; col<n_cols; ++col)
{
arrayops::inplace_minus(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! X %= Y.submat(...) //! X %= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "matrix schur product"); arma_debug_assert_same_size(out, in, "matrix schur product");
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) if(n_rows == 1)
{ {
eT* out_coldata = out.colptr(col); eT* out_mem = out.memptr();
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]; out_mem[col] *= in.at(0,col);
}
}
else
{
for(u32 col=0; col<n_cols; ++col)
{
arrayops::inplace_mul(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
//! X /= Y.submat(...) //! X /= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise matrix division"); arma_debug_assert_same_size(out, in, "element-wise matrix division");
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) if(n_rows == 1)
{ {
eT* out_coldata = out.colptr(col); eT* out_mem = out.memptr();
const eT* in_coldata = in.colptr(col);
for(u32 row = 0; row<n_rows; ++row) for(u32 col=0; col<n_cols; ++col)
{
out_mem[col] /= in.at(0,col);
}
}
else
{
for(u32 col=0; col<n_cols; ++col)
{ {
out_coldata[row] /= in_coldata[row]; arrayops::inplace_div(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
// //
// //
// //
template<typename eT> template<typename eT>
arma_inline arma_inline
 End of changes. 106 change blocks. 
183 lines changed or deleted 268 lines changed or added


 subview_proto.hpp   subview_proto.hpp 
skipping to change at line 56 skipping to change at line 56
public: public:
inline ~subview(); inline ~subview();
inline void operator+= (const eT val); inline void operator+= (const eT val);
inline void operator-= (const eT val); inline void operator-= (const eT val);
inline void operator*= (const eT val); inline void operator*= (const eT val);
inline void operator/= (const eT val); inline void operator/= (const eT val);
template<typename T1> inline void operator_equ_mat (const Base<eT,T1>& x
);
template<typename T1> inline void operator_equ_proxy(const Base<eT,T1>& x
);
// deliberately returning void // deliberately returning void
template<typename T1> inline void operator= (const Base<eT,T1>& x); template<typename T1> inline void operator= (const Base<eT,T1>& x);
template<typename T1> inline void operator+= (const Base<eT,T1>& x); template<typename T1> inline void operator+= (const Base<eT,T1>& x);
template<typename T1> inline void operator-= (const Base<eT,T1>& x); template<typename T1> inline void operator-= (const Base<eT,T1>& x);
template<typename T1> inline void operator%= (const Base<eT,T1>& x); template<typename T1> inline void operator%= (const Base<eT,T1>& x);
template<typename T1> inline void operator/= (const Base<eT,T1>& x); template<typename T1> inline void operator/= (const Base<eT,T1>& x);
inline void operator= (const subview& x); inline void operator= (const subview& x);
inline void operator+= (const subview& x); inline void operator+= (const subview& x);
inline void operator-= (const subview& x); inline void operator-= (const subview& x);
 End of changes. 1 change blocks. 
5 lines changed or deleted 0 lines changed or added


 typedef.hpp   typedef.hpp 
skipping to change at line 19 skipping to change at line 19
// 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 typedef //! \addtogroup typedef
//! @{ //! @{
#if UCHAR_MAX == 0xff #if UCHAR_MAX >= 0xff
//! unsigned 8 bit type //! unsigned 8 bit type
typedef unsigned char u8; typedef unsigned char u8;
typedef char s8; typedef char s8;
#else #else
#error "don't know how to typedef 'u8' on this system" #error "don't know how to typedef 'u8' on this system"
#endif #endif
// NOTE: // NOTE:
// "signed char" is not the same as "char". // "signed char" is not the same as "char".
// see http://www.embedded.com/columns/programmingpointers/206107018 // see http://www.embedded.com/columns/programmingpointers/206107018
#if USHRT_MAX == 0xffff #if USHRT_MAX >= 0xffff
//! unsigned 16 bit type //! unsigned 16 bit type
typedef unsigned short u16; typedef unsigned short u16;
typedef short s16; typedef short s16;
#else #else
#error "don't know how to typedef 'u16' on this system" #error "don't know how to typedef 'u16' on this system"
#endif #endif
#if UINT_MAX == 0xffffffff #if UINT_MAX >= 0xffffffff
typedef unsigned int u32; typedef unsigned int u32;
typedef int s32; typedef int s32;
#elif ULONG_MAX == 0xffffffff #elif ULONG_MAX >= 0xffffffff
typedef unsigned long u32; typedef unsigned long u32;
typedef long s32; typedef long s32;
#else #else
#error "don't know how to typedef 'u32' on this system" #error "don't know how to typedef 'u32' on this system"
#endif #endif
// // // //
// // only supported by C++0x, via #include <cstdint>, or by C99, via #incl ude <stdint.h> // // only supported by C++0x, via #include <cstdint>, or by C99, via #incl ude <stdint.h>
// //
// //! unsigned 8 bit type // //! unsigned 8 bit type
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 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/