Base.hpp   Base.hpp 
skipping to change at line 36 skipping to change at line 36
arma_inline arma_inline
const derived& const derived&
get_ref() const get_ref() const
{ {
return static_cast<const derived&>(*this); return static_cast<const derived&>(*this);
} }
}; };
template<typename elem_type, typename derived_vec> template<typename elem_type, typename derived>
struct Base_vec struct BaseVec
{ {
arma_inline arma_inline
const derived_vec& const derived&
get_ref() const get_ref() const
{ {
return static_cast<const derived_vec&>(*this); return static_cast<const derived&>(*this);
} }
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added


 Col_meat.hpp   Col_meat.hpp 
skipping to change at line 31 skipping to change at line 31
Col<eT>::Col() Col<eT>::Col()
: Mat<eT>() : Mat<eT>()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
//! 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) : Mat<eT>(in_n_elem, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT>
inline
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_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
//! construct a column vector from specified text //! construct a column vector from specified text
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const char* text) Col<eT>::Col(const char* text)
: Mat<eT>(text) : Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
skipping to change at line 122 skipping to change at line 132
Col<eT>::operator*=(const Mat<eT>& X) Col<eT>::operator*=(const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
return *this; return *this;
} }
//! construct a column vector from a given auxillary 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(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_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); // set_size(aux_length, 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 );
}
arma_check( (Mat<eT>::n_elem != aux_length), "Col::Col(): don't know how //! construct a column vector from a given auxiliary array of eTs
to handle the given array" ); template<typename eT>
inline
Col<eT>::Col(const eT* aux_mem, const u32 aux_length)
: Mat<eT>(aux_mem, aux_length, 1)
{
arma_extra_debug_sigprint();
syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem ); // set_size(aux_length, 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
) )
skipping to change at line 328 skipping to change at line 376
inline inline
void void
Col<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::set_size( in_n_rows, (std::min)( u32(1), in_n_cols ) ); Mat<eT>::set_size( in_n_rows, (std::min)( u32(1), in_n_cols ) );
arma_debug_check( (in_n_cols > 1), "Col::set_size(): incompatible dimensi ons" ); arma_debug_check( (in_n_cols > 1), "Col::set_size(): incompatible dimensi ons" );
} }
//! change the number of n_rows (this function re-implements mat::copy_siz
e() in order to check the number of columns)
template<typename eT>
inline
void
Col<eT>::copy_size(const Mat<eT>& x)
{
arma_extra_debug_sigprint();
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> template<typename eT>
inline inline
void void
Col<eT>::zeros() Col<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::zeros(); Mat<eT>::zeros();
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::zeros(const u32 in_n_elem) Col<eT>::zeros(const u32 in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::zeros(in_n_elem,1); Mat<eT>::zeros(in_n_elem, 1);
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::zeros( in_n_rows, (std::min)( u32(1), in_n_cols ) ); Mat<eT>::zeros( in_n_rows, (std::min)( u32(1), in_n_cols ) );
arma_debug_check( (in_n_cols > 1), "Col::zeros(): incompatible dimensions " ); arma_debug_check( (in_n_cols > 1), "Col::zeros(): incompatible dimensions " );
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::ones()
{
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();
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) Col<eT>::load(const std::string name, const file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(name,type); Mat<eT>::load(name,type);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
} }
//! @} //! @}
 End of changes. 10 change blocks. 
8 lines changed or deleted 107 lines changed or added


 Col_proto.hpp   Col_proto.hpp 
skipping to change at line 21 skipping to change at line 21
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Col //! \addtogroup Col
//! @{ //! @{
//! 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 Base_vec<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<elem_type>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
inline Col(); inline Col();
inline explicit Col(const u32 n_elem); inline explicit Col(const u32 n_elem);
inline Col(const u32 in_rows, const u32 in_cols);
inline Col(const char* text); inline Col(const char* text);
inline const Col& operator=(const char* text); // TODO: std::string i nput inline const Col& operator=(const char* text); // TODO: std::string i nput
inline Col(const Col& X); inline Col(const Col& X);
inline const Col& operator=(const Col& X); inline const Col& operator=(const Col& X);
//inline explicit Col(const Mat<eT>& X); //inline explicit Col(const Mat<eT>& X);
inline Col(const Mat<eT>& X); inline Col(const Mat<eT>& X);
inline const Col& operator=(const Mat<eT>& X); inline const Col& operator=(const Mat<eT>& X);
inline const Col& operator*=(const Mat<eT>& X); inline const Col& operator*=(const Mat<eT>& X);
inline Col(const eT* aux_mem, const u32 aux_length); inline Col( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols,
const bool copy_aux_mem = true);
inline Col(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols)
;
inline Col( eT* aux_mem, const u32 aux_length, const bool copy_aux_m
em = true);
inline Col(const eT* aux_mem, const u32 aux_length);
template<typename T1, typename T2> template<typename T1, typename T2>
inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
inline Col(const subview<eT>& X); inline Col(const subview<eT>& X);
inline const Col& operator=(const subview<eT>& X); inline const Col& operator=(const subview<eT>& X);
inline const Col& operator*=(const subview<eT>& X); inline const Col& operator*=(const subview<eT>& X);
// TODO: handling of subview_cube
inline Col(const diagview<eT>& X); inline Col(const diagview<eT>& X);
inline const Col& operator=(const diagview<eT>& X); inline const Col& operator=(const diagview<eT>& X);
inline const Col& operator*=(const diagview<eT>& X); inline const Col& operator*=(const diagview<eT>& X);
template<typename T1, typename op_type> inline Col(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline Col(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Col& operator=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Col& operator=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Col& operator*=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Col& operator*=(cons t Op<T1, op_type>& X);
template<typename T1, typename T2, typename glue_type> inline Col(const Glue<T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline Col(const Glue<T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Col& operator=(const Glue<T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Col& operator=(const Glue<T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Col& operator*=(const Glue<T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Col& operator*=(const Glue<T1, T2, glue_type>& X);
inline void set_size(const u32 n_elem); inline void set_size(const u32 n_elem);
inline void set_size(const u32 n_rows, const u32 n_cols); inline void set_size(const u32 n_rows, const u32 n_cols);
inline void copy_size(const Mat<eT>& x);
inline void zeros(); inline void zeros();
inline void zeros(const u32 n_elem); inline void zeros(const u32 n_elem);
inline void zeros(const u32 n_rows, const u32 n_cols); inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones();
inline void ones(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_dete ct); inline void load(const std::string name, const file_type type = auto_dete ct);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
4 lines changed or deleted 19 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 24 skipping to change at line 24
//! \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(n_elem > sizeof(mem_local)/sizeof(eT) ) if(use_aux_mem == false)
{ {
delete [] mem; if(n_elem > sizeof(mem_local)/sizeof(eT) )
{
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;
access::rw(n_elem) = 0; access::rw(n_elem) = 0;
access::rw(mem) = 0; access::rw(mem) = 0;
} }
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)
//, 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)
//, 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);
} }
//! 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_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);
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 u32 new_n_elem = in_n_rows * in_n_cols;
if(n_elem == new_n_elem) if(n_elem == new_n_elem)
{ {
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
} }
else else
{ {
arma_debug_check
(
(use_aux_mem == true),
"Mat::init(): can't change the amount of memory as auxiliary memory i
s in use"
);
if(n_elem > sizeof(mem_local)/sizeof(eT) ) if(n_elem > sizeof(mem_local)/sizeof(eT) )
{ {
delete [] mem; delete [] mem;
} }
if(new_n_elem <= sizeof(mem_local)/sizeof(eT) ) if(new_n_elem <= sizeof(mem_local)/sizeof(eT) )
{ {
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
skipping to change at line 126 skipping to change at line 125
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
} }
else else
{ {
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
} }
} }
} }
//! 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)
//, 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 162
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)
//, 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 237 skipping to change at line 237
} }
else else
arma_check( (line_n_cols != t_n_cols), "Mat::init(): inconsistent n umber of columns in given string"); arma_check( (line_n_cols != t_n_cols), "Mat::init(): inconsistent n umber of columns in given string");
++t_n_rows; ++t_n_rows;
} }
line_start = line_end+1; line_start = line_end+1;
} }
Mat<eT> &x = *this; Mat<eT>& x = *this;
x.set_size(t_n_rows, t_n_cols); x.set_size(t_n_rows, t_n_cols);
line_start = 0; line_start = 0;
line_end = 0; line_end = 0;
u32 row = 0; u32 row = 0;
while( line_start < text.length() ) while( line_start < text.length() )
{ {
skipping to change at line 358 skipping to change at line 358
{ {
access::rw(mem[i]) /= val; access::rw(mem[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)
//, 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 386 skipping to change at line 387
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(x); init(x);
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
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, n_elem );
} }
} }
//! construct a matrix from a given auxillary 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 false, the auxiliary array is used directly (without
allocating memory and copying).
//! the default is to copy the array.
template<typename eT>
inline
Mat<eT>::Mat(eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols, const
bool copy_aux_mem)
: n_rows (copy_aux_mem ? 0 : aux_n_rows )
, n_cols (copy_aux_mem ? 0 : aux_n_cols )
, n_elem (copy_aux_mem ? 0 : aux_n_rows*aux_n_cols)
, use_aux_mem(copy_aux_mem ? false : true )
, mem (copy_aux_mem ? mem : aux_mem )
{
arma_extra_debug_sigprint_this(this);
if(copy_aux_mem == true)
{
init(aux_n_rows, aux_n_cols);
syslib::copy_elem( memptr(), aux_mem, n_elem );
}
}
//! construct a matrix from a given auxiliary read-only array of eTs.
//! 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)
//, 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.
//! This constructor is NOT intended for usage by user code.
//! Its sole purpose is to be used by the Cube class.
template<typename eT>
inline
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_cols (aux_n_cols )
, n_elem (aux_n_rows*aux_n_cols)
, use_aux_mem(true )
, mem (aux_mem )
{
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();
glue_plus::apply_inplace(*this, m); glue_plus::apply_inplace(*this, m);
return *this; return *this;
skipping to change at line 485 skipping to change at line 527
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)
//, 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 e-time abort if eT isn't std::complex 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; typedef typename T1::elem_type T;
arma_type_check< is_complex<T>::value == true >::apply(); //!< compile- time abort if T is std::complex arma_type_check< is_complex<T>::value == true >::apply(); //!< compile- time abort if T is std::complex
skipping to change at line 523 skipping to change at line 566
} }
} }
//! 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)
//, 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>
skipping to change at line 603 skipping to change at line 647
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
template<typename eT>
inline
Mat<eT>::Mat(const subview_cube<eT>& x)
: n_rows(0)
, n_cols(0)
, n_elem(0)
, use_aux_mem(false)
//, mem(0)
, mem(mem)
{
arma_extra_debug_sigprint_this(this);
this->operator=(x);
}
//! construct a matrix from a subview_cube instance
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
subview_cube<eT>::extract(*this, X);
return *this;
}
//! in-place matrix addition (using a single-slice subcube on the right-han
d-side)
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator+=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
subview_cube<eT>::plus_inplace(*this, X);
return *this;
}
//! in-place matrix subtraction (using a single-slice subcube on the right-
hand-side)
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator-=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
subview_cube<eT>::minus_inplace(*this, X);
return *this;
}
//! in-place matrix mutiplication (using a single-slice subcube on the righ
t-hand-side)
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator*=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
const Mat<eT> tmp(X);
glue_times::apply_inplace(*this, tmp);
return *this;
}
//! in-place element-wise matrix mutiplication (using a single-slice subcub
e on the right-hand-side)
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator%=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
subview_cube<eT>::schur_inplace(*this, X);
return *this;
}
//! in-place element-wise matrix division (using a single-slice subcube on
the right-hand-side)
template<typename eT>
inline
const Mat<eT>&
Mat<eT>::operator/=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
subview_cube<eT>::div_inplace(*this, X);
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)
//, 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>
skipping to change at line 696 skipping to change at line 830
Mat<eT>::rows(const u32 in_row1, const u32 in_row2) Mat<eT>::rows(const u32 in_row1, const u32 in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"Mat::rows(): indices out of bounds or incorrectly used" "Mat::rows(): indices out of bounds or incorrectly used"
); );
return subview<eT>(*this, in_row1, 0, in_row2, n_cols-1); return subview<eT>(*this, in_row1, 0, in_row2, ((n_cols>0) ? n_cols-1 : 0 ) );
} }
//! creation of subview (submatrix comprised of specified row vectors) //! creation of subview (submatrix comprised of specified row vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview<eT> const subview<eT>
Mat<eT>::rows(const u32 in_row1, const u32 in_row2) const Mat<eT>::rows(const u32 in_row1, const u32 in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"Mat::rows(): indices out of bounds or incorrectly used" "Mat::rows(): indices out of bounds or incorrectly used"
); );
return subview<eT>(*this, in_row1, 0, in_row2, n_cols-1); return subview<eT>(*this, in_row1, 0, in_row2, ((n_cols>0) ? n_cols-1 : 0 ) );
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview<eT> subview<eT>
Mat<eT>::cols(const u32 in_col1, const u32 in_col2) Mat<eT>::cols(const u32 in_col1, const u32 in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"Mat::cols(): indices out of bounds or incorrectly used" "Mat::cols(): indices out of bounds or incorrectly used"
); );
return subview<eT>(*this, 0, in_col1, n_rows-1, in_col2); return subview<eT>(*this, 0, in_col1, ((n_rows>0) ? n_rows-1 : 0), in_col 2);
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
arma_inline arma_inline
const subview<eT> const subview<eT>
Mat<eT>::cols(const u32 in_col1, const u32 in_col2) const Mat<eT>::cols(const u32 in_col1, const u32 in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"Mat::cols(): indices out of bounds or incorrectly used" "Mat::cols(): indices out of bounds or incorrectly used"
); );
return subview<eT>(*this, 0, in_col1, n_rows-1, in_col2); return subview<eT>(*this, 0, in_col1, ((n_rows>0) ? n_rows-1 : 0), in_col 2);
} }
//! creation of subview (submatrix) //! creation of subview (submatrix)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview<eT> subview<eT>
Mat<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2, co nst u32 in_col2) Mat<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2, co nst u32 in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 887 skipping to change at line 1021
} }
//! 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)
//, 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 999 skipping to change at line 1134
} }
//! 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)
//, 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);
} }
//! 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>
skipping to change at line 1308 skipping to change at line 1444
//! on return, the stream's flags are restored to their original values. //! on return, the stream's flags 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();
cout << extra_text << '\n'; cout << extra_text << '\n';
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 flags 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();
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
user_stream.width(orig_width);
} }
arma_ostream::print(user_stream, *this, true); arma_ostream::print(user_stream, *this, true);
} }
//! print contents of the matrix (to the cout stream), //! print contents of the matrix (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's flags are used as is and are not modified //! the stream's flags are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print(const std::string extra_text) const Mat<eT>::raw_print(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = cout.width();
cout << extra_text << '\n'; cout << extra_text << '\n';
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 flags are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print(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)
{ {
const std::streamsize orig_width = user_stream.width();
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
user_stream.width(orig_width);
} }
arma_ostream::print(user_stream, *this, false); arma_ostream::print(user_stream, *this, false);
} }
//! 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_n_rows, const u32 in_n_cols)
{
arma_extra_debug_sigprint();
init(in_n_rows, in_n_cols);
}
//! change the matrix (without preserving data) to have the same dimensions
as the given matrix
template<typename eT>
template<typename eT2>
inline
void
Mat<eT>::copy_size(const Mat<eT2>& m)
{
arma_extra_debug_sigprint();
init(m.n_rows, m.n_cols);
}
//! fill the matrix with the specified value //! fill the matrix with the specified value
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::fill(const eT val) Mat<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 1409 skipping to change at line 1584
{ {
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()
{
arma_extra_debug_sigprint();
fill(eT(1));
}
template<typename eT>
inline
void
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 );
set_size(in_rows, in_cols);
fill(eT(1));
}
template<typename eT>
inline
void
Mat<eT>::reset() Mat<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0); init(0,0);
} }
//! save the matrix to a file //! save the matrix to a file
template<typename eT> template<typename eT>
inline inline
skipping to change at line 1443 skipping to change at line 1639
case arma_binary: case arma_binary:
diskio::save_arma_binary(*this, name); diskio::save_arma_binary(*this, name);
break; break;
case pgm_binary: case pgm_binary:
diskio::save_pgm_binary(*this, name); diskio::save_pgm_binary(*this, name);
break; break;
default: default:
arma_stop("Mat::save(): unsupported type"); arma_stop("Mat::save(): unsupported file type");
} }
} }
//! load a matrix from a file //! load a matrix from a file
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::load(const std::string name, const file_type type) Mat<eT>::load(const std::string name, const file_type type)
{ {
skipping to change at line 1479 skipping to change at line 1675
case arma_binary: case arma_binary:
diskio::load_arma_binary(*this, name); diskio::load_arma_binary(*this, name);
break; break;
case pgm_binary: case pgm_binary:
diskio::load_pgm_binary(*this, name); diskio::load_pgm_binary(*this, name);
break; break;
default: default:
arma_stop("Mat::load(): unsupported type"); arma_stop("Mat::load(): unsupported file type");
} }
} }
//! 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)
{ {
 End of changes. 38 change blocks. 
26 lines changed or deleted 233 lines changed or added


 Mat_proto.hpp   Mat_proto.hpp 
skipping to change at line 21 skipping to change at line 21
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Mat //! \addtogroup Mat
//! @{ //! @{
//! 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 elements stored in the matrix typedef eT elem_type; //!< the type of elements stored in the matrix
typedef typename get_pod_type<elem_type>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
//!< if eT is std::complex, pod_type is the underlying type used by std:: complex. //!< if eT is std::complex, pod_type is the underlying type used by std:: complex.
//!< otherwise pod_type is the same as elem_type //!< otherwise pod_type is the same as elem_type
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
sed (read-only)
arma_aligned const eT* const mem; //!< pointer to memory used by the mat rix (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[ 16 ];
public: public:
inline ~Mat(); inline ~Mat();
inline Mat(); inline Mat();
inline Mat(const u32 in_rows, const u32 in_cols); inline Mat(const u32 in_rows, const u32 in_cols);
inline void set_size(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(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 80 skipping to change at line 81
inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
inline Mat(const subview<eT>& X); inline Mat(const subview<eT>& X);
inline const Mat& operator=(const subview<eT>& X); inline const Mat& operator=(const subview<eT>& X);
inline const Mat& operator+=(const subview<eT>& X); inline const Mat& operator+=(const subview<eT>& X);
inline const Mat& operator-=(const subview<eT>& X); inline const Mat& operator-=(const subview<eT>& X);
inline const Mat& operator*=(const subview<eT>& X); inline const Mat& operator*=(const subview<eT>& X);
inline const Mat& operator%=(const subview<eT>& X); inline const Mat& operator%=(const subview<eT>& X);
inline const Mat& operator/=(const subview<eT>& X); inline const Mat& operator/=(const subview<eT>& X);
//inline explicit Mat(const subview_cube<eT>& X);
inline Mat(const subview_cube<eT>& X);
inline const Mat& operator=(const subview_cube<eT>& X);
inline const Mat& operator+=(const subview_cube<eT>& X);
inline const Mat& operator-=(const subview_cube<eT>& X);
inline const Mat& operator*=(const subview_cube<eT>& X);
inline const Mat& operator%=(const subview_cube<eT>& X);
inline const Mat& operator/=(const subview_cube<eT>& X);
//inline explicit Mat(const diagview<eT>& X); //inline explicit Mat(const diagview<eT>& X);
inline Mat(const diagview<eT>& X); inline Mat(const diagview<eT>& X);
inline const Mat& operator=(const diagview<eT>& X); inline const Mat& operator=(const diagview<eT>& X);
arma_inline subview_row<eT> row(const u32 row_num); arma_inline subview_row<eT> row(const u32 row_num);
arma_inline const subview_row<eT> row(const u32 row_num) const; arma_inline const subview_row<eT> row(const u32 row_num) const;
arma_inline subview_col<eT> col(const u32 col_num); arma_inline subview_col<eT> col(const u32 col_num);
arma_inline const subview_col<eT> col(const u32 col_num) const; arma_inline const subview_col<eT> col(const u32 col_num) const;
skipping to change at line 153 skipping to change at line 163
arma_inline eT* memptr(); arma_inline eT* memptr();
arma_inline const eT* memptr() const; arma_inline const eT* memptr() const;
inline void print(const std::string extra_text = "") const; inline void print(const std::string extra_text = "") const;
inline void print(std::ostream& user_stream, const std::string extra_text = "") const; inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
inline void raw_print(const std::string extra_text = "") const; inline void raw_print(const std::string extra_text = "") const;
inline void raw_print(std::ostream& user_stream, const std::string extra_ text = "") const; inline void raw_print(std::ostream& user_stream, const std::string extra_ text = "") const;
inline void set_size(const u32 in_rows, const u32 in_cols);
template<typename eT2> inline void copy_size(const Mat<eT2>& m);
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const u32 in_rows, const u32 in_cols); inline void zeros(const u32 in_rows, const u32 in_cols);
inline void ones();
inline void ones(const u32 in_rows, const u32 in_cols);
inline void reset(); inline void reset();
inline void save(const std::string name, const file_type type = arma_bina ry) const; inline void save(const std::string name, const file_type type = arma_bina ry) const;
inline void load(const std::string name, const file_type type = auto_dete ct); inline void load(const std::string name, const file_type type = auto_dete ct);
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);
inline Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons
t u32 aux_n_cols);
friend class Cube<eT>;
}; };
class Mat_aux class Mat_aux
{ {
public: public:
template<typename eT> arma_inline static void prefix_pp(Mat<eT>& x); template<typename eT> arma_inline static void prefix_pp(Mat<eT>& x);
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);
 End of changes. 10 change blocks. 
7 lines changed or deleted 31 lines changed or added


 Op_proto.hpp   Op_proto.hpp 
skipping to change at line 43 skipping to change at line 43
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
inline explicit Op(const T1& in_m); inline explicit Op(const T1& in_m);
inline Op(const T1& in_m, const elem_type in_aux); inline Op(const T1& in_m, const elem_type in_aux);
inline Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_a ux_u32_b); inline Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_a ux_u32_b);
inline Op(const u32 in_aux_u32_a, const u32 in_aux_u32_b, const char junk); inline Op(const u32 in_aux_u32_a, const u32 in_aux_u32_b, const char junk);
inline ~Op(); inline ~Op();
const T1& m; //!< storage of reference to the operand (e.g . a matrix) const T1& m; //!< storage of reference to the operand (e.g . a matrix)
const elem_type aux; //!< storage of auxilliary data, user defined const elem_type aux; //!< storage of auxiliary data, user defined
format format
const u32 aux_u32_a; //!< storage of auxilliary data, u32 format const u32 aux_u32_a; //!< storage of auxiliary data, u32 format
const u32 aux_u32_b; //!< storage of auxilliary data, u32 format const u32 aux_u32_b; //!< storage of auxiliary data, u32 format
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
4 lines changed or deleted 4 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 36 skipping to change at line 36
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) : Mat<eT>(1,in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
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_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
Row<eT>::Row(const char* text) Row<eT>::Row(const char* text)
: Mat<eT>(text) : Mat<eT>(text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
skipping to change at line 108 skipping to change at line 118
const Row<eT>& const Row<eT>&
Row<eT>::operator*=(const Mat<eT>& X) Row<eT>::operator*=(const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator*=(X); Mat<eT>::operator*=(X);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
return *this; return *this;
} }
//! construct a row vector from a given auxillary 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(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_extra_debug_sigprint();
Mat<eT>::set_size(1, aux_length); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
arma_check( (Mat<eT>::n_elem != aux_length), "Row(): don't know how to ha );
ndle the given array" ); }
//! 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();
syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem ); 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(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem)
: Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem)
{
arma_extra_debug_sigprint();
// Mat<eT>::set_size(1, aux_length);
// 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
template<typename eT>
inline
Row<eT>::Row(const eT* aux_mem, const u32 aux_length)
: Mat<eT>(aux_mem, 1, aux_length)
{
arma_extra_debug_sigprint();
// Mat<eT>::set_size(1, aux_length);
// 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
) )
skipping to change at line 310 skipping to change at line 357
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::set_size( (std::min)( u32(1), in_n_rows), in_n_cols ); Mat<eT>::set_size( (std::min)( u32(1), in_n_rows), in_n_cols );
arma_debug_check( (in_n_rows > 1), "Row::set_size(): incompatible dimensi ons" ); arma_debug_check( (in_n_rows > 1), "Row::set_size(): incompatible dimensi ons" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::copy_size(const Mat<eT>& x)
{
arma_extra_debug_sigprint();
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() Row<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::zeros(); Mat<eT>::zeros();
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::zeros(const u32 in_n_elem) Row<eT>::zeros(const u32 in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::zeros(1,in_n_elem); Mat<eT>::zeros(1, in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::zeros( (std::min)( u32(1), in_n_rows), in_n_cols ); Mat<eT>::zeros( (std::min)( u32(1), in_n_rows), in_n_cols );
arma_debug_check( (in_n_rows > 1), "Row<eT>::zeros(): incompatible dimens ions" ); arma_debug_check( (in_n_rows > 1), "Row<eT>::zeros(): incompatible dimens ions" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::ones()
{
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();
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) Row<eT>::load(const std::string name, const file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(name,type); Mat<eT>::load(name,type);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
//! @} //! @}
 End of changes. 8 change blocks. 
7 lines changed or deleted 104 lines changed or added


 Row_proto.hpp   Row_proto.hpp 
skipping to change at line 21 skipping to change at line 21
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup 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 Base_vec<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>::pod_type pod_type; typedef typename get_pod_type<elem_type>::pod_type pod_type;
inline Row(); inline Row();
inline explicit Row(const u32 N); inline explicit Row(const u32 N);
inline Row(const u32 in_rows, const u32 in_cols);
inline Row(const char* text); inline Row(const char* text);
inline const Row& operator=(const char* text); // TODO: std::string i nput inline const Row& operator=(const char* text); // TODO: std::string i nput
inline Row(const Row& X); inline Row(const Row& X);
inline const Row& operator=(const Row& X); inline const Row& operator=(const Row& X);
inline const Row& operator*=(const Row& X); inline const Row& operator*=(const Row& X);
//inline explicit Row(const Mat<eT>& X); //inline explicit Row(const Mat<eT>& X);
inline Row(const Mat<eT>& X); inline Row(const Mat<eT>& X);
inline const Row& operator=(const Mat<eT>& X); inline const Row& operator=(const Mat<eT>& X);
inline const Row& operator*=(const Mat<eT>& X); inline const Row& operator*=(const Mat<eT>& X);
inline Row(const eT* aux_mem, const u32 aux_length); inline Row( eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols,
const bool copy_aux_mem = true);
inline Row(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols)
;
inline Row( eT* aux_mem, const u32 aux_length, const bool copy_aux_m
em = true);
inline Row(const eT* aux_mem, const u32 aux_length);
template<typename T1, typename T2> template<typename T1, typename T2>
inline explicit Row(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Row(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
inline Row(const subview<eT>& X); inline Row(const subview<eT>& X);
inline const Row& operator=(const subview<eT>& X); inline const Row& operator=(const subview<eT>& X);
inline const Row& operator*=(const subview<eT>& X); inline const Row& operator*=(const subview<eT>& X);
// TODO: handling of subview_cube
inline explicit Row(const diagview<eT>& X); inline explicit Row(const diagview<eT>& X);
inline const Row& operator=(const diagview<eT>& X); inline const Row& operator=(const diagview<eT>& X);
inline const Row& operator*=(const diagview<eT>& X); inline const Row& operator*=(const diagview<eT>& X);
template<typename T1, typename op_type> inline Row(cons t Op<T1, op_type> &X); template<typename T1, typename op_type> inline Row(cons t Op<T1, op_type> &X);
template<typename T1, typename op_type> inline const Row& operator=(cons t Op<T1, op_type> &X); template<typename T1, typename op_type> inline const Row& operator=(cons t Op<T1, op_type> &X);
template<typename T1, typename op_type> inline const Row& operator*=(cons t Op<T1, op_type> &X); template<typename T1, typename op_type> inline const Row& operator*=(cons t Op<T1, op_type> &X);
template<typename T1, typename T2, typename glue_type> inline Row(const Glue<T1, T2, glue_type> &X); template<typename T1, typename T2, typename glue_type> inline Row(const Glue<T1, T2, glue_type> &X);
template<typename T1, typename T2, typename glue_type> inline const Row& operator=(const Glue<T1, T2, glue_type> &X); template<typename T1, typename T2, typename glue_type> inline const Row& operator=(const Glue<T1, T2, glue_type> &X);
template<typename T1, typename T2, typename glue_type> inline const Row& operator*=(const Glue<T1, T2, glue_type> &X); template<typename T1, typename T2, typename glue_type> inline const Row& operator*=(const Glue<T1, T2, glue_type> &X);
inline void set_size(const u32 N); inline void set_size(const u32 N);
inline void set_size(const u32 n_rows, const u32 n_cols); inline void set_size(const u32 n_rows, const u32 n_cols);
inline void copy_size(const Mat<eT>& x);
inline void zeros(); inline void zeros();
inline void zeros(const u32 N); inline void zeros(const u32 N);
inline void zeros(const u32 n_rows, const u32 n_cols); inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones();
inline void ones(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_dete ct); inline void load(const std::string name, const file_type type = auto_dete ct);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
4 lines changed or deleted 19 lines changed or added


 armadillo   armadillo 
skipping to change at line 133 skipping to change at line 133
#include "armadillo_bits/syslib_proto.hpp" #include "armadillo_bits/syslib_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/Mat_proto.hpp" #include "armadillo_bits/Mat_proto.hpp"
#include "armadillo_bits/Col_proto.hpp" #include "armadillo_bits/Col_proto.hpp"
#include "armadillo_bits/Row_proto.hpp" #include "armadillo_bits/Row_proto.hpp"
#include "armadillo_bits/Cube_proto.hpp"
#include "armadillo_bits/field_proto.hpp" #include "armadillo_bits/field_proto.hpp"
#include "armadillo_bits/subview_proto.hpp" #include "armadillo_bits/subview_proto.hpp"
#include "armadillo_bits/subview_field_proto.hpp" #include "armadillo_bits/subview_field_proto.hpp"
#include "armadillo_bits/subview_cube_proto.hpp"
#include "armadillo_bits/diagview_proto.hpp" #include "armadillo_bits/diagview_proto.hpp"
#include "armadillo_bits/diskio_proto.hpp" #include "armadillo_bits/diskio_proto.hpp"
#include "armadillo_bits/wall_clock_proto.hpp" #include "armadillo_bits/wall_clock_proto.hpp"
#include "armadillo_bits/running_stat_proto.hpp" #include "armadillo_bits/running_stat_proto.hpp"
#include "armadillo_bits/Op_proto.hpp" #include "armadillo_bits/Op_proto.hpp"
#include "armadillo_bits/OpCube_proto.hpp"
#include "armadillo_bits/Glue_proto.hpp" #include "armadillo_bits/Glue_proto.hpp"
#include "armadillo_bits/GlueCube_proto.hpp"
#include "armadillo_bits/op_diagmat_proto.hpp" #include "armadillo_bits/op_diagmat_proto.hpp"
#include "armadillo_bits/op_dot_proto.hpp" #include "armadillo_bits/op_dot_proto.hpp"
#include "armadillo_bits/op_inv_proto.hpp" #include "armadillo_bits/op_inv_proto.hpp"
#include "armadillo_bits/op_htrans_proto.hpp" #include "armadillo_bits/op_htrans_proto.hpp"
#include "armadillo_bits/op_misc_proto.hpp" #include "armadillo_bits/op_misc_proto.hpp"
#include "armadillo_bits/op_max_proto.hpp" #include "armadillo_bits/op_max_proto.hpp"
#include "armadillo_bits/op_min_proto.hpp" #include "armadillo_bits/op_min_proto.hpp"
#include "armadillo_bits/op_mean_proto.hpp" #include "armadillo_bits/op_mean_proto.hpp"
#include "armadillo_bits/op_median_proto.hpp" #include "armadillo_bits/op_median_proto.hpp"
skipping to change at line 169 skipping to change at line 176
#include "armadillo_bits/op_rand_proto.hpp" #include "armadillo_bits/op_rand_proto.hpp"
#include "armadillo_bits/op_randn_proto.hpp" #include "armadillo_bits/op_randn_proto.hpp"
#include "armadillo_bits/op_scalar_misc_proto.hpp" #include "armadillo_bits/op_scalar_misc_proto.hpp"
#include "armadillo_bits/op_sort_proto.hpp" #include "armadillo_bits/op_sort_proto.hpp"
#include "armadillo_bits/op_sum_proto.hpp" #include "armadillo_bits/op_sum_proto.hpp"
#include "armadillo_bits/op_stddev_proto.hpp" #include "armadillo_bits/op_stddev_proto.hpp"
#include "armadillo_bits/op_trig_proto.hpp" #include "armadillo_bits/op_trig_proto.hpp"
#include "armadillo_bits/op_trans_proto.hpp" #include "armadillo_bits/op_trans_proto.hpp"
#include "armadillo_bits/op_var_proto.hpp" #include "armadillo_bits/op_var_proto.hpp"
#include "armadillo_bits/op_zeros_proto.hpp" #include "armadillo_bits/op_zeros_proto.hpp"
#include "armadillo_bits/op_repmat_proto.hpp"
#include "armadillo_bits/glue_plus_proto.hpp" #include "armadillo_bits/glue_plus_proto.hpp"
#include "armadillo_bits/glue_minus_proto.hpp" #include "armadillo_bits/glue_minus_proto.hpp"
#include "armadillo_bits/glue_times_proto.hpp" #include "armadillo_bits/glue_times_proto.hpp"
#include "armadillo_bits/glue_schur_proto.hpp" #include "armadillo_bits/glue_schur_proto.hpp"
#include "armadillo_bits/glue_div_proto.hpp" #include "armadillo_bits/glue_div_proto.hpp"
#include "armadillo_bits/glue_cube_plus_proto.hpp"
#include "armadillo_bits/glue_cube_minus_proto.hpp"
#include "armadillo_bits/glue_cube_schur_proto.hpp"
#include "armadillo_bits/glue_cube_div_proto.hpp"
// //
// debugging functions // debugging functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
//
// classes that underlay metaprogramming
#include "armadillo_bits/unwrap.hpp" #include "armadillo_bits/unwrap.hpp"
#include "armadillo_bits/unwrap_cube.hpp"
#include "armadillo_bits/Op_meat.hpp" #include "armadillo_bits/Op_meat.hpp"
#include "armadillo_bits/OpCube_meat.hpp"
#include "armadillo_bits/Glue_meat.hpp" #include "armadillo_bits/Glue_meat.hpp"
#include "armadillo_bits/GlueCube_meat.hpp"
#include "armadillo_bits/glue_metaprog.hpp" #include "armadillo_bits/glue_metaprog.hpp"
#include "armadillo_bits/glue_cube_metaprog.hpp"
//
// ostream
#include "armadillo_bits/arma_ostream_proto.hpp"
#include "armadillo_bits/arma_ostream_meat.hpp"
// //
// operators // operators
#include "armadillo_bits/operator_plus.hpp" #include "armadillo_bits/operator_plus.hpp"
#include "armadillo_bits/operator_minus.hpp" #include "armadillo_bits/operator_minus.hpp"
#include "armadillo_bits/operator_times.hpp" #include "armadillo_bits/operator_times.hpp"
#include "armadillo_bits/operator_times_dot.hpp" #include "armadillo_bits/operator_times_dot.hpp"
#include "armadillo_bits/operator_schur.hpp" #include "armadillo_bits/operator_schur.hpp"
#include "armadillo_bits/operator_div.hpp" #include "armadillo_bits/operator_div.hpp"
#include "armadillo_bits/operator_relational.hpp" #include "armadillo_bits/operator_relational.hpp"
// #include "armadillo_bits/operator_cube_plus.hpp"
// ostream #include "armadillo_bits/operator_cube_minus.hpp"
#include "armadillo_bits/operator_cube_times.hpp"
#include "armadillo_bits/operator_cube_schur.hpp"
#include "armadillo_bits/operator_cube_div.hpp"
#include "armadillo_bits/operator_cube_relational.hpp"
#include "armadillo_bits/ostream_mat.hpp" #include "armadillo_bits/operator_ostream.hpp"
#include "armadillo_bits/ostream_diagmat.hpp"
#include "armadillo_bits/ostream_field.hpp"
#include "armadillo_bits/ostream_misc.hpp"
// //
// user accessible functions // user accessible functions
#include "armadillo_bits/fn_conv_to.hpp" #include "armadillo_bits/fn_conv_to.hpp"
#include "armadillo_bits/fn_min.hpp" #include "armadillo_bits/fn_min.hpp"
#include "armadillo_bits/fn_max.hpp" #include "armadillo_bits/fn_max.hpp"
#include "armadillo_bits/fn_accu.hpp" #include "armadillo_bits/fn_accu.hpp"
#include "armadillo_bits/fn_sum.hpp" #include "armadillo_bits/fn_sum.hpp"
#include "armadillo_bits/fn_diagmat.hpp" #include "armadillo_bits/fn_diagmat.hpp"
skipping to change at line 239 skipping to change at line 268
#include "armadillo_bits/fn_median.hpp" #include "armadillo_bits/fn_median.hpp"
#include "armadillo_bits/fn_stddev.hpp" #include "armadillo_bits/fn_stddev.hpp"
#include "armadillo_bits/fn_var.hpp" #include "armadillo_bits/fn_var.hpp"
#include "armadillo_bits/fn_sort.hpp" #include "armadillo_bits/fn_sort.hpp"
#include "armadillo_bits/fn_sort_index.hpp" #include "armadillo_bits/fn_sort_index.hpp"
#include "armadillo_bits/fn_htrans.hpp" #include "armadillo_bits/fn_htrans.hpp"
#include "armadillo_bits/fn_chol.hpp" #include "armadillo_bits/fn_chol.hpp"
#include "armadillo_bits/fn_qr.hpp" #include "armadillo_bits/fn_qr.hpp"
#include "armadillo_bits/fn_svd.hpp" #include "armadillo_bits/fn_svd.hpp"
#include "armadillo_bits/fn_solve.hpp" #include "armadillo_bits/fn_solve.hpp"
#include "armadillo_bits/fn_repmat.hpp"
// //
// class meat // class meat
#include "armadillo_bits/gemm.hpp" #include "armadillo_bits/gemm.hpp"
#include "armadillo_bits/gemv.hpp" #include "armadillo_bits/gemv.hpp"
#include "armadillo_bits/gemm_mixed.hpp" #include "armadillo_bits/gemm_mixed.hpp"
#include "armadillo_bits/podarray_meat.hpp" #include "armadillo_bits/podarray_meat.hpp"
#include "armadillo_bits/auxlib_meat.hpp" #include "armadillo_bits/auxlib_meat.hpp"
#include "armadillo_bits/Mat_meat.hpp" #include "armadillo_bits/Mat_meat.hpp"
#include "armadillo_bits/Col_meat.hpp" #include "armadillo_bits/Col_meat.hpp"
#include "armadillo_bits/Row_meat.hpp" #include "armadillo_bits/Row_meat.hpp"
#include "armadillo_bits/Cube_meat.hpp"
#include "armadillo_bits/field_meat.hpp" #include "armadillo_bits/field_meat.hpp"
#include "armadillo_bits/subview_meat.hpp" #include "armadillo_bits/subview_meat.hpp"
#include "armadillo_bits/subview_field_meat.hpp" #include "armadillo_bits/subview_field_meat.hpp"
#include "armadillo_bits/subview_cube_meat.hpp"
#include "armadillo_bits/diagview_meat.hpp" #include "armadillo_bits/diagview_meat.hpp"
#include "armadillo_bits/diskio_meat.hpp" #include "armadillo_bits/diskio_meat.hpp"
#include "armadillo_bits/wall_clock_meat.hpp" #include "armadillo_bits/wall_clock_meat.hpp"
#include "armadillo_bits/running_stat_meat.hpp" #include "armadillo_bits/running_stat_meat.hpp"
#include "armadillo_bits/op_diagmat_meat.hpp" #include "armadillo_bits/op_diagmat_meat.hpp"
#include "armadillo_bits/op_dot_meat.hpp" #include "armadillo_bits/op_dot_meat.hpp"
#include "armadillo_bits/op_inv_meat.hpp" #include "armadillo_bits/op_inv_meat.hpp"
#include "armadillo_bits/op_htrans_meat.hpp" #include "armadillo_bits/op_htrans_meat.hpp"
skipping to change at line 283 skipping to change at line 315
#include "armadillo_bits/op_rand_meat.hpp" #include "armadillo_bits/op_rand_meat.hpp"
#include "armadillo_bits/op_randn_meat.hpp" #include "armadillo_bits/op_randn_meat.hpp"
#include "armadillo_bits/op_scalar_misc_meat.hpp" #include "armadillo_bits/op_scalar_misc_meat.hpp"
#include "armadillo_bits/op_sort_meat.hpp" #include "armadillo_bits/op_sort_meat.hpp"
#include "armadillo_bits/op_sum_meat.hpp" #include "armadillo_bits/op_sum_meat.hpp"
#include "armadillo_bits/op_stddev_meat.hpp" #include "armadillo_bits/op_stddev_meat.hpp"
#include "armadillo_bits/op_trans_meat.hpp" #include "armadillo_bits/op_trans_meat.hpp"
#include "armadillo_bits/op_trig_meat.hpp" #include "armadillo_bits/op_trig_meat.hpp"
#include "armadillo_bits/op_var_meat.hpp" #include "armadillo_bits/op_var_meat.hpp"
#include "armadillo_bits/op_zeros_meat.hpp" #include "armadillo_bits/op_zeros_meat.hpp"
#include "armadillo_bits/op_repmat_meat.hpp"
#include "armadillo_bits/glue_plus_meat.hpp" #include "armadillo_bits/glue_plus_meat.hpp"
#include "armadillo_bits/glue_minus_meat.hpp" #include "armadillo_bits/glue_minus_meat.hpp"
#include "armadillo_bits/glue_times_meat.hpp" #include "armadillo_bits/glue_times_meat.hpp"
#include "armadillo_bits/glue_schur_meat.hpp" #include "armadillo_bits/glue_schur_meat.hpp"
#include "armadillo_bits/glue_div_meat.hpp" #include "armadillo_bits/glue_div_meat.hpp"
#include "armadillo_bits/deprecated.hpp" #include "armadillo_bits/glue_cube_plus_meat.hpp"
#include "armadillo_bits/glue_cube_minus_meat.hpp"
#include "armadillo_bits/glue_cube_schur_meat.hpp"
#include "armadillo_bits/glue_cube_div_meat.hpp"
} }
#endif #endif
 End of changes. 19 change blocks. 
8 lines changed or deleted 43 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
skipping to change at line 457 skipping to change at line 457
atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp.memptr(), tmp.n_rows, ipiv.memptr()); atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp.memptr(), tmp.n_rows, ipiv.memptr());
// on output tmp appears to be L+U_alt, where U_alt is U with the m ain diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the m ain diagonal set to zero
eT val = tmp.at(0,0); eT val = tmp.at(0,0);
for(u32 i=1; i < tmp.n_rows; ++i) for(u32 i=1; i < tmp.n_rows; ++i)
{ {
val *= tmp.at(i,i); val *= tmp.at(i,i);
} }
eT sign = eT(1); int sign = +1;
for(u32 i=0; i < tmp.n_rows; ++i) for(u32 i=0; i < tmp.n_rows; ++i)
{ {
if(s32(i) != ipiv.mem[i]) if( int(i) != ipiv.mem[i] ) // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0
{ {
sign *= eT(-1); sign *= -1;
} }
} }
return sign*val; return val * eT(sign);
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
{ {
Mat<eT> tmp = X; Mat<eT> tmp = X;
podarray<int> ipiv(tmp.n_rows); podarray<int> ipiv(tmp.n_rows);
int info = 0; int info = 0;
int n_rows = tmp.n_rows; int n_rows = int(tmp.n_rows);
int n_cols = tmp.n_cols; int n_cols = int(tmp.n_cols);
lapack::getrf_(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr (), &info); lapack::getrf_(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr (), &info);
// on output tmp appears to be L+U_alt, where U_alt is U with the m ain diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the m ain diagonal set to zero
eT val = tmp.at(0,0); eT val = tmp.at(0,0);
for(u32 i=1; i < tmp.n_rows; ++i) for(u32 i=1; i < tmp.n_rows; ++i)
{ {
val *= tmp.at(i,i); val *= tmp.at(i,i);
} }
eT sign = eT(1); int sign = +1;
for(u32 i=0; i < tmp.n_rows; ++i) for(u32 i=0; i < tmp.n_rows; ++i)
{ {
if(s32(i) != ipiv.mem[i]) if( int(i) != (ipiv.mem[i] - 1) ) // NOTE: adjustment of -1 is r equired as Fortran counts from 1
{ {
sign *= eT(-1); sign *= -1;
} }
} }
return sign*val; return val * eT(sign);
} }
#else #else
{ {
arma_stop("auxlib::det(): need ATLAS or LAPACK library"); arma_stop("auxlib::det(): need ATLAS or LAPACK library");
return eT(0); return eT(0);
} }
#endif #endif
} }
} }
} }
skipping to change at line 544 skipping to change at line 544
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
{ {
ipiv.set_size(U.n_rows); ipiv.set_size(U.n_rows);
int info = 0; int info = 0;
int n_rows = U.n_rows; int n_rows = U.n_rows;
int n_cols = U.n_cols; int n_cols = U.n_cols;
lapack::getrf_(&n_rows, &n_cols, U.memptr(), &n_rows, ipiv.memptr(), &info); lapack::getrf_(&n_rows, &n_cols, U.memptr(), &n_rows, ipiv.memptr(), &info);
// take into account that Fortran counts from 1
for(u32 i=0; i<U.n_rows; ++i)
{
ipiv[i] -= 1;
}
} }
#endif #endif
L.set_size(U.n_rows, U.n_rows); L.set_size(U.n_rows, U.n_rows);
for(u32 col=0; col<L.n_cols; ++col) for(u32 col=0; col<L.n_cols; ++col)
{ {
for(u32 row=0; row<col; ++row) for(u32 row=0; row<col; ++row)
{ {
skipping to change at line 595 skipping to change at line 602
auxlib::lu(L, U, ipiv, X); auxlib::lu(L, U, ipiv, X);
const u32 n = ipiv.n_elem; const u32 n = ipiv.n_elem;
P.set_size(n,n); P.set_size(n,n);
Mat<eT> ident = eye(n,n); Mat<eT> ident = eye(n,n);
for(u32 i=n; i>0; --i) for(u32 i=n; i>0; --i)
{ {
const u32 j = i-1; const u32 j = i-1;
const u32 k = ipiv[j]-1; const u32 k = ipiv[j];
ident.swap_rows(j,k); ident.swap_rows(j,k);
if(i == n) if(i == n)
{
P = ident; P = ident;
}
else else
{
P *= ident; P *= ident;
}
ident.swap_rows(j,k); ident.swap_rows(j,k);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
auxlib::lu(Mat<eT>& L, Mat<eT>& U, const Mat<eT>& X) auxlib::lu(Mat<eT>& L, Mat<eT>& U, const Mat<eT>& X)
 End of changes. 15 change blocks. 
11 lines changed or deleted 22 lines changed or added


 config.hpp   config.hpp 
skipping to change at line 23 skipping to change at line 23
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
#define ARMA_HAVE_STD_ISFINITE #define ARMA_HAVE_STD_ISFINITE
#define ARMA_HAVE_STD_ISINF #define ARMA_HAVE_STD_ISINF
#define ARMA_HAVE_STD_ISNAN #define ARMA_HAVE_STD_ISNAN
#define ARMA_HAVE_STD_SNPRINTF #define ARMA_HAVE_STD_SNPRINTF
#define ARMA_HAVE_LOG1P #define ARMA_HAVE_LOG1P
#define ARMA_HAVE_GETTIMEOFDAY #define ARMA_HAVE_GETTIMEOFDAY
/* #undef ARMA_USE_ATLAS */ #define ARMA_USE_ATLAS
#define ARMA_USE_LAPACK #define ARMA_USE_LAPACK
#define ARMA_USE_BLAS #define ARMA_USE_BLAS
#define ARMA_USE_BOOST #define ARMA_USE_BOOST
#define ARMA_USE_BOOST_DATE #define ARMA_USE_BOOST_DATE
/* #undef ARMA_EXTRA_DEBUG */ /* #undef ARMA_EXTRA_DEBUG */
/* #undef ARMA_NO_DEBUG */ /* #undef ARMA_NO_DEBUG */
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
#if !defined(ARMA_ATLAS_INCLUDE_DIR) #if !defined(ARMA_ATLAS_INCLUDE_DIR)
#define ARMA_ATLAS_INCLUDE_DIR #define ARMA_ATLAS_INCLUDE_DIR /usr/include
#endif #endif
#endif #endif
#if defined(__CUDACC__) #if defined(__CUDACC__)
#undef ARMA_HAVE_STD_ISFINITE #undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_ISINF #undef ARMA_HAVE_STD_ISINF
#undef ARMA_HAVE_STD_ISNAN #undef ARMA_HAVE_STD_ISNAN
#endif #endif
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 constants.hpp   constants.hpp 
skipping to change at line 157 skipping to change at line 157
typedef Math<float> fmath; typedef Math<float> fmath;
typedef Math<double> math; typedef Math<double> math;
typedef Phy<float> fphy; typedef Phy<float> fphy;
typedef Phy<double> phy; typedef Phy<double> phy;
struct arma_version struct arma_version
{ {
static const unsigned int major = 0; static const unsigned int major = 0;
static const unsigned int minor = 6; static const unsigned int minor = 7;
static const unsigned int patch = 12; static const unsigned int patch = 0;
}; };
struct arma_config struct arma_config
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
static const bool atlas = true; static const bool atlas = true;
#else #else
static const bool atlas = false; static const bool atlas = false;
#endif #endif
 End of changes. 1 change blocks. 
2 lines changed or deleted 2 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 90 skipping to change at line 90
arma_bktprint() arma_bktprint()
{ {
std::cout << std::endl; std::cout << std::endl;
} }
template<typename T1> template<typename T1>
inline inline
void void
arma_bktprint(const T1& x) arma_bktprint(const T1& x)
{ {
std::cout << " [" << x << "]" << std::endl; std::cout << " [" << x << ']' << std::endl;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
arma_bktprint(const T1& x, const T2& y) arma_bktprint(const T1& x, const T2& y)
{ {
std::cout << " [" << x << y << "]" << std::endl; std::cout << " [" << x << y << ']' << std::endl;
} }
#ifdef ARMA_USE_BOOST #ifdef ARMA_USE_BOOST
template<typename T1> template<typename T1>
inline inline
void void
arma_bktprint(const arma_boost::basic_format<T1>& x) arma_bktprint(const arma_boost::basic_format<T1>& x)
{ {
std::cout << " [" << x << "]" << std::endl; std::cout << " [" << x << ']' << std::endl;
} }
#else #else
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
arma_bktprint(const arma_boost::basic_format<T1,T2>& x) arma_bktprint(const arma_boost::basic_format<T1,T2>& x)
{ {
std::cout << " [" << x << "]" << std::endl; std::cout << " [" << x << ']' << std::endl;
} }
#endif #endif
// //
// arma_thisprint // arma_thisprint
inline inline
void void
arma_thisprint(void* this_ptr) arma_thisprint(void* this_ptr)
{ {
std::cout << " [this = " << this_ptr << "]" << std::endl; std::cout << " [this = " << this_ptr << ']' << std::endl;
} }
// //
// arma_warn // arma_warn
//! if state is true, print a message on cout //! if state is true, print a message on cout
template<typename T1> template<typename T1>
inline inline
void void
arma_hot arma_hot
skipping to change at line 233 skipping to change at line 233
arma_hot arma_hot
arma_check(const bool state, const arma_boost::basic_format<T1,T2>& x) arma_check(const bool state, const arma_boost::basic_format<T1,T2>& x)
{ {
if(state==true) if(state==true)
{ {
throw std::runtime_error(str(x)); throw std::runtime_error(str(x));
} }
} }
#endif #endif
//
// functions for checking whether two matrices have the same dimensions
inline inline
std::string std::string
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_rows, const u32 B_n_cols, const char* x) arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_rows, const u32 B_n_cols, const char* x)
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << x << ": incompatible matrix dimensions: (" << A_n_rows << "," << A _n_cols << ") and (" << B_n_rows << "," << B_n_cols << ")"; tmp << x << ": incompatible matrix dimensions: (" << A_n_rows << ',' << A _n_cols << ") and (" << B_n_rows << ',' << B_n_cols << ')';
return tmp.str(); return tmp.str();
} }
inline inline
void void
arma_hot arma_hot
arma_assert_same_size(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n _rows, const u32 B_n_cols, const char* x) arma_assert_same_size(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n _rows, const u32 B_n_cols, const char* x)
{ {
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) ) if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
skipping to change at line 319 skipping to change at line 322
{ {
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) ) if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) )
{ {
throw std::runtime_error throw std::runtime_error
( (
arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_cols, x) arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_cols, x)
); );
} }
} }
//
// functions for checking whether two cubes have the same dimensions
inline
std::string
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32
A_n_slices, const u32 B_n_rows, const u32 B_n_cols, const u32 B_n_slices,
const char* x)
{
std::stringstream tmp;
tmp << x << ": incompatible cube dimensions: (" << A_n_rows << ',' << A_n
_cols << ',' << A_n_slices << ") and (" << B_n_rows << ',' << B_n_cols << '
,' << B_n_slices << ')';
return tmp.str();
}
inline
void
arma_hot
arma_assert_same_size(const u32 A_n_rows, const u32 A_n_cols, const u32 A_n
_slices, const u32 B_n_rows, const u32 B_n_cols, const u32 B_n_slices, cons
t char* x)
{
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_
n_slices) )
{
throw std::runtime_error
(
arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_n_rows, B
_n_cols, B_n_slices, x)
);
}
}
//! if given cubes have different sizes, throw a run-time error exception
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const Cube<eT1>& A, const Cube<eT2>& B, const char* x
)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.
n_slices) )
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B
.n_cols, B.n_slices, x)
);
}
}
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const Cube<eT1>& A, const subview_cube<eT2>& B, const
char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.
n_slices) )
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B
.n_cols, B.n_slices, x)
);
}
}
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const subview_cube<eT1>& A, const Cube<eT2>& B, const
char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.
n_slices) )
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B
.n_cols, B.n_slices, x)
);
}
}
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const subview_cube<eT1>& A, const subview_cube<eT2>&
B, const char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.
n_slices))
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B
.n_cols, B.n_slices, x)
);
}
}
//
// functions for checking whether a cube or subcube can be interpreted as a
matrix (i.e. single slice)
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const Cube<eT1>& A, const Mat<eT2>& B, const char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != 1)
)
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B
.n_cols, 1, x)
);
}
}
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const Mat<eT1>& A, const Cube<eT2>& B, const char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (1 != B.n_slices)
)
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, 1, B.n_rows, B.n_cols,
B.n_slices, x)
);
}
}
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const subview_cube<eT1>& A, const Mat<eT2>& B, const
char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != 1)
)
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B
.n_cols, 1, x)
);
}
}
template<typename eT1, typename eT2>
inline
void
arma_hot
arma_assert_same_size(const Mat<eT1>& A, const subview_cube<eT2>& B, const
char* x)
{
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (1 != B.n_slices)
)
{
throw std::runtime_error
(
arma_incompat_size_string(A.n_rows, A.n_cols, 1, B.n_rows, B.n_cols,
B.n_slices, x)
);
}
}
//
// functions for checking whether two matrices have dimensions that are com
patible with the matrix multiply operation
inline inline
void void
arma_hot arma_hot
arma_assert_mul_size(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_ rows, const u32 B_n_cols, const char* x) arma_assert_mul_size(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_ rows, const u32 B_n_cols, const char* x)
{ {
if(A_n_cols != B_n_rows) if(A_n_cols != B_n_rows)
{ {
throw std::runtime_error throw std::runtime_error
( (
arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x)
 End of changes. 8 change blocks. 
6 lines changed or deleted 196 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 154 skipping to change at line 154
{ {
return std::string("ARMA_MAT_BIN_FC016"); return std::string("ARMA_MAT_BIN_FC016");
} }
else else
{ {
return std::string(); return std::string();
} }
} }
//! Generate the first line of the header used for saving cubes in text for
mat.
//! Format: "ARMA_CUB_TXT_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a
ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i
ndicates eight bytes.
template<typename eT>
inline
std::string
diskio::gen_txt_header(const Cube<eT>& x)
{
arma_type_check<diskio::is_supported_type<eT>::value == false>::apply();
if(is_u8<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IU001");
}
else
if(is_s8<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IS001");
}
else
if(is_u16<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IU002");
}
else
if(is_s16<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IS002");
}
else
if(is_u32<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IU004");
}
else
if(is_s32<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IS004");
}
else
if(is_float<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_FN004");
}
else
if(is_double<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_FN008");
}
else
if(is_complex_float<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_FC008");
}
else
if(is_complex_double<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_FC016");
}
else
{
return std::string();
}
}
//! Generate the first line of the header used for saving cubes in binary f
ormat.
//! Format: "ARMA_CUB_BIN_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a
ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i
ndicates eight bytes.
template<typename eT>
inline
std::string
diskio::gen_bin_header(const Cube<eT>& x)
{
arma_type_check<diskio::is_supported_type<eT>::value == false>::apply();
if(is_u8<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IU001");
}
else
if(is_s8<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IS001");
}
else
if(is_u16<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IU002");
}
else
if(is_s16<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IS002");
}
else
if(is_u32<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IU004");
}
else
if(is_s32<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IS004");
}
else
if(is_float<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_FN004");
}
else
if(is_double<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_FN008");
}
else
if(is_complex_float<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_FC008");
}
else
if(is_complex_double<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_FC016");
}
else
{
return std::string();
}
}
inline inline
char char
diskio::conv_to_hex_char(const u8 x) diskio::conv_to_hex_char(const u8 x)
{ {
char out; char out;
switch(x) switch(x)
{ {
case 0: out = '0'; break; case 0: out = '0'; break;
case 1: out = '1'; break; case 1: out = '1'; break;
case 2: out = '2'; break; case 2: out = '2'; break;
case 3: out = '3'; break; case 3: out = '3'; break;
case 4: out = '4'; break; case 4: out = '4'; break;
case 5: out = '5'; break; case 5: out = '5'; break;
case 6: out = '6'; break; case 6: out = '6'; break;
case 7: out = '7'; break; case 7: out = '7'; break;
skipping to change at line 981 skipping to change at line 1118
else else
{ {
load_raw_ascii(x, name); load_raw_ascii(x, name);
} }
f.close(); f.close();
} }
} }
template<typename T1> // cubes
//! Save a cube as raw text (no header, human readable).
template<typename eT>
inline inline
void void
diskio::save_field_arma_binary(const field<T1>& x, const std::string& final _name) diskio::save_raw_ascii(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary );
std::fstream f(tmp_name.c_str(), std::fstream::out);
if(f.is_open() == false) if(f.is_open() == false)
{ {
arma_print("couldn't write ", tmp_name); arma_print("unable to write ", tmp_name);
} }
else else
{ {
f << "ARMA_FLD_BIN" << '\n'; u32 cell_width;
f << x.n_rows << '\n';
f << x.n_cols << '\n';
for(u32 i=0; i<x.n_elem; ++i) // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
diskio::save_arma_binary(x[i], tmp_name, f); f.setf(ios::scientific);
f.precision(8);
cell_width = 16;
}
for(u32 slice=0; slice < x.n_slices; ++slice)
{
for(u32 row=0; row < x.n_rows; ++row)
{
for(u32 col=0; col < x.n_cols; ++col)
{
f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == tru
e) )
{
f.width(cell_width);
}
f << x.at(row,col,slice);
}
f.put('\n');
}
} }
const bool writing_problem = (f.good() == false); const bool writing_problem = (f.good() == false);
arma_warn(writing_problem, "trouble writing ", tmp_name ); arma_warn(writing_problem, "trouble writing ", tmp_name );
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); diskio::safe_rename(tmp_name, final_name);
} }
} }
} }
template<typename T1> //! Save a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions
template<typename eT>
inline inline
void void
diskio::load_field_arma_binary(field<T1>& x, const std::string& name) diskio::save_arma_ascii(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); const std::string tmp_name = diskio::gen_tmp_name(final_name);
bool load_okay = true;
std::ifstream f( name.c_str() );
if(f.fail())
{
load_okay = false;
arma_extra_debug_print("unable to read ", name);
}
else
{
std::string f_type;
f >> f_type;
if(f_type != "ARMA_FLD_BIN")
{
arma_print("unsupported field type in ", name);
load_okay = false;
}
else
{
u32 f_n_rows;
u32 f_n_cols;
f >> f_n_rows;
f >> f_n_cols;
x.set_size(f_n_rows, f_n_cols);
f.get(); std::ofstream f(tmp_name.c_str());
for(u32 i=0; i<x.n_elem; ++i) diskio::save_arma_ascii(x, tmp_name, f);
{
diskio::load_arma_binary(x[i], name, f);
if(f.good() == false) const bool writing_problem = (f.good() == false);
{
arma_print("trouble reading ", name);
load_okay = false;
break;
}
}
}
}
f.flush();
f.close(); f.close();
if(load_okay == false) arma_warn( writing_problem, "trouble writing ", tmp_name );
if(writing_problem == false)
{ {
x.reset(); diskio::safe_rename(tmp_name, final_name);
} }
} }
template<typename T1> //! Save a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions
template<typename eT>
inline inline
void void
diskio::save_field_ppm_binary(const field<T1>& x, const std::string& final_ name) diskio::save_arma_ascii(const Cube<eT>& x, const std::string& name, std::of stream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply();
typedef typename T1::elem_type eT;
arma_debug_check( (x.n_elem != 3), "diskio::save_field_ppm_binary(): give
n field must have exactly 3 matrices of equal size" );
bool same_size = true;
for(u32 i=1; i<3; ++i)
{
if( (x(0).n_rows != x(i).n_rows) || (x(0).n_cols != x(i).n_cols) )
{
same_size = false;
break;
}
}
arma_debug_check( (same_size != true), "diskio::save_field_ppm_binary():
given field must have exactly 3 matrices of equal size" );
const Mat<eT>& R = x(0);
const Mat<eT>& G = x(1);
const Mat<eT>& B = x(2);
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) if(f.is_open() == false)
{ {
arma_print("couldn't write ", tmp_name); arma_debug_print("unable to write ", name);
} }
else else
{ {
f << "P6" << '\n'; const ios::fmtflags orig_flags = f.flags();
f << R.n_cols << '\n';
f << R.n_rows << '\n';
f << 255 << '\n';
const u32 n_elem = 3 * R.n_rows * R.n_cols; f << diskio::gen_txt_header(x) << '\n';
podarray<u8> tmp(n_elem); f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
u32 i = 0; u32 cell_width;
for(u32 row=0; row < R.n_rows; ++row)
{
for(u32 col=0; col < R.n_cols; ++col)
{
tmp[i+0] = u8( R.at(row,col) );
tmp[i+1] = u8( G.at(row,col) );
tmp[i+2] = u8( B.at(row,col) );
i+=3; // TODO: need sane values for complex numbers
}
}
f.write(reinterpret_cast<const char*>(tmp.mem), n_elem); if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
f.setf(ios::scientific);
f.precision(8);
cell_width = 16;
}
const bool writing_problem = (f.good() == false); for(u32 slice=0; slice < x.n_slices; ++slice)
{
for(u32 row=0; row < x.n_rows; ++row)
{
for(u32 col=0; col < x.n_cols; ++col)
{
f.put(' ');
arma_warn(writing_problem, "trouble writing ", tmp_name ); if( (is_float<eT>::value == true) || (is_double<eT>::value == tru
e) )
{
f.width(cell_width);
}
f.flush(); f << x.at(row,col,slice);
f.close(); }
if(writing_problem == false) f.put('\n');
{ }
diskio::safe_rename(tmp_name, final_name);
} }
f.flags(orig_flags);
} }
} }
template<typename T1> //! Save a cube in binary format,
//! with a header that stores the cube type as well as its dimensions
template<typename eT>
inline inline
void void
diskio::load_field_ppm_binary(field<T1>& x, const std::string& name) diskio::save_arma_binary(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); const std::string tmp_name = diskio::gen_tmp_name(final_name);
typedef typename T1::elem_type eT;
std::fstream f; std::ofstream f(tmp_name.c_str(), std::fstream::binary);
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
diskio::save_arma_binary(x, tmp_name, f);
const bool writing_problem = (f.good() == false);
f.flush();
f.close();
arma_warn( writing_problem, "trouble writing ", tmp_name );
if(writing_problem == false)
{
diskio::safe_rename(tmp_name, final_name);
}
}
//! Save a cube in binary format,
//! with a header that stores the cube type as well as its dimensions
template<typename eT>
inline
void
diskio::save_arma_binary(const Cube<eT>& x, const std::string& name, std::o
fstream& f)
{
arma_extra_debug_sigprint();
if(f.is_open() == false)
{
arma_print("unable to write ", name);
}
else
{
f << diskio::gen_bin_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
}
}
//! Load a cube as raw text (no header, human readable).
//! NOTE: this is much slower than reading a file with a header.
template<typename eT>
inline
void
diskio::load_raw_ascii(Cube<eT>& x, const std::string& name)
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
tmp.load(name);
x.set_size(tmp.n_rows, tmp.n_cols, 1);
if(x.n_slices > 0)
{
x.slice(0) = tmp;
}
}
//! Load a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions
template<typename eT>
inline
void
diskio::load_arma_ascii(Cube<eT>& x, const std::string& name)
{
arma_extra_debug_sigprint();
std::ifstream f(name.c_str());
diskio::load_arma_ascii(x, name, f);
f.close();
}
//! Load a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions
template<typename eT>
inline
void
diskio::load_arma_ascii(Cube<eT>& x, const std::string& name, std::ifstream
& f)
{
arma_extra_debug_sigprint();
bool load_okay = true;
if(f.is_open() == false)
{
load_okay = false;
arma_extra_debug_print("unable to read ", name);
}
else
{
std::string f_header;
u32 f_n_rows;
u32 f_n_cols;
u32 f_n_slices;
f >> f_header;
f >> f_n_rows;
f >> f_n_cols;
f >> f_n_slices;
if(f_header == diskio::gen_txt_header(x))
{
x.set_size(f_n_rows, f_n_cols, f_n_slices);
for(u32 slice=0; slice < x.n_slices; ++slice)
{
for(u32 row=0; row < x.n_rows; ++row)
{
for(u32 col=0; col < x.n_cols; ++col)
{
f >> x.at(row,col,slice);
}
}
}
if(f.good() == false)
{
arma_print("trouble reading ", name);
load_okay = false;
}
}
else
{
arma_print("incorrect header in ", name );
load_okay = false;
}
}
if(load_okay == false)
{
x.reset();
}
}
//! Load a cube in binary format,
//! with a header that indicates the cube type as well as its dimensions
template<typename eT>
inline
void
diskio::load_arma_binary(Cube<eT>& x, const std::string& name)
{
arma_extra_debug_sigprint();
std::ifstream f;
f.open(name.c_str(), std::fstream::binary);
diskio::load_arma_binary(x, name, f);
f.close();
}
template<typename eT>
inline
void
diskio::load_arma_binary(Cube<eT>& x, const std::string& name, std::ifstrea
m& f)
{
arma_extra_debug_sigprint();
bool load_okay = true;
if(f.is_open() == false)
{
load_okay = false;
arma_extra_debug_print("unable to read ", name);
}
else
{
std::string f_header;
u32 f_n_rows;
u32 f_n_cols;
u32 f_n_slices;
f >> f_header;
f >> f_n_rows;
f >> f_n_cols;
f >> f_n_slices;
if(f_header == diskio::gen_bin_header(x))
{
//f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a W
indows machine a newline could be two characters
f.get();
x.set_size(f_n_rows, f_n_cols, f_n_slices);
f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT));
if(f.good() == false)
{
arma_print("trouble reading ", name);
load_okay = false;
}
}
else
{
arma_print("incorrect header in ", name);
load_okay = false;
}
}
if(load_okay == false)
{
x.reset();
}
}
//! Try to load a cube by automatically determining its type
template<typename eT>
inline
void
diskio::load_auto_detect(Cube<eT>& x, const std::string& name)
{
arma_extra_debug_sigprint();
static const std::string ARMA_CUB_TXT = "ARMA_CUB_TXT";
static const std::string ARMA_CUB_BIN = "ARMA_CUB_BIN";
static const std::string P6 = "P6";
std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false)
{
x.reset();
arma_extra_debug_print("unable to read ", name);
}
else
{
podarray<char> raw_header(ARMA_CUB_TXT.length() + 1);
f.read(raw_header.memptr(), ARMA_CUB_TXT.length());
raw_header[ARMA_CUB_TXT.length()] = '\0';
const std::string header = raw_header.mem;
if(ARMA_CUB_TXT == header.substr(0, ARMA_CUB_TXT.length()))
{
load_arma_ascii(x, name);
}
else
if(ARMA_CUB_BIN == header.substr(0, ARMA_CUB_BIN.length()))
{
load_arma_binary(x, name);
}
else
if(P6 == header.substr(0,P6.length()))
{
load_ppm_binary(x, name);
}
else
{
load_raw_ascii(x, name);
}
f.close();
}
}
// fields
template<typename T1>
inline
void
diskio::save_arma_binary(const field<T1>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f
alse) >::apply();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false)
{
arma_print("couldn't write ", tmp_name);
}
else
{
f << "ARMA_FLD_BIN" << '\n';
f << x.n_rows << '\n';
f << x.n_cols << '\n';
for(u32 i=0; i<x.n_elem; ++i)
{
diskio::save_arma_binary(x[i], tmp_name, f);
}
const bool writing_problem = (f.good() == false);
arma_warn(writing_problem, "trouble writing ", tmp_name );
f.flush();
f.close();
if(writing_problem == false)
{
diskio::safe_rename(tmp_name, final_name);
}
}
}
template<typename T1>
inline
void
diskio::load_arma_binary(field<T1>& x, const std::string& name)
{
arma_extra_debug_sigprint();
arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f
alse) >::apply();
bool load_okay = true;
std::ifstream f( name.c_str() );
if(f.fail())
{
load_okay = false;
arma_extra_debug_print("unable to read ", name);
}
else
{
std::string f_type;
f >> f_type;
if(f_type != "ARMA_FLD_BIN")
{
arma_print("unsupported field type in ", name);
load_okay = false;
}
else
{
u32 f_n_rows;
u32 f_n_cols;
f >> f_n_rows;
f >> f_n_cols;
x.set_size(f_n_rows, f_n_cols);
f.get();
for(u32 i=0; i<x.n_elem; ++i)
{
diskio::load_arma_binary(x[i], name, f);
if(f.good() == false)
{
arma_print("trouble reading ", name);
load_okay = false;
break;
}
}
}
}
f.close();
if(load_okay == false)
{
x.reset();
}
}
inline
void
diskio::save_std_string(const field<std::string>& x, const std::string& fin
al_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false)
{
arma_print("couldn't write ", tmp_name);
}
else
{
for(u32 row=0; row<x.n_rows; ++row)
for(u32 col=0; col<x.n_cols; ++col)
{
f << x.at(row,col);
if(col < x.n_cols-1)
{
f << ' ';
}
else
{
f << '\n';
}
}
const bool writing_problem = (f.good() == false);
arma_warn(writing_problem, "trouble writing ", tmp_name );
f.flush();
f.close();
if(writing_problem == false)
{
diskio::safe_rename(tmp_name, final_name);
}
}
}
inline
void
diskio::load_std_string(field<std::string>& x, const std::string& name)
{
arma_extra_debug_sigprint();
bool load_okay = true;
std::ifstream f( name.c_str() );
if(f.fail())
{
load_okay = false;
arma_extra_debug_print("unable to read ", name);
}
else
{
//
// work out the size
u32 f_n_rows = 0;
u32 f_n_cols = 0;
bool f_n_cols_found = false;
std::string line_string;
std::string token;
while( (f.good() == true) && (load_okay == true) )
{
std::getline(f, line_string);
if(line_string.size() == 0)
break;
std::stringstream line_stream(line_string);
u32 line_n_cols = 0;
while (line_stream >> token)
line_n_cols++;
if(f_n_cols_found == false)
{
f_n_cols = line_n_cols;
f_n_cols_found = true;
}
else
{
if(line_n_cols != f_n_cols)
{
load_okay = false;
arma_print("inconsistent number of columns in ", name );
}
}
++f_n_rows;
}
if(load_okay == true)
{
f.clear();
f.seekg(0, ios::beg);
//f.seekg(start);
x.set_size(f_n_rows, f_n_cols);
for(u32 row=0; row < x.n_rows; ++row)
{
for(u32 col=0; col < x.n_cols; ++col)
{
f >> x.at(row,col);
}
}
}
if(f.good() == false)
{
load_okay = false;
arma_print("trouble reading ", name );
}
f.close();
}
if(load_okay == false)
{
x.reset();
}
}
//! Try to load a field by automatically determining its type
template<typename T1>
inline
void
diskio::load_auto_detect(field<T1>& x, const std::string& name)
{
arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply();
static const std::string ARMA_FLD_BIN = "ARMA_FLD_BIN";
static const std::string P6 = "P6";
std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false)
{
x.reset();
arma_extra_debug_print("unable to read ", name);
}
else
{
podarray<char> raw_header(ARMA_FLD_BIN.length() + 1);
f.read(raw_header.memptr(), ARMA_FLD_BIN.length());
raw_header[ARMA_FLD_BIN.length()] = '\0';
const std::string header = raw_header.mem;
if(ARMA_FLD_BIN == header.substr(0,ARMA_FLD_BIN.length()))
{
load_arma_binary(x, name);
}
else
if(P6 == header.substr(0,P6.length()))
{
load_ppm_binary(x, name);
}
else
{
arma_print("unsupported header in ", name);
x.reset();
}
f.close();
}
}
//
// handling of PPM images
template<typename eT>
inline
void
diskio::load_ppm_binary(Cube<eT>& x, const std::string& name)
{
arma_extra_debug_sigprint();
std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
bool load_okay = true; bool load_okay = true;
if(f.is_open() == false) if(f.is_open() == false)
{ {
load_okay = false; load_okay = false;
arma_extra_debug_print("unable to read ", name); arma_extra_debug_print("unable to read ", name);
} }
else else
{ {
skipping to change at line 1206 skipping to change at line 1874
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_n_rows; f >> f_n_rows;
diskio::pnm_skip_comments(f); diskio::pnm_skip_comments(f);
f >> f_maxval; f >> f_maxval;
f.get(); f.get();
if( (f_maxval > 0) || (f_maxval <= 65535) ) if( (f_maxval > 0) || (f_maxval <= 65535) )
{ {
x.set_size(3); x.set_size(f_n_rows, f_n_cols, 3);
Mat<eT>& R = x(0);
Mat<eT>& G = x(1);
Mat<eT>& B = x(2);
R.set_size(f_n_rows,f_n_cols);
G.set_size(f_n_rows,f_n_cols);
B.set_size(f_n_rows,f_n_cols);
if(f_maxval <= 255) if(f_maxval <= 255)
{ {
const u32 n_elem = 3*f_n_cols*f_n_rows; const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem); f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem);
u32 i = 0; u32 i = 0;
//cout << "f_n_cols = " << f_n_cols << endl; //cout << "f_n_cols = " << f_n_cols << endl;
//cout << "f_n_rows = " << f_n_rows << endl; //cout << "f_n_rows = " << f_n_rows << endl;
for(u32 row=0; row < f_n_rows; ++row) for(u32 row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(u32 col=0; col < f_n_cols; ++col)
{ {
R.at(row,col) = eT(tmp[i+0]); x.at(row,col,0) = eT(tmp[i+0]);
G.at(row,col) = eT(tmp[i+1]); x.at(row,col,1) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]); x.at(row,col,2) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
else else
{ {
const u32 n_elem = 3*f_n_cols*f_n_rows; const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem); podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), 2*n_elem); f.read( reinterpret_cast<char *>(tmp.memptr()), 2*n_elem);
u32 i = 0; u32 i = 0;
for(u32 row=0; row < f_n_rows; ++row) for(u32 row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < f_n_cols; ++col) for(u32 col=0; col < f_n_cols; ++col)
{ {
R.at(row,col) = eT(tmp[i+0]); x.at(row,col,0) = eT(tmp[i+0]);
G.at(row,col) = eT(tmp[i+1]); x.at(row,col,1) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]); x.at(row,col,2) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
} }
if(f.good() == false) if(f.good() == false)
skipping to change at line 1287 skipping to change at line 1948
f.close(); f.close();
} }
if(load_okay == false) if(load_okay == false)
{ {
x.reset(); x.reset();
} }
} }
template<typename eT>
inline inline
void void
diskio::save_field_std_string(const field<std::string>& x, const std::strin g& final_name) diskio::save_ppm_binary(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (x.n_slices != 3), "diskio::save_ppm_binary(): given cu
be must have exactly 3 slices" );
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary ); std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) if(f.is_open() == false)
{ {
arma_print("couldn't write ", tmp_name); arma_print("couldn't write ", tmp_name);
} }
else else
{ {
for(u32 row=0; row<x.n_rows; ++row) const u32 n_elem = 3 * x.n_rows * x.n_cols;
for(u32 col=0; col<x.n_cols; ++col) podarray<u8> tmp(n_elem);
{
f << x.at(row,col);
if(col < x.n_cols-1) u32 i = 0;
{ for(u32 row=0; row < x.n_rows; ++row)
f << ' '; {
} for(u32 col=0; col < x.n_cols; ++col)
else
{ {
f << '\n'; tmp[i+0] = u8( x.at(row,col,0) );
tmp[i+1] = u8( x.at(row,col,1) );
tmp[i+2] = u8( x.at(row,col,2) );
i+=3;
} }
} }
f << "P6" << '\n';
f << x.n_cols << '\n';
f << x.n_rows << '\n';
f << 255 << '\n';
f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
const bool writing_problem = (f.good() == false); const bool writing_problem = (f.good() == false);
arma_warn(writing_problem, "trouble writing ", tmp_name ); arma_warn(writing_problem, "trouble writing ", tmp_name );
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); diskio::safe_rename(tmp_name, final_name);
} }
} }
} }
template<typename T1>
inline inline
void void
diskio::load_field_std_string(field<std::string>& x, const std::string& nam e) diskio::load_ppm_binary(field<T1>& x, const std::string& name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; arma_type_check<is_Mat<T1>::value == false>::apply();
typedef typename T1::elem_type eT;
std::ifstream f( name.c_str() ); std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.fail()) bool load_okay = true;
if(f.is_open() == false)
{ {
load_okay = false; load_okay = false;
arma_extra_debug_print("unable to read ", name); arma_extra_debug_print("unable to read ", name);
} }
else else
{ {
// std::string f_header;
// work out the size f >> f_header;
u32 f_n_rows = 0;
u32 f_n_cols = 0;
bool f_n_cols_found = false; if(f_header == "P6")
{
u32 f_n_rows = 0;
u32 f_n_cols = 0;
int f_maxval = 0;
std::string line_string; diskio::pnm_skip_comments(f);
std::string token;
while( (f.good() == true) && (load_okay == true) ) f >> f_n_cols;
{ diskio::pnm_skip_comments(f);
std::getline(f, line_string);
if(line_string.size() == 0)
break;
std::stringstream line_stream(line_string); f >> f_n_rows;
diskio::pnm_skip_comments(f);
u32 line_n_cols = 0; f >> f_maxval;
while (line_stream >> token) f.get();
line_n_cols++;
if(f_n_cols_found == false) if( (f_maxval > 0) || (f_maxval <= 65535) )
{
f_n_cols = line_n_cols;
f_n_cols_found = true;
}
else
{ {
if(line_n_cols != f_n_cols) x.set_size(3);
Mat<eT>& R = x(0);
Mat<eT>& G = x(1);
Mat<eT>& B = x(2);
R.set_size(f_n_rows,f_n_cols);
G.set_size(f_n_rows,f_n_cols);
B.set_size(f_n_rows,f_n_cols);
if(f_maxval <= 255)
{ {
load_okay = false; const u32 n_elem = 3*f_n_cols*f_n_rows;
arma_print("inconsistent number of columns in ", name ); podarray<u8> tmp(n_elem);
}
}
++f_n_rows; f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem);
}
if(load_okay == true) u32 i = 0;
{
f.clear();
f.seekg(0, ios::beg);
//f.seekg(start);
x.set_size(f_n_rows, f_n_cols); //cout << "f_n_cols = " << f_n_cols << endl;
//cout << "f_n_rows = " << f_n_rows << endl;
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < f_n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < f_n_cols; ++col)
{
R.at(row,col) = eT(tmp[i+0]);
G.at(row,col) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]);
i+=3;
}
}
}
else
{ {
f >> x.at(row,col); const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), 2*n_elem);
u32 i = 0;
for(u32 row=0; row < f_n_rows; ++row)
{
for(u32 col=0; col < f_n_cols; ++col)
{
R.at(row,col) = eT(tmp[i+0]);
G.at(row,col) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]);
i+=3;
}
}
} }
} }
}
if(f.good() == false) if(f.good() == false)
{
arma_print("trouble reading ", name);
load_okay = false;
}
}
else
{ {
arma_print("unsupported header in ", name);
load_okay = false; load_okay = false;
arma_print("trouble reading ", name );
} }
f.close(); f.close();
} }
if(load_okay == false) if(load_okay == false)
{ {
x.reset(); x.reset();
} }
} }
//! Try to load a field by automatically determining its type
template<typename T1> template<typename T1>
inline inline
void void
diskio::load_field_auto_detect(field<T1>& x, const std::string& name) diskio::save_ppm_binary(const field<T1>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check<is_Mat<T1>::value == false>::apply();
typedef typename T1::elem_type eT;
static const std::string ARMA_FLD_BIN = "ARMA_FLD_BIN"; arma_debug_check( (x.n_elem != 3), "diskio::save_ppm_binary(): given fiel
static const std::string P6 = "P6"; d must have exactly 3 matrices of equal size" );
std::fstream f; bool same_size = true;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); for(u32 i=1; i<3; ++i)
{
if( (x(0).n_rows != x(i).n_rows) || (x(0).n_cols != x(i).n_cols) )
{
same_size = false;
break;
}
}
arma_debug_check( (same_size != true), "diskio::save_ppm_binary(): given
field must have exactly 3 matrices of equal size" );
const Mat<eT>& R = x(0);
const Mat<eT>& G = x(1);
const Mat<eT>& B = x(2);
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) if(f.is_open() == false)
{ {
x.reset(); arma_print("couldn't write ", tmp_name);
arma_extra_debug_print("unable to read ", name);
} }
else else
{ {
podarray<char> raw_header(ARMA_FLD_BIN.length() + 1); f << "P6" << '\n';
f << R.n_cols << '\n';
f.read(raw_header.memptr(), ARMA_FLD_BIN.length()); f << R.n_rows << '\n';
raw_header[ARMA_FLD_BIN.length()] = '\0'; f << 255 << '\n';
const std::string header = raw_header.mem; const u32 n_elem = 3 * R.n_rows * R.n_cols;
podarray<u8> tmp(n_elem);
if(ARMA_FLD_BIN == header.substr(0,ARMA_FLD_BIN.length())) u32 i = 0;
{ for(u32 row=0; row < R.n_rows; ++row)
load_field_arma_binary(x, name);
}
else
if(P6 == header.substr(0,P6.length()))
{ {
load_field_ppm_binary(x, name); for(u32 col=0; col < R.n_cols; ++col)
{
tmp[i+0] = u8( R.at(row,col) );
tmp[i+1] = u8( G.at(row,col) );
tmp[i+2] = u8( B.at(row,col) );
i+=3;
}
} }
else
f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
const bool writing_problem = (f.good() == false);
arma_warn(writing_problem, "trouble writing ", tmp_name );
f.flush();
f.close();
if(writing_problem == false)
{ {
arma_print("unsupported header in ", name); diskio::safe_rename(tmp_name, final_name);
x.reset();
} }
f.close();
} }
} }
//! @} //! @}
 End of changes. 86 change blocks. 
216 lines changed or deleted 965 lines changed or added


 diskio_proto.hpp   diskio_proto.hpp 
skipping to change at line 42 skipping to change at line 42
|| is_s16<eT>::value || is_s16<eT>::value
|| is_u32<eT>::value || is_u32<eT>::value
|| is_s32<eT>::value || is_s32<eT>::value
|| is_float<eT>::value || is_float<eT>::value
|| is_double<eT>::value || is_double<eT>::value
|| is_complex_float<eT>::value || is_complex_float<eT>::value
|| is_complex_double<eT>::value || is_complex_double<eT>::value
); );
}; };
template<typename eT> template<typename eT> inline static std::string gen_txt_header(const Mat<
inline static std::string gen_txt_header(const Mat<eT>& x); eT>& x);
template<typename eT> inline static std::string gen_bin_header(const Mat<
eT>& x);
template<typename eT> template<typename eT> inline static std::string gen_txt_header(const Cube
inline static std::string gen_bin_header(const Mat<eT>& x); <eT>& x);
template<typename eT> inline static std::string gen_bin_header(const Cube
<eT>& x);
inline static char conv_to_hex_char(const u8 x); inline static char conv_to_hex_char(const u8 x);
inline static void conv_to_hex(char* out, const u8 x); inline static void conv_to_hex(char* out, const u8 x);
inline static std::string gen_tmp_name(const std::string& x); inline static std::string gen_tmp_name(const std::string& x);
inline static void safe_rename(const std::string& old_name, const std::st ring& new_name); inline static void safe_rename(const std::string& old_name, const std::st ring& new_name);
// //
// saving // matrix saving
template<typename eT> template<typename eT> inline static void save_raw_ascii (const Mat<eT>&
inline static void save_raw_ascii (const Mat<eT>& x, const std::string& x, const std::string& name);
name); template<typename eT> inline static void save_arma_ascii (const Mat<eT>&
x, const std::string& name);
template<typename eT> template<typename eT> inline static void save_arma_ascii (const Mat<eT>&
inline static void save_arma_ascii (const Mat<eT>& x, const std::string& x, const std::string& name, std::ofstream& f);
name); template<typename eT> inline static void save_arma_binary(const Mat<eT>&
x, const std::string& name);
template<typename eT> template<typename eT> inline static void save_arma_binary(const Mat<eT>&
inline static void save_arma_ascii (const Mat<eT>& x, const std::string& x, const std::string& name, std::ofstream& f);
name, std::ofstream& f); template<typename eT> inline static void save_pgm_binary (const Mat<eT>&
x, const std::string& name);
template<typename eT> template<typename T> inline static void save_pgm_binary (const Mat< std:
inline static void save_arma_binary(const Mat<eT>& x, const std::string& :complex<T> >& x, const std::string& name);
name);
template<typename eT>
inline static void save_arma_binary(const Mat<eT>& x, const std::string&
name, std::ofstream& f);
template<typename eT>
inline static void save_pgm_binary (const Mat<eT>& x, const std::string&
name);
template<typename T>
inline static void save_pgm_binary (const Mat< std::complex<T> >& x, cons
t std::string& name);
// //
// loading // matrix loading
template<typename eT>
inline static void load_raw_ascii (Mat<eT>& x, const std::string& name);
template<typename eT>
inline static void load_arma_ascii (Mat<eT>& x, const std::string& name);
template<typename eT> template<typename eT> inline static void load_raw_ascii (Mat<eT>& x, con
inline static void load_arma_ascii (Mat<eT>& x, const std::string& name, st std::string& name);
std::ifstream& f); template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con
st std::string& name);
template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con
st std::string& name, std::ifstream& f);
template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con
st std::string& name);
template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con
st std::string& name, std::ifstream& f);
template<typename eT> inline static void load_pgm_binary (Mat<eT>& x, con
st std::string& name);
template<typename T> inline static void load_pgm_binary (Mat< std::compl
ex<T> >& x, const std::string& name);
template<typename eT> inline static void load_auto_detect(Mat<eT>& x, con
st std::string& name);
template<typename eT> inline static void pnm_skip_comments(std::fstream& f);
inline static void load_arma_binary(Mat<eT>& x, const std::string& name);
template<typename eT> //
inline static void load_arma_binary(Mat<eT>& x, const std::string& name, // cube saving
std::ifstream& f);
template<typename eT> template<typename eT> inline static void save_raw_ascii (const Cube<eT>&
inline static void load_pgm_binary (Mat<eT>& x, const std::string& name); x, const std::string& name);
template<typename eT> inline static void save_arma_ascii (const Cube<eT>&
x, const std::string& name);
template<typename eT> inline static void save_arma_ascii (const Cube<eT>&
x, const std::string& name, std::ofstream& f);
template<typename eT> inline static void save_arma_binary(const Cube<eT>&
x, const std::string& name);
template<typename eT> inline static void save_arma_binary(const Cube<eT>&
x, const std::string& name, std::ofstream& f);
template<typename T> //
inline static void load_pgm_binary (Mat< std::complex<T> >& x, const std: // cube loading
:string& name);
template<typename eT> template<typename eT> inline static void load_raw_ascii (Cube<eT>& x, co
inline static void load_auto_detect(Mat<eT>& x, const std::string& name); nst std::string& name);
template<typename eT> inline static void load_arma_ascii (Cube<eT>& x, co
inline static void pnm_skip_comments(std::fstream& f); nst std::string& name);
template<typename eT> inline static void load_arma_ascii (Cube<eT>& x, co
nst std::string& name, std::ifstream& f);
template<typename eT> inline static void load_arma_binary(Cube<eT>& x, co
nst std::string& name);
template<typename eT> inline static void load_arma_binary(Cube<eT>& x, co
nst std::string& name, std::ifstream& f);
template<typename eT> inline static void load_auto_detect(Cube<eT>& x, co
nst std::string& name);
//
// field saving and loading // field saving and loading
template<typename T1> template<typename T1> inline static void save_arma_binary(const field<T1>
inline static void save_field_arma_binary(const field<T1>& x, const std:: & x, const std::string& name);
string& name); template<typename T1> inline static void load_arma_binary( field<T1>
& x, const std::string& name);
template<typename T1> inline static void save_std_string(const field<std::string>& x, const std
inline static void load_field_arma_binary( field<T1>& x, const std:: ::string& name);
string& name); inline static void load_std_string( field<std::string>& x, const std
::string& name);
template<typename T1> template<typename T1> inline static void load_auto_detect(field<T1>& x, c
inline static void save_field_ppm_binary(const field<T1>& x, const std::s onst std::string& name);
tring& final_name);
template<typename T1> //
inline static void load_field_ppm_binary( field<T1>& x, const std::s // PPM images
tring& final_name);
inline static void save_field_std_string(const field<std::string>& x, con template<typename T1> inline static void save_ppm_binary(const Cube<T1>&
st std::string& name); x, const std::string& final_name);
inline static void load_field_std_string( field<std::string>& x, con template<typename T1> inline static void load_ppm_binary( Cube<T1>&
st std::string& name); x, const std::string& final_name);
template<typename T1> template<typename T1> inline static void save_ppm_binary(const field<T1>&
inline static void load_field_auto_detect(field<T1>& x, const std::string x, const std::string& final_name);
& name); template<typename T1> inline static void load_ppm_binary( field<T1>&
x, const std::string& final_name);
}; };
//! @} //! @}
 End of changes. 18 change blocks. 
75 lines changed or deleted 88 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 156 skipping to change at line 156
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::set_size(const u32 n_rows_in, const u32 n_cols_in) field<oT>::set_size(const u32 n_rows_in, const u32 n_cols_in)
{ {
arma_extra_debug_sigprint(arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in); arma_extra_debug_sigprint(arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in);
init(n_rows_in, n_cols_in); init(n_rows_in, n_cols_in);
} }
//! change the field to have the specified dimensions (data is not preserve
d)
template<typename oT>
inline
void
field<oT>::copy_size(const field<oT>& x)
{
arma_extra_debug_sigprint();
if(this != &x)
{
init(x.n_rows, x.n_cols);
}
}
//! linear element accessor (treats the field as a vector); no bounds check //! linear element accessor (treats the field as a vector); no bounds check
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
field<oT>::operator[] (const u32 i) field<oT>::operator[] (const u32 i)
{ {
return (*mem[i]); return (*mem[i]);
} }
//! linear element accessor (treats the field as a vector); no bounds check //! linear element accessor (treats the field as a vector); no bounds check
skipping to change at line 382 skipping to change at line 396
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (i n_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (i n_col2 >= n_cols),
"field::subfield(): indices out of bounds or incorrectly used" "field::subfield(): indices out of bounds or incorrectly used"
); );
return subview_field<oT>(*this, in_row1, in_col1, in_row2, in_col2); return subview_field<oT>(*this, in_row1, in_col1, in_row2, in_col2);
} }
//! print contents of the field, optionally preceding with a user specified //! print contents of the field (to the cout stream),
line of text //! optionally preceding with a user specified line of text.
//! the field class preserves the stream's flags
//! but the associated operator<< function for type oT
//! may still modify the stream's parameters.
//! NOTE: this function assumes that type oT can be printed,
//! i.e. the function "std::ostream& operator<< (std::ostream&, const oT&)"
//! has been defined.
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::print(const std::string extra_text) const field<oT>::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();
cout << extra_text << '\n'; cout << extra_text << '\n';
cout.width(orig_width);
}
arma_ostream::print(cout, *this);
}
//! print contents of the field to a user specified stream,
//! optionally preceding with a user specified line of text.
//! the field class preserves the stream's flags
//! but the associated operator<< function for type oT
//! may still modify the stream's parameters.
//! NOTE: this function assumes that type oT can be printed,
//! i.e. the function "std::ostream& operator<< (std::ostream&, const oT&)"
//! has been defined.
template<typename oT>
inline
void
field<oT>::print(std::ostream& user_stream, const std::string extra_text) c
onst
{
arma_extra_debug_sigprint();
if(extra_text.length() != 0)
{
const std::streamsize orig_width = user_stream.width();
user_stream << extra_text << '\n';
user_stream.width(orig_width);
} }
cout << *this << '\n'; arma_ostream::print(user_stream, *this);
} }
//! fill the field with an object //! fill the field with an object
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::fill(const oT& x) field<oT>::fill(const oT& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 618 skipping to change at line 672
field_aux::reset_objects(field< Row<eT> >& x) field_aux::reset_objects(field< Row<eT> >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(u32 i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).reset(); (*(x.mem[i])).reset();
} }
} }
template<typename eT>
inline
void
field_aux::reset_objects(field< Cube<eT> >& x)
{
arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i)
{
(*(x.mem[i])).reset();
}
}
inline inline
void void
field_aux::reset_objects(field< std::string >& x) field_aux::reset_objects(field< std::string >& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 i=0; i<x.n_elem; ++i) for(u32 i=0; i<x.n_elem; ++i)
{ {
(*(x.mem[i])).clear(); (*(x.mem[i])).clear();
} }
skipping to change at line 665 skipping to change at line 732
template<typename eT> template<typename eT>
inline inline
void void
field_aux::save(const field< Mat<eT> >& x, const std::string& name, const f ile_type type) field_aux::save(const field< Mat<eT> >& x, const std::string& name, const f ile_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_field_arma_binary(x, name); diskio::save_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_field_ppm_binary(x, name); diskio::save_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); arma_stop("field_aux::save(): unsupported type");
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::load(field< Mat<eT> >& x, const std::string& name, const file_ty pe type) field_aux::load(field< Mat<eT> >& x, const std::string& name, const file_ty pe type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_field_auto_detect(x, name); diskio::load_auto_detect(x, name);
break; break;
case arma_binary: case arma_binary:
diskio::load_field_arma_binary(x, name); diskio::load_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_field_ppm_binary(x, name); diskio::load_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); arma_stop("field_aux::load(): unsupported type");
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::save(const field< Col<eT> >& x, const std::string& name, const f ile_type type) field_aux::save(const field< Col<eT> >& x, const std::string& name, const f ile_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_field_arma_binary(x, name); diskio::save_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_field_ppm_binary(x, name); diskio::save_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); arma_stop("field_aux::save(): unsupported type");
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::load(field< Col<eT> >& x, const std::string& name, const file_ty pe type) field_aux::load(field< Col<eT> >& x, const std::string& name, const file_ty pe type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_field_auto_detect(x, name); diskio::load_auto_detect(x, name);
break; break;
case arma_binary: case arma_binary:
diskio::load_field_arma_binary(x, name); diskio::load_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_field_ppm_binary(x, name); diskio::load_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); arma_stop("field_aux::load(): unsupported type");
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::save(const field< Row<eT> >& x, const std::string& name, const f ile_type type) field_aux::save(const field< Row<eT> >& x, const std::string& name, const f ile_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_field_arma_binary(x, name); diskio::save_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_field_ppm_binary(x, name); diskio::save_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); arma_stop("field_aux::save(): unsupported type");
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
field_aux::load(field< Row<eT> >& x, const std::string& name, const file_ty pe type) field_aux::load(field< Row<eT> >& x, const std::string& name, const file_ty pe type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_field_auto_detect(x, name); diskio::load_auto_detect(x, name);
break;
case arma_binary:
diskio::load_arma_binary(x, name);
break;
case ppm_binary:
diskio::load_ppm_binary(x, name);
break;
default:
arma_stop("field_aux::load(): unsupported type");
}
}
template<typename eT>
inline
void
field_aux::save(const field< Cube<eT> >& x, const std::string& name, const
file_type type)
{
arma_extra_debug_sigprint();
switch(type)
{
case arma_binary:
diskio::save_arma_binary(x, name);
break;
case ppm_binary:
diskio::save_ppm_binary(x, name);
break;
default:
arma_stop("field_aux::save(): unsupported type");
}
}
template<typename eT>
inline
void
field_aux::load(field< Cube<eT> >& x, const std::string& name, const file_t
ype type)
{
arma_extra_debug_sigprint();
switch(type)
{
case auto_detect:
diskio::load_auto_detect(x, name);
break; break;
case arma_binary: case arma_binary:
diskio::load_field_arma_binary(x, name); diskio::load_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_field_ppm_binary(x, name); diskio::load_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); arma_stop("field_aux::load(): unsupported type");
} }
} }
inline inline
void void
field_aux::save(const field< std::string >& x, const std::string& name, con st file_type type) field_aux::save(const field< std::string >& x, const std::string& name, con st file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diskio::save_field_std_string(x, name); diskio::save_std_string(x, name);
} }
inline inline
void void
field_aux::load(field< std::string >& x, const std::string& name, const fil e_type type) field_aux::load(field< std::string >& x, const std::string& name, const fil e_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diskio::load_field_std_string(x, name); diskio::load_std_string(x, name);
} }
//! @} //! @}
 End of changes. 23 change blocks. 
20 lines changed or deleted 138 lines changed or added


 field_proto.hpp   field_proto.hpp 
skipping to change at line 53 skipping to change at line 53
inline field(const field& x); inline field(const field& x);
inline const field& operator=(const field& x); inline const field& operator=(const field& x);
inline field(const subview_field<oT>& x); inline field(const subview_field<oT>& x);
inline const field& operator=(const subview_field<oT>& x); inline const field& operator=(const subview_field<oT>& x);
inline explicit field(const u32 n_elem_in); inline explicit field(const u32 n_elem_in);
inline field(const u32 n_rows_in, const u32 n_cols_in); inline field(const u32 n_rows_in, const u32 n_cols_in);
inline void set_size(const u32 n_obj_in); inline void set_size(const u32 n_obj_in);
inline void set_size(const u32 n_rows_in, const u32 n_cols_in); inline void set_size(const u32 n_rows_in, const u32 n_cols_in);
inline void copy_size(const field& x);
arma_inline oT& operator[](const u32 i); arma_inline oT& operator[](const u32 i);
arma_inline const oT& operator[](const u32 i) const; arma_inline const oT& operator[](const u32 i) const;
arma_inline oT& operator()(const u32 i); arma_inline oT& operator()(const u32 i);
arma_inline const oT& operator()(const u32 i) const; arma_inline const oT& operator()(const u32 i) const;
arma_inline oT& at(const u32 row, const u32 col); arma_inline oT& at(const u32 row, const u32 col);
arma_inline const oT& at(const u32 row, const u32 col) const; arma_inline const oT& at(const u32 row, const u32 col) const;
skipping to change at line 84 skipping to change at line 85
inline subview_field<oT> rows(const u32 in_row1, const u32 in_row2) ; inline subview_field<oT> rows(const u32 in_row1, const u32 in_row2) ;
inline const subview_field<oT> rows(const u32 in_row1, const u32 in_row2) const; inline const subview_field<oT> rows(const u32 in_row1, const u32 in_row2) const;
inline subview_field<oT> cols(const u32 in_col1, const u32 in_col2) ; inline subview_field<oT> cols(const u32 in_col1, const u32 in_col2) ;
inline const subview_field<oT> cols(const u32 in_col1, const u32 in_col2) const; inline const subview_field<oT> cols(const u32 in_col1, const u32 in_col2) const;
inline subview_field<oT> subfield(const u32 in_row1, const u32 in_c ol1, const u32 in_row2, const u32 in_col2); inline subview_field<oT> subfield(const u32 in_row1, const u32 in_c ol1, const u32 in_row2, const u32 in_col2);
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 fill(const oT& x); inline void fill(const oT& x);
inline void reset(); inline void reset();
inline void reset_objects(); inline void reset_objects();
inline void save(const std::string name, const file_type type = arma_bina ry) const; inline void save(const std::string name, const file_type type = arma_bina ry) const;
inline void load(const std::string name, const file_type type = auto_dete ct); inline void load(const std::string name, const file_type type = auto_dete ct);
private: private:
skipping to change at line 109 skipping to change at line 111
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>;
}; };
class field_aux class field_aux
{ {
public: public:
template<typename oT> template<typename oT> inline static void reset_objects(field< oT >& x);
inline static void reset_objects(field< oT >& x); template<typename eT> inline static void reset_objects(field< Mat<eT> >&
x);
template<typename eT> inline static void reset_objects(field< Col<eT> >&
x);
template<typename eT> inline static void reset_objects(field< Row<eT> >&
x);
template<typename eT> inline static void reset_objects(field< Cube<eT> >&
x);
inline static void reset_objects(field< std::string
>& x);
template<typename oT> inline static void save(const field< oT >& x,
const std::string& name, const file_type type);
template<typename oT> inline static void load( field< oT >& x,
const std::string& name, const file_type type);
template<typename eT> inline static void save(const field< Mat<eT> >& x,
const std::string& name, const file_type type);
template<typename eT> inline static void load( field< Mat<eT> >& x,
const std::string& name, const file_type type);
template<typename eT> inline static void save(const field< Col<eT> >& x,
const std::string& name, const file_type type);
template<typename eT> inline static void load( field< Col<eT> >& x,
const std::string& name, const file_type type);
template<typename eT> template<typename eT> inline static void save(const field< Row<eT> >& x,
inline static void reset_objects(field< Mat<eT> >& x); const std::string& name, const file_type type);
template<typename eT> inline static void load( field< Row<eT> >& x,
const std::string& name, const file_type type);
template<typename eT> template<typename eT> inline static void save(const field< Cube<eT> >& x,
inline static void reset_objects(field< Col<eT> >& x); const std::string& name, const file_type type);
template<typename eT> inline static void load( field< Cube<eT> >& x,
const std::string& name, const file_type type);
template<typename eT> inline static void save(const field< std::string >&
inline static void reset_objects(field< Row<eT> >& x); x, const std::string& name, const file_type type);
inline static void load( field< std::string >&
inline static void reset_objects(field< std::string >& x); x, const std::string& name, const file_type type);
template<typename oT>
inline static void save(const field< oT >& x, const std::string&
name, const file_type type);
template<typename oT>
inline static void load( field< oT >& x, const std::string&
name, const file_type type);
template<typename eT>
inline static void save(const field< Mat<eT> >& x, const std::string&
name, const file_type type);
template<typename eT>
inline static void load( field< Mat<eT> >& x, const std::string&
name, const file_type type);
template<typename eT>
inline static void save(const field< Col<eT> >& x, const std::string&
name, const file_type type);
template<typename eT>
inline static void load( field< Col<eT> >& x, const std::string&
name, const file_type type);
template<typename eT>
inline static void save(const field< Row<eT> >& x, const std::string&
name, const file_type type);
template<typename eT>
inline static void load( field< Row<eT> >& x, const std::string&
name, const file_type type);
inline static void save(const field< std::string >& x, const std::string&
name, const file_type type);
inline static void load( field< std::string >& x, const std::string&
name, const file_type type);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
49 lines changed or deleted 42 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
skipping to change at line 460 skipping to change at line 460
const u32 B_row_mod = B_aux_row1 + row; const u32 B_row_mod = B_aux_row1 + row;
val += A.at(A_row_mod, A_col_mod) * B.at(B_row_mod, B_col_mod); val += A.at(A_row_mod, A_col_mod) * B.at(B_row_mod, B_col_mod);
} }
} }
return val; return val;
} }
//
//
// Cube handling
//! accumulate the elements of a cube
template<typename T1>
inline
typename T1::elem_type
accu(const BaseCube<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT val = eT(0);
for(u32 i=0; i<A_n_elem; ++i)
{
val += A_mem[i];
}
return val;
}
//! sum of squares
template<typename T1>
inline
typename T1::elem_type
accu(const OpCube<T1, op_square>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i)
{
const eT val = A_mem[i];
acc += val*val;
}
return acc;
}
//! sum of square roots
template<typename T1>
inline
typename T1::elem_type
accu(const OpCube<T1, op_sqrt>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 A_n_elem = A.n_elem;
const eT* A_mem = A.mem;
eT acc = eT(0);
for(u32 i=0; i<A_n_elem; ++i)
{
acc += std::sqrt(A_mem[i]);
}
return acc;
}
//! sum of squares of differences
template<typename T1, typename T2>
inline
typename T1::elem_type
accu(const OpCube< GlueCube<T1,T2, glue_cube_minus>, op_square>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp1(in.m.A);
const unwrap_cube<T2> tmp2(in.m.B);
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A,B, "accu()");
const u32 n_elem = A.n_elem;
eT acc = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
const eT val = A.mem[i] - B.mem[i];
acc += val*val;
}
return acc;
}
//! accumulate the result of A % B, where % is the Schur product (element-w
ise multiplication)
template<typename eT>
inline
eT
accu_schur(const Cube<eT>& A, const Cube<eT>& B)
{
arma_extra_debug_sigprint();
arma_debug_assert_same_size(A,B, "accu()");
const eT* const A_mem = A.mem;
const eT* const B_mem = B.mem;
const u32 n_elem = A.n_elem;
eT val = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
val += A_mem[i] * B_mem[i];
}
return val;
}
//! accumulate the result of A % B, where % is the Schur product (element-w
ise multiplication)
template<typename eT>
inline
eT
accu(const GlueCube< Cube<eT>, Cube<eT>, glue_cube_schur >& X)
{
return accu_schur(X.A, X.B);
}
//! accumulate the result of A % B % C, where % is the Schur product (eleme
nt-wise multiplication)
template<typename eT>
inline
eT
accu(const GlueCube< GlueCube< Cube<eT>, Cube<eT>, glue_cube_schur >, Cube<
eT>, glue_cube_schur >& X)
{
arma_extra_debug_sigprint();
const Cube<eT>& A = X.A.A;
const Cube<eT>& B = X.A.B;
const Cube<eT>& C = X.B;
arma_debug_assert_same_size(A,B, "accu()");
arma_debug_assert_same_size(B,C, "accu()");
const eT* const A_mem = A.mem;
const eT* const B_mem = B.mem;
const eT* const C_mem = C.mem;
const u32 n_elem = A.n_elem;
eT val = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
val += A_mem[i] * B_mem[i] * C_mem[i];
}
return val;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 179 lines changed or added


 fn_conv_to.hpp   fn_conv_to.hpp 
skipping to change at line 69 skipping to change at line 69
public: public:
inline static out_eT from(const Mat< out_eT >& in); inline static out_eT from(const Mat< out_eT >& in);
template<typename in_eT> template<typename in_eT>
inline static out_eT from(const Mat< in_eT >& in); inline static out_eT from(const Mat< in_eT >& in);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static out_eT from(const Base<in_eT,T1>& in); inline static out_eT from(const Base<in_eT,T1>& in);
//
inline static out_eT from(const Cube< out_eT >& in);
template<typename in_eT>
inline static out_eT from(const Cube< in_eT >& in);
template<typename in_eT, typename T1>
inline static out_eT from(const BaseCube<in_eT,T1>& in);
}; };
template<typename out_eT> template<typename out_eT>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const Mat<out_eT>& in) conv_to<out_eT>::from(const Mat<out_eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (in.n_elem != 1), "conv_to<>: matrix doesn't have exact ly one element" ); arma_debug_check( (in.n_elem != 1), "conv_to<>: matrix doesn't have exact ly one element" );
skipping to change at line 116 skipping to change at line 125
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( );
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
return conv_to<out_eT>::from( tmp.M ); return conv_to<out_eT>::from( tmp.M );
} }
template<typename out_eT>
inline
out_eT
conv_to<out_eT>::from(const Cube<out_eT>& in)
{
arma_extra_debug_sigprint();
arma_debug_check( (in.n_elem != 1), "conv_to<>: cube doesn't have exactly
one element" );
return in.mem[0];
}
template<typename out_eT>
template<typename in_eT>
inline
out_eT
conv_to<out_eT>::from(const Cube<in_eT>& in)
{
arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply(
);
arma_debug_check( (in.n_elem != 1), "conv_to<>: cube doesn't have exactly
one element" );
out_eT out;
copy_complex_elem(out, in.mem[0]);
return out;
}
template<typename out_eT>
template<typename in_eT, typename T1>
inline
out_eT
conv_to<out_eT>::from(const BaseCube<in_eT,T1>& in)
{
arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply(
);
const unwrap_cube<T1> tmp(in.get_ref());
return conv_to<out_eT>::from( tmp.M );
}
// //
// //
// Mat family // Mat family
template<typename out_eT> template<typename out_eT>
class conv_to< Mat<out_eT> > class conv_to< Mat<out_eT> >
{ {
public: public:
template<typename in_eT> template<typename in_eT>
skipping to change at line 666 skipping to change at line 720
// for(u32 i=0; i<out.n_elem; ++i) // for(u32 i=0; i<out.n_elem; ++i)
// { // {
// copy_complex_elem(out_mem[i], in_mem[i]); // copy_complex_elem(out_mem[i], in_mem[i]);
// } // }
// //
// return out; // return out;
// } // }
// //
// //
// Cube family
template<typename out_eT>
class conv_to< Cube<out_eT> >
{
public:
template<typename in_eT>
inline static Cube<out_eT> from(const Cube< in_eT >& in);
template<typename in_T>
inline static Cube<out_eT> from(const Cube< std::complex<in_T> >& in);
template<typename in_eT, typename T1>
inline static Cube<out_eT> from(const BaseCube<in_eT,T1>& in);
};
template<typename out_eT>
template<typename in_eT>
inline
Cube<out_eT>
conv_to< Cube<out_eT> >::from(const Cube<in_eT>& in)
{
arma_extra_debug_sigprint();
Cube<out_eT> out(in.n_rows, in.n_cols, in.n_slices);
const in_eT* in_mem = in.mem;
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i)
{
out_mem[i] = out_eT( in_mem[i] );
}
return out;
}
template<typename out_eT>
template<typename in_T>
inline
Cube<out_eT>
conv_to< Cube<out_eT> >::from(const Cube< std::complex<in_T> >& in)
{
arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT;
Cube<out_eT> out(in.n_rows, in.n_cols, in.n_slices);
const in_eT* in_mem = in.mem;
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i)
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out;
}
template<typename out_eT>
template<typename in_eT, typename T1>
inline
Cube<out_eT>
conv_to< Cube<out_eT> >::from(const BaseCube<in_eT,T1>& in)
{
arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref());
return conv_to< Mat<out_eT> >::from( tmp.M );
}
//
//
// itpp::Mat family // itpp::Mat family
template<typename out_eT> template<typename out_eT>
class conv_to< itpp::Mat<out_eT> > class conv_to< itpp::Mat<out_eT> >
{ {
public: public:
inline static itpp::Mat<out_eT> from(const Mat< out_eT >& in); inline static itpp::Mat<out_eT> from(const Mat< out_eT >& in);
inline static itpp::Mat<out_eT> from(const Col< out_eT >& in); inline static itpp::Mat<out_eT> from(const Col< out_eT >& in);
 End of changes. 3 change blocks. 
0 lines changed or deleted 134 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 74 skipping to change at line 74
template<typename T1> template<typename T1>
inline inline
Mat<typename T1::elem_type> Mat<typename T1::elem_type>
reshape(const Base<typename T1::elem_type,T1>& X, const u32 in_n_rows, cons t u32 in_n_cols, const u32 dim = 0) reshape(const Base<typename T1::elem_type,T1>& X, const u32 in_n_rows, cons t u32 in_n_cols, const u32 dim = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
Mat<eT> out;
const unwrap<T1> A_tmp(X.get_ref()); const unwrap<T1> A_tmp(X.get_ref());
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const u32 in_n_elem = in_n_rows * in_n_cols; const u32 in_n_elem = in_n_rows * in_n_cols;
arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen sions"); arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen sions");
arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1");
if(dim == 0) if(dim == 0)
{ {
out = A; return Mat<eT>(A.mem, in_n_rows, in_n_cols);
access::rw(out.n_rows) = in_n_rows;
access::rw(out.n_cols) = in_n_cols;
return out;
} }
else else
{ {
out.set_size(in_n_rows, in_n_cols); Mat<eT> out(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i = 0; u32 i = 0;
for(u32 row=0; row<A.n_rows; ++row) for(u32 row=0; row<A.n_rows; ++row)
{ {
for(u32 col=0; col<A.n_cols; ++col) for(u32 col=0; col<A.n_cols; ++col)
{ {
out_mem[i] = A.at(row,col); out_mem[i] = A.at(row,col);
++i; ++i;
} }
} }
return out; return out;
} }
} }
template<typename T1>
inline
Cube<typename T1::elem_type>
reshape(const BaseCube<typename T1::elem_type,T1>& X, const u32 in_n_rows,
const u32 in_n_cols, const u32 in_n_slices, const u32 dim = 0)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> A_tmp(X.get_ref());
const Cube<eT>& A = A_tmp.M;
const u32 in_n_elem = in_n_rows * in_n_cols * in_n_slices;
arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen
sions");
arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1");
if(dim == 0)
{
return Cube<eT>(A.mem, in_n_rows, in_n_cols, in_n_slices);
}
else
{
Cube<eT> out(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr();
u32 i = 0;
for(u32 slice=0; slice<A.n_slices; ++slice)
{
for(u32 row=0; row<A.n_rows; ++row)
{
for(u32 col=0; col<A.n_cols; ++col)
{
out_mem[i] = A.at(row,col,slice);
++i;
}
}
}
return out;
}
}
// //
// real // real
template<typename T, typename T1> template<typename T, typename T1>
inline inline
Mat<T> Mat<T>
real(const Base<std::complex<T>, T1>& X) real(const Base<std::complex<T>, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 141 skipping to change at line 178
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) for(u32 i=0; i<out.n_elem; ++i)
{ {
out_mem[i] = std::real(A_mem[i]); out_mem[i] = std::real(A_mem[i]);
} }
return out; return out;
} }
template<typename T, typename T1>
inline
Cube<T>
real(const BaseCube<std::complex<T>, T1>& X)
{
arma_extra_debug_sigprint();
typedef std::complex<T> eT;
const unwrap_cube<T1> A_tmp(X.get_ref());
const Cube<eT>& A = A_tmp.M;
Cube<T> out(A.n_rows, A.n_cols, A.n_slices);
const eT* A_mem = A.mem;
T* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i)
{
out_mem[i] = std::real(A_mem[i]);
}
return out;
}
// //
// imag // imag
template<typename T, typename T1> template<typename T, typename T1>
inline inline
Mat<T> Mat<T>
imag(const Base<std::complex<T>,T1>& X) imag(const Base<std::complex<T>,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 169 skipping to change at line 231
T* out_mem = out.memptr(); T* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) for(u32 i=0; i<out.n_elem; ++i)
{ {
out_mem[i] = std::imag(A_mem[i]); out_mem[i] = std::imag(A_mem[i]);
} }
return out; return out;
} }
template<typename T, typename T1>
inline
Cube<T>
imag(const BaseCube<std::complex<T>,T1>& X)
{
arma_extra_debug_sigprint();
typedef std::complex<T> eT;
const unwrap_cube<T1> A_tmp(X.get_ref());
const Cube<eT>& A = A_tmp.M;
Cube<T> out(A.n_rows, A.n_cols, A.n_slices);
const eT* A_mem = A.mem;
T* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i)
{
out_mem[i] = std::imag(A_mem[i]);
}
return out;
}
// //
// log_add // log_add
template<typename eT> template<typename eT>
inline inline
eT eT
log_add(eT log_a, eT log_b) log_add(eT log_a, eT log_b)
{ {
if(log_a < log_b) if(log_a < log_b)
{ {
skipping to change at line 248 skipping to change at line 335
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_log> const Op<T1, op_log>
log(const Base<typename T1::elem_type,T1>& A) log(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_log>(A.get_ref()); return Op<T1, op_log>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_log>
log(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_log>(A.get_ref());
}
// //
// trunc_log // trunc_log
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_trunc_log> const Op<T1, op_trunc_log>
trunc_log(const Base<typename T1::elem_type,T1>& A) trunc_log(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_trunc_log>(A.get_ref()); return Op<T1, op_trunc_log>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_trunc_log>
trunc_log(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_trunc_log>(A.get_ref());
}
// //
// log10 // log10
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_log10> const Op<T1, op_log10>
log10(const Base<typename T1::elem_type,T1>& A) log10(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_log10>(A.get_ref()); return Op<T1, op_log10>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_log10>
log10(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_log10>(A.get_ref());
}
// //
// exp // exp
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_exp> const Op<T1, op_exp>
exp(const Base<typename T1::elem_type,T1>& A) exp(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_exp>(A.get_ref()); return Op<T1, op_exp>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_exp>
exp(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_exp>(A.get_ref());
}
// //
// trunc_exp // trunc_exp
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_trunc_exp> const Op<T1, op_trunc_exp>
trunc_exp(const Base<typename T1::elem_type,T1>& A) trunc_exp(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_trunc_exp>(A.get_ref()); return Op<T1, op_trunc_exp>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_trunc_exp>
trunc_exp(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_trunc_exp>(A.get_ref());
}
// //
// abs // abs
template<typename T1> template<typename T1>
inline inline
Mat<typename T1::pod_type> Mat<typename T1::pod_type>
abs(const Base<typename T1::elem_type,T1>& X) abs(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 334 skipping to change at line 471
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) for(u32 i=0; i<out.n_elem; ++i)
{ {
out_mem[i] = std::abs(A_mem[i]); out_mem[i] = std::abs(A_mem[i]);
} }
return out; return out;
} }
template<typename T1>
inline
Cube<typename T1::pod_type>
abs(const BaseCube<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
const unwrap_cube<T1> A_tmp(X.get_ref());
// if T1 is a complex matrix,
// pod_type is the underlying type used by std::complex;
// otherwise pod_type is the same as elem_type
typedef typename T1::elem_type in_eT;
typedef typename T1::pod_type out_eT;
const Cube<in_eT>& A = A_tmp.M;
Cube<out_eT> out(A.n_rows, A.n_cols, A.n_slices);
const in_eT* A_mem = A.mem;
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i)
{
out_mem[i] = std::abs(A_mem[i]);
}
return out;
}
// //
// fabs // fabs
template<typename T1> template<typename T1>
inline inline
Mat<typename T1::pod_type> Mat<typename T1::pod_type>
fabs(const Base<typename T1::elem_type,T1>& A) fabs(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return abs(A); return abs(A);
} }
template<typename T1>
inline
Cube<typename T1::pod_type>
fabs(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return abs(A);
}
// //
// square // square
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_square> const Op<T1, op_square>
square(const Base<typename T1::elem_type,T1>& A) square(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_square>(A.get_ref()); return Op<T1, op_square>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_square>
square(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_square>(A.get_ref());
}
// //
// sqrt // sqrt
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_sqrt> const Op<T1, op_sqrt>
sqrt(const Base<typename T1::elem_type,T1>& A) sqrt(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_sqrt>(A.get_ref()); return Op<T1, op_sqrt>(A.get_ref());
} }
template<typename T1>
inline
const OpCube<T1, op_sqrt>
sqrt(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_sqrt>(A.get_ref());
}
// pow // pow
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pow> const Op<T1, op_pow>
pow(const Base<typename T1::elem_type,T1>& A, const typename T1::elem_type exponent) pow(const Base<typename T1::elem_type,T1>& A, const typename T1::elem_type exponent)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_pow>(A.get_ref(), exponent); return Op<T1, op_pow>(A.get_ref(), exponent);
} }
template<typename T1>
inline
const OpCube<T1, op_pow>
pow(const BaseCube<typename T1::elem_type,T1>& A, const typename T1::elem_t
ype exponent)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_pow>(A.get_ref(), exponent);
}
// pow, specialised handling (non-complex exponent for complex matrices) // pow, specialised handling (non-complex exponent for complex matrices)
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pow> const Op<T1, op_pow>
pow(const Base<typename T1::elem_type,T1>& A, const typename T1::elem_type: :value_type exponent) pow(const Base<typename T1::elem_type,T1>& A, const typename T1::elem_type: :value_type exponent)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_pow>(A.get_ref(), eT(exponent)); return Op<T1, op_pow>(A.get_ref(), eT(exponent));
} }
template<typename T1>
inline
const OpCube<T1, op_pow>
pow(const BaseCube<typename T1::elem_type,T1>& A, const typename T1::elem_t
ype::value_type exponent)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_pow>(A.get_ref(), eT(exponent));
}
// pow_s32 (integer exponent) // pow_s32 (integer exponent)
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pow_s32> const Op<T1, op_pow_s32>
pow(const Base<typename T1::elem_type,T1>& A, const s32 exponent) pow(const Base<typename T1::elem_type,T1>& A, const s32 exponent)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(exponent >= 0) if(exponent >= 0)
{ {
return Op<T1, op_pow_s32>(A.get_ref(), exponent, 0); return Op<T1, op_pow_s32>(A.get_ref(), exponent, 0);
} }
else else
{ {
return Op<T1, op_pow_s32>(A.get_ref(), -exponent, 1); return Op<T1, op_pow_s32>(A.get_ref(), -exponent, 1);
} }
} }
template<typename T1>
inline
const OpCube<T1, op_pow_s32>
pow(const BaseCube<typename T1::elem_type,T1>& A, const s32 exponent)
{
arma_extra_debug_sigprint();
if(exponent >= 0)
{
return OpCube<T1, op_pow_s32>(A.get_ref(), exponent, 0);
}
else
{
return OpCube<T1, op_pow_s32>(A.get_ref(), -exponent, 1);
}
}
// conj // conj
template<typename T, typename T1> template<typename T, typename T1>
inline inline
const Op<T1, op_conj> const Op<T1, op_conj>
conj(const Base<std::complex<T>,T1>& A) conj(const Base<std::complex<T>,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_conj>(A.get_ref()); return Op<T1, op_conj>(A.get_ref());
} }
template<typename T, typename T1>
inline
const OpCube<T1, op_conj>
conj(const BaseCube<std::complex<T>,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_conj>(A.get_ref());
}
template<typename T1> template<typename T1>
inline inline
const T1& const T1&
conj(const Op<T1, op_conj>& A) conj(const Op<T1, op_conj>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return A.m; return A.m;
} }
template<typename T1>
inline
const T1&
conj(const OpCube<T1, op_conj>& A)
{
arma_extra_debug_sigprint();
return A.m;
}
//! the conjugate of the transpose of a complex matrix is the same as the h ermitian transpose //! the conjugate of the transpose of a complex matrix is the same as the h ermitian transpose
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_htrans> const Op<T1, op_htrans>
conj(const Op<T1, op_trans>& A) conj(const Op<T1, op_trans>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_complex<typename T1::elem_type>::value == false >::ap ply(); arma_type_check< is_complex<typename T1::elem_type>::value == false >::ap ply();
 End of changes. 20 change blocks. 
9 lines changed or deleted 268 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
skipping to change at line 85 skipping to change at line 85
const Op<mat_type,op_ones_diag> const Op<mat_type,op_ones_diag>
eye(const u32 n_rows, const u32 n_cols) eye(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat_only<mat_type>::value == false>::apply(); arma_type_check<is_Mat_only<mat_type>::value == false>::apply();
return Op<mat_type,op_ones_diag>(n_rows, n_cols, 'j'); return Op<mat_type,op_ones_diag>(n_rows, n_cols, 'j');
} }
//
//
// handling of cubes
//! Delayed generation of a dense cube with all elements set to one
inline
const OpCube<cube,op_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{
arma_extra_debug_sigprint();
return OpCube<cube,op_ones_full>(n_rows, n_cols, n_slices);
}
template<typename cube_type>
inline
const OpCube<cube_type,op_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{
arma_extra_debug_sigprint();
arma_type_check<is_Cube<cube_type>::value == false>::apply();
return OpCube<cube_type,op_ones_full>(n_rows, n_cols, n_slices);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 27 lines changed or added


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


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


 fn_sort_index.hpp   fn_sort_index.hpp 
skipping to change at line 94 skipping to change at line 94
//template<> //template<>
template<typename eT> template<typename eT>
struct sort_index_result_type_deducer< Row<eT> > struct sort_index_result_type_deducer< Row<eT> >
{ {
typedef urowvec out_type; typedef urowvec out_type;
}; };
template<typename T1> template<typename T1>
inline inline
typename sort_index_result_type_deducer<T1>::out_type typename sort_index_result_type_deducer<T1>::out_type
sort_index(const Base_vec<typename T1::elem_type,T1>& X, const u32 sort_typ e = 0) sort_index(const BaseVec<typename T1::elem_type,T1>& X, const u32 sort_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_type_check< is_complex<eT>::value == true>::apply(); arma_type_check< is_complex<eT>::value == true>::apply();
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;
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_trig.hpp   fn_trig.hpp 
skipping to change at line 180 skipping to change at line 180
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_atanh> const Op<T1, op_atanh>
atanh(const Base<typename T1::elem_type,T1>& A) atanh(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_atanh>(A.get_ref()); return Op<T1, op_atanh>(A.get_ref());
} }
//
//
// handling of cubes
//
// cos
template<typename T1>
inline
const OpCube<T1, op_cos>
cos(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_cos>(A.get_ref());
}
//
// acos
template<typename T1>
inline
const OpCube<T1, op_acos>
acos(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_acos>(A.get_ref());
}
//
// cosh
template<typename T1>
inline
const OpCube<T1, op_cosh>
cosh(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_cosh>(A.get_ref());
}
//
// acosh
template<typename T1>
inline
const OpCube<T1, op_acosh>
acosh(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_acosh>(A.get_ref());
}
//
// sin
template<typename T1>
inline
const OpCube<T1, op_sin>
sin(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_sin>(A.get_ref());
}
//
// asin
template<typename T1>
inline
const OpCube<T1, op_asin>
asin(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_asin>(A.get_ref());
}
//
// sinh
template<typename T1>
inline
const OpCube<T1, op_sinh>
sinh(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_sinh>(A.get_ref());
}
//
// asinh
template<typename T1>
inline
const OpCube<T1, op_asinh>
asinh(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_asinh>(A.get_ref());
}
//
// tan
template<typename T1>
inline
const OpCube<T1, op_tan>
tan(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_tan>(A.get_ref());
}
//
// atan
template<typename T1>
inline
const OpCube<T1, op_atan>
atan(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_atan>(A.get_ref());
}
//
// tanh
template<typename T1>
inline
const OpCube<T1, op_tanh>
tanh(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_tanh>(A.get_ref());
}
//
// atanh
template<typename T1>
inline
const OpCube<T1, op_atanh>
atanh(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return OpCube<T1, op_atanh>(A.get_ref());
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 160 lines changed or added


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


 forward_proto.hpp   forward_proto.hpp 
skipping to change at line 23 skipping to change at line 23
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
using std::cout; using std::cout;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
using std::ios; using std::ios;
template<typename eT> class Mat; template<typename eT> class Mat;
template<typename eT> class Col; template<typename eT> class Col;
template<typename eT> class Row; template<typename eT> class Row;
template<typename eT> class Cube;
template<typename eT> class subview; template<typename eT> class subview;
template<typename eT> class subview_col; template<typename eT> class subview_col;
template<typename eT> class subview_row; template<typename eT> class subview_row;
template<typename oT> class subview_field; template<typename oT> class subview_field;
template<typename oT> class subview_cube;
template<typename eT> class diagview; template<typename eT> class diagview;
class diskio; class diskio;
class op_min; class op_min;
class op_max; class op_max;
class op_trans; class op_trans;
class op_htrans; class op_htrans;
skipping to change at line 61 skipping to change at line 63
class glue_plus; class glue_plus;
class glue_times; class glue_times;
class glue_times_vec; class glue_times_vec;
class glue_schur; class glue_schur;
class glue_plus_diag; class glue_plus_diag;
class glue_minus_diag; class glue_minus_diag;
class glue_times_diag; class glue_times_diag;
class glue_schur_diag; class glue_schur_diag;
class glue_cube_div;
class glue_cube_minus;
class glue_cube_plus;
class glue_cube_schur;
template<const bool, const bool, const bool, const bool> class gemm; template<const bool, const bool, const bool, const bool> class gemm;
template<const bool, const bool, const bool> class gemv; template<const bool, const bool, const bool> class gemv;
template<typename T1, typename op_type> class Op; template<typename T1, typename op_type> class Op;
template<typename T1, typename op_type> class OpCube;
template<typename T1, typename T2, typename glue_type> class Glue; template<typename T1, typename T2, typename glue_type> class Glue;
template<typename T1, typename T2, typename glue_type> class GlueCube;
//! \addtogroup diskio //! \addtogroup diskio
//! @{ //! @{
//! file types supported by Armadillo //! file types supported by Armadillo
enum file_type enum file_type
{ {
auto_detect, //!< Automatically detect the file type (file must be one o f the following types) auto_detect, //!< Automatically detect the file type (file must be one o f the following types)
raw_ascii, //!< ASCII format (text), without any other information. raw_ascii, //!< ASCII format (text), without any other information.
arma_ascii, //!< Armadillo ASCII format (text), with information about matrix type and size arma_ascii, //!< Armadillo ASCII format (text), with information about matrix type and size
 End of changes. 6 change blocks. 
1 lines changed or deleted 11 lines changed or added


 glue_div_meat.hpp   glue_div_meat.hpp 
skipping to change at line 28 skipping to change at line 28
template<typename eT> template<typename eT>
inline inline
void void
glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "element-wise matrix division"); arma_debug_assert_same_size(A, B, "element-wise matrix division");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out[i] = A.mem[i] / B.mem[i]; out[i] = A.mem[i] / B.mem[i];
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat <eT>& C) glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat <eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "element-wise matrix division"); arma_debug_assert_same_size(A, B, "element-wise matrix division");
arma_debug_assert_same_size(A, C, "element-wise matrix division"); arma_debug_assert_same_size(B, C, "element-wise matrix division");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i != n_elem; ++i) for(u32 i=0; i != n_elem; ++i)
{ {
out[i] = A.mem[i] / B.mem[i] / C.mem[i]; out[i] = A.mem[i] / B.mem[i] / C.mem[i];
} }
} }
template<typename eT> template<typename eT>
skipping to change at line 202 skipping to change at line 204
inline inline
void void
glue_div::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, con st Mat<eT1>& X, const Mat<eT2>& Y) glue_div::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, con st Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "element-wise matrix division"); arma_debug_assert_same_size(X,Y, "element-wise matrix division");
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem; const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT 2>::apply(Y_mem[i]);
 End of changes. 4 change blocks. 
4 lines changed or deleted 7 lines changed or added


 glue_minus_meat.hpp   glue_minus_meat.hpp 
skipping to change at line 29 skipping to change at line 29
template<typename eT> template<typename eT>
inline inline
void void
glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows,A.n_cols); //out.set_size(A.n_rows,A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = A_mem[i] - B_mem[i]; out_mem[i] = A_mem[i] - B_mem[i];
skipping to change at line 56 skipping to change at line 57
inline inline
void void
glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M at<eT>& C) glue_minus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M at<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
arma_debug_assert_same_size(A, C, "matrix subtraction"); arma_debug_assert_same_size(A, C, "matrix subtraction");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem; const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 221 skipping to change at line 223
inline inline
void void
glue_minus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y) glue_minus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix subtraction"); arma_debug_assert_same_size(X,Y, "matrix subtraction");
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem; const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT 2>::apply(Y_mem[i]);
skipping to change at line 259 skipping to change at line 262
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_check( !B.is_square(), "glue_minus_diag::apply(): matrices mus t be square" ); arma_debug_check( !B.is_square(), "glue_minus_diag::apply(): matrices mus t be square" );
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
for(u32 col=0; col<A.n_cols; ++col) for(u32 col=0; col<A.n_cols; ++col)
{ {
for(u32 row=0; row<A.n_rows; ++row) for(u32 row=0; row<A.n_rows; ++row)
{ {
if(col != row) if(col != row)
{ {
out.at(row,col) = A.at(row,col); out.at(row,col) = A.at(row,col);
} }
else else
skipping to change at line 299 skipping to change at line 303
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_check( !A.is_square(), "glue_minus_diag::apply(): matrices mus t be square" ); arma_debug_check( !A.is_square(), "glue_minus_diag::apply(): matrices mus t be square" );
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
for(u32 col=0; col<A.n_cols; ++col) for(u32 col=0; col<A.n_cols; ++col)
{ {
for(u32 row=0; row<A.n_rows; ++row) for(u32 row=0; row<A.n_rows; ++row)
{ {
if(col != row) if(col != row)
{ {
out.at(row,col) = -B.at(row,col); out.at(row,col) = -B.at(row,col);
} }
else else
 End of changes. 5 change blocks. 
5 lines changed or deleted 10 lines changed or added


 glue_plus_meat.hpp   glue_plus_meat.hpp 
skipping to change at line 28 skipping to change at line 28
template<typename eT> template<typename eT>
inline inline
void void
glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = A_mem[i] + B_mem[i]; out_mem[i] = A_mem[i] + B_mem[i];
skipping to change at line 54 skipping to change at line 55
inline inline
void void
glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Ma t<eT>& C) glue_plus::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Ma t<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_assert_same_size(A, C, "matrix addition"); arma_debug_assert_same_size(A, C, "matrix addition");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem; const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 195 skipping to change at line 197
const Mat<eT>& orig_A = X.A; const Mat<eT>& orig_A = X.A;
const Mat<eT>& orig_B = X.B.m; const Mat<eT>& orig_B = X.B.m;
if( &out != &orig_B ) if( &out != &orig_B )
{ {
//const u32 sub_B_n_rows = X.B.n_rows; //const u32 sub_B_n_rows = X.B.n_rows;
//const u32 sub_B_n_cols = X.B.n_cols; //const u32 sub_B_n_cols = X.B.n_cols;
arma_debug_assert_same_size(X.A, X.B, "matrix addition"); arma_debug_assert_same_size(X.A, X.B, "matrix addition");
out.set_size(orig_A.n_rows, orig_A.n_cols); //out.set_size(orig_A.n_rows, orig_A.n_cols);
out.copy_size(orig_A);
for(u32 col = 0; col<orig_A.n_cols; ++col) for(u32 col = 0; col<orig_A.n_cols; ++col)
{ {
const u32 B_col_mod = X.B.aux_col1 + col; const u32 B_col_mod = X.B.aux_col1 + col;
for(u32 row = 0; row<orig_A.n_rows; ++row) for(u32 row = 0; row<orig_A.n_rows; ++row)
{ {
const u32 B_row_mod = X.B.aux_row1 + row; const u32 B_row_mod = X.B.aux_row1 + row;
out.at(row,col) = orig_A.at(row, col) + orig_B.at(B_row_mod, B_col _mod); out.at(row,col) = orig_A.at(row, col) + orig_B.at(B_row_mod, B_col _mod);
skipping to change at line 515 skipping to change at line 518
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.A.m); const unwrap<T1> tmp1(in.A.m);
const unwrap<T2> tmp2(in.B.m); const unwrap<T2> tmp2(in.B.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const eT k1 = in.A.aux; const eT k1 = in.A.aux;
const eT k2 = in.B.aux; const eT k2 = in.B.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 local_n_elem = A.n_elem; const u32 local_n_elem = A.n_elem;
skipping to change at line 557 skipping to change at line 561
const unwrap<T2> tmp2(in.A.B.m); const unwrap<T2> tmp2(in.A.B.m);
const unwrap<T3> tmp3(in.B.m); const unwrap<T3> tmp3(in.B.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_assert_same_size(B, C, "matrix addition"); arma_debug_assert_same_size(B, C, "matrix addition");
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const eT k1 = in.A.A.aux; const eT k1 = in.A.A.aux;
const eT k2 = in.A.B.aux; const eT k2 = in.A.B.aux;
const eT k3 = in.B.aux; const eT k3 = in.B.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem; const eT* C_mem = C.mem;
skipping to change at line 598 skipping to change at line 603
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.A.m); const unwrap<T1> tmp1(in.A.m);
const unwrap<T2> tmp2(in.B.m); const unwrap<T2> tmp2(in.B.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const eT k1 = in.A.aux; const eT k1 = in.A.aux;
const eT k2 = in.B.aux; const eT k2 = in.B.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 local_n_elem = A.n_elem; const u32 local_n_elem = A.n_elem;
skipping to change at line 640 skipping to change at line 646
const unwrap<T2> tmp2(in.A.B.m); const unwrap<T2> tmp2(in.A.B.m);
const unwrap<T3> tmp3(in.B.m); const unwrap<T3> tmp3(in.B.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_assert_same_size(B, C, "matrix addition"); arma_debug_assert_same_size(B, C, "matrix addition");
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const eT k1 = in.A.A.aux; const eT k1 = in.A.A.aux;
const eT k2 = in.A.B.aux; const eT k2 = in.A.B.aux;
const eT k3 = in.B.aux; const eT k3 = in.B.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem; const eT* C_mem = C.mem;
skipping to change at line 681 skipping to change at line 688
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.A.m); const unwrap<T1> tmp1(in.A.m);
const unwrap<T2> tmp2(in.B.m); const unwrap<T2> tmp2(in.B.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const eT k1 = in.A.aux; const eT k1 = in.A.aux;
const eT k2 = in.B.aux; const eT k2 = in.B.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 local_n_elem = A.n_elem; const u32 local_n_elem = A.n_elem;
skipping to change at line 723 skipping to change at line 731
const unwrap<T2> tmp2(in.A.B.m); const unwrap<T2> tmp2(in.A.B.m);
const unwrap<T3> tmp3(in.B.m); const unwrap<T3> tmp3(in.B.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
arma_debug_assert_same_size(B, C, "matrix addition"); arma_debug_assert_same_size(B, C, "matrix addition");
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
const eT k1 = in.A.A.aux; const eT k1 = in.A.A.aux;
const eT k2 = in.A.B.aux; const eT k2 = in.A.B.aux;
const eT k3 = in.B.aux; const eT k3 = in.B.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem; const eT* C_mem = C.mem;
skipping to change at line 757 skipping to change at line 766
inline inline
void void
glue_plus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, co nst Mat<eT1>& X, const Mat<eT2>& Y) glue_plus::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, co nst Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix addition"); arma_debug_assert_same_size(X,Y, "matrix addition");
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem; const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT 2>::apply(Y_mem[i]);
skipping to change at line 795 skipping to change at line 805
const unwrap<T1> tmp1(A_orig); const unwrap<T1> tmp1(A_orig);
const unwrap<T2> tmp2(B_orig.m); const unwrap<T2> tmp2(B_orig.m);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_check( !B.is_square(), "glue_plus_diag::apply(): matrices must be square" ); arma_debug_check( !B.is_square(), "glue_plus_diag::apply(): matrices must be square" );
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
for(u32 col=0; col<A.n_cols; ++col) for(u32 col=0; col<A.n_cols; ++col)
{ {
for(u32 row=0; row<A.n_rows; ++row) for(u32 row=0; row<A.n_rows; ++row)
{ {
if(col != row) if(col != row)
{ {
out.at(row,col) = A.at(row,col); out.at(row,col) = A.at(row,col);
} }
else else
skipping to change at line 845 skipping to change at line 856
{ {
out.zeros(A.n_rows, A.n_cols); out.zeros(A.n_rows, A.n_cols);
for(u32 i=0; i<A.n_rows; ++i) for(u32 i=0; i<A.n_rows; ++i)
{ {
out.at(i,i) = A.at(i,i) + B.at(i,i); out.at(i,i) = A.at(i,i) + B.at(i,i);
} }
} }
else else
{ {
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
for(u32 col=0; col<A.n_cols; ++col) for(u32 col=0; col<A.n_cols; ++col)
{ {
for(u32 row=0; row<A.n_rows; ++row) for(u32 row=0; row<A.n_rows; ++row)
{ {
if(col != row) if(col != row)
{ {
out.at(row,col) = 0.0; out.at(row,col) = 0.0;
} }
else else
 End of changes. 12 change blocks. 
12 lines changed or deleted 24 lines changed or added


 glue_plus_proto.hpp   glue_plus_proto.hpp 
skipping to change at line 18 skipping to change at line 18
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_plus //! \addtogroup glue_plus
//! @{ //! @{
//! Class which implements the immediate addition matrices, with the result stored in 'Mat' (dense matrix) //! Class which implements the immediate addition of matrices, with the res ult stored in 'Mat' (dense matrix)
class glue_plus class glue_plus
{ {
public: public:
// mat // mat
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B ); inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B );
template<typename eT> template<typename eT>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 glue_schur_meat.hpp   glue_schur_meat.hpp 
skipping to change at line 28 skipping to change at line 28
template<typename eT> template<typename eT>
inline inline
void void
glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix schur product"); arma_debug_assert_same_size(A, B, "matrix schur product");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = A_mem[i] * B_mem[i]; out_mem[i] = A_mem[i] * B_mem[i];
skipping to change at line 54 skipping to change at line 55
inline inline
void void
glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M at<eT>& C) glue_schur::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const M at<eT>& C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(A, B, "matrix schur product"); arma_debug_assert_same_size(A, B, "matrix schur product");
arma_debug_assert_same_size(A, C, "matrix schur product"); arma_debug_assert_same_size(A, C, "matrix schur product");
// no aliasing problem // no aliasing problem
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT* C_mem = C.mem; const eT* C_mem = C.mem;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 214 skipping to change at line 216
inline inline
void void
glue_schur::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y) glue_schur::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c onst Mat<eT1>& X, const Mat<eT2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
arma_debug_assert_same_size(X,Y, "matrix schur product"); arma_debug_assert_same_size(X,Y, "matrix schur product");
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const eT1* X_mem = X.mem; const eT1* X_mem = X.mem;
const eT2* Y_mem = Y.mem; const eT2* Y_mem = Y.mem;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) * upgrade_val<eT1,eT 2>::apply(Y_mem[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) * upgrade_val<eT1,eT 2>::apply(Y_mem[i]);
 End of changes. 3 change blocks. 
3 lines changed or deleted 6 lines changed or added


 op_misc_meat.hpp   op_misc_meat.hpp 
skipping to change at line 30 skipping to change at line 30
void void
op_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log>& in) op_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::log(A.mem[i]);
}
}
template<typename T1>
inline
void
op_log::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_log>& i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::log(A.mem[i]); out_ptr[i] = std::log(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 54 skipping to change at line 82
void void
op_trunc_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ log>& in) op_trunc_log::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ log>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = trunc_log(A.mem[i]);
}
}
template<typename T1>
inline
void
op_trunc_log::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_t
runc_log>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = trunc_log(A.mem[i]); out_ptr[i] = trunc_log(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 78 skipping to change at line 134
void void
op_log10::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log10>& in ) op_log10::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_log10>& in )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::log10(A.mem[i]);
}
}
template<typename T1>
inline
void
op_log10::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_log10
>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::log10(A.mem[i]); out_ptr[i] = std::log10(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 104 skipping to change at line 188
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::exp(A.mem[i]);
}
}
template<typename T1>
inline
void
op_exp::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_exp>& i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::exp(A.mem[i]); out_ptr[i] = std::exp(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 126 skipping to change at line 238
void void
op_trunc_exp::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ exp>& in) op_trunc_exp::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trunc_ exp>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = trunc_exp(A.mem[i]);
}
}
template<typename T1>
inline
void
op_trunc_exp::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_t
runc_exp>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = trunc_exp(A.mem[i]); out_ptr[i] = trunc_exp(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 150 skipping to change at line 290
void void
op_sqrt::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sqrt>& in) op_sqrt::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sqrt>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::sqrt(A.mem[i]);
}
}
template<typename T1>
inline
void
op_sqrt::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sqrt>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::sqrt(A.mem[i]); out_ptr[i] = std::sqrt(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 176 skipping to change at line 344
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
const eT tmp_val = A.mem[i];
out_ptr[i] = tmp_val*tmp_val;
}
}
template<typename T1>
inline
void
op_square::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_squa
re>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT tmp_val = A.mem[i]; const eT tmp_val = A.mem[i];
out_ptr[i] = tmp_val*tmp_val; out_ptr[i] = tmp_val*tmp_val;
} }
} }
skipping to change at line 199 skipping to change at line 396
void void
op_pow::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow>& in) op_pow::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::pow(A.mem[i], in.aux);
}
}
template<typename T1>
inline
void
op_pow::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_pow>& i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::pow(A.mem[i], in.aux); out_ptr[i] = std::pow(A.mem[i], in.aux);
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
skipping to change at line 227 skipping to change at line 452
typedef std::complex<T> eT; typedef std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
if(in.aux.imag() == T(0))
{
const T in_aux_real = in.aux.real();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::pow(A.mem[i], in_aux_real);
}
}
else
{
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::pow(A.mem[i], in.aux);
}
}
}
template<typename T, typename T1>
inline
void
op_pow::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_pow>& in)
{
arma_extra_debug_sigprint();
typedef std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
if(in.aux.imag() == T(0)) if(in.aux.imag() == T(0))
{ {
const T in_aux_real = in.aux.real(); const T in_aux_real = in.aux.real();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::pow(A.mem[i], in_aux_real); out_ptr[i] = std::pow(A.mem[i], in_aux_real);
} }
skipping to change at line 300 skipping to change at line 566
void void
op_pow_s32::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow_s32> & in) op_pow_s32::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pow_s32> & in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a;
for(u32 i=0; i<n_elem; ++i)
{
//out_ptr[i] = std::pow(A.mem[i], exponent); // causes problems with g
cc 4.1/4.2 for base that has an integer type
out_ptr[i] = op_pow_s32::internal_pow(A.mem[i], exponent);
}
}
template<typename T1>
inline
void
op_pow_s32::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_pow
_s32>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a; const int exponent = (in.aux_u32_b == 0) ? in.aux_u32_a : -in.aux_u32_a;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
//out_ptr[i] = std::pow(A.mem[i], exponent); // causes problems with g cc 4.1/4.2 for base that has an integer type //out_ptr[i] = std::pow(A.mem[i], exponent); // causes problems with g cc 4.1/4.2 for base that has an integer type
out_ptr[i] = op_pow_s32::internal_pow(A.mem[i], exponent); out_ptr[i] = op_pow_s32::internal_pow(A.mem[i], exponent);
} }
skipping to change at line 329 skipping to change at line 626
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_type_check< is_complex<T1>::value == true >::apply(); arma_type_check< is_complex<T1>::value == true >::apply();
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::conj(A.mem[i]);
}
}
template<typename T1>
inline
void
op_conj::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_conj>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
arma_type_check< is_complex<T1>::value == true >::apply();
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
out.set_size(A.n_rows, A.n_cols);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::conj(A.mem[i]); out_ptr[i] = std::conj(A.mem[i]);
} }
} }
//! @} //! @}
 End of changes. 19 change blocks. 
19 lines changed or deleted 357 lines changed or added


 op_misc_proto.hpp   op_misc_proto.hpp 
skipping to change at line 22 skipping to change at line 22
// 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_misc //! \addtogroup op_misc
//! @{ //! @{
class op_log class op_log
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_log>& in);
_log>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_log>& in);
}; };
class op_trunc_log class op_trunc_log
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_trunc_log>& in);
_trunc_log>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_trunc_log>& in);
}; };
class op_log10 class op_log10
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_log10>& in);
_log10>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_log10>& in);
}; };
class op_exp class op_exp
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_exp>& in);
_exp>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_exp>& in);
}; };
class op_trunc_exp class op_trunc_exp
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_trunc_exp>& in);
_trunc_exp>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_trunc_exp>& in);
}; };
class op_sqrt class op_sqrt
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_sqrt>& in);
_sqrt>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_sqrt>& in);
}; };
class op_square class op_square
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_square>& in);
_square>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_square>& in);
}; };
class op_pow class op_pow
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_pow>& in);
_pow>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_pow>& in);
template<typename T, typename T1> template<typename T, typename T1> inline static void apply( Mat< std::com
inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_pow> plex<T> >& out, const Op<T1,op_pow>& in);
& in); template<typename T, typename T1> inline static void apply(Cube< std::com
plex<T> >& out, const OpCube<T1,op_pow>& in);
}; };
class op_pow_s32 class op_pow_s32
{ {
public: public:
template<typename T1> template<typename T1> static inline T1 internal_pow(const T1 base, const
static inline T1 internal_pow(const T1 base, const int exponent); int exponent);
static inline char internal_pow(const char base, const int exponent); static inline char internal_pow(const char base, const int exponent);
static inline unsigned char internal_pow(const unsigned char base, const int exponent); static inline unsigned char internal_pow(const unsigned char base, const int exponent);
static inline int internal_pow(const int base, const int exponent); static inline int internal_pow(const int base, const int exponent);
static inline unsigned int internal_pow(const unsigned int base, const int exponent); static inline unsigned int internal_pow(const unsigned int base, const int exponent);
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_pow_s32>& in);
_pow_s32>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_pow_s32>& in);
}; };
class op_conj class op_conj
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_conj>& in);
_conj>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_conj>& in);
}; };
//! @} //! @}
 End of changes. 12 change blocks. 
35 lines changed or deleted 46 lines changed or added


 op_neg_meat.hpp   op_neg_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_neg //! \addtogroup op_neg
//! @{ //! @{
//! Negate all element of a matrix and store the result in a dense matrix //! Negate all elements of a dense matrix
template<typename T1> template<typename T1>
inline inline
void void
op_neg::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_neg> &in) op_neg::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_neg> &in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// no alias problems // no alias problems
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
const eT* X_mem = X.mem;
eT* out_mem = out.memptr();
for(u32 i=0; i<X.n_elem; ++i)
{
out_mem[i] = -X_mem[i];
}
}
//! Negate all elements of a dense cube
template<typename T1>
inline
void
op_neg::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_neg> &i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X.n_elem; ++i)
{ {
out_mem[i] = -X_mem[i]; out_mem[i] = -X_mem[i];
} }
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 31 lines changed or added


 op_neg_proto.hpp   op_neg_proto.hpp 
skipping to change at line 18 skipping to change at line 18
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_neg //! \addtogroup op_neg
//! @{ //! @{
//! 'negate matrix' operation //! negate operation
class op_neg class op_neg
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_neg>& in);
_neg>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_neg>& in);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
4 lines changed or deleted 5 lines changed or added


 op_ones_meat.hpp   op_ones_meat.hpp 
skipping to change at line 76 skipping to change at line 76
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a); out.set_size(in.aux_u32_a);
out.fill(eT(1)); out.fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void void
op_ones_full::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_ones_full>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
out.fill(eT(1));
}
template<typename eT>
inline
void
op_ones_diag::apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in) op_ones_diag::apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a, in.aux_u32_b); out.zeros(in.aux_u32_a, in.aux_u32_b);
for(u32 i=0; i<out.n_rows; ++i) for(u32 i=0; i<out.n_rows; ++i)
{ {
out.at(i,i) = eT(1); out.at(i,i) = eT(1);
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 11 lines changed or added


 op_ones_proto.hpp   op_ones_proto.hpp 
skipping to change at line 18 skipping to change at line 18
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_ones //! \addtogroup op_ones
//! @{ //! @{
//! Class for creation of a dense matrix/vector with all elements set to on e //! Class for creation of a dense matrix/vector/cube with all elements set to one
class op_ones_full class op_ones_full
{ {
public: public:
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>, op_ones_full>& in); inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_full>& in );
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_ones_full>& in ); inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_ones_full>& in );
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_ones_full>& in ); inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_ones_full>& in );
template<typename eT> template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_ones_full>& in ); inline static void apply(Col<eT>& out, const Op<Col<eT>,op_ones_full>& in );
template<typename eT> template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_ones_full>& in ); inline static void apply(Row<eT>& out, const Op<Row<eT>,op_ones_full>& in );
//
template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_ones_ful
l>& in);
}; };
class op_ones_diag class op_ones_diag
{ {
public: public:
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in ); inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_ones_diag>& in );
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
2 lines changed or deleted 8 lines changed or added


 op_rand_meat.hpp   op_rand_meat.hpp 
skipping to change at line 113 skipping to change at line 113
void void
op_rand::apply(Row<eT>& out, const Op<Row<eT>,op_rand>& in) op_rand::apply(Row<eT>& out, const Op<Row<eT>,op_rand>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a); out.set_size(in.aux_u32_a);
op_rand::direct_rand(out.memptr(), out.n_elem); op_rand::direct_rand(out.memptr(), out.n_elem);
} }
template<typename eT>
inline
void
op_rand::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
op_rand::direct_rand(out.memptr(), out.n_elem);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 12 lines changed or added


 op_rand_proto.hpp   op_rand_proto.hpp 
skipping to change at line 47 skipping to change at line 47
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_rand>& in); inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_rand>& in);
template<typename eT> template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_rand>& in); inline static void apply(Col<eT>& out, const Op<Col<eT>,op_rand>& in);
template<typename eT> template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_rand>& in); inline static void apply(Row<eT>& out, const Op<Row<eT>,op_rand>& in);
//
template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& i
n);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 5 lines changed or added


 op_randn_meat.hpp   op_randn_meat.hpp 
skipping to change at line 121 skipping to change at line 121
void void
op_randn::apply(Row<eT>& out, const Op<Row<eT>,op_randn>& in) op_randn::apply(Row<eT>& out, const Op<Row<eT>,op_randn>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a); out.set_size(in.aux_u32_a);
op_randn::direct_randn(out.memptr(), out.n_elem); op_randn::direct_randn(out.memptr(), out.n_elem);
} }
template<typename eT>
inline
void
op_randn::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_randn>& in)
{
arma_extra_debug_sigprint();
out.set_size(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
op_randn::direct_randn(out.memptr(), out.n_elem);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 12 lines changed or added


 op_randn_proto.hpp   op_randn_proto.hpp 
skipping to change at line 46 skipping to change at line 46
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_randn>& in); inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_randn>& in);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_randn>& in); inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_randn>& in);
template<typename eT> template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_randn>& in); inline static void apply(Col<eT>& out, const Op<Col<eT>,op_randn>& in);
template<typename eT> template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_randn>& in); inline static void apply(Row<eT>& out, const Op<Row<eT>,op_randn>& in);
//
template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_randn>&
in);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 6 lines changed or added


 op_scalar_misc_meat.hpp   op_scalar_misc_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_scalar_misc //! \addtogroup op_scalar_misc
//! @{ //! @{
//! Add a scalar to all elements of a matrix and store the result in a dens e matrix //! Add a scalar to all elements of a matrix
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_plus::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_scal ar_plus>& in) op_scalar_plus::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_scal ar_plus>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// no alias problems // no alias problems
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X.n_elem; ++i)
{ {
out_mem[i] = X_mem[i] + k; out_mem[i] = X_mem[i] + k;
} }
} }
//! For each element of a matrix, subtract it from a scalar and store the r //! Add a scalar to all elements of a cube
esult in a dense matrix template<typename T1>
inline
void
op_scalar_plus::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op
_scalar_plus>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i)
{
out_mem[i] = X_mem[i] + k;
}
}
//! For each element of a matrix, subtract it from a scalar
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_minus_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op _scalar_minus_pre>& in) op_scalar_minus_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op _scalar_minus_pre>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// no alias problems // no alias problems
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i)
{
out_mem[i] = k - X_mem[i];
}
}
//! For each element of a cube, subtract it from a scalar
template<typename T1>
inline
void
op_scalar_minus_pre::apply(Cube<typename T1::elem_type>& out, const OpCube<
T1,op_scalar_minus_pre>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X.n_elem; ++i)
{ {
out_mem[i] = k - X_mem[i]; out_mem[i] = k - X_mem[i];
} }
skipping to change at line 86 skipping to change at line 144
op_scalar_minus_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,o p_scalar_minus_post>& in) op_scalar_minus_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,o p_scalar_minus_post>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// no alias problems // no alias problems
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i)
{
out_mem[i] = X_mem[i] - k;
}
}
//! subtract a scalar from each element of a cube
template<typename T1>
inline
void
op_scalar_minus_post::apply(Cube<typename T1::elem_type>& out, const OpCube
<T1,op_scalar_minus_post>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X.n_elem; ++i)
{ {
out_mem[i] = X_mem[i] - k; out_mem[i] = X_mem[i] - k;
} }
} }
//! Multiply all elements of a matrix by a scalar and store the result in a dense matrix //! Multiply all elements of a matrix by a scalar
template<typename T1> template<typename T1>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sca lar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sca lar_times>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// no alias problems // no alias problems
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] * k;
}
}
//! Multiply all elements of a cube by a scalar
template<typename T1>
inline
void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,o
p_scalar_times>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// no alias problems
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i < X.n_elem; ++i)
{ {
out_mem[i] = X_mem[i] * k; out_mem[i] = X_mem[i] * k;
} }
} }
//! \brief
//! Evaluate Glue<T1,T2,glue_type>, and then multiply each element of the r esult by a scalar. //! Evaluate Glue<T1,T2,glue_type>, and then multiply each element of the r esult by a scalar.
//! Store the final result in a dense matrix.
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<Glue<T1,T 2,glue_type>, op_scalar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op<Glue<T1,T 2,glue_type>, op_scalar_times>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Mat<eT>' out = in.m; // implicit conversion to 'Mat<eT>'
skipping to change at line 150 skipping to change at line 264
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] *= k; out_mem[i] *= k;
} }
} }
//! \brief //! Evaluate GlueCube<T1,T2,glue_type>, and then multiply each element of t
he result by a scalar.
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube<Glue
Cube<T1,T2,glue_type>, op_scalar_times>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Cube<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] *= k;
}
}
//! Evaluate A + B, and then multiply each element of the result by a scala r. //! Evaluate A + B, and then multiply each element of the result by a scala r.
//! Store the final result in a dense matrix.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_plus>, op_scalar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_plus>, op_scalar_times>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp1(in.m.A); const unwrap<T1> tmp1(in.m.A);
const unwrap<T2> tmp2(in.m.B); const unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = (A_mem[i] + B_mem[i]) * k;
}
}
//! Evaluate A + B, and then multiply each element of the result by a scala
r.
template<typename T1, typename T2>
inline
void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube< Glu
eCube<T1,T2,glue_cube_plus>, op_scalar_times>& in)
{
arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp1(in.m.A);
const unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "cube addition");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = (A_mem[i] + B_mem[i]) * k; out_mem[i] = (A_mem[i] + B_mem[i]) * k;
} }
} }
//! \brief
//! Evaluate A - B, and then multiply each element of the result by a scala r. //! Evaluate A - B, and then multiply each element of the result by a scala r.
//! Store the final result in a dense matrix.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_minus>, op_scalar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_minus>, op_scalar_times>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp1(in.m.A); const unwrap<T1> tmp1(in.m.A);
const unwrap<T2> tmp2(in.m.B); const unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = (A_mem[i] - B_mem[i]) * k;
}
}
//! Evaluate A - B, and then multiply each element of the result by a scala
r.
template<typename T1, typename T2>
inline
void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube< Glu
eCube<T1,T2,glue_cube_minus>, op_scalar_times>& in)
{
arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp1(in.m.A);
const unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "cube subtraction");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = (A_mem[i] - B_mem[i]) * k; out_mem[i] = (A_mem[i] - B_mem[i]) * k;
} }
} }
//! \brief
//! Evaluate A % B (where % is the element-wise multiply operation) and the n multiply each element of the result by a scalar. //! Evaluate A % B (where % is the element-wise multiply operation) and the n multiply each element of the result by a scalar.
//! Store the final result in a dense matrix.
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_schur>, op_scalar_times>& in) op_scalar_times::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1, T2,glue_schur>, op_scalar_times>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp1(in.m.A); const unwrap<T1> tmp1(in.m.A);
const unwrap<T2> tmp2(in.m.B); const unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "schur product"); arma_debug_assert_same_size(A, B, "schur product");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = (A_mem[i] * B_mem[i]) * k;
}
}
//! Evaluate A % B (where % is the element-wise multiply operation) and the
n multiply each element of the result by a scalar.
template<typename T1, typename T2>
inline
void
op_scalar_times::apply(Cube<typename T1::elem_type>& out, const OpCube< Glu
eCube<T1,T2,glue_cube_schur>, op_scalar_times>& in)
{
arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp1(in.m.A);
const unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "schur product");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 278 skipping to change at line 519
op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_s calar_div_pre>& in) op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_s calar_div_pre>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// TODO: analyse effects of aliasing // TODO: analyse effects of aliasing
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = k / X_mem[i];
}
}
template<typename T1>
inline
void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube<T1
,op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// TODO: analyse effects of aliasing
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i < X.n_elem; ++i)
{ {
out_mem[i] = k / X_mem[i]; out_mem[i] = k / X_mem[i];
} }
skipping to change at line 302 skipping to change at line 571
inline inline
void void
op_scalar_div_pre::apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_pre>& in) op_scalar_div_pre::apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_pre>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
if(&out != &X) if(&out != &X)
{ {
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = k / X_mem[i];
}
}
else
{
eT* out_mem = out.memptr();
const eT k = in.aux;
for(u32 i=0; i < out.n_elem; ++i)
{
out_mem[i] = k / out_mem[i];
}
}
}
template<typename eT>
inline
void
op_scalar_div_pre::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_scalar_div
_pre>& in)
{
arma_extra_debug_sigprint();
const Cube<eT>& X = in.m;
if(&out != &X)
{
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i < X.n_elem; ++i)
{ {
out_mem[i] = k / X_mem[i]; out_mem[i] = k / X_mem[i];
} }
} }
skipping to change at line 348 skipping to change at line 655
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] = k / out_mem[i]; out_mem[i] = k / out_mem[i];
} }
} }
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube<Gl
ueCube<T1,T2,glue_type>, op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Cube<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = k / out_mem[i];
}
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T 1,T2,glue_plus>, op_scalar_div_pre>& in) op_scalar_div_pre::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T 1,T2,glue_plus>, op_scalar_div_pre>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
unwrap<T1> tmp1(in.m.A); unwrap<T1> tmp1(in.m.A);
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = k / (A_mem[i] + B_mem[i]);
}
}
template<typename T1, typename T2>
inline
void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube< G
lueCube<T1,T2,glue_cube_plus>, op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
unwrap_cube<T1> tmp1(in.m.A);
unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "cube addition");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 400 skipping to change at line 764
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = k / (A_mem[i] - B_mem[i]);
}
}
template<typename T1, typename T2>
inline
void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube< G
lueCube<T1,T2,glue_cube_minus>, op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
unwrap_cube<T1> tmp1(in.m.A);
unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "cube subtraction");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 434 skipping to change at line 834
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "schur product"); arma_debug_assert_same_size(A, B, "schur product");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = k / (A_mem[i] * B_mem[i]);
}
}
template<typename T1, typename T2>
inline
void
op_scalar_div_pre::apply(Cube<typename T1::elem_type>& out, const OpCube< G
lueCube<T1,T2,glue_cube_schur>, op_scalar_div_pre>& in)
{
arma_extra_debug_sigprint();
unwrap_cube<T1> tmp1(in.m.A);
unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "schur product");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 467 skipping to change at line 903
op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ scalar_div_post>& in) op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ scalar_div_post>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// TODO: analyse effects of aliasing // TODO: analyse effects of aliasing
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] / k;
}
}
template<typename T1>
inline
void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<T
1,op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& X = tmp.M;
// TODO: analyse effects of aliasing
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i < X.n_elem; ++i)
{ {
out_mem[i] = X_mem[i] / k; out_mem[i] = X_mem[i] / k;
} }
skipping to change at line 491 skipping to change at line 955
inline inline
void void
op_scalar_div_post::apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_post >& in) op_scalar_div_post::apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_post >& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
if(&out != &X) if(&out != &X)
{ {
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
eT* out_mem = out.memptr();
const eT* X_mem = X.mem;
const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i)
{
out_mem[i] = X_mem[i] / k;
}
}
else
{
eT* out_mem = out.memptr();
const eT k = in.aux;
for(u32 i=0; i < out.n_elem; ++i)
{
out_mem[i] /= k;
}
}
}
template<typename eT>
inline
void
op_scalar_div_post::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_scalar_di
v_post>& in)
{
arma_extra_debug_sigprint();
const Cube<eT>& X = in.m;
if(&out != &X)
{
//out.set_size(X.n_rows, X.n_cols, X.n_slices);
out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.mem; const eT* X_mem = X.mem;
const eT k = in.aux; const eT k = in.aux;
for(u32 i=0; i < X.n_elem; ++i) for(u32 i=0; i < X.n_elem; ++i)
{ {
out_mem[i] = X_mem[i] / k; out_mem[i] = X_mem[i] / k;
} }
} }
skipping to change at line 537 skipping to change at line 1039
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = out.n_elem; const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= k; out_mem[i] /= k;
} }
} }
template<typename T1, typename T2, typename glue_type>
inline
void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<G
lueCube<T1,T2,glue_type>, op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
out = in.m; // implicit conversion to 'Cube<eT>'
eT* out_mem = out.memptr();
const eT k = in.aux;
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] /= k;
}
}
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op< Glue< T1,T2,glue_plus>, op_scalar_div_post>& in) op_scalar_div_post::apply(Mat<typename T1::elem_type>& out, const Op< Glue< T1,T2,glue_plus>, op_scalar_div_post>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
unwrap<T1> tmp1(in.m.A); unwrap<T1> tmp1(in.m.A);
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix addition"); arma_debug_assert_same_size(A, B, "matrix addition");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = (A_mem[i] + B_mem[i]) / k;
}
}
template<typename T1, typename T2>
inline
void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<
GlueCube<T1,T2,glue_cube_plus>, op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
unwrap_cube<T1> tmp1(in.m.A);
unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "cube addition");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 589 skipping to change at line 1148
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "matrix subtraction"); arma_debug_assert_same_size(A, B, "matrix subtraction");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = (A_mem[i] - B_mem[i]) / k;
}
}
template<typename T1, typename T2>
inline
void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<
GlueCube<T1,T2,glue_cube_minus>, op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
unwrap_cube<T1> tmp1(in.m.A);
unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "cube subtraction");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
skipping to change at line 623 skipping to change at line 1218
unwrap<T2> tmp2(in.m.B); unwrap<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "schur product"); arma_debug_assert_same_size(A, B, "schur product");
// no alias problems // no alias problems
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_mem = out.memptr();
const eT* A_mem = A.mem;
const eT* B_mem = B.mem;
const eT k = in.aux;
const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = (A_mem[i] * B_mem[i]) / k;
}
}
template<typename T1, typename T2>
inline
void
op_scalar_div_post::apply(Cube<typename T1::elem_type>& out, const OpCube<
GlueCube<T1,T2,glue_cube_schur>, op_scalar_div_post>& in)
{
arma_extra_debug_sigprint();
unwrap_cube<T1> tmp1(in.m.A);
unwrap_cube<T2> tmp2(in.m.B);
typedef typename T1::elem_type eT;
const Cube<eT>& A = tmp1.M;
const Cube<eT>& B = tmp2.M;
arma_debug_assert_same_size(A, B, "schur product");
// no alias problems
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* A_mem = A.mem; const eT* A_mem = A.mem;
const eT* B_mem = B.mem; const eT* B_mem = B.mem;
const eT k = in.aux; const eT k = in.aux;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
 End of changes. 30 change blocks. 
29 lines changed or deleted 683 lines changed or added


 op_scalar_misc_proto.hpp   op_scalar_misc_proto.hpp 
skipping to change at line 18 skipping to change at line 18
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_scalar_misc //! \addtogroup op_scalar_misc
//! @{ //! @{
//! 'add scalar to matrix' operation //! 'add scalar to a matrix/cube' operation
class op_scalar_plus class op_scalar_plus
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_scalar_plus>& in);
_scalar_plus>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_scalar_plus>& in);
}; };
//! 'subtract matrix from a scalar' operation //! 'subtract matrix/cube from a scalar' operation
class op_scalar_minus_pre class op_scalar_minus_pre
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_scalar_minus_pre>& in);
_scalar_minus_pre>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_scalar_minus_pre>& in);
}; };
//! 'subtract scalar from matrix' operation //! 'subtract scalar from a matrix/cube' operation
class op_scalar_minus_post class op_scalar_minus_post
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_scalar_minus_post>& in);
_scalar_minus_post>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_scalar_minus_post>& in);
}; };
//! 'multiply matrix by a scalar' operation //! 'multiply matrix/cube by a scalar' operation
class op_scalar_times class op_scalar_times
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_scalar_times>& in);
_scalar_times>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_scalar_times>& in);
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type> inline static void
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_
T1,T2,glue_type>, op_scalar_times>& in); type>, op_scalar_times>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_
type>, op_scalar_times>& in);
template<typename T1, typename T2> template<typename T1, typename T2> inline static void apply( Mat<typename
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal
T1,T2,glue_plus>, op_scalar_times>& in); ar_times>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal
ar_times>& in);
template<typename T1, typename T2> template<typename T1, typename T2> inline static void apply( Mat<typename
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal
T1,T2,glue_minus>, op_scalar_times>& in); ar_times>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
template<typename T1, typename T2> T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< ar_times>& in);
T1,T2,glue_schur>, op_scalar_times>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename
T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal
ar_times>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal
ar_times>& in);
}; };
//! 'divide scalar by a matrix' operation //! 'divide scalar by a matrix/cube' operation
class op_scalar_div_pre class op_scalar_div_pre
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_scalar_div_pre>& in);
_scalar_div_pre>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_scalar_div_pre>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_pre
>& in);
template<typename T1, typename T2, typename glue_type> template<typename eT> inline static void apply( Mat<eT>& out, const O
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< p< Mat<eT>,op_scalar_div_pre>& in);
T1,T2,glue_type>, op_scalar_div_pre>& in); template<typename eT> inline static void apply(Cube<eT>& out, const OpCub
e<Cube<eT>,op_scalar_div_pre>& in);
template<typename T1, typename T2> template<typename T1, typename T2, typename glue_type> inline static void
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_
T1,T2,glue_plus>, op_scalar_div_pre>& in); type>, op_scalar_div_pre>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_
type>, op_scalar_div_pre>& in);
template<typename T1, typename T2> template<typename T1, typename T2> inline static void apply( Mat<typename
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal
T1,T2,glue_minus>, op_scalar_div_pre>& in); ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal
ar_div_pre>& in);
template<typename T1, typename T2> template<typename T1, typename T2> inline static void apply( Mat<typename
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal
T1,T2,glue_schur>, op_scalar_div_pre>& in); ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal
ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename
T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal
ar_div_pre>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal
ar_div_pre>& in);
}; };
//! 'divide matrix by a scalar' operation //! 'divide matrix/cube by a scalar' operation
class op_scalar_div_post class op_scalar_div_post
{ {
public: public:
template<typename T1> template<typename T1> inline static void apply( Mat<typename T1::elem_typ
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op e>& out, const Op<T1,op_scalar_div_post>& in);
_scalar_div_post>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_scalar_div_post>& in);
template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Mat<eT>,op_scalar_div_pos
t>& in);
template<typename T1, typename T2, typename glue_type> template<typename eT> inline static void apply( Mat<eT>& out, const O
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< p< Mat<eT>,op_scalar_div_post>& in);
T1,T2,glue_type>, op_scalar_div_post>& in); template<typename eT> inline static void apply(Cube<eT>& out, const OpCub
e<Cube<eT>,op_scalar_div_post>& in);
template<typename T1, typename T2> template<typename T1, typename T2, typename glue_type> inline static void
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< apply( Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_
T1,T2,glue_plus>, op_scalar_div_post>& in); type>, op_scalar_div_post>& in);
template<typename T1, typename T2, typename glue_type> inline static void
apply(Cube<typename T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_
type>, op_scalar_div_post>& in);
template<typename T1, typename T2> template<typename T1, typename T2> inline static void apply( Mat<typename
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1::elem_type>& out, const Op< Glue<T1,T2, glue_plus>, op_scal
T1,T2,glue_minus>, op_scalar_div_post>& in); ar_div_post>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_plus>, op_scal
ar_div_post>& in);
template<typename T1, typename T2> template<typename T1, typename T2> inline static void apply( Mat<typename
inline static void apply(Mat<typename T1::elem_type>& out, const Op<Glue< T1::elem_type>& out, const Op< Glue<T1,T2, glue_minus>, op_scal
T1,T2,glue_schur>, op_scalar_div_post>& in); ar_div_post>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_minus>, op_scal
ar_div_post>& in);
template<typename T1, typename T2> inline static void apply( Mat<typename
T1::elem_type>& out, const Op< Glue<T1,T2, glue_schur>, op_scal
ar_div_post>& in);
template<typename T1, typename T2> inline static void apply(Cube<typename
T1::elem_type>& out, const OpCube<GlueCube<T1,T2,glue_cube_schur>, op_scal
ar_div_post>& in);
}; };
//! @} //! @}
 End of changes. 26 change blocks. 
69 lines changed or deleted 110 lines changed or added


 op_sort_meat.hpp   op_sort_meat.hpp 
skipping to change at line 165 skipping to change at line 165
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
unwrap<T1> tmp(in.m); unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 sort_type = in.aux_u32_a; const u32 sort_type = in.aux_u32_a;
const u32 dim = in.aux_u32_b; const u32 dim = in.aux_u32_b;
arma_debug_check( (sort_type > 1), "op_sort::apply(): incorrect usage. so arma_debug_check( (X.is_finite() == false), "op_sort::apply(): given obje
rt_type must be 0 or 1"); ct has non-finite elements" );
arma_debug_check( (dim > 1), "op_sort::apply(): incorrect usage. di arma_debug_check( (sort_type > 1), "op_sort::apply(): incorrect
m must be 0 or 1" ); usage. sort_type must be 0 or 1");
arma_debug_check( (dim > 1), "op_sort::apply(): incorrect
usage. dim must be 0 or 1" );
if(dim == 0) // column-wise if(dim == 0) // column-wise
{ {
arma_extra_debug_print("op_sort::apply(), dim = 0"); arma_extra_debug_print("op_sort::apply(), dim = 0");
out = X; out = X;
for(u32 col=0; col<out.n_cols; ++col) for(u32 col=0; col<out.n_cols; ++col)
{ {
op_sort::direct_sort( out.colptr(col), out.n_rows, sort_type ); op_sort::direct_sort( out.colptr(col), out.n_rows, sort_type );
} }
} }
else else
if(dim == 1) // row-wise if(dim == 1) // row-wise
{ {
if(X.n_rows != 1) // not a row vector if(X.n_rows != 1) // not a row vector
{ {
arma_extra_debug_print("op_sort::apply(), dim = 1, generic"); arma_extra_debug_print("op_sort::apply(), dim = 1, generic");
out.set_size(X.n_rows, X.n_cols); //out.set_size(X.n_rows, X.n_cols);
out.copy_size(X);
podarray<eT> tmp_array(X.n_cols); podarray<eT> tmp_array(X.n_cols);
for(u32 row=0; row<out.n_rows; ++row) for(u32 row=0; row<out.n_rows; ++row)
{ {
for(u32 col=0; col<out.n_cols; ++col) for(u32 col=0; col<out.n_cols; ++col)
{ {
tmp_array[col] = X.at(row,col); tmp_array[col] = X.at(row,col);
} }
 End of changes. 2 change blocks. 
5 lines changed or deleted 9 lines changed or added


 op_trig_meat.hpp   op_trig_meat.hpp 
skipping to change at line 40 skipping to change at line 40
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::cos(A.mem[i]);
}
}
template<typename T1>
inline
void
op_cos::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_cos>& i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::cos(A.mem[i]); out_ptr[i] = std::cos(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 64 skipping to change at line 92
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::acos(A.mem[i]);
}
}
template<typename T1>
inline
void
op_acos::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_acos>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::acos(A.mem[i]); out_ptr[i] = std::acos(A.mem[i]);
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
skipping to change at line 91 skipping to change at line 147
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
{ {
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = boost::math::acos(A.mem[i]);
}
}
#else
{
arma_stop("op_acos::apply(): need Boost libraries");
}
#endif
}
template<typename T, typename T1>
inline
void
op_acos::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_acos>& in)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST)
{
typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::acos(A.mem[i]); out_ptr[i] = boost::math::acos(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_acos::apply(): need Boost libraries"); arma_stop("op_acos::apply(): need Boost libraries");
skipping to change at line 120 skipping to change at line 212
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::cosh(A.mem[i]);
}
}
template<typename T1>
inline
void
op_cosh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_cosh>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::cosh(A.mem[i]); out_ptr[i] = std::cosh(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 146 skipping to change at line 266
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = boost::math::acosh(A.mem[i]);
}
}
#else
{
arma_stop("op_acosh::apply(): need Boost libraries");
}
#endif
}
template<typename T1>
inline
void
op_acosh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_acosh
>& in)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST)
{
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::acosh(A.mem[i]); out_ptr[i] = boost::math::acosh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_acosh::apply(): need Boost libraries"); arma_stop("op_acosh::apply(): need Boost libraries");
skipping to change at line 178 skipping to change at line 334
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::sin(A.mem[i]);
}
}
template<typename T1>
inline
void
op_sin::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sin>& i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::sin(A.mem[i]); out_ptr[i] = std::sin(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 202 skipping to change at line 386
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::acos(A.mem[i]);
}
}
template<typename T1>
inline
void
op_asin::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asin>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::acos(A.mem[i]); out_ptr[i] = std::acos(A.mem[i]);
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
skipping to change at line 229 skipping to change at line 441
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
{ {
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = boost::math::asin(A.mem[i]);
}
}
#else
{
arma_stop("op_asin::apply(): need Boost libraries");
}
#endif
}
template<typename T, typename T1>
inline
void
op_asin::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_asin>& in)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST)
{
typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::asin(A.mem[i]); out_ptr[i] = boost::math::asin(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asin::apply(): need Boost libraries"); arma_stop("op_asin::apply(): need Boost libraries");
skipping to change at line 258 skipping to change at line 506
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::sinh(A.mem[i]);
}
}
template<typename T1>
inline
void
op_sinh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sinh>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::sinh(A.mem[i]); out_ptr[i] = std::sinh(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 284 skipping to change at line 560
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = boost::math::asinh(A.mem[i]);
}
}
#else
{
arma_stop("op_asinh::apply(): need Boost libraries");
}
#endif
}
template<typename T1>
inline
void
op_asinh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asinh
>& in)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST)
{
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::asinh(A.mem[i]); out_ptr[i] = boost::math::asinh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asinh::apply(): need Boost libraries"); arma_stop("op_asinh::apply(): need Boost libraries");
skipping to change at line 315 skipping to change at line 626
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::tan(A.mem[i]);
}
}
template<typename T1>
inline
void
op_tan::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_tan>& i
n)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::tan(A.mem[i]); out_ptr[i] = std::tan(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 339 skipping to change at line 678
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::atan(A.mem[i]);
}
}
template<typename T1>
inline
void
op_atan::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_atan>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::atan(A.mem[i]); out_ptr[i] = std::atan(A.mem[i]);
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
skipping to change at line 366 skipping to change at line 733
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
{ {
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check(); isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = boost::math::atan(A.mem[i]);
}
}
#else
{
arma_stop("op_asin::apply(): need Boost libraries");
}
#endif
}
template<typename T, typename T1>
inline
void
op_atan::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_atan>& in)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST)
{
typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::atan(A.mem[i]); out_ptr[i] = boost::math::atan(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_asin::apply(): need Boost libraries"); arma_stop("op_asin::apply(): need Boost libraries");
skipping to change at line 395 skipping to change at line 798
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = std::tanh(A.mem[i]);
}
}
template<typename T1>
inline
void
op_tanh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_tanh>&
in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = std::tanh(A.mem[i]); out_ptr[i] = std::tanh(A.mem[i]);
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 421 skipping to change at line 852
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const u32 n_elem = A.n_elem; const u32 n_elem = A.n_elem;
out.set_size(A.n_rows, A.n_cols); //out.set_size(A.n_rows, A.n_cols);
out.copy_size(A);
eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_ptr[i] = boost::math::atanh(A.mem[i]);
}
}
#else
{
arma_stop("op_atanh::apply(): need Boost libraries");
}
#endif
}
template<typename T1>
inline
void
op_atanh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_atanh
>& in)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST)
{
typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M;
const u32 n_elem = A.n_elem;
//out.set_size(A.n_rows, A.n_cols, A.n_slices);
out.copy_size(A);
eT* out_ptr = out.memptr(); eT* out_ptr = out.memptr();
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_ptr[i] = boost::math::atanh(A.mem[i]); out_ptr[i] = boost::math::atanh(A.mem[i]);
} }
} }
#else #else
{ {
arma_stop("op_atanh::apply(): need Boost libraries"); arma_stop("op_atanh::apply(): need Boost libraries");
 End of changes. 15 change blocks. 
15 lines changed or deleted 494 lines changed or added


 op_trig_proto.hpp   op_trig_proto.hpp 
skipping to change at line 29 skipping to change at line 29
// trigonometric functions: // trigonometric functions:
// cos family: cos, acos, cosh, acosh // cos family: cos, acos, cosh, acosh
// sin family: sin, asin, sinh, asinh // sin family: sin, asin, sinh, asinh
// tan family: tan, atan, tanh, atanh // tan family: tan, atan, tanh, atanh
// cos family // cos family
class op_cos class op_cos
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_cos>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_cos>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_cos>& in);
}; };
class op_acos class op_acos
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_acos>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
template<typename T, typename T1> inline static void apply(Mat< std::comp e>& out, const Op<T1,op_acos>& in);
lex<T> >& out, const Op<T1,op_acos>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_acos>& in);
template<typename T, typename T1> inline static void apply( Mat< std::com
plex<T> >& out, const Op<T1,op_acos>& in);
template<typename T, typename T1> inline static void apply(Cube< std::com
plex<T> >& out, const OpCube<T1,op_acos>& in);
}; };
class op_cosh class op_cosh
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_cosh>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_cosh>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_cosh>& in);
}; };
class op_acosh class op_acosh
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_acosh>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
template<typename T, typename T1> inline static void apply(Mat< std::comp e>& out, const Op<T1,op_acosh>& in);
lex<T> >& out, const Op<T1,op_acosh>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_acosh>& in);
template<typename T, typename T1> inline static void apply( Mat< std::com
plex<T> >& out, const Op<T1,op_acosh>& in);
template<typename T, typename T1> inline static void apply(Cube< std::com
plex<T> >& out, const OpCube<T1,op_acosh>& in);
}; };
// sin family // sin family
class op_sin class op_sin
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_sin>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_sin>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_sin>& in);
}; };
class op_asin class op_asin
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_asin>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
template<typename T, typename T1> inline static void apply(Mat< std::comp e>& out, const Op<T1,op_asin>& in);
lex<T> >& out, const Op<T1,op_asin>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_asin>& in);
template<typename T, typename T1> inline static void apply( Mat< std::com
plex<T> >& out, const Op<T1,op_asin>& in);
template<typename T, typename T1> inline static void apply(Cube< std::com
plex<T> >& out, const OpCube<T1,op_asin>& in);
}; };
class op_sinh class op_sinh
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_sinh>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_sinh>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_sinh>& in);
}; };
class op_asinh class op_asinh
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_asinh>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_asinh>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_asinh>& in);
}; };
// tan family // tan family
class op_tan class op_tan
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_tan>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_tan>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_tan>& in);
}; };
class op_atan class op_atan
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_atan>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
template<typename T, typename T1> inline static void apply(Mat< std::comp e>& out, const Op<T1,op_atan>& in);
lex<T> >& out, const Op<T1,op_atan>& in); template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_atan>& in);
template<typename T, typename T1> inline static void apply( Mat< std::com
plex<T> >& out, const Op<T1,op_atan>& in);
template<typename T, typename T1> inline static void apply(Cube< std::com
plex<T> >& out, const OpCube<T1,op_atan>& in);
}; };
class op_tanh class op_tanh
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_tanh>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_tanh>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_tanh>& in);
}; };
class op_atanh class op_atanh
{ {
public: public:
template<typename T1> inline static void apply(Mat<typename T1::elem_type
>& out, const Op<T1,op_atanh>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_atanh>& in);
template<typename T1> inline static void apply(Cube<typename T1::elem_typ
e>& out, const OpCube<T1,op_atanh>& in);
}; };
//! @} //! @}
 End of changes. 12 change blocks. 
32 lines changed or deleted 80 lines changed or added


 op_zeros_meat.hpp   op_zeros_meat.hpp 
skipping to change at line 71 skipping to change at line 71
template<typename eT> template<typename eT>
inline inline
void void
op_zeros::apply(Row<eT>& out, const Op<Row<eT>,op_zeros>& in) op_zeros::apply(Row<eT>& out, const Op<Row<eT>,op_zeros>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a); out.zeros(in.aux_u32_a);
} }
template<typename eT>
inline
void
op_zeros::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_zeros>& in)
{
arma_extra_debug_sigprint();
out.zeros(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 10 lines changed or added


 op_zeros_proto.hpp   op_zeros_proto.hpp 
skipping to change at line 38 skipping to change at line 38
inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_zeros>& in); inline static void apply(Mat<eT>& out, const Op<Col<eT>,op_zeros>& in);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_zeros>& in); inline static void apply(Mat<eT>& out, const Op<Row<eT>,op_zeros>& in);
template<typename eT> template<typename eT>
inline static void apply(Col<eT>& out, const Op<Col<eT>,op_zeros>& in); inline static void apply(Col<eT>& out, const Op<Col<eT>,op_zeros>& in);
template<typename eT> template<typename eT>
inline static void apply(Row<eT>& out, const Op<Row<eT>,op_zeros>& in); inline static void apply(Row<eT>& out, const Op<Row<eT>,op_zeros>& in);
//
template<typename eT>
inline static void apply(Cube<eT>& out, const OpCube<Cube<eT>,op_zeros>&
in);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 6 lines changed or added


 subview_field_meat.hpp   subview_field_meat.hpp 
skipping to change at line 27 skipping to change at line 27
template<typename oT> template<typename oT>
inline inline
subview_field<oT>::~subview_field() subview_field<oT>::~subview_field()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
subview_field<oT>::subview_field(const field<oT>& in_f, const u32 in_row1, subview_field<oT>::subview_field
const u32 in_col1, const u32 in_row2, const u32 in_col2) (
const field<oT>& in_f,
const u32 in_row1,
const u32 in_col1,
const u32 in_row2,
const u32 in_col2
)
: f(in_f) : f(in_f)
, f_ptr(0) , f_ptr(0)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, aux_row2(in_row2) , aux_row2(in_row2)
, aux_col2(in_col2) , aux_col2(in_col2)
, 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 oT> template<typename oT>
arma_inline arma_inline
subview_field<oT>::subview_field(field<oT>& in_f, const u32 in_row1, const subview_field<oT>::subview_field
u32 in_col1, const u32 in_row2, const u32 in_col2) (
field<oT>& in_f,
const u32 in_row1,
const u32 in_col1,
const u32 in_row2,
const u32 in_col2
)
: f(in_f) : f(in_f)
, f_ptr(&in_f) , f_ptr(&in_f)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, aux_row2(in_row2) , aux_row2(in_row2)
, aux_col2(in_col2) , aux_col2(in_col2)
, 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)
{ {
 End of changes. 2 change blocks. 
4 lines changed or deleted 16 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 374 skipping to change at line 374
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) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
t_coldata[row] -= x_coldata[row]; t_coldata[row] -= x_coldata[row];
} }
}
if(overlap)
{
delete tmp_subview;
delete tmp_mat;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator%= (const subview& x_in) subview<eT>::operator%= (const subview& 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 schur product"); arma_debug_assert_same_size(t, x, "matrix schur product");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
t_coldata[row] *= x_coldata[row]; t_coldata[row] *= x_coldata[row];
} }
}
if(overlap)
{
delete tmp_subview;
delete tmp_mat;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator/= (const subview& x_in) subview<eT>::operator/= (const subview& 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, "element-wise matrix division"); arma_debug_assert_same_size(t, x, "element-wise matrix division");
for(u32 col = 0; col<t.n_cols; ++col) for(u32 col = 0; col<t.n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col); const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t.n_rows; ++row)
{ {
t_coldata[row] /= x_coldata[row]; t_coldata[row] /= x_coldata[row];
} }
}
if(overlap)
{
delete tmp_subview;
delete tmp_mat;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::zeros() subview<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 860 skipping to change at line 875
} }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) for(u32 i=0; i<out.n_elem; ++i)
{ {
const eT tmp = out_mem[i]; const eT tmp = out_mem[i];
out_mem[i] = tmp*tmp; out_mem[i] = tmp/tmp; // using tmp/tmp as tmp might be zero
} }
} }
} }
// //
// //
// //
template<typename eT> template<typename eT>
 End of changes. 10 change blocks. 
4 lines changed or deleted 19 lines changed or added


 traits.hpp   traits.hpp 
skipping to change at line 87 skipping to change at line 87
template<typename eT> template<typename eT>
struct is_diagview< diagview<eT> > struct is_diagview< diagview<eT> >
{ static const bool value = true; }; { static const bool value = true; };
// //
// //
// //
template<typename T> template<typename T>
struct is_Cube
{ static const bool value = false; };
template<typename eT>
struct is_Cube< Cube<eT> >
{ static const bool value = true; };
template<typename T>
struct is_subview_cube
{ static const bool value = false; };
template<typename eT>
struct is_subview_cube< subview_cube<eT> >
{ static const bool value = true; };
//
//
//
template<typename T>
struct is_Op struct is_Op
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1, typename op_type> template<typename T1, typename op_type>
struct is_Op< Op<T1,op_type> > struct is_Op< Op<T1,op_type> >
{ static const bool value = true; }; { static const bool value = true; };
template<typename T> template<typename T>
struct is_OpCube
{ static const bool value = false; };
template<typename T1, typename op_type>
struct is_OpCube< OpCube<T1,op_type> >
{ static const bool value = true; };
template<typename T>
struct is_Glue struct is_Glue
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
struct is_Glue< Glue<T1,T2,glue_type> > struct is_Glue< Glue<T1,T2,glue_type> >
{ static const bool value = true; }; { static const bool value = true; };
template<typename T> template<typename T>
struct is_GlueCube
{ static const bool value = false; };
template<typename T1, typename T2, typename glue_type>
struct is_GlueCube< GlueCube<T1,T2,glue_type> >
{ static const bool value = true; };
template<typename T>
struct is_glue_times struct is_glue_times
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct is_glue_times< Glue<T1,T2,glue_times> > struct is_glue_times< Glue<T1,T2,glue_times> >
{ static const bool value = true; }; { static const bool value = true; };
// //
// //
// //
skipping to change at line 126 skipping to change at line 162
{ {
static const bool value static const bool value
= is_Mat<T1>::value = is_Mat<T1>::value
|| is_Op<T1>::value || is_Op<T1>::value
|| is_Glue<T1>::value || is_Glue<T1>::value
|| is_subview<T1>::value || is_subview<T1>::value
|| is_diagview<T1>::value || is_diagview<T1>::value
; ;
}; };
template<typename T1>
struct is_arma_cube_type
{
static const bool value
= is_Cube<T1>::value
|| is_OpCube<T1>::value
|| is_GlueCube<T1>::value
|| is_subview_cube<T1>::value
;
};
// //
// //
// //
template<typename T1, typename T2> template<typename T1, typename T2>
struct is_same_type struct is_same_type
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1> template<typename T1>
struct is_same_type<T1,T1> struct is_same_type<T1,T1>
 End of changes. 4 change blocks. 
0 lines changed or deleted 47 lines changed or added


 typedef.hpp   typedef.hpp 
skipping to change at line 66 skipping to change at line 66
// //
// //! unsigned 32 bit type // //! unsigned 32 bit type
// typedef uint32_t u32; // typedef uint32_t u32;
// //
// //! signed 32 bit type // //! signed 32 bit type
// typedef int32_t s32; // typedef int32_t s32;
typedef std::complex<float> cx_float; typedef std::complex<float> cx_float;
typedef std::complex<double> cx_double; typedef std::complex<double> cx_double;
typedef Mat<unsigned char> uchar_mat; typedef Mat<unsigned char> uchar_mat;
typedef Col<unsigned char> uchar_vec; typedef Col<unsigned char> uchar_vec;
typedef Col<unsigned char> uchar_colvec; typedef Col<unsigned char> uchar_colvec;
typedef Row<unsigned char> uchar_rowvec; typedef Row<unsigned char> uchar_rowvec;
typedef Cube<unsigned char> uchar_cube;
typedef Mat<u32> umat;
typedef Col<u32> uvec; typedef Mat<u32> umat;
typedef Col<u32> ucolvec; typedef Col<u32> uvec;
typedef Row<u32> urowvec; typedef Col<u32> ucolvec;
typedef Row<u32> urowvec;
typedef Mat<s32> imat; typedef Cube<u32> ucube;
typedef Col<s32> ivec;
typedef Col<s32> icolvec; typedef Mat<s32> imat;
typedef Row<s32> irowvec; typedef Col<s32> ivec;
typedef Col<s32> icolvec;
typedef Mat<float> fmat; typedef Row<s32> irowvec;
typedef Col<float> fvec; typedef Cube<s32> icube;
typedef Col<float> fcolvec;
typedef Row<float> frowvec; typedef Mat<float> fmat;
typedef Col<float> fvec;
typedef Mat<double> mat; typedef Col<float> fcolvec;
typedef Col<double> vec; typedef Row<float> frowvec;
typedef Col<double> colvec; typedef Cube<float> fcube;
typedef Row<double> rowvec;
typedef Mat<double> mat;
typedef Mat<cx_float> cx_fmat; typedef Col<double> vec;
typedef Col<cx_float> cx_fvec; typedef Col<double> colvec;
typedef Col<cx_float> cx_fcolvec; typedef Row<double> rowvec;
typedef Row<cx_float> cx_frowvec; typedef Cube<double> cube;
typedef Mat<cx_double> cx_mat; typedef Mat<cx_float> cx_fmat;
typedef Col<cx_double> cx_vec; typedef Col<cx_float> cx_fvec;
typedef Col<cx_double> cx_colvec; typedef Col<cx_float> cx_fcolvec;
typedef Row<cx_double> cx_rowvec; typedef Row<cx_float> cx_frowvec;
typedef Cube<cx_float> cx_fcube;
typedef Mat<cx_double> cx_mat;
typedef Col<cx_double> cx_vec;
typedef Col<cx_double> cx_colvec;
typedef Row<cx_double> cx_rowvec;
typedef Cube<cx_double> cx_cube;
namespace junk namespace junk
{ {
struct arma_elem_size_test struct arma_elem_size_test
{ {
arma_static_assert<sizeof(u8) == 1> ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZ E; arma_static_assert<sizeof(u8) == 1> ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZ E;
arma_static_assert<sizeof(s8) == 1> ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZ E; arma_static_assert<sizeof(s8) == 1> ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZ E;
arma_static_assert<sizeof(u16) == 2> ERROR___TYPE_U16_HAS_UNSUPPORTED_S IZE; arma_static_assert<sizeof(u16) == 2> ERROR___TYPE_U16_HAS_UNSUPPORTED_S IZE;
 End of changes. 1 change blocks. 
34 lines changed or deleted 41 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/