Col_meat.hpp   Col_meat.hpp 
skipping to change at line 35 skipping to change at line 35
//! 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)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
Mat<eT>::init(in_n_elem, 1); Mat<eT>::init(in_n_elem, (in_n_elem > 0) ? 1 : 0);
} }
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols) Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
skipping to change at line 160 skipping to change at line 160
Mat<eT>::operator=(X.get_ref()); Mat<eT>::operator=(X.get_ref());
return *this; return *this;
} }
//! construct a column vector from a given auxiliary array of eTs //! construct a column vector from a given auxiliary array of eTs
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co nst bool strict) Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co nst bool strict)
: Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem, strict) : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0), copy_aux_mem, strict)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
} }
//! construct a column vector from a given auxiliary array of eTs //! construct a column vector from a given auxiliary array of eTs
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const eT* aux_mem, const u32 aux_length) Col<eT>::Col(const eT* aux_mem, const u32 aux_length)
: Mat<eT>(aux_mem, aux_length, 1) : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0))
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Col<eT>::Col Col<eT>::Col
skipping to change at line 484 skipping to change at line 484
return Mat<eT>::memptr() + row_num + 1; return Mat<eT>::memptr() + row_num + 1;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<u32 fixed_n_elem>
arma_inline arma_inline
void void
Col<eT>::fixed<fixed_n_elem>::mem_setup() Col<eT>::fixed<fixed_n_elem>::mem_setup()
{ {
arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = (fixed_n_elem > 0) ? 1 : 0;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>:
:mem_local;
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
void
Col<eT>::fixed<fixed_n_elem>::change_to_row()
{
arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0;
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
Col<eT>::fixed<fixed_n_elem>::fixed()
{
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) mem_setup();
{ }
access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = 1; template<typename eT>
access::rw(Mat<eT>::n_elem) = fixed_n_elem; template<u32 fixed_n_elem>
access::rw(Mat<eT>::vec_state) = 1; arma_inline
access::rw(Mat<eT>::mem_state) = 3; Col<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_preal {
loc) ? mem_local_extra : Mat<eT>::mem_local; arma_extra_debug_sigprint_this(this);
}
else mem_setup();
{
access::rw(Mat<eT>::n_rows) = 0; eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0; arrayops::copy( dest, X.mem, fixed_n_elem );
access::rw(Mat<eT>::vec_state) = 1; }
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0; template<typename eT>
} template<u32 fixed_n_elem>
inline
Col<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Col<eT>::operator=(X);
}
template<typename eT>
template<u32 fixed_n_elem>
template<typename T1>
inline
Col<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Col<eT>::operator=(A.get_ref());
}
template<typename eT>
template<u32 fixed_n_elem>
template<typename T1, typename T2>
inline
Col<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base<
pod_type,T2>& B)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Col<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<u32 fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = (fixed_n_elem > 0) ? 1 : 0;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true)
{ {
access::rw(Mat<eT>::n_rows) = fixed_n_elem; eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true) access::rw(Mat<eT>::mem) = dest;
{
access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc)
? mem_local_extra : Mat<eT>::mem_local;
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem arrayops::copy( dest, aux_mem, fixed_n_elem );
);
}
else
{
access::rw(Mat<eT>::mem) = aux_mem;
}
} }
else else
{ {
access::rw(Mat<eT>::n_rows) = 0; access::rw(Mat<eT>::mem) = aux_mem;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0;
} }
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<u32 fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
//! NOTE: this function relies on
//! Col::operator=(text), to change vec_state as well as swapping n_rows an
d n_cols,
//! and Mat::init(), to check that the given vector will not have a differe
nt size than fixed_n_elem.
template<typename eT>
template<u32 fixed_n_elem>
inline
Col<eT>::fixed<fixed_n_elem>::fixed(const char* text)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
change_to_row();
Col<eT>::operator=(text);
}
//! NOTE: this function relies on
//! Col::operator=(text), to change vec_state as well as swapping n_rows an
d n_cols,
//! and Mat::init(), to check that the given vector will not have a differe
nt size than fixed_n_elem.
template<typename eT>
template<u32 fixed_n_elem>
inline
Col<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
change_to_row();
Col<eT>::operator=(text);
}
template<typename eT>
template<u32 fixed_n_elem>
template<typename T1>
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
{
arma_extra_debug_sigprint();
Col<eT>::operator=(A.get_ref());
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const eT val)
{
arma_extra_debug_sigprint();
Col<eT>::operator=(val);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const char* text)
{
arma_extra_debug_sigprint();
change_to_row();
Col<eT>::operator=(text);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
{
arma_extra_debug_sigprint();
change_to_row();
Col<eT>::operator=(text);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
Col<eT>::operator=(X);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
inline
subview_row<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col
_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
const subview_row<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col
_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
subview_col<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co
l_num)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
const subview_col<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co
l_num) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
subview<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
const subview<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Col<eT>::fixed<fixed_n_elem>::operator[] (const u32 i)
{
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Col<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) const
{
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Col<eT>::fixed<fixed_n_elem>::at(const u32 i)
{
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Col<eT>::fixed<fixed_n_elem>::at(const u32 i) const
{
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 i)
{
arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo
unds");
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 i) const
{
arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo
unds");
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Col<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col)
{
return access::rw( Mat<eT>::mem[in_row] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Col<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) const
{
return ( Mat<eT>::mem[in_row] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co
l)
{
arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe
d::operator(): out of bounds" );
return access::rw( Mat<eT>::mem[in_row] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Col<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co
l) const
{
arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe
d::operator(): out of bounds" );
return ( Mat<eT>::mem[in_row] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_hot
inline
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::fill(const eT val)
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem )
;
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
arma_hot
inline
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::zeros()
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem
);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
arma_hot
inline
const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::ones()
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem
);
return *this;
}
#ifdef ARMA_EXTRA_COL_MEAT #ifdef ARMA_EXTRA_COL_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT)
#endif #endif
//! @} //! @}
 End of changes. 12 change blocks. 
45 lines changed or deleted 432 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 44 skipping to change at line 44
// try to expose buggy user code that accesses deleted objects // try to expose buggy user code that accesses deleted objects
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
access::rw(n_elem_slice) = 0; access::rw(n_elem_slice) = 0;
access::rw(n_slices) = 0; access::rw(n_slices) = 0;
access::rw(n_elem) = 0; access::rw(n_elem) = 0;
access::rw(mat_ptrs) = 0; access::rw(mat_ptrs) = 0;
access::rw(mem) = 0; access::rw(mem) = 0;
} }
isnt_supported_elem_type<eT>::check(); arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
} }
template<typename eT> template<typename eT>
inline inline
Cube<eT>::Cube() Cube<eT>::Cube()
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
skipping to change at line 93 skipping to change at line 93
inline inline
void void
Cube<eT>::init(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces) Cube<eT>::init(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_sli ces)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d, in_n_slices = %d") % in_n_rows % in_n_cols % in_n_slices ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d, in_n_slices = %d") % in_n_rows % in_n_cols % in_n_slices );
const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) & & (n_slices == in_n_slices) ); const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) & & (n_slices == in_n_slices) );
if(same_size == false) if(same_size == false)
{ {
arma_debug_check( (mem_state == 3), "Cube::init(): size can't be change const u32 t_mem_state = mem_state;
d as template based size specification is in use" );
bool err_state = false;
char* err_msg = 0;
arma_debug_set_error
(
err_state,
err_msg,
(t_mem_state == 3),
"Cube::init(): size is fixed and hence cannot be changed"
);
arma_debug_set_error
(
err_state,
err_msg,
(double(in_n_rows) * double(in_n_cols) * double(in_n_slices)) > doubl
e(0xFFFFFFFF),
"Cube::init(): requested size is too large"
);
arma_debug_check(err_state, err_msg);
const u32 old_n_elem = n_elem; const u32 old_n_elem = n_elem;
const u32 new_n_elem = in_n_rows * in_n_cols * in_n_slices; const u32 new_n_elem = in_n_rows * in_n_cols * in_n_slices;
if(old_n_elem == new_n_elem) if(old_n_elem == new_n_elem)
{ {
if(same_size == false) if(same_size == false)
{ {
delete_mat(); delete_mat();
skipping to change at line 117 skipping to change at line 138
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols; access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices; access::rw(n_slices) = in_n_slices;
create_mat(); create_mat();
} }
} }
} }
else else
{ {
arma_debug_check( (mem_state == 2), "Cube::init(): requested size is not compatible with the size of auxiliary memory" ); arma_debug_check( (t_mem_state == 2), "Cube::init(): requested size i s not compatible with the size of auxiliary memory" );
delete_mat(); delete_mat();
if(mem_state == 0) if(t_mem_state == 0)
{ {
if(n_elem > Cube_prealloc::mem_n_elem ) if(n_elem > Cube_prealloc::mem_n_elem )
{ {
arma_extra_debug_print("Cube::init(): freeing memory"); arma_extra_debug_print("Cube::init(): freeing memory");
delete [] mem; delete [] mem;
} }
} }
access::rw(mem_state) = 0; access::rw(mem_state) = 0;
skipping to change at line 189 skipping to change at line 210
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type T; typedef typename T1::elem_type T;
typedef typename ProxyCube<T1>::ea_type ea_type1; typedef typename ProxyCube<T1>::ea_type ea_type1;
typedef typename ProxyCube<T2>::ea_type ea_type2; typedef typename ProxyCube<T2>::ea_type ea_type2;
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil 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
arma_type_check< is_complex< T>::value == true >::apply(); //!< compil e-time abort if T is std::complex arma_type_check< is_complex< T>::value == true >::apply(); //!< compil e-time abort if T is std::complex
isnt_same_type<std::complex<T>, eT>::check(); //!< compile-time abort i f types are not compatible arma_type_check< is_same_type< std::complex<T>, eT >::value == false >::a pply(); //!< compile-time abort if types are not compatible
const ProxyCube<T1> X(A.get_ref()); const ProxyCube<T1> X(A.get_ref());
const ProxyCube<T2> Y(B.get_ref()); const ProxyCube<T2> Y(B.get_ref());
arma_assert_same_size(X, Y, "Cube()"); arma_assert_same_size(X, Y, "Cube()");
init(X.get_n_rows(), X.get_n_cols(), X.get_n_slices()); init(X.get_n_rows(), X.get_n_cols(), X.get_n_slices());
const u32 N = n_elem; const u32 N = n_elem;
eT* out_mem = memptr(); eT* out_mem = memptr();
skipping to change at line 1015 skipping to change at line 1036
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! create a cube from OpCube, i.e. run the previously delayed unary operat ions //! create a cube from OpCube, i.e. run the previously delayed unary operat ions
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const OpCube<T1, op_type>& X) Cube<eT>::operator=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
op_type::apply(*this, X); op_type::apply(*this, X);
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operand having delayed operations //! in-place cube addition, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const OpCube<T1, op_type>& X) Cube<eT>::operator+=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place cube subtraction, with the right-hand-side operand having dela yed operations //! in-place cube subtraction, with the right-hand-side operand having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const OpCube<T1, op_type>& X) Cube<eT>::operator-=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const OpCube<T1, op_type>& X) Cube<eT>::operator%=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations //! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const OpCube<T1, op_type>& X) Cube<eT>::operator/=(const OpCube<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! create a cube from eOpCube, i.e. run the previously delayed unary opera tions //! create a cube from eOpCube, i.e. run the previously delayed unary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
skipping to change at line 1116 skipping to change at line 1137
, n_cols(0) , n_cols(0)
, n_elem_slice(0) , n_elem_slice(0)
, n_slices(0) , n_slices(0)
, n_elem(0) , n_elem(0)
, mem_state(0) , mem_state(0)
, mat_ptrs(mat_ptrs) , mat_ptrs(mat_ptrs)
, mem(mem) , mem(mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
//! create a cube from eOpCube, i.e. run the previously delayed unary opera tions //! create a cube from eOpCube, i.e. run the previously delayed unary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply(*this, X); eop_type::apply(*this, X);
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operand having delayed operations //! in-place cube addition, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator+=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_plus(*this, X); eop_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
//! in-place cube subtraction, with the right-hand-side operand having dela yed operations //! in-place cube subtraction, with the right-hand-side operand having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator-=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_minus(*this, X); eop_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator%=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_schur(*this, X); eop_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations //! in-place cube element-wise division, with the right-hand-side operand h aving delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const eOpCube<T1, eop_type>& X) Cube<eT>::operator/=(const eOpCube<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_div(*this, X); eop_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
skipping to change at line 1317 skipping to change at line 1338
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
glue_type::apply(*this, X); glue_type::apply(*this, X);
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operands having delaye d operations //! in-place cube addition, with the right-hand-side operands having delaye d operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator+=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place cube subtraction, with the right-hand-side operands having del ayed operations //! in-place cube subtraction, with the right-hand-side operands having del ayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator-=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator%=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place cube element-wise division, with the right-hand-side operands having delayed operations //! in-place cube element-wise division, with the right-hand-side operands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const GlueCube<T1, T2, glue_type>& X) Cube<eT>::operator/=(const GlueCube<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Cube<eT> m(X); const Cube<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! create a cube from eGlue, i.e. run the previously delayed binary operat ions //! create a cube from eGlue, i.e. run the previously delayed binary operat ions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
skipping to change at line 1420 skipping to change at line 1441
//! create a cube from Glue, i.e. run the previously delayed binary operati ons //! create a cube from Glue, i.e. run the previously delayed binary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
return *this; return *this;
} }
//! in-place cube addition, with the right-hand-side operands having delaye d operations //! in-place cube addition, with the right-hand-side operands having delaye d operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator+=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator+=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_plus(*this, X); eglue_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
//! in-place cube subtraction, with the right-hand-side operands having del ayed operations //! in-place cube subtraction, with the right-hand-side operands having del ayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator-=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator-=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_minus(*this, X); eglue_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations //! in-place cube element-wise multiplication, with the right-hand-side ope rands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator%=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator%=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_schur(*this, X); eglue_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
//! in-place cube element-wise division, with the right-hand-side operands having delayed operations //! in-place cube element-wise division, with the right-hand-side operands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator/=(const eGlueCube<T1, T2, eglue_type>& X) Cube<eT>::operator/=(const eGlueCube<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_div(*this, X); eglue_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
 End of changes. 27 change blocks. 
38 lines changed or deleted 79 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 39 skipping to change at line 39
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(); arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat() Mat<eT>::Mat()
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
skipping to change at line 88 skipping to change at line 88
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols );
const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) ) ; const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) ) ;
if(same_size == false) if(same_size == false)
{ {
const u32 t_vec_state = vec_state; const u32 t_vec_state = vec_state;
const u32 t_mem_state = mem_state; const u32 t_mem_state = mem_state;
arma_debug_check bool err_state = false;
char* err_msg = 0;
arma_debug_set_error
( (
err_state,
err_msg,
(t_mem_state == 3), (t_mem_state == 3),
"Mat::init(): size is fixed and hence cannot be changed" "Mat::init(): size is fixed and hence cannot be changed"
); );
arma_debug_check arma_debug_set_error
( (
err_state,
err_msg,
( (
(t_vec_state > 0) && (t_vec_state > 0) &&
( (
((t_vec_state == 1) && (in_n_cols > 1)) || ((t_vec_state == 1) && (in_n_cols > 1)) ||
((t_vec_state == 2) && (in_n_rows > 1)) ((t_vec_state == 2) && (in_n_rows > 1))
) )
), ),
"Mat::init(): object is a row or column vector; requested size is not "Mat::init(): object is a vector; requested size is not compatible"
compatible" );
// ensure that n_elem can hold the result of (n_rows * n_cols)
// (due to a limitation in the C++98 standard: there is no official "lo
ng long" variable type)
arma_debug_set_error
(
err_state,
err_msg,
(double(in_n_rows) * double(in_n_cols)) > double(0xFFFFFFFF),
"Mat::init(): requested size is too large"
); );
arma_debug_check(err_state, err_msg);
const u32 old_n_elem = n_elem; const u32 old_n_elem = n_elem;
const u32 new_n_elem = in_n_rows * in_n_cols; const u32 new_n_elem = in_n_rows * in_n_cols;
if(old_n_elem == new_n_elem) if(old_n_elem == new_n_elem)
{ {
arma_extra_debug_print("Mat::init(): reusing memory"); arma_extra_debug_print("Mat::init(): reusing memory");
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
} }
else else
{ {
arma_debug_check arma_debug_check
( (
(t_mem_state == 2), (t_mem_state == 2),
"Mat::init(): requested size is not compatible with the size of aux iliary memory" "Mat::init(): mismatch between size of auxiliary memory and request ed size"
); );
if(t_mem_state == 0) if(t_mem_state == 0)
{ {
if(old_n_elem > arma_config::mat_prealloc) if(old_n_elem > arma_config::mat_prealloc)
{ {
arma_extra_debug_print("Mat::init(): freeing memory"); arma_extra_debug_print("Mat::init(): freeing memory");
delete [] mem; delete [] mem;
} }
skipping to change at line 152 skipping to change at line 171
access::rw(mem) = new(std::nothrow) eT[new_n_elem]; access::rw(mem) = new(std::nothrow) eT[new_n_elem];
arma_check( (mem == 0), "Mat::init(): out of memory" ); arma_check( (mem == 0), "Mat::init(): out of memory" );
} }
access::rw(n_elem) = new_n_elem; access::rw(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;
access::rw(mem_state) = 0; access::rw(mem_state) = 0;
} }
if(new_n_elem == 0)
{
access::rw(n_rows) = 0;
access::rw(n_cols) = 0;
}
} }
} }
//! create the matrix from a textual description //! create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const char* text) Mat<eT>::Mat(const char* text)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
skipping to change at line 443 skipping to change at line 456
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type T; typedef typename T1::elem_type T;
typedef typename Proxy<T1>::ea_type ea_type1; typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; typedef typename Proxy<T2>::ea_type ea_type2;
arma_type_check< is_complex<eT>::value == false >::apply(); //!< compil 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
arma_type_check< is_complex< T>::value == true >::apply(); //!< compil e-time abort if T is std::complex arma_type_check< is_complex< T>::value == true >::apply(); //!< compil e-time abort if T is std::complex
isnt_same_type<std::complex<T>, eT>::check(); //!< compile-time abort i f types are not compatible arma_type_check< is_same_type< std::complex<T>, eT >::value == false >::a pply(); //!< compile-time abort if types are not compatible
const Proxy<T1> X(A.get_ref()); const Proxy<T1> X(A.get_ref());
const Proxy<T2> Y(B.get_ref()); const Proxy<T2> Y(B.get_ref());
arma_assert_same_size(X, Y, "Mat()"); arma_assert_same_size(X, Y, "Mat()");
init(X.get_n_rows(), X.get_n_cols()); init(X.get_n_rows(), X.get_n_cols());
const u32 N = n_elem; const u32 N = n_elem;
eT* out_mem = memptr(); eT* out_mem = memptr();
skipping to change at line 1911 skipping to change at line 1924
// } // }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT> diagview<eT>
Mat<eT>::diag(const s32 in_id) Mat<eT>::diag(const s32 in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; if(n_elem > 0)
const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; {
const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0;
const u32 col_offset = (in_id > 0) ? u32( in_id) : 0;
arma_debug_check arma_debug_check
( (
(row_offset >= n_rows) || (col_offset >= n_cols), (row_offset >= n_rows) || (col_offset >= n_cols),
"Mat::diag(): requested diagonal out of bounds" "Mat::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
return diagview<eT>(*this, row_offset, col_offset, len); return diagview<eT>(*this, row_offset, col_offset, len);
}
else
{
return diagview<eT>(*this, 0, 0, 0);
}
} }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
arma_inline arma_inline
const diagview<eT> const diagview<eT>
Mat<eT>::diag(const s32 in_id) const Mat<eT>::diag(const s32 in_id) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0; if(n_elem > 0)
const u32 col_offset = (in_id > 0) ? in_id : 0; {
const u32 row_offset = (in_id < 0) ? -in_id : 0;
const u32 col_offset = (in_id > 0) ? in_id : 0;
arma_debug_check arma_debug_check
( (
(row_offset >= n_rows) || (col_offset >= n_cols), (row_offset >= n_rows) || (col_offset >= n_cols),
"Mat::diag(): requested diagonal out of bounds" "Mat::diag(): requested diagonal out of bounds"
); );
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
return diagview<eT>(*this, row_offset, col_offset, len); return diagview<eT>(*this, row_offset, col_offset, len);
}
else
{
return diagview<eT>(*this, 0, 0, 0);
}
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2) Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
skipping to change at line 2275 skipping to change at line 2302
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) //, mem(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(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
op_type::apply(*this, X); op_type::apply(*this, X);
} }
//! create a matrix from Op, i.e. run the previously delayed unary operatio ns //! create a matrix from Op, i.e. run the previously delayed unary operatio ns
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const Op<T1, op_type>& X) Mat<eT>::operator=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
op_type::apply(*this, X); op_type::apply(*this, X);
return *this; return *this;
} }
//! in-place matrix addition, with the right-hand-side operand having delay ed operations //! in-place matrix addition, with the right-hand-side operand having delay ed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Op<T1, op_type>& X) Mat<eT>::operator+=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place matrix subtraction, with the right-hand-side operand having de layed operations //! in-place matrix subtraction, with the right-hand-side operand having de layed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Op<T1, op_type>& X) Mat<eT>::operator-=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place matrix multiplication, with the right-hand-side operand having delayed operations //! in-place matrix multiplication, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const Op<T1, op_type>& X) Mat<eT>::operator*=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix element-wise multiplication, with the right-hand-side o perand having delayed operations //! in-place matrix element-wise multiplication, with the right-hand-side o perand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const Op<T1, op_type>& X) Mat<eT>::operator%=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place matrix element-wise division, with the right-hand-side operand having delayed operations //! in-place matrix element-wise division, with the right-hand-side operand having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const Op<T1, op_type>& X) Mat<eT>::operator/=(const Op<T1, op_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! create a matrix from eOp, i.e. run the previously delayed unary operati ons //! create a matrix from eOp, i.e. run the previously delayed unary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
skipping to change at line 2391 skipping to change at line 2418
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) //, mem(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(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
//! create a matrix from eOp, i.e. run the previously delayed unary operati ons //! create a matrix from eOp, i.e. run the previously delayed unary operati ons
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eOp<T1, eop_type>& X) Mat<eT>::operator=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply(*this, X); eop_type::apply(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const eOp<T1, eop_type>& X) Mat<eT>::operator+=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_plus(*this, X); eop_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const eOp<T1, eop_type>& X) Mat<eT>::operator-=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_minus(*this, X); eop_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const eOp<T1, eop_type>& X) Mat<eT>::operator*=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const eOp<T1, eop_type>& X) Mat<eT>::operator%=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_schur(*this, X); eop_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const eOp<T1, eop_type>& X) Mat<eT>::operator/=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal se >::apply();
eop_type::apply_inplace_div(*this, X); eop_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL //! EXPERIMENTAL
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
skipping to change at line 2604 skipping to change at line 2631
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) //, mem(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(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
glue_type::apply(*this, X); glue_type::apply(*this, X);
} }
//! create a matrix from Glue, i.e. run the previously delayed binary opera tions //! create a matrix from Glue, i.e. run the previously delayed binary opera tions
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
glue_type::apply(*this, X); glue_type::apply(*this, X);
return *this; return *this;
} }
//! in-place matrix addition, with the right-hand-side operands having dela yed operations //! in-place matrix addition, with the right-hand-side operands having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator+=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator+=(m); return (*this).operator+=(m);
} }
//! in-place matrix subtraction, with the right-hand-side operands having d elayed operations //! in-place matrix subtraction, with the right-hand-side operands having d elayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator-=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator-=(m); return (*this).operator-=(m);
} }
//! in-place matrix multiplications, with the right-hand-side operands havi ng delayed operations //! in-place matrix multiplications, with the right-hand-side operands havi ng delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator*=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
//! in-place matrix element-wise multiplication, with the right-hand-side o perands having delayed operations //! in-place matrix element-wise multiplication, with the right-hand-side o perands having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator%=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator%=(m); return (*this).operator%=(m);
} }
//! in-place matrix element-wise division, with the right-hand-side operand s having delayed operations //! in-place matrix element-wise division, with the right-hand-side operand s having delayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const Glue<T1, T2, glue_type>& X) Mat<eT>::operator/=(const Glue<T1, T2, glue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Mat<eT>& const Mat<eT>&
skipping to change at line 2753 skipping to change at line 2780
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
//, mem(0) //, mem(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(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
} }
//! create a matrix from eGlue, i.e. run the previously delayed binary oper ations //! create a matrix from eGlue, i.e. run the previously delayed binary oper ations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
return *this; return *this;
} }
//! in-place matrix addition, with the right-hand-side operands having dela yed operations //! in-place matrix addition, with the right-hand-side operands having dela yed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator+=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_plus(*this, X); eglue_type::apply_inplace_plus(*this, X);
return *this; return *this;
} }
//! in-place matrix subtraction, with the right-hand-side operands having d elayed operations //! in-place matrix subtraction, with the right-hand-side operands having d elayed operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator-=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_minus(*this, X); eglue_type::apply_inplace_minus(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator*=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
glue_times::apply_inplace(*this, X); glue_times::apply_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator%=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_schur(*this, X); eglue_type::apply_inplace_schur(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator/=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, typename T1::elem_type>::check(); arma_type_check< is_same_type< eT, typename T1::elem_type >::value == fal
isnt_same_type<eT, typename T2::elem_type>::check(); se >::apply();
arma_type_check< is_same_type< eT, typename T2::elem_type >::value == fal
se >::apply();
eglue_type::apply_inplace_div(*this, X); eglue_type::apply_inplace_div(*this, X);
return *this; return *this;
} }
//! EXPERIMENTAL: create a matrix from mtGlue, i.e. run the previously dela yed binary operations //! EXPERIMENTAL: create a matrix from mtGlue, i.e. run the previously dela yed binary operations
template<typename eT> template<typename eT>
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
inline inline
Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X) Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X)
skipping to change at line 3118 skipping to change at line 3145
return (n_elem == 0); return (n_elem == 0);
} }
//! returns true if the object can be interpreted as a column or row vector //! returns true if the object can be interpreted as a column or row vector
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::is_vec() const Mat<eT>::is_vec() const
{ {
return ( (n_rows == 1) || (n_cols == 1) ); const u32 t_n_rows = n_rows;
const u32 t_n_cols = n_cols;
return ( (t_n_rows == 1) || (t_n_cols == 1) || ( (t_n_rows == 0) && (t_n_
cols == 0) ) );
} }
//! returns true if the object has the same number of non-zero rows and col umnns //! returns true if the object has the same number of non-zero rows and col umnns
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::is_square() const Mat<eT>::is_square() const
{ {
return ( (n_rows == n_cols) && (n_elem > 0) ); return (n_rows == n_cols);
} }
//! returns true if all of the elements are finite //! returns true if all of the elements are finite
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::is_finite() const Mat<eT>::is_finite() const
{ {
return arrayops::is_finite( memptr(), n_elem ); return arrayops::is_finite( memptr(), n_elem );
skipping to change at line 3343 skipping to change at line 3373
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print_trans(const std::string extra_text) const Mat<eT>::print_trans(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.print(extra_text); tmp.print(extra_text);
} }
//! print contents of the transposed version of matrix to a user specified stream, //! print contents of the transposed version of matrix to a user specified stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::print_trans(std::ostream& user_stream, const std::string extra_tex t) const Mat<eT>::print_trans(std::ostream& user_stream, const std::string extra_tex t) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.print(user_stream, extra_text); tmp.print(user_stream, extra_text);
} }
//! print contents of the matrix (to the cout stream), //! print contents of the matrix (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified //! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
skipping to change at line 3423 skipping to change at line 3453
//! the stream's state are used as is and are not modified //! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print_trans(const std::string extra_text) const Mat<eT>::raw_print_trans(const std::string extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.raw_print(extra_text); tmp.raw_print(extra_text);
} }
//! print contents of the transposed version of the matrix to a user specif ied stream, //! print contents of the transposed version of the matrix to a user specif ied stream,
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified. //! the stream's state are used as is and are not modified.
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::raw_print_trans(std::ostream& user_stream, const std::string extra _text) const Mat<eT>::raw_print_trans(std::ostream& user_stream, const std::string extra _text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
op_trans::apply_noalias(tmp, *this); op_strans::apply_noalias(tmp, *this);
tmp.raw_print(user_stream, extra_text); tmp.raw_print(user_stream, extra_text);
} }
//! change the matrix to have user specified dimensions (data is not preser ved) //! change the matrix to have user specified dimensions (data is not preser ved)
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::set_size(const u32 in_elem) Mat<eT>::set_size(const u32 in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(vec_state) switch(vec_state)
{ {
case 0: case 0:
case 1: case 1:
init(in_elem, 1); init(in_elem, (in_elem > 0) ? 1 : 0);
break; break;
case 2: case 2:
init(1, in_elem); init((in_elem > 0) ? 1 : 0, in_elem);
break; break;
default: default:
; ;
} }
} }
//! change the matrix to have user specified dimensions (data is not preser ved) //! change the matrix to have user specified dimensions (data is not preser ved)
template<typename eT> template<typename eT>
inline inline
skipping to change at line 4406 skipping to change at line 4436
return typename Mat<eT>::const_row_iterator(*this, row_num + 1); return typename Mat<eT>::const_row_iterator(*this, row_num + 1);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline arma_inline
void void
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::mem_setup() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::mem_setup()
{ {
arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : mem_loca
l;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed()
{
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) mem_setup();
{ }
access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols; template<typename eT>
access::rw(Mat<eT>::n_elem) = fixed_n_elem; template<u32 fixed_n_rows, u32 fixed_n_cols>
access::rw(Mat<eT>::vec_state) = 0; arma_inline
access::rw(Mat<eT>::mem_state) = 3; Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const fixed<fixed_n_rows,
access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_preal fixed_n_cols>& X)
loc) ? mem_local_extra : mem_local; {
} arma_extra_debug_sigprint_this(this);
else
{ mem_setup();
access::rw(Mat<eT>::n_rows) = 0;
access::rw(Mat<eT>::n_cols) = 0; eT* dest = (use_extra) ? mem_local_extra : mem_local;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 0; arrayops::copy( dest, X.mem, fixed_n_elem );
access::rw(Mat<eT>::mem_state) = 3; }
access::rw(Mat<eT>::mem) = 0;
} template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
template<typename T1>
inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const Base<eT,T1>& A)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Mat<eT>::operator=(A.get_ref());
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
template<typename T1, typename T2>
inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const Base<pod_type,T1>&
A, const Base<pod_type,T2>& B)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Mat<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<u32 fixed_n_rows, u32 fixed_n_cols>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(eT* aux_mem, const bool c opy_aux_mem) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(eT* aux_mem, const bool c opy_aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true)
{ {
access::rw(Mat<eT>::n_rows) = fixed_n_rows; eT* dest = (use_extra) ? mem_local_extra : mem_local;
access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true) access::rw(Mat<eT>::mem) = dest;
{
access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc)
? mem_local_extra : mem_local;
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem arrayops::copy( dest, aux_mem, fixed_n_elem );
);
}
else
{
access::rw(Mat<eT>::mem) = aux_mem;
}
} }
else else
{ {
access::rw(Mat<eT>::n_rows) = 0; access::rw(Mat<eT>::mem) = aux_mem;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0;
} }
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols> template<u32 fixed_n_rows, u32 fixed_n_cols>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const eT* aux_mem) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const char* text)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Mat<eT>::operator=(text);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::string& text)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Mat<eT>::operator=(text);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const Base<eT,T1>& A)
{
Mat<eT>::operator=(A.get_ref());
return *this;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const eT val)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(val);
return *this;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const char* text)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(text);
return *this;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::string& te
xt)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(text);
return *this;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
subview_row<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const u32 row_num, c
onst span& col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
const subview_row<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const u32 row_num, c
onst span& col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
subview_col<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const u32 col_num)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
const subview_col<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const u32 col_num) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
subview<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const span& col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
inline
const subview<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const span& col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const u32 i)
{
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const u32 i) const
{
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const u32 i)
{
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const u32 i) const
{
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const u32 i)
{
arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo
unds");
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const u32 i) const
{
arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo
unds");
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const u32 in_row, const u32
in_col)
{
const u32 i = in_row + in_col*fixed_n_rows;
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const u32 in_row, const u32
in_col) const
{
const u32 i = in_row + in_col*fixed_n_rows;
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const u32 in_row, c
onst u32 in_col)
{
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)),
"Mat::fixed::operator(): out of bounds");
const u32 i = in_row + in_col*fixed_n_rows;
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_inline
arma_warn_unused
eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const u32 in_row, c
onst u32 in_col) const
{
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)),
"Mat::fixed::operator(): out of bounds");
const u32 i = in_row + in_col*fixed_n_rows;
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_hot
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fill(const eT val)
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem )
;
return *this;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_hot
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::zeros()
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem
);
return *this;
}
template<typename eT>
template<u32 fixed_n_rows, u32 fixed_n_cols>
arma_hot
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::ones()
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem
);
return *this;
}
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::prefix_pp(Mat<eT>& x) Mat_aux::prefix_pp(Mat<eT>& x)
{ {
eT* memptr = x.memptr(); eT* memptr = x.memptr();
const u32 n_elem = x.n_elem; const u32 n_elem = x.n_elem;
u32 i,j; u32 i,j;
 End of changes. 63 change blocks. 
123 lines changed or deleted 529 lines changed or added


 Proxy.hpp   Proxy.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 39 skipping to change at line 39
template<typename eT> template<typename eT>
class Proxy< Mat<eT> > class Proxy< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Mat<eT>& Q; arma_aligned const Mat<eT>& Q;
inline explicit Proxy(const Mat<eT>& A) inline explicit Proxy(const Mat<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 68 skipping to change at line 70
template<typename eT> template<typename eT>
class Proxy< Col<eT> > class Proxy< Col<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Col<eT> stored_type; typedef Col<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Col<eT>& Q; arma_aligned const Col<eT>& Q;
inline explicit Proxy(const Col<eT>& A) inline explicit Proxy(const Col<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 97 skipping to change at line 101
template<typename eT> template<typename eT>
class Proxy< Row<eT> > class Proxy< Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Row<eT> stored_type; typedef Row<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Row<eT>& Q; arma_aligned const Row<eT>& Q;
inline explicit Proxy(const Row<eT>& A) inline explicit Proxy(const Row<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 126 skipping to change at line 132
template<typename T1, typename op_type> template<typename T1, typename op_type>
class Proxy< Op<T1, op_type> > class Proxy< Op<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Op<T1, op_type>& A) inline explicit Proxy(const Op<T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 155 skipping to change at line 163
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class Proxy< Glue<T1, T2, glue_type> > class Proxy< Glue<T1, T2, glue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Glue<T1, T2, glue_type>& A) inline explicit Proxy(const Glue<T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 184 skipping to change at line 194
template<typename eT> template<typename eT>
class Proxy< subview<eT> > class Proxy< subview<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview<eT> stored_type; typedef subview<eT> stored_type;
typedef const subview<eT>& ea_type; typedef const subview<eT>& ea_type;
static const bool prefer_at_accessor = true;
arma_aligned const subview<eT>& Q; arma_aligned const subview<eT>& Q;
inline explicit Proxy(const subview<eT>& A) inline explicit Proxy(const subview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 213 skipping to change at line 225
template<typename eT, typename T1> template<typename eT, typename T1>
class Proxy< subview_elem1<eT,T1> > class Proxy< subview_elem1<eT,T1> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Mat<eT> Q; arma_aligned const Mat<eT> Q;
inline explicit Proxy(const subview_elem1<eT,T1>& A) inline explicit Proxy(const subview_elem1<eT,T1>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 242 skipping to change at line 256
template<typename eT> template<typename eT>
class Proxy< diagview<eT> > class Proxy< diagview<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef diagview<eT> stored_type; typedef diagview<eT> stored_type;
typedef const diagview<eT>& ea_type; typedef const diagview<eT>& ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const diagview<eT>& Q; arma_aligned const diagview<eT>& Q;
inline explicit Proxy(const diagview<eT>& A) inline explicit Proxy(const diagview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 271 skipping to change at line 287
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
class Proxy< eOp<T1, eop_type > > class Proxy< eOp<T1, eop_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eOp<T1, eop_type> stored_type; typedef eOp<T1, eop_type> stored_type;
typedef const eOp<T1, eop_type>& ea_type; typedef const eOp<T1, eop_type>& ea_type;
static const bool prefer_at_accessor = eOp<T1, eop_type>::prefer_at_acces
sor;
arma_aligned const eOp<T1, eop_type>& Q; arma_aligned const eOp<T1, eop_type>& Q;
inline explicit Proxy(const eOp<T1, eop_type>& A) inline explicit Proxy(const eOp<T1, eop_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline u32 get_n_rows() const { return Q.get_n_rows(); }
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } arma_inline u32 get_n_cols() const { return Q.get_n_cols(); }
skipping to change at line 300 skipping to change at line 318
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
class Proxy< eGlue<T1, T2, eglue_type > > class Proxy< eGlue<T1, T2, eglue_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eGlue<T1, T2, eglue_type> stored_type; typedef eGlue<T1, T2, eglue_type> stored_type;
typedef const eGlue<T1, T2, eglue_type>& ea_type; typedef const eGlue<T1, T2, eglue_type>& ea_type;
static const bool prefer_at_accessor = eGlue<T1, T2, eglue_type>::prefer_
at_accessor;
arma_aligned const eGlue<T1, T2, eglue_type>& Q; arma_aligned const eGlue<T1, T2, eglue_type>& Q;
inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A) inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline u32 get_n_rows() const { return Q.get_n_rows(); }
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } arma_inline u32 get_n_cols() const { return Q.get_n_cols(); }
skipping to change at line 329 skipping to change at line 349
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class Proxy< mtOp<out_eT, T1, op_type> > class Proxy< mtOp<out_eT, T1, op_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Mat<out_eT> stored_type; typedef Mat<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A) inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 358 skipping to change at line 380
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class Proxy< mtGlue<out_eT, T1, T2, glue_type > > class Proxy< mtGlue<out_eT, T1, T2, glue_type > >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Mat<out_eT> stored_type; typedef Mat<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A) inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
 End of changes. 13 change blocks. 
2 lines changed or deleted 28 lines changed or added


 ProxyCube.hpp   ProxyCube.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 39 skipping to change at line 39
template<typename eT> template<typename eT>
class ProxyCube< Cube<eT> > class ProxyCube< Cube<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Cube<eT> stored_type; typedef Cube<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Cube<eT>& Q; arma_aligned const Cube<eT>& Q;
inline explicit ProxyCube(const Cube<eT>& A) inline explicit ProxyCube(const Cube<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 69 skipping to change at line 71
template<typename T1, typename op_type> template<typename T1, typename op_type>
class ProxyCube< OpCube<T1, op_type> > class ProxyCube< OpCube<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Cube<elem_type> stored_type; typedef Cube<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Cube<elem_type> Q; arma_aligned const Cube<elem_type> Q;
inline explicit ProxyCube(const OpCube<T1, op_type>& A) inline explicit ProxyCube(const OpCube<T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 99 skipping to change at line 103
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class ProxyCube< GlueCube<T1, T2, glue_type> > class ProxyCube< GlueCube<T1, T2, glue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Cube<elem_type> stored_type; typedef Cube<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Cube<elem_type> Q; arma_aligned const Cube<elem_type> Q;
inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A) inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 129 skipping to change at line 135
template<typename eT> template<typename eT>
class ProxyCube< subview_cube<eT> > class ProxyCube< subview_cube<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview_cube<eT> stored_type; typedef subview_cube<eT> stored_type;
typedef const subview_cube<eT>& ea_type; typedef const subview_cube<eT>& ea_type;
static const bool prefer_at_accessor = true;
arma_aligned const subview_cube<eT>& Q; arma_aligned const subview_cube<eT>& Q;
inline explicit ProxyCube(const subview_cube<eT>& A) inline explicit ProxyCube(const subview_cube<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 159 skipping to change at line 167
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
class ProxyCube< eOpCube<T1, eop_type > > class ProxyCube< eOpCube<T1, eop_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eOpCube<T1, eop_type> stored_type; typedef eOpCube<T1, eop_type> stored_type;
typedef const eOpCube<T1, eop_type>& ea_type; typedef const eOpCube<T1, eop_type>& ea_type;
static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_a
ccessor;
arma_aligned const eOpCube<T1, eop_type>& Q; arma_aligned const eOpCube<T1, eop_type>& Q;
inline explicit ProxyCube(const eOpCube<T1, eop_type>& A) inline explicit ProxyCube(const eOpCube<T1, eop_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline u32 get_n_rows() const { return Q.get_n_rows(); }
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } arma_inline u32 get_n_cols() const { return Q.get_n_cols(); }
skipping to change at line 189 skipping to change at line 199
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
class ProxyCube< eGlueCube<T1, T2, eglue_type > > class ProxyCube< eGlueCube<T1, T2, eglue_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eGlueCube<T1, T2, eglue_type> stored_type; typedef eGlueCube<T1, T2, eglue_type> stored_type;
typedef const eGlueCube<T1, T2, eglue_type>& ea_type; typedef const eGlueCube<T1, T2, eglue_type>& ea_type;
static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::pre
fer_at_accessor;
arma_aligned const eGlueCube<T1, T2, eglue_type>& Q; arma_aligned const eGlueCube<T1, T2, eglue_type>& Q;
inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A) inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.get_n_rows(); } arma_inline u32 get_n_rows() const { return Q.get_n_rows(); }
arma_inline u32 get_n_cols() const { return Q.get_n_cols(); } arma_inline u32 get_n_cols() const { return Q.get_n_cols(); }
skipping to change at line 219 skipping to change at line 231
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class ProxyCube< mtOpCube<out_eT, T1, op_type> > class ProxyCube< mtOpCube<out_eT, T1, op_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Cube<out_eT> stored_type; typedef Cube<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Cube<out_eT> Q; arma_aligned const Cube<out_eT> Q;
inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A) inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
skipping to change at line 249 skipping to change at line 263
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > > class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Cube<out_eT> stored_type; typedef Cube<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false;
arma_aligned const Cube<out_eT> Q; arma_aligned const Cube<out_eT> Q;
inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A) inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline u32 get_n_rows() const { return Q.n_rows; } arma_inline u32 get_n_rows() const { return Q.n_rows; }
arma_inline u32 get_n_cols() const { return Q.n_cols; } arma_inline u32 get_n_cols() const { return Q.n_cols; }
 End of changes. 9 change blocks. 
2 lines changed or deleted 20 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 33 skipping to change at line 33
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const u32 in_n_elem) Row<eT>::Row(const u32 in_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::init(1, in_n_elem); Mat<eT>::init((in_n_elem > 0) ? 1 : 0, in_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols) Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
skipping to change at line 134 skipping to change at line 134
Mat<eT>::operator=(X.get_ref()); Mat<eT>::operator=(X.get_ref());
return *this; return *this;
} }
//! construct a row vector from a given auxiliary array //! construct a row vector from a given auxiliary array
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co nst bool strict) Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co nst bool strict)
: Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict) : Mat<eT>(aux_mem, ((aux_length > 0) ? 1 : 0), aux_length, copy_aux_mem, strict)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
} }
//! construct a row vector from a given auxiliary array //! construct a row vector from a given auxiliary array
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const eT* aux_mem, const u32 aux_length) Row<eT>::Row(const eT* aux_mem, const u32 aux_length)
: Mat<eT>(aux_mem, 1, aux_length) : Mat<eT>(aux_mem, ((aux_length > 0) ? 1 : 0), aux_length)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
Row<eT>::Row Row<eT>::Row
skipping to change at line 458 skipping to change at line 458
return Mat<eT>::memptr() + Mat<eT>::n_cols; return Mat<eT>::memptr() + Mat<eT>::n_cols;
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<u32 fixed_n_elem>
arma_inline arma_inline
void void
Row<eT>::fixed<fixed_n_elem>::mem_setup() Row<eT>::fixed<fixed_n_elem>::mem_setup()
{ {
arma_extra_debug_sigprint();
access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0;
access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>:
:mem_local;
}
template<typename eT>
template<u32 fixed_n_elem>
inline
Row<eT>::fixed<fixed_n_elem>::fixed()
{
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) mem_setup();
{ }
access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = fixed_n_elem; template<typename eT>
access::rw(Mat<eT>::n_elem) = fixed_n_elem; template<u32 fixed_n_elem>
access::rw(Mat<eT>::vec_state) = 2; arma_inline
access::rw(Mat<eT>::mem_state) = 3; Row<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_preal {
loc) ? mem_local_extra : Mat<eT>::mem_local; arma_extra_debug_sigprint_this(this);
}
else mem_setup();
{
access::rw(Mat<eT>::n_rows) = 0; eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0; arrayops::copy( dest, X.mem, fixed_n_elem );
access::rw(Mat<eT>::vec_state) = 2; }
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0; template<typename eT>
} template<u32 fixed_n_elem>
arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Row<eT>::operator=(X);
}
template<typename eT>
template<u32 fixed_n_elem>
template<typename T1>
arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Row<eT>::operator=(A.get_ref());
}
template<typename eT>
template<u32 fixed_n_elem>
template<typename T1, typename T2>
arma_inline
Row<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base<
pod_type,T2>& B)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Row<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<u32 fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
if(fixed_n_elem > 0) access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0;
access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true)
{ {
access::rw(Mat<eT>::n_rows) = 1; eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true) access::rw(Mat<eT>::mem) = dest;
{
access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc)
? mem_local_extra : Mat<eT>::mem_local;
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem arrayops::copy( dest, aux_mem, fixed_n_elem );
);
}
else
{
access::rw(Mat<eT>::mem) = aux_mem;
}
} }
else else
{ {
access::rw(Mat<eT>::n_rows) = 0; access::rw(Mat<eT>::mem) = aux_mem;
access::rw(Mat<eT>::n_cols) = 0;
access::rw(Mat<eT>::n_elem) = 0;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
access::rw(Mat<eT>::mem) = 0;
} }
} }
template<typename eT> template<typename eT>
template<u32 fixed_n_elem> template<u32 fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
template<typename eT>
template<u32 fixed_n_elem>
inline
Row<eT>::fixed<fixed_n_elem>::fixed(const char* text)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Row<eT>::operator=(text);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
Row<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
{
arma_extra_debug_sigprint_this(this);
mem_setup();
Row<eT>::operator=(text);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
subview_row<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col
_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
template<typename T1>
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
{
arma_extra_debug_sigprint();
Row<eT>::operator=(A.get_ref());
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const eT val)
{
arma_extra_debug_sigprint();
Row<eT>::operator=(val);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const char* text)
{
arma_extra_debug_sigprint();
Row<eT>::operator=(text);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
{
arma_extra_debug_sigprint();
Row<eT>::operator=(text);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
{
arma_extra_debug_sigprint();
Row<eT>::operator=(X);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
inline
const subview_row<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col
_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
subview_col<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co
l_num)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
const subview_col<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const u32 co
l_num) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
subview<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
inline
const subview<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Row<eT>::fixed<fixed_n_elem>::operator[] (const u32 i)
{
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Row<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) const
{
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Row<eT>::fixed<fixed_n_elem>::at(const u32 i)
{
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Row<eT>::fixed<fixed_n_elem>::at(const u32 i) const
{
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 i)
{
arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo
unds");
return access::rw( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 i) const
{
arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo
unds");
return ( Mat<eT>::mem[i] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Row<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col)
{
return access::rw( Mat<eT>::mem[in_col] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Row<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) const
{
return ( Mat<eT>::mem[in_col] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co
l)
{
arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe
d::operator(): out of bounds" );
return access::rw( Mat<eT>::mem[in_col] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_inline
arma_warn_unused
eT
Row<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_co
l) const
{
arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe
d::operator(): out of bounds" );
return ( Mat<eT>::mem[in_col] );
}
template<typename eT>
template<u32 fixed_n_elem>
arma_hot
inline
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::fill(const eT val)
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem )
;
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
arma_hot
inline
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::zeros()
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem
);
return *this;
}
template<typename eT>
template<u32 fixed_n_elem>
arma_hot
inline
const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::ones()
{
arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem
);
return *this;
}
#ifdef ARMA_EXTRA_ROW_MEAT #ifdef ARMA_EXTRA_ROW_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT)
#endif #endif
//! @} //! @}
 End of changes. 12 change blocks. 
45 lines changed or deleted 402 lines changed or added


 arma_ostream_meat.hpp   arma_ostream_meat.hpp 
skipping to change at line 199 skipping to change at line 199
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , m.memptr(), m.n_elem) : o.width(); const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , m.memptr(), m.n_elem) : o.width();
const u32 m_n_rows = m.n_rows; const u32 m_n_rows = m.n_rows;
const u32 m_n_cols = m.n_cols; const u32 m_n_cols = m.n_cols;
if(m_n_cols > 0) if(m.is_empty() == false)
{ {
if(cell_width > 0) if(m_n_cols > 0)
{ {
for(u32 row=0; row < m_n_rows; ++row) if(cell_width > 0)
{ {
for(u32 col=0; col < m_n_cols; ++col) for(u32 row=0; row < m_n_rows; ++row)
{ {
// the cell width appears to be reset after each element is print for(u32 col=0; col < m_n_cols; ++col)
ed, {
// hence we need to restore it // the cell width appears to be reset after each element is pri
o.width(cell_width); nted,
arma_ostream::print_elem(o, m.at(row,col)); // hence we need to restore it
} o.width(cell_width);
arma_ostream::print_elem(o, m.at(row,col));
}
o << '\n'; o << '\n';
}
} }
} else
else
{
for(u32 row=0; row < m_n_rows; ++row)
{ {
for(u32 col=0; col < m_n_cols-1; ++col) for(u32 row=0; row < m_n_rows; ++row)
{ {
arma_ostream::print_elem(o, m.at(row,col)); for(u32 col=0; col < m_n_cols-1; ++col)
o << ' '; {
} arma_ostream::print_elem(o, m.at(row,col));
o << ' ';
}
arma_ostream::print_elem(o, m.at(row, m_n_cols-1)); arma_ostream::print_elem(o, m.at(row, m_n_cols-1));
o << '\n'; o << '\n';
}
} }
} }
} }
else
{
o << "[matrix size: " << m_n_rows << 'x' << m_n_cols << "]\n";
}
o.flush(); o.flush();
stream_state.restore(o); stream_state.restore(o);
} }
//! Print a cube to the specified stream //! Print a cube to the specified stream
template<typename eT> template<typename eT>
inline inline
void void
arma_ostream::print(std::ostream& o, const Cube<eT>& x, const bool modify) arma_ostream::print(std::ostream& o, const Cube<eT>& x, const bool modify)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , x.memptr(), x.n_elem) : o.width(); const std::streamsize cell_width = modify ? arma_ostream::modify_stream(o , x.memptr(), x.n_elem) : o.width();
for(u32 slice=0; slice < x.n_slices; ++slice) if(x.is_empty() == false)
{
for(u32 slice=0; slice < x.n_slices; ++slice)
{
o << "[cube slice " << slice << ']' << '\n';
o.width(cell_width);
arma_ostream::print(o, x.slice(slice), false);
o << '\n';
}
}
else
{ {
o << "[cube slice " << slice << ']' << '\n'; o << "[cube size: " << x.n_rows << 'x' << x.n_cols << 'x' << x.n_slices
o.width(cell_width); << "]\n";
arma_ostream::print(o, x.slice(slice), false);
o << '\n';
} }
stream_state.restore(o); stream_state.restore(o);
} }
//! Print a field to the specified stream //! Print a field to the specified stream
//! Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (s td::ostream&, const oT&) //! Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (s td::ostream&, const oT&)
template<typename oT> template<typename oT>
inline inline
void void
skipping to change at line 275 skipping to change at line 289
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o); const arma_ostream_state stream_state(o);
const std::streamsize cell_width = o.width(); const std::streamsize cell_width = o.width();
const u32 x_n_rows = x.n_rows; const u32 x_n_rows = x.n_rows;
const u32 x_n_cols = x.n_cols; const u32 x_n_cols = x.n_cols;
for(u32 col=0; col<x_n_cols; ++col) if(x.is_empty() == false)
{ {
o << "[field column " << col << ']' << '\n'; for(u32 col=0; col<x_n_cols; ++col)
for(u32 row=0; row<x_n_rows; ++row)
{ {
o.width(cell_width); o << "[field column " << col << ']' << '\n';
o << x.at(row,col) << '\n';
}
o << '\n'; for(u32 row=0; row<x_n_rows; ++row)
{
o.width(cell_width);
o << x.at(row,col) << '\n';
}
o << '\n';
}
}
else
{
o << "[field size: " << x_n_rows << 'x' << x_n_cols << "]\n";
} }
o.flush(); o.flush();
stream_state.restore(o); stream_state.restore(o);
} }
//! Print a subfield to the specified stream //! Print a subfield to the specified stream
//! Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (s td::ostream&, const oT&) //! Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (s td::ostream&, const oT&)
template<typename oT> template<typename oT>
inline inline
 End of changes. 17 change blocks. 
34 lines changed or deleted 56 lines changed or added


 arma_static_assert.hpp   arma_static_assert.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_static_assert //! \addtogroup arma_static_assert
//! @{ //! @{
//! Classes for primitive compile time assertions (until the next version o f C++) //! Classes for primitive compile time assertions and checks (until the nex t version of C++)
template<bool> struct arma_static_assert; template<bool> struct arma_static_assert;
template<> struct arma_static_assert<true> {}; template<> struct arma_static_assert<true> {};
template<bool> struct arma_static_check;
template<> struct arma_static_check<false> {};
template<bool val> template<bool val>
struct arma_type_check struct arma_type_check
{ {
arma_inline static void apply() arma_inline
static
void
apply()
{ {
arma_static_assert<!val> ERROR___INCORRECT_TYPE; arma_static_check<val> ERROR___INCORRECT_TYPE;
ERROR___INCORRECT_TYPE = ERROR___INCORRECT_TYPE; ERROR___INCORRECT_TYPE = ERROR___INCORRECT_TYPE;
} }
}; };
template<>
struct arma_type_check<false>
{
arma_inline
static
void
apply()
{
}
};
//! @} //! @}
 End of changes. 6 change blocks. 
5 lines changed or deleted 22 lines changed or added


 arma_version.hpp   arma_version.hpp 
skipping to change at line 17 skipping to change at line 17
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 1 #define ARMA_VERSION_MAJOR 1
#define ARMA_VERSION_MINOR 2 #define ARMA_VERSION_MINOR 99
#define ARMA_VERSION_PATCH 0 #define ARMA_VERSION_PATCH 2
#define ARMA_VERSION_NAME "Unscrupulous Carbon Emitter" #define ARMA_VERSION_NAME "v2.0 beta 2"
struct arma_version struct arma_version
{ {
static const unsigned int major = ARMA_VERSION_MAJOR; static const unsigned int major = ARMA_VERSION_MAJOR;
static const unsigned int minor = ARMA_VERSION_MINOR; static const unsigned int minor = ARMA_VERSION_MINOR;
static const unsigned int patch = ARMA_VERSION_PATCH; static const unsigned int patch = ARMA_VERSION_PATCH;
static static
inline inline
std::string std::string
 End of changes. 1 change blocks. 
3 lines changed or deleted 3 lines changed or added


 armadillo   armadillo 
skipping to change at line 90 skipping to change at line 90
} }
#undef ARMA_STR1 #undef ARMA_STR1
#undef ARMA_STR2 #undef ARMA_STR2
#undef ARMA_CBLAS #undef ARMA_CBLAS
#undef ARMA_CLAPACK #undef ARMA_CLAPACK
#endif #endif
#endif #endif
#include "armadillo_bits/itpp_wrap.hpp" #include "armadillo_bits/itpp_wrap.hpp"
#include "armadillo_bits/undefine_conflicts.hpp"
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
// preliminaries // preliminaries
#include "armadillo_bits/forward_proto.hpp" #include "armadillo_bits/forward_bones.hpp"
#include "armadillo_bits/arma_static_assert.hpp" #include "armadillo_bits/arma_static_assert.hpp"
#include "armadillo_bits/typedef.hpp" #include "armadillo_bits/typedef.hpp"
#include "armadillo_bits/typedef_u64.hpp"
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/format_wrap.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
#include "armadillo_bits/span.hpp" #include "armadillo_bits/span.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
// //
// class prototypes // class prototypes
#include "armadillo_bits/Base.hpp" #include "armadillo_bits/Base.hpp"
#include "armadillo_bits/BaseCube.hpp" #include "armadillo_bits/BaseCube.hpp"
#include "armadillo_bits/blas_proto.hpp" #include "armadillo_bits/blas_bones.hpp"
#include "armadillo_bits/lapack_proto.hpp" #include "armadillo_bits/lapack_bones.hpp"
#include "armadillo_bits/atlas_proto.hpp" #include "armadillo_bits/atlas_bones.hpp"
#include "armadillo_bits/arrayops_proto.hpp" #include "armadillo_bits/arrayops_bones.hpp"
#include "armadillo_bits/podarray_proto.hpp" #include "armadillo_bits/podarray_bones.hpp"
#include "armadillo_bits/auxlib_proto.hpp" #include "armadillo_bits/auxlib_bones.hpp"
#include "armadillo_bits/injector_proto.hpp" #include "armadillo_bits/injector_bones.hpp"
#include "armadillo_bits/Mat_proto.hpp" #include "armadillo_bits/Mat_bones.hpp"
#include "armadillo_bits/Col_proto.hpp" #include "armadillo_bits/Col_bones.hpp"
#include "armadillo_bits/Row_proto.hpp" #include "armadillo_bits/Row_bones.hpp"
#include "armadillo_bits/Cube_proto.hpp" #include "armadillo_bits/Cube_bones.hpp"
#include "armadillo_bits/typedef_fixed.hpp" #include "armadillo_bits/typedef_fixed.hpp"
#include "armadillo_bits/field_proto.hpp" #include "armadillo_bits/field_bones.hpp"
#include "armadillo_bits/subview_proto.hpp" #include "armadillo_bits/subview_bones.hpp"
#include "armadillo_bits/subview_elem1_proto.hpp" #include "armadillo_bits/subview_elem1_bones.hpp"
#include "armadillo_bits/subview_field_proto.hpp" #include "armadillo_bits/subview_field_bones.hpp"
#include "armadillo_bits/subview_cube_proto.hpp" #include "armadillo_bits/subview_cube_bones.hpp"
#include "armadillo_bits/diagview_proto.hpp" #include "armadillo_bits/diagview_bones.hpp"
#include "armadillo_bits/diskio_proto.hpp" #include "armadillo_bits/diskio_bones.hpp"
#include "armadillo_bits/wall_clock_proto.hpp" #include "armadillo_bits/wall_clock_bones.hpp"
#include "armadillo_bits/running_stat_proto.hpp" #include "armadillo_bits/running_stat_bones.hpp"
#include "armadillo_bits/running_stat_vec_proto.hpp" #include "armadillo_bits/running_stat_vec_bones.hpp"
#include "armadillo_bits/Op_proto.hpp" #include "armadillo_bits/Op_bones.hpp"
#include "armadillo_bits/OpCube_proto.hpp" #include "armadillo_bits/OpCube_bones.hpp"
#include "armadillo_bits/eOp_proto.hpp" #include "armadillo_bits/eOp_bones.hpp"
#include "armadillo_bits/eOpCube_proto.hpp" #include "armadillo_bits/eOpCube_bones.hpp"
#include "armadillo_bits/mtOp_proto.hpp" #include "armadillo_bits/mtOp_bones.hpp"
#include "armadillo_bits/mtOpCube_proto.hpp" #include "armadillo_bits/mtOpCube_bones.hpp"
#include "armadillo_bits/Glue_proto.hpp" #include "armadillo_bits/Glue_bones.hpp"
#include "armadillo_bits/eGlue_proto.hpp" #include "armadillo_bits/eGlue_bones.hpp"
#include "armadillo_bits/mtGlue_proto.hpp" #include "armadillo_bits/mtGlue_bones.hpp"
#include "armadillo_bits/GlueCube_proto.hpp" #include "armadillo_bits/GlueCube_bones.hpp"
#include "armadillo_bits/eGlueCube_proto.hpp" #include "armadillo_bits/eGlueCube_bones.hpp"
#include "armadillo_bits/mtGlueCube_proto.hpp" #include "armadillo_bits/mtGlueCube_bones.hpp"
#include "armadillo_bits/eop_core_proto.hpp" #include "armadillo_bits/eop_core_bones.hpp"
#include "armadillo_bits/eglue_core_proto.hpp" #include "armadillo_bits/eglue_core_bones.hpp"
#include "armadillo_bits/op_diagmat_proto.hpp" #include "armadillo_bits/op_diagmat_bones.hpp"
#include "armadillo_bits/op_diagvec_proto.hpp" #include "armadillo_bits/op_diagvec_bones.hpp"
#include "armadillo_bits/op_dot_proto.hpp" #include "armadillo_bits/op_dot_bones.hpp"
#include "armadillo_bits/op_inv_proto.hpp" #include "armadillo_bits/op_inv_bones.hpp"
#include "armadillo_bits/op_htrans_proto.hpp" #include "armadillo_bits/op_htrans_bones.hpp"
#include "armadillo_bits/op_max_proto.hpp" #include "armadillo_bits/op_max_bones.hpp"
#include "armadillo_bits/op_min_proto.hpp" #include "armadillo_bits/op_min_bones.hpp"
#include "armadillo_bits/op_mean_proto.hpp" #include "armadillo_bits/op_mean_bones.hpp"
#include "armadillo_bits/op_median_proto.hpp" #include "armadillo_bits/op_median_bones.hpp"
#include "armadillo_bits/op_sort_proto.hpp" #include "armadillo_bits/op_sort_bones.hpp"
#include "armadillo_bits/op_sum_proto.hpp" #include "armadillo_bits/op_sum_bones.hpp"
#include "armadillo_bits/op_stddev_proto.hpp" #include "armadillo_bits/op_stddev_bones.hpp"
#include "armadillo_bits/op_trans_proto.hpp" #include "armadillo_bits/op_strans_bones.hpp"
#include "armadillo_bits/op_var_proto.hpp" #include "armadillo_bits/op_var_bones.hpp"
#include "armadillo_bits/op_repmat_proto.hpp" #include "armadillo_bits/op_repmat_bones.hpp"
#include "armadillo_bits/op_reshape_proto.hpp" #include "armadillo_bits/op_reshape_bones.hpp"
#include "armadillo_bits/op_cov_proto.hpp" #include "armadillo_bits/op_cov_bones.hpp"
#include "armadillo_bits/op_cor_proto.hpp" #include "armadillo_bits/op_cor_bones.hpp"
#include "armadillo_bits/op_shuffle_proto.hpp" #include "armadillo_bits/op_shuffle_bones.hpp"
#include "armadillo_bits/op_prod_proto.hpp" #include "armadillo_bits/op_prod_bones.hpp"
#include "armadillo_bits/op_pinv_proto.hpp" #include "armadillo_bits/op_pinv_bones.hpp"
#include "armadillo_bits/op_dotext_proto.hpp" #include "armadillo_bits/op_dotext_bones.hpp"
#include "armadillo_bits/op_flip_proto.hpp" #include "armadillo_bits/op_flip_bones.hpp"
#include "armadillo_bits/op_princomp_proto.hpp" #include "armadillo_bits/op_princomp_bones.hpp"
#include "armadillo_bits/op_princomp_cov_proto.hpp" #include "armadillo_bits/op_princomp_cov_bones.hpp"
#include "armadillo_bits/op_misc_proto.hpp" #include "armadillo_bits/op_misc_bones.hpp"
#include "armadillo_bits/op_relational_proto.hpp" #include "armadillo_bits/op_relational_bones.hpp"
#include "armadillo_bits/op_find_proto.hpp" #include "armadillo_bits/op_find_bones.hpp"
#include "armadillo_bits/op_chol_proto.hpp" #include "armadillo_bits/op_chol_bones.hpp"
#include "armadillo_bits/op_cx_scalar_proto.hpp" #include "armadillo_bits/op_cx_scalar_bones.hpp"
#include "armadillo_bits/op_trimat_proto.hpp" #include "armadillo_bits/op_trimat_bones.hpp"
#include "armadillo_bits/op_cumsum_proto.hpp" #include "armadillo_bits/op_cumsum_bones.hpp"
#include "armadillo_bits/op_symmat_bones.hpp"
#include "armadillo_bits/glue_times_proto.hpp"
#include "armadillo_bits/glue_mixed_proto.hpp" #include "armadillo_bits/glue_times_bones.hpp"
#include "armadillo_bits/glue_cov_proto.hpp" #include "armadillo_bits/glue_mixed_bones.hpp"
#include "armadillo_bits/glue_cor_proto.hpp" #include "armadillo_bits/glue_cov_bones.hpp"
#include "armadillo_bits/glue_kron_proto.hpp" #include "armadillo_bits/glue_cor_bones.hpp"
#include "armadillo_bits/glue_cross_proto.hpp" #include "armadillo_bits/glue_kron_bones.hpp"
#include "armadillo_bits/glue_join_proto.hpp" #include "armadillo_bits/glue_cross_bones.hpp"
#include "armadillo_bits/glue_relational_proto.hpp" #include "armadillo_bits/glue_join_bones.hpp"
#include "armadillo_bits/glue_solve_proto.hpp" #include "armadillo_bits/glue_relational_bones.hpp"
#include "armadillo_bits/glue_conv_proto.hpp" #include "armadillo_bits/glue_solve_bones.hpp"
#include "armadillo_bits/glue_toeplitz_proto.hpp" #include "armadillo_bits/glue_conv_bones.hpp"
#include "armadillo_bits/glue_toeplitz_bones.hpp"
// //
// debugging functions // debugging functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
// //
// //
#include "armadillo_bits/cmath_wrap.hpp" #include "armadillo_bits/cmath_wrap.hpp"
skipping to change at line 257 skipping to change at line 260
#include "armadillo_bits/eGlue_meat.hpp" #include "armadillo_bits/eGlue_meat.hpp"
#include "armadillo_bits/eGlueCube_meat.hpp" #include "armadillo_bits/eGlueCube_meat.hpp"
#include "armadillo_bits/mtGlue_meat.hpp" #include "armadillo_bits/mtGlue_meat.hpp"
#include "armadillo_bits/mtGlueCube_meat.hpp" #include "armadillo_bits/mtGlueCube_meat.hpp"
// //
// ostream // ostream
#include "armadillo_bits/arma_ostream_proto.hpp" #include "armadillo_bits/arma_ostream_bones.hpp"
#include "armadillo_bits/arma_ostream_meat.hpp" #include "armadillo_bits/arma_ostream_meat.hpp"
// //
// operators // operators
#include "armadillo_bits/operator_plus.hpp" #include "armadillo_bits/operator_plus.hpp"
#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_schur.hpp" #include "armadillo_bits/operator_schur.hpp"
#include "armadillo_bits/operator_div.hpp" #include "armadillo_bits/operator_div.hpp"
skipping to change at line 301 skipping to change at line 304
#include "armadillo_bits/fn_diagvec.hpp" #include "armadillo_bits/fn_diagvec.hpp"
#include "armadillo_bits/fn_inv.hpp" #include "armadillo_bits/fn_inv.hpp"
#include "armadillo_bits/fn_trace.hpp" #include "armadillo_bits/fn_trace.hpp"
#include "armadillo_bits/fn_trans.hpp" #include "armadillo_bits/fn_trans.hpp"
#include "armadillo_bits/fn_det.hpp" #include "armadillo_bits/fn_det.hpp"
#include "armadillo_bits/fn_log_det.hpp" #include "armadillo_bits/fn_log_det.hpp"
#include "armadillo_bits/fn_eig.hpp" #include "armadillo_bits/fn_eig.hpp"
#include "armadillo_bits/fn_lu.hpp" #include "armadillo_bits/fn_lu.hpp"
#include "armadillo_bits/fn_zeros.hpp" #include "armadillo_bits/fn_zeros.hpp"
#include "armadillo_bits/fn_ones.hpp" #include "armadillo_bits/fn_ones.hpp"
#include "armadillo_bits/fn_eye.hpp"
#include "armadillo_bits/fn_misc.hpp" #include "armadillo_bits/fn_misc.hpp"
#include "armadillo_bits/fn_elem.hpp" #include "armadillo_bits/fn_elem.hpp"
#include "armadillo_bits/fn_norm.hpp" #include "armadillo_bits/fn_norm.hpp"
#include "armadillo_bits/fn_dot.hpp" #include "armadillo_bits/fn_dot.hpp"
#include "armadillo_bits/fn_randu.hpp" #include "armadillo_bits/fn_randu.hpp"
#include "armadillo_bits/fn_randn.hpp" #include "armadillo_bits/fn_randn.hpp"
#include "armadillo_bits/fn_trig.hpp" #include "armadillo_bits/fn_trig.hpp"
#include "armadillo_bits/fn_mean.hpp" #include "armadillo_bits/fn_mean.hpp"
#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_strans.hpp"
#include "armadillo_bits/fn_chol.hpp" #include "armadillo_bits/fn_chol.hpp"
#include "armadillo_bits/fn_qr.hpp" #include "armadillo_bits/fn_qr.hpp"
#include "armadillo_bits/fn_svd.hpp" #include "armadillo_bits/fn_svd.hpp"
#include "armadillo_bits/fn_solve.hpp" #include "armadillo_bits/fn_solve.hpp"
#include "armadillo_bits/fn_repmat.hpp" #include "armadillo_bits/fn_repmat.hpp"
#include "armadillo_bits/fn_reshape.hpp" #include "armadillo_bits/fn_reshape.hpp"
#include "armadillo_bits/fn_cov.hpp" #include "armadillo_bits/fn_cov.hpp"
#include "armadillo_bits/fn_cor.hpp" #include "armadillo_bits/fn_cor.hpp"
#include "armadillo_bits/fn_shuffle.hpp" #include "armadillo_bits/fn_shuffle.hpp"
#include "armadillo_bits/fn_prod.hpp" #include "armadillo_bits/fn_prod.hpp"
skipping to change at line 341 skipping to change at line 345
#include "armadillo_bits/fn_princomp.hpp" #include "armadillo_bits/fn_princomp.hpp"
#include "armadillo_bits/fn_princomp_cov.hpp" #include "armadillo_bits/fn_princomp_cov.hpp"
#include "armadillo_bits/fn_cross.hpp" #include "armadillo_bits/fn_cross.hpp"
#include "armadillo_bits/fn_join.hpp" #include "armadillo_bits/fn_join.hpp"
#include "armadillo_bits/fn_conv.hpp" #include "armadillo_bits/fn_conv.hpp"
#include "armadillo_bits/fn_trunc_exp.hpp" #include "armadillo_bits/fn_trunc_exp.hpp"
#include "armadillo_bits/fn_trunc_log.hpp" #include "armadillo_bits/fn_trunc_log.hpp"
#include "armadillo_bits/fn_toeplitz.hpp" #include "armadillo_bits/fn_toeplitz.hpp"
#include "armadillo_bits/fn_trimat.hpp" #include "armadillo_bits/fn_trimat.hpp"
#include "armadillo_bits/fn_cumsum.hpp" #include "armadillo_bits/fn_cumsum.hpp"
#include "armadillo_bits/fn_symmat.hpp"
#include "armadillo_bits/fn_syl_lyap.hpp"
// //
// class meat // class meat
#include "armadillo_bits/gemm.hpp"
#include "armadillo_bits/gemv.hpp" #include "armadillo_bits/gemv.hpp"
#include "armadillo_bits/gemm.hpp"
#include "armadillo_bits/gemm_mixed.hpp" #include "armadillo_bits/gemm_mixed.hpp"
#include "armadillo_bits/eop_core_meat.hpp" #include "armadillo_bits/eop_core_meat.hpp"
#include "armadillo_bits/eglue_core_meat.hpp" #include "armadillo_bits/eglue_core_meat.hpp"
#include "armadillo_bits/arrayops_meat.hpp" #include "armadillo_bits/arrayops_meat.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/injector_meat.hpp" #include "armadillo_bits/injector_meat.hpp"
skipping to change at line 386 skipping to change at line 392
#include "armadillo_bits/op_dot_meat.hpp" #include "armadillo_bits/op_dot_meat.hpp"
#include "armadillo_bits/op_inv_meat.hpp" #include "armadillo_bits/op_inv_meat.hpp"
#include "armadillo_bits/op_htrans_meat.hpp" #include "armadillo_bits/op_htrans_meat.hpp"
#include "armadillo_bits/op_max_meat.hpp" #include "armadillo_bits/op_max_meat.hpp"
#include "armadillo_bits/op_min_meat.hpp" #include "armadillo_bits/op_min_meat.hpp"
#include "armadillo_bits/op_mean_meat.hpp" #include "armadillo_bits/op_mean_meat.hpp"
#include "armadillo_bits/op_median_meat.hpp" #include "armadillo_bits/op_median_meat.hpp"
#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_strans_meat.hpp"
#include "armadillo_bits/op_var_meat.hpp" #include "armadillo_bits/op_var_meat.hpp"
#include "armadillo_bits/op_repmat_meat.hpp" #include "armadillo_bits/op_repmat_meat.hpp"
#include "armadillo_bits/op_reshape_meat.hpp" #include "armadillo_bits/op_reshape_meat.hpp"
#include "armadillo_bits/op_cov_meat.hpp" #include "armadillo_bits/op_cov_meat.hpp"
#include "armadillo_bits/op_cor_meat.hpp" #include "armadillo_bits/op_cor_meat.hpp"
#include "armadillo_bits/op_shuffle_meat.hpp" #include "armadillo_bits/op_shuffle_meat.hpp"
#include "armadillo_bits/op_prod_meat.hpp" #include "armadillo_bits/op_prod_meat.hpp"
#include "armadillo_bits/op_pinv_meat.hpp" #include "armadillo_bits/op_pinv_meat.hpp"
#include "armadillo_bits/op_dotext_meat.hpp" #include "armadillo_bits/op_dotext_meat.hpp"
#include "armadillo_bits/op_flip_meat.hpp" #include "armadillo_bits/op_flip_meat.hpp"
#include "armadillo_bits/op_princomp_meat.hpp" #include "armadillo_bits/op_princomp_meat.hpp"
#include "armadillo_bits/op_princomp_cov_meat.hpp" #include "armadillo_bits/op_princomp_cov_meat.hpp"
#include "armadillo_bits/op_misc_meat.hpp" #include "armadillo_bits/op_misc_meat.hpp"
#include "armadillo_bits/op_relational_meat.hpp" #include "armadillo_bits/op_relational_meat.hpp"
#include "armadillo_bits/op_find_meat.hpp" #include "armadillo_bits/op_find_meat.hpp"
#include "armadillo_bits/op_chol_meat.hpp" #include "armadillo_bits/op_chol_meat.hpp"
#include "armadillo_bits/op_cx_scalar_meat.hpp" #include "armadillo_bits/op_cx_scalar_meat.hpp"
#include "armadillo_bits/op_trimat_meat.hpp" #include "armadillo_bits/op_trimat_meat.hpp"
#include "armadillo_bits/op_cumsum_meat.hpp" #include "armadillo_bits/op_cumsum_meat.hpp"
#include "armadillo_bits/op_symmat_meat.hpp"
#include "armadillo_bits/glue_times_meat.hpp" #include "armadillo_bits/glue_times_meat.hpp"
#include "armadillo_bits/glue_mixed_meat.hpp" #include "armadillo_bits/glue_mixed_meat.hpp"
#include "armadillo_bits/glue_cov_meat.hpp" #include "armadillo_bits/glue_cov_meat.hpp"
#include "armadillo_bits/glue_cor_meat.hpp" #include "armadillo_bits/glue_cor_meat.hpp"
#include "armadillo_bits/glue_kron_meat.hpp" #include "armadillo_bits/glue_kron_meat.hpp"
#include "armadillo_bits/glue_cross_meat.hpp" #include "armadillo_bits/glue_cross_meat.hpp"
#include "armadillo_bits/glue_join_meat.hpp" #include "armadillo_bits/glue_join_meat.hpp"
#include "armadillo_bits/glue_relational_meat.hpp" #include "armadillo_bits/glue_relational_meat.hpp"
#include "armadillo_bits/glue_solve_meat.hpp" #include "armadillo_bits/glue_solve_meat.hpp"
 End of changes. 13 change blocks. 
95 lines changed or deleted 102 lines changed or added


 arrayops_meat.hpp   arrayops_meat.hpp 
skipping to change at line 18 skipping to change at line 18
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arrayops //! \addtogroup arrayops
//! @{ //! @{
template<typename eT> template<typename eT>
arma_hot arma_hot
inline arma_inline
void void
arrayops::copy(eT* dest, const eT* src, const u32 n_elem) arrayops::copy(eT* dest, const eT* src, const u32 n_elem)
{ {
#if !defined(__OPTIMIZE__) switch(n_elem)
{ {
std::memcpy(dest, src, n_elem*sizeof(eT)); default:
arrayops::copy_big(dest, src, n_elem);
break;
case 8:
dest[7] = src[7];
case 7:
dest[6] = src[6];
case 6:
dest[5] = src[5];
case 5:
dest[4] = src[4];
case 4:
dest[3] = src[3];
case 3:
dest[2] = src[2];
case 2:
dest[1] = src[1];
case 1:
dest[0] = src[0];
} }
#else }
template<typename eT>
inline
void
arrayops::copy_big(eT* dest, const eT* src, const u32 n_elem)
{
switch(n_elem)
{ {
switch(n_elem) default:
{ std::memcpy(dest, src, n_elem*sizeof(eT));
default: break;
std::memcpy(dest, src, n_elem*sizeof(eT)); case 32:
break; dest[31] = src[31];
case 16: case 31:
dest[15] = src[15]; dest[30] = src[30];
case 15: case 30:
dest[14] = src[14]; dest[29] = src[29];
case 14: case 29:
dest[13] = src[13]; dest[28] = src[28];
case 13: case 28:
dest[12] = src[12]; dest[27] = src[27];
case 12: case 27:
dest[11] = src[11]; dest[26] = src[26];
case 11: case 26:
dest[10] = src[10]; dest[25] = src[25];
case 10: case 25:
dest[9] = src[9]; dest[24] = src[24];
case 9: case 24:
dest[8] = src[8]; dest[23] = src[23];
case 8: case 23:
dest[7] = src[7]; dest[22] = src[22];
case 7: case 22:
dest[6] = src[6]; dest[21] = src[21];
case 6: case 21:
dest[5] = src[5]; dest[20] = src[20];
case 5: case 20:
dest[4] = src[4]; dest[19] = src[19];
case 4: case 19:
dest[3] = src[3]; dest[18] = src[18];
case 3: case 18:
dest[2] = src[2]; dest[17] = src[17];
case 2: case 17:
dest[1] = src[1]; dest[16] = src[16];
case 1: case 16:
dest[0] = src[0]; dest[15] = src[15];
case 0: case 15:
; dest[14] = src[14];
} case 14:
dest[13] = src[13];
case 13:
dest[12] = src[12];
case 12:
dest[11] = src[11];
case 11:
dest[10] = src[10];
case 10:
dest[9] = src[9];
case 9:
dest[8] = src[8];
case 8:
dest[7] = src[7];
case 7:
dest[6] = src[6];
case 6:
dest[5] = src[5];
case 5:
dest[4] = src[4];
case 4:
dest[3] = src[3];
case 3:
dest[2] = src[2];
case 2:
dest[1] = src[1];
case 1:
dest[0] = src[0];
} }
#endif
} }
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_hot
arma_inline arma_inline
void void
arrayops::convert_cx_scalar arrayops::convert_cx_scalar
( (
out_eT& out, out_eT& out,
const in_eT& in, const in_eT& in,
 End of changes. 6 change blocks. 
45 lines changed or deleted 96 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 25 skipping to change at line 26
//! @{ //! @{
//! immediate matrix inverse //! immediate matrix inverse
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::inv(Mat<eT>& out, const Base<eT,T1>& X) auxlib::inv(Mat<eT>& out, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool status; bool status = false;
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
const u32 N = out.n_rows; const u32 N = out.n_rows;
if(N <= 4) if(N <= 4)
{ {
status = auxlib::inv_inplace_tinymat(out, N); status = auxlib::inv_inplace_tinymat(out, N);
skipping to change at line 61 skipping to change at line 62
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::inv(Mat<eT>& out, const Mat<eT>& X) auxlib::inv(Mat<eT>& out, const Mat<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s quare" ); arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s quare" );
bool status; bool status = false;
const u32 N = X.n_rows; const u32 N = X.n_rows;
if(N <= 4) if(N <= 4)
{ {
status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib ::inv_inplace_tinymat(out, N); status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib ::inv_inplace_tinymat(out, N);
} }
if( (N > 4) || (status == false) ) if( (N > 4) || (status == false) )
{ {
skipping to change at line 106 skipping to change at line 107
switch(N) switch(N)
{ {
case 1: case 1:
{ {
out[0] = eT(1) / X[0]; out[0] = eT(1) / X[0];
}; };
break; break;
case 2: case 2:
{ {
const eT a = X.at(0,0); const eT* Xm = X.memptr();
const eT b = X.at(0,1);
const eT c = X.at(1,0); const eT a = Xm[pos<0,0>::n2];
const eT d = X.at(1,1); const eT b = Xm[pos<0,1>::n2];
const eT c = Xm[pos<1,0>::n2];
const eT d = Xm[pos<1,1>::n2];
const eT tmp_det = (a*d - b*c); const eT tmp_det = (a*d - b*c);
if(tmp_det != eT(0)) if(tmp_det != eT(0))
{ {
out.at(0,0) = d / tmp_det; eT* outm = out.memptr();
out.at(0,1) = -b / tmp_det;
out.at(1,0) = -c / tmp_det; outm[pos<0,0>::n2] = d / tmp_det;
out.at(1,1) = a / tmp_det; outm[pos<0,1>::n2] = -b / tmp_det;
outm[pos<1,0>::n2] = -c / tmp_det;
outm[pos<1,1>::n2] = a / tmp_det;
} }
else else
{ {
det_ok = false; det_ok = false;
} }
}; };
break; break;
case 3: case 3:
{ {
skipping to change at line 176 skipping to change at line 181
} }
}; };
break; break;
case 4: case 4:
{ {
const eT tmp_det = det(X); const eT tmp_det = det(X);
if(tmp_det != eT(0)) if(tmp_det != eT(0))
{ {
out.at(0,0) = ( X.at(1,2)*X.at(2,3)*X.at(3,1) - X.at(1,3)*X.at(2,2) const eT* Xm = X.memptr();
*X.at(3,1) + X.at(1,3)*X.at(2,1)*X.at(3,2) - X.at(1,1)*X.at(2,3)*X.at(3,2) eT* outm = out.memptr();
- X.at(1,2)*X.at(2,1)*X.at(3,3) + X.at(1,1)*X.at(2,2)*X.at(3,3) ) / tmp_det
; outm[pos<0,0>::n4] = ( Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,1
out.at(1,0) = ( X.at(1,3)*X.at(2,2)*X.at(3,0) - X.at(1,2)*X.at(2,3) >::n4] - Xm[pos<1,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,1>::n4] + Xm[pos<1,3>::
*X.at(3,0) - X.at(1,3)*X.at(2,0)*X.at(3,2) + X.at(1,0)*X.at(2,3)*X.at(3,2) n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4]*X
+ X.at(1,2)*X.at(2,0)*X.at(3,3) - X.at(1,0)*X.at(2,2)*X.at(3,3) ) / tmp_det m[pos<3,2>::n4] - Xm[pos<1,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] + Xm[p
; os<1,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
out.at(2,0) = ( X.at(1,1)*X.at(2,3)*X.at(3,0) - X.at(1,3)*X.at(2,1) outm[pos<1,0>::n4] = ( Xm[pos<1,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0
*X.at(3,0) + X.at(1,3)*X.at(2,0)*X.at(3,1) - X.at(1,0)*X.at(2,3)*X.at(3,1) >::n4] - Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<1,3>::
- X.at(1,1)*X.at(2,0)*X.at(3,3) + X.at(1,0)*X.at(2,1)*X.at(3,3) ) / tmp_det n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] + Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4]*X
; m[pos<3,2>::n4] + Xm[pos<1,2>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
out.at(3,0) = ( X.at(1,2)*X.at(2,1)*X.at(3,0) - X.at(1,1)*X.at(2,2) os<1,0>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
*X.at(3,0) - X.at(1,2)*X.at(2,0)*X.at(3,1) + X.at(1,0)*X.at(2,2)*X.at(3,1) outm[pos<2,0>::n4] = ( Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0
+ X.at(1,1)*X.at(2,0)*X.at(3,2) - X.at(1,0)*X.at(2,1)*X.at(3,2) ) / tmp_det >::n4] - Xm[pos<1,3>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<1,3>::
; n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4]*X
m[pos<3,1>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
out.at(0,1) = ( X.at(0,3)*X.at(2,2)*X.at(3,1) - X.at(0,2)*X.at(2,3) os<1,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
*X.at(3,1) - X.at(0,3)*X.at(2,1)*X.at(3,2) + X.at(0,1)*X.at(2,3)*X.at(3,2) outm[pos<3,0>::n4] = ( Xm[pos<1,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0
+ X.at(0,2)*X.at(2,1)*X.at(3,3) - X.at(0,1)*X.at(2,2)*X.at(3,3) ) / tmp_det >::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0>::n4] - Xm[pos<1,2>::
; n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4]*X
out.at(1,1) = ( X.at(0,2)*X.at(2,3)*X.at(3,0) - X.at(0,3)*X.at(2,2) m[pos<3,1>::n4] + Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] - Xm[p
*X.at(3,0) + X.at(0,3)*X.at(2,0)*X.at(3,2) - X.at(0,0)*X.at(2,3)*X.at(3,2) os<1,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] ) / tmp_det;
- X.at(0,2)*X.at(2,0)*X.at(3,3) + X.at(0,0)*X.at(2,2)*X.at(3,3) ) / tmp_det
; outm[pos<0,1>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,1
out.at(2,1) = ( X.at(0,3)*X.at(2,1)*X.at(3,0) - X.at(0,1)*X.at(2,3) >::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,3>::
*X.at(3,0) - X.at(0,3)*X.at(2,0)*X.at(3,1) + X.at(0,0)*X.at(2,3)*X.at(3,1) n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] + Xm[pos<0,1>::n4]*Xm[pos<2,3>::n4]*X
+ X.at(0,1)*X.at(2,0)*X.at(3,3) - X.at(0,0)*X.at(2,1)*X.at(3,3) ) / tmp_det m[pos<3,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] - Xm[p
; os<0,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
out.at(3,1) = ( X.at(0,1)*X.at(2,2)*X.at(3,0) - X.at(0,2)*X.at(2,1) outm[pos<1,1>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0
*X.at(3,0) + X.at(0,2)*X.at(2,0)*X.at(3,1) - X.at(0,0)*X.at(2,2)*X.at(3,1) >::n4] - Xm[pos<0,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,3>::
- X.at(0,1)*X.at(2,0)*X.at(3,2) + X.at(0,0)*X.at(2,1)*X.at(3,2) ) / tmp_det n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] - Xm[pos<0,0>::n4]*Xm[pos<2,3>::n4]*X
; m[pos<3,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
out.at(0,2) = ( X.at(0,2)*X.at(1,3)*X.at(3,1) - X.at(0,3)*X.at(1,2) outm[pos<2,1>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0
*X.at(3,1) + X.at(0,3)*X.at(1,1)*X.at(3,2) - X.at(0,1)*X.at(1,3)*X.at(3,2) >::n4] - Xm[pos<0,1>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,3>::
- X.at(0,2)*X.at(1,1)*X.at(3,3) + X.at(0,1)*X.at(1,2)*X.at(3,3) ) / tmp_det n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<2,3>::n4]*X
; m[pos<3,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
out.at(1,2) = ( X.at(0,3)*X.at(1,2)*X.at(3,0) - X.at(0,2)*X.at(1,3) os<0,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
*X.at(3,0) - X.at(0,3)*X.at(1,0)*X.at(3,2) + X.at(0,0)*X.at(1,3)*X.at(3,2) outm[pos<3,1>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0
+ X.at(0,2)*X.at(1,0)*X.at(3,3) - X.at(0,0)*X.at(1,2)*X.at(3,3) ) / tmp_det >::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,2>::
; n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<2,2>::n4]*X
out.at(2,2) = ( X.at(0,1)*X.at(1,3)*X.at(3,0) - X.at(0,3)*X.at(1,1) m[pos<3,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] + Xm[p
*X.at(3,0) + X.at(0,3)*X.at(1,0)*X.at(3,1) - X.at(0,0)*X.at(1,3)*X.at(3,1) os<0,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] ) / tmp_det;
- X.at(0,1)*X.at(1,0)*X.at(3,3) + X.at(0,0)*X.at(1,1)*X.at(3,3) ) / tmp_det
; outm[pos<0,2>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,1
out.at(3,2) = ( X.at(0,2)*X.at(1,1)*X.at(3,0) - X.at(0,1)*X.at(1,2) >::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,3>::
*X.at(3,0) - X.at(0,2)*X.at(1,0)*X.at(3,1) + X.at(0,0)*X.at(1,2)*X.at(3,1) n4]*Xm[pos<1,1>::n4]*Xm[pos<3,2>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*X
+ X.at(0,1)*X.at(1,0)*X.at(3,2) - X.at(0,0)*X.at(1,1)*X.at(3,2) ) / tmp_det m[pos<3,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,3>::n4] + Xm[p
; os<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<1,2>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,0
out.at(0,3) = ( X.at(0,3)*X.at(1,2)*X.at(2,1) - X.at(0,2)*X.at(1,3) >::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,3>::
*X.at(2,1) - X.at(0,3)*X.at(1,1)*X.at(2,2) + X.at(0,1)*X.at(1,3)*X.at(2,2) n4]*Xm[pos<1,0>::n4]*Xm[pos<3,2>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
+ X.at(0,2)*X.at(1,1)*X.at(2,3) - X.at(0,1)*X.at(1,2)*X.at(2,3) ) / tmp_det m[pos<3,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
; os<0,0>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
out.at(1,3) = ( X.at(0,2)*X.at(1,3)*X.at(2,0) - X.at(0,3)*X.at(1,2) outm[pos<2,2>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,0
*X.at(2,0) + X.at(0,3)*X.at(1,0)*X.at(2,2) - X.at(0,0)*X.at(1,3)*X.at(2,2) >::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,3>::
- X.at(0,2)*X.at(1,0)*X.at(2,3) + X.at(0,0)*X.at(1,2)*X.at(2,3) ) / tmp_det n4]*Xm[pos<1,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
; m[pos<3,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
out.at(2,3) = ( X.at(0,3)*X.at(1,1)*X.at(2,0) - X.at(0,1)*X.at(1,3) os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
*X.at(2,0) - X.at(0,3)*X.at(1,0)*X.at(2,1) + X.at(0,0)*X.at(1,3)*X.at(2,1) outm[pos<3,2>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,0
+ X.at(0,1)*X.at(1,0)*X.at(2,3) - X.at(0,0)*X.at(1,1)*X.at(2,3) ) / tmp_det >::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,2>::
; n4]*Xm[pos<1,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,2>::n4]*X
out.at(3,3) = ( X.at(0,1)*X.at(1,2)*X.at(2,0) - X.at(0,2)*X.at(1,1) m[pos<3,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,2>::n4] - Xm[p
*X.at(2,0) + X.at(0,2)*X.at(1,0)*X.at(2,1) - X.at(0,0)*X.at(1,2)*X.at(2,1) os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,2>::n4] ) / tmp_det;
- X.at(0,1)*X.at(1,0)*X.at(2,2) + X.at(0,0)*X.at(1,1)*X.at(2,2) ) / tmp_det
; outm[pos<0,3>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,1
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,1>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*X
m[pos<2,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4] - Xm[p
os<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4] ) / tmp_det;
outm[pos<1,3>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,0
>::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,0>::n4] + Xm[pos<0,3>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
m[pos<2,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4] ) / tmp_det;
outm[pos<2,3>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,0
>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,0>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<2,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
m[pos<2,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4] - Xm[p
os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4] ) / tmp_det;
outm[pos<3,3>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,0
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4] + Xm[pos<0,2>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<2,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,2>::n4]*X
m[pos<2,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4] ) / tmp_det;
} }
else else
{ {
det_ok = false; det_ok = false;
} }
}; };
break; break;
default: default:
; ;
skipping to change at line 235 skipping to change at line 243
switch(N) switch(N)
{ {
case 1: case 1:
{ {
X[0] = eT(1) / X[0]; X[0] = eT(1) / X[0];
}; };
break; break;
case 2: case 2:
{ {
const eT a = X.at(0,0); const eT a = X[pos<0,0>::n2];
const eT b = X.at(0,1); const eT b = X[pos<0,1>::n2];
const eT c = X.at(1,0); const eT c = X[pos<1,0>::n2];
const eT d = X.at(1,1); const eT d = X[pos<1,1>::n2];
const eT tmp_det = (a*d - b*c); const eT tmp_det = (a*d - b*c);
if(tmp_det != eT(0)) if(tmp_det != eT(0))
{ {
X.at(0,0) = d / tmp_det; X[pos<0,0>::n2] = d / tmp_det;
X.at(0,1) = -b / tmp_det; X[pos<0,1>::n2] = -b / tmp_det;
X.at(1,0) = -c / tmp_det; X[pos<1,0>::n2] = -c / tmp_det;
X.at(1,1) = a / tmp_det; X[pos<1,1>::n2] = a / tmp_det;
} }
else else
{ {
det_ok = false; det_ok = false;
} }
}; };
break; break;
case 3: case 3:
{ {
skipping to change at line 305 skipping to change at line 313
break; break;
case 4: case 4:
{ {
const eT tmp_det = det(X); const eT tmp_det = det(X);
if(tmp_det != eT(0)) if(tmp_det != eT(0))
{ {
const Mat<eT> A(X); const Mat<eT> A(X);
X.at(0,0) = ( A.at(1,2)*A.at(2,3)*A.at(3,1) - A.at(1,3)*A.at(2,2)*A const eT* Am = A.memptr();
.at(3,1) + A.at(1,3)*A.at(2,1)*A.at(3,2) - A.at(1,1)*A.at(2,3)*A.at(3,2) - eT* Xm = X.memptr();
A.at(1,2)*A.at(2,1)*A.at(3,3) + A.at(1,1)*A.at(2,2)*A.at(3,3) ) / tmp_det;
X.at(1,0) = ( A.at(1,3)*A.at(2,2)*A.at(3,0) - A.at(1,2)*A.at(2,3)*A Xm[pos<0,0>::n4] = ( Am[pos<1,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,1>:
.at(3,0) - A.at(1,3)*A.at(2,0)*A.at(3,2) + A.at(1,0)*A.at(2,3)*A.at(3,2) + :n4] - Am[pos<1,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,1>::n4] + Am[pos<1,3>::n4
A.at(1,2)*A.at(2,0)*A.at(3,3) - A.at(1,0)*A.at(2,2)*A.at(3,3) ) / tmp_det; ]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] - Am[pos<1,1>::n4]*Am[pos<2,3>::n4]*Am[
X.at(2,0) = ( A.at(1,1)*A.at(2,3)*A.at(3,0) - A.at(1,3)*A.at(2,1)*A pos<3,2>::n4] - Am[pos<1,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] + Am[pos
.at(3,0) + A.at(1,3)*A.at(2,0)*A.at(3,1) - A.at(1,0)*A.at(2,3)*A.at(3,1) - <1,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
A.at(1,1)*A.at(2,0)*A.at(3,3) + A.at(1,0)*A.at(2,1)*A.at(3,3) ) / tmp_det; Xm[pos<1,0>::n4] = ( Am[pos<1,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>:
X.at(3,0) = ( A.at(1,2)*A.at(2,1)*A.at(3,0) - A.at(1,1)*A.at(2,2)*A :n4] - Am[pos<1,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>::n4] - Am[pos<1,3>::n4
.at(3,0) - A.at(1,2)*A.at(2,0)*A.at(3,1) + A.at(1,0)*A.at(2,2)*A.at(3,1) + ]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] + Am[pos<1,0>::n4]*Am[pos<2,3>::n4]*Am[
A.at(1,1)*A.at(2,0)*A.at(3,2) - A.at(1,0)*A.at(2,1)*A.at(3,2) ) / tmp_det; pos<3,2>::n4] + Am[pos<1,2>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] - Am[pos
<1,0>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
X.at(0,1) = ( A.at(0,3)*A.at(2,2)*A.at(3,1) - A.at(0,2)*A.at(2,3)*A Xm[pos<2,0>::n4] = ( Am[pos<1,1>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>:
.at(3,1) - A.at(0,3)*A.at(2,1)*A.at(3,2) + A.at(0,1)*A.at(2,3)*A.at(3,2) + :n4] - Am[pos<1,3>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>::n4] + Am[pos<1,3>::n4
A.at(0,2)*A.at(2,1)*A.at(3,3) - A.at(0,1)*A.at(2,2)*A.at(3,3) ) / tmp_det; ]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] - Am[pos<1,0>::n4]*Am[pos<2,3>::n4]*Am[
X.at(1,1) = ( A.at(0,2)*A.at(2,3)*A.at(3,0) - A.at(0,3)*A.at(2,2)*A pos<3,1>::n4] - Am[pos<1,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] + Am[pos
.at(3,0) + A.at(0,3)*A.at(2,0)*A.at(3,2) - A.at(0,0)*A.at(2,3)*A.at(3,2) - <1,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
A.at(0,2)*A.at(2,0)*A.at(3,3) + A.at(0,0)*A.at(2,2)*A.at(3,3) ) / tmp_det; Xm[pos<3,0>::n4] = ( Am[pos<1,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>:
X.at(2,1) = ( A.at(0,3)*A.at(2,1)*A.at(3,0) - A.at(0,1)*A.at(2,3)*A :n4] - Am[pos<1,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>::n4] - Am[pos<1,2>::n4
.at(3,0) - A.at(0,3)*A.at(2,0)*A.at(3,1) + A.at(0,0)*A.at(2,3)*A.at(3,1) + ]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] + Am[pos<1,0>::n4]*Am[pos<2,2>::n4]*Am[
A.at(0,1)*A.at(2,0)*A.at(3,3) - A.at(0,0)*A.at(2,1)*A.at(3,3) ) / tmp_det; pos<3,1>::n4] + Am[pos<1,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] - Am[pos
X.at(3,1) = ( A.at(0,1)*A.at(2,2)*A.at(3,0) - A.at(0,2)*A.at(2,1)*A <1,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] ) / tmp_det;
.at(3,0) + A.at(0,2)*A.at(2,0)*A.at(3,1) - A.at(0,0)*A.at(2,2)*A.at(3,1) -
A.at(0,1)*A.at(2,0)*A.at(3,2) + A.at(0,0)*A.at(2,1)*A.at(3,2) ) / tmp_det; Xm[pos<0,1>::n4] = ( Am[pos<0,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,1>:
:n4] - Am[pos<0,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,1>::n4] - Am[pos<0,3>::n4
X.at(0,2) = ( A.at(0,2)*A.at(1,3)*A.at(3,1) - A.at(0,3)*A.at(1,2)*A ]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] + Am[pos<0,1>::n4]*Am[pos<2,3>::n4]*Am[
.at(3,1) + A.at(0,3)*A.at(1,1)*A.at(3,2) - A.at(0,1)*A.at(1,3)*A.at(3,2) - pos<3,2>::n4] + Am[pos<0,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] - Am[pos
A.at(0,2)*A.at(1,1)*A.at(3,3) + A.at(0,1)*A.at(1,2)*A.at(3,3) ) / tmp_det; <0,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
X.at(1,2) = ( A.at(0,3)*A.at(1,2)*A.at(3,0) - A.at(0,2)*A.at(1,3)*A Xm[pos<1,1>::n4] = ( Am[pos<0,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>:
.at(3,0) - A.at(0,3)*A.at(1,0)*A.at(3,2) + A.at(0,0)*A.at(1,3)*A.at(3,2) + :n4] - Am[pos<0,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>::n4] + Am[pos<0,3>::n4
A.at(0,2)*A.at(1,0)*A.at(3,3) - A.at(0,0)*A.at(1,2)*A.at(3,3) ) / tmp_det; ]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] - Am[pos<0,0>::n4]*Am[pos<2,3>::n4]*Am[
X.at(2,2) = ( A.at(0,1)*A.at(1,3)*A.at(3,0) - A.at(0,3)*A.at(1,1)*A pos<3,2>::n4] - Am[pos<0,2>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] + Am[pos
.at(3,0) + A.at(0,3)*A.at(1,0)*A.at(3,1) - A.at(0,0)*A.at(1,3)*A.at(3,1) - <0,0>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
A.at(0,1)*A.at(1,0)*A.at(3,3) + A.at(0,0)*A.at(1,1)*A.at(3,3) ) / tmp_det; Xm[pos<2,1>::n4] = ( Am[pos<0,3>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>:
X.at(3,2) = ( A.at(0,2)*A.at(1,1)*A.at(3,0) - A.at(0,1)*A.at(1,2)*A :n4] - Am[pos<0,1>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>::n4] - Am[pos<0,3>::n4
.at(3,0) - A.at(0,2)*A.at(1,0)*A.at(3,1) + A.at(0,0)*A.at(1,2)*A.at(3,1) + ]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] + Am[pos<0,0>::n4]*Am[pos<2,3>::n4]*Am[
A.at(0,1)*A.at(1,0)*A.at(3,2) - A.at(0,0)*A.at(1,1)*A.at(3,2) ) / tmp_det; pos<3,1>::n4] + Am[pos<0,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] - Am[pos
<0,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
X.at(0,3) = ( A.at(0,3)*A.at(1,2)*A.at(2,1) - A.at(0,2)*A.at(1,3)*A Xm[pos<3,1>::n4] = ( Am[pos<0,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>:
.at(2,1) - A.at(0,3)*A.at(1,1)*A.at(2,2) + A.at(0,1)*A.at(1,3)*A.at(2,2) + :n4] - Am[pos<0,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>::n4] + Am[pos<0,2>::n4
A.at(0,2)*A.at(1,1)*A.at(2,3) - A.at(0,1)*A.at(1,2)*A.at(2,3) ) / tmp_det; ]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] - Am[pos<0,0>::n4]*Am[pos<2,2>::n4]*Am[
X.at(1,3) = ( A.at(0,2)*A.at(1,3)*A.at(2,0) - A.at(0,3)*A.at(1,2)*A pos<3,1>::n4] - Am[pos<0,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] + Am[pos
.at(2,0) + A.at(0,3)*A.at(1,0)*A.at(2,2) - A.at(0,0)*A.at(1,3)*A.at(2,2) - <0,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] ) / tmp_det;
A.at(0,2)*A.at(1,0)*A.at(2,3) + A.at(0,0)*A.at(1,2)*A.at(2,3) ) / tmp_det;
X.at(2,3) = ( A.at(0,3)*A.at(1,1)*A.at(2,0) - A.at(0,1)*A.at(1,3)*A Xm[pos<0,2>::n4] = ( Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<3,1>:
.at(2,0) - A.at(0,3)*A.at(1,0)*A.at(2,1) + A.at(0,0)*A.at(1,3)*A.at(2,1) + :n4] - Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<3,1>::n4] + Am[pos<0,3>::n4
A.at(0,1)*A.at(1,0)*A.at(2,3) - A.at(0,0)*A.at(1,1)*A.at(2,3) ) / tmp_det; ]*Am[pos<1,1>::n4]*Am[pos<3,2>::n4] - Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[
X.at(3,3) = ( A.at(0,1)*A.at(1,2)*A.at(2,0) - A.at(0,2)*A.at(1,1)*A pos<3,2>::n4] - Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<3,3>::n4] + Am[pos
.at(2,0) + A.at(0,2)*A.at(1,0)*A.at(2,1) - A.at(0,0)*A.at(1,2)*A.at(2,1) - <0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
A.at(0,1)*A.at(1,0)*A.at(2,2) + A.at(0,0)*A.at(1,1)*A.at(2,2) ) / tmp_det; Xm[pos<1,2>::n4] = ( Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<3,0>:
:n4] - Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<3,0>::n4] - Am[pos<0,3>::n4
]*Am[pos<1,0>::n4]*Am[pos<3,2>::n4] + Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[
pos<3,2>::n4] + Am[pos<0,2>::n4]*Am[pos<1,0>::n4]*Am[pos<3,3>::n4] - Am[pos
<0,0>::n4]*Am[pos<1,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
Xm[pos<2,2>::n4] = ( Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[pos<3,0>:
:n4] - Am[pos<0,3>::n4]*Am[pos<1,1>::n4]*Am[pos<3,0>::n4] + Am[pos<0,3>::n4
]*Am[pos<1,0>::n4]*Am[pos<3,1>::n4] - Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[
pos<3,1>::n4] - Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<3,3>::n4] + Am[pos
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<3,3>::n4] ) / tmp_det;
Xm[pos<3,2>::n4] = ( Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<3,0>:
:n4] - Am[pos<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<3,0>::n4] - Am[pos<0,2>::n4
]*Am[pos<1,0>::n4]*Am[pos<3,1>::n4] + Am[pos<0,0>::n4]*Am[pos<1,2>::n4]*Am[
pos<3,1>::n4] + Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<3,2>::n4] - Am[pos
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<3,2>::n4] ) / tmp_det;
Xm[pos<0,3>::n4] = ( Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<2,1>:
:n4] - Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<2,1>::n4] - Am[pos<0,3>::n4
]*Am[pos<1,1>::n4]*Am[pos<2,2>::n4] + Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[
pos<2,2>::n4] + Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<2,3>::n4] - Am[pos
<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<2,3>::n4] ) / tmp_det;
Xm[pos<1,3>::n4] = ( Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<2,0>:
:n4] - Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<2,0>::n4] + Am[pos<0,3>::n4
]*Am[pos<1,0>::n4]*Am[pos<2,2>::n4] - Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[
pos<2,2>::n4] - Am[pos<0,2>::n4]*Am[pos<1,0>::n4]*Am[pos<2,3>::n4] + Am[pos
<0,0>::n4]*Am[pos<1,2>::n4]*Am[pos<2,3>::n4] ) / tmp_det;
Xm[pos<2,3>::n4] = ( Am[pos<0,3>::n4]*Am[pos<1,1>::n4]*Am[pos<2,0>:
:n4] - Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[pos<2,0>::n4] - Am[pos<0,3>::n4
]*Am[pos<1,0>::n4]*Am[pos<2,1>::n4] + Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[
pos<2,1>::n4] + Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<2,3>::n4] - Am[pos
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<2,3>::n4] ) / tmp_det;
Xm[pos<3,3>::n4] = ( Am[pos<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<2,0>:
:n4] - Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<2,0>::n4] + Am[pos<0,2>::n4
]*Am[pos<1,0>::n4]*Am[pos<2,1>::n4] - Am[pos<0,0>::n4]*Am[pos<1,2>::n4]*Am[
pos<2,1>::n4] - Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<2,2>::n4] + Am[pos
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<2,2>::n4] ) / tmp_det;
} }
else else
{ {
det_ok = false; det_ok = false;
} }
}; };
break; break;
default: default:
; ;
skipping to change at line 405 skipping to change at line 416
} }
lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &work_len, &info); lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &work_len, &info);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_stop("inv(): need ATLAS or LAPACK"); arma_stop("inv(): use of ATLAS or LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout) auxlib::inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
if(out.is_empty())
{
return true;
}
bool status; bool status;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
char uplo = (layout == 0) ? 'U' : 'L'; char uplo = (layout == 0) ? 'U' : 'L';
char diag = 'N'; char diag = 'N';
blas_int n = blas_int(out.n_rows); blas_int n = blas_int(out.n_rows);
blas_int info = 0; blas_int info = 0;
lapack::trtri(&uplo, &diag, &n, out.memptr(), &n, &info); lapack::trtri(&uplo, &diag, &n, out.memptr(), &n, &info);
status = (info == 0); status = (info == 0);
} }
#else #else
{ {
arma_ignore(layout); arma_ignore(layout);
arma_stop("inv(): need LAPACK"); arma_stop("inv(): use of LAPACK needs to enabled");
status = false; status = false;
} }
#endif #endif
if(status == false) if(status == false)
{ {
arma_print("inv(): matrix appears to be singular" ); arma_print("inv(): matrix appears to be singular" );
out.reset(); out.reset();
} }
else else
skipping to change at line 467 skipping to change at line 483
// lower triangular // lower triangular
out = trimatl(out); out = trimatl(out);
} }
} }
return status; return status;
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool
auxlib::inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const u32 layout)
{
arma_extra_debug_sigprint();
out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not
square" );
if(out.is_empty())
{
return true;
}
bool status;
#if defined(ARMA_USE_LAPACK)
{
char uplo = (layout == 0) ? 'U' : 'L';
blas_int n = blas_int(out.n_rows);
blas_int info = 0;
lapack::potrf(&uplo, &n, out.memptr(), &n, &info);
lapack::potri(&uplo, &n, out.memptr(), &n, &info);
out = (layout == 0) ? symmatu(out) : symmatl(out);
status = (info == 0);
}
#else
{
arma_ignore(layout);
arma_stop("inv(): use of LAPACK needs to enabled");
status = false;
}
#endif
if(status == false)
{
arma_print("inv(): matrix appears to be singular" );
out.reset();
}
return status;
}
template<typename eT, typename T1>
inline
eT eT
auxlib::det(const Base<eT,T1>& X) auxlib::det(const Base<eT,T1>& X)
{ {
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( !A.is_square(), "det(): matrix is not square" ); arma_debug_check( !A.is_square(), "det(): matrix is not square" );
const bool make_copy = (is_Mat<T1>::value == true) ? true : false; const bool make_copy = (is_Mat<T1>::value == true) ? true : false;
skipping to change at line 512 skipping to change at line 576
template<typename eT> template<typename eT>
inline inline
eT eT
auxlib::det_tinymat(const Mat<eT>& X, const u32 N) auxlib::det_tinymat(const Mat<eT>& X, const u32 N)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(N) switch(N)
{ {
case 0: case 0:
return eT(0); return eT(1);
break;
case 1: case 1:
return X[0]; return X[0];
break;
case 2: case 2:
return (X.at(0,0)*X.at(1,1) - X.at(0,1)*X.at(1,0)); {
const eT* Xm = X.memptr();
return ( Xm[pos<0,0>::n2]*Xm[pos<1,1>::n2] - Xm[pos<0,1>::n2]*Xm[pos<
1,0>::n2] );
}
break;
case 3: case 3:
{ {
// const double tmp1 = X.at(0,0) * X.at(1,1) * X.at(2,2); // const double tmp1 = X.at(0,0) * X.at(1,1) * X.at(2,2);
// const double tmp2 = X.at(0,1) * X.at(1,2) * X.at(2,0); // const double tmp2 = X.at(0,1) * X.at(1,2) * X.at(2,0);
// const double tmp3 = X.at(0,2) * X.at(1,0) * X.at(2,1); // const double tmp3 = X.at(0,2) * X.at(1,0) * X.at(2,1);
// const double tmp4 = X.at(2,0) * X.at(1,1) * X.at(0,2); // const double tmp4 = X.at(2,0) * X.at(1,1) * X.at(0,2);
// const double tmp5 = X.at(2,1) * X.at(1,2) * X.at(0,0); // const double tmp5 = X.at(2,1) * X.at(1,2) * X.at(0,0);
// const double tmp6 = X.at(2,2) * X.at(1,0) * X.at(0,1); // const double tmp6 = X.at(2,2) * X.at(1,0) * X.at(0,1);
// return (tmp1+tmp2+tmp3) - (tmp4+tmp5+tmp6); // return (tmp1+tmp2+tmp3) - (tmp4+tmp5+tmp6);
skipping to change at line 547 skipping to change at line 618
const eT a22 = a_col1[1]; const eT a22 = a_col1[1];
const eT a32 = a_col1[2]; const eT a32 = a_col1[2];
const eT* a_col2 = X.colptr(2); const eT* a_col2 = X.colptr(2);
const eT a13 = a_col2[0]; const eT a13 = a_col2[0];
const eT a23 = a_col2[1]; const eT a23 = a_col2[1];
const eT a33 = a_col2[2]; const eT a33 = a_col2[2];
return ( a11*(a33*a22 - a32*a23) - a21*(a33*a12-a32*a13) + a31*(a23*a 12 - a22*a13) ); return ( a11*(a33*a22 - a32*a23) - a21*(a33*a12-a32*a13) + a31*(a23*a 12 - a22*a13) );
} }
break;
case 4: case 4:
{ {
const eT* Xm = X.memptr();
const eT val = \ const eT val = \
X.at(0,3) * X.at(1,2) * X.at(2,1) * X.at(3,0) \ Xm[pos<0,3>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3
- X.at(0,2) * X.at(1,3) * X.at(2,1) * X.at(3,0) \ ,0>::n4] \
- X.at(0,3) * X.at(1,1) * X.at(2,2) * X.at(3,0) \ - Xm[pos<0,2>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3
+ X.at(0,1) * X.at(1,3) * X.at(2,2) * X.at(3,0) \ ,0>::n4] \
+ X.at(0,2) * X.at(1,1) * X.at(2,3) * X.at(3,0) \ - Xm[pos<0,3>::n4] * Xm[pos<1,1>::n4] * Xm[pos<2,2>::n4] * Xm[pos<3
- X.at(0,1) * X.at(1,2) * X.at(2,3) * X.at(3,0) \ ,0>::n4] \
- X.at(0,3) * X.at(1,2) * X.at(2,0) * X.at(3,1) \ + Xm[pos<0,1>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,2>::n4] * Xm[pos<3
+ X.at(0,2) * X.at(1,3) * X.at(2,0) * X.at(3,1) \ ,0>::n4] \
+ X.at(0,3) * X.at(1,0) * X.at(2,2) * X.at(3,1) \ + Xm[pos<0,2>::n4] * Xm[pos<1,1>::n4] * Xm[pos<2,3>::n4] * Xm[pos<3
- X.at(0,0) * X.at(1,3) * X.at(2,2) * X.at(3,1) \ ,0>::n4] \
- X.at(0,2) * X.at(1,0) * X.at(2,3) * X.at(3,1) \ - Xm[pos<0,1>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,3>::n4] * Xm[pos<3
+ X.at(0,0) * X.at(1,2) * X.at(2,3) * X.at(3,1) \ ,0>::n4] \
+ X.at(0,3) * X.at(1,1) * X.at(2,0) * X.at(3,2) \ - Xm[pos<0,3>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,0>::n4] * Xm[pos<3
- X.at(0,1) * X.at(1,3) * X.at(2,0) * X.at(3,2) \ ,1>::n4] \
- X.at(0,3) * X.at(1,0) * X.at(2,1) * X.at(3,2) \ + Xm[pos<0,2>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,0>::n4] * Xm[pos<3
+ X.at(0,0) * X.at(1,3) * X.at(2,1) * X.at(3,2) \ ,1>::n4] \
+ X.at(0,1) * X.at(1,0) * X.at(2,3) * X.at(3,2) \ + Xm[pos<0,3>::n4] * Xm[pos<1,0>::n4] * Xm[pos<2,2>::n4] * Xm[pos<3
- X.at(0,0) * X.at(1,1) * X.at(2,3) * X.at(3,2) \ ,1>::n4] \
- X.at(0,2) * X.at(1,1) * X.at(2,0) * X.at(3,3) \ - Xm[pos<0,0>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,2>::n4] * Xm[pos<3
+ X.at(0,1) * X.at(1,2) * X.at(2,0) * X.at(3,3) \ ,1>::n4] \
+ X.at(0,2) * X.at(1,0) * X.at(2,1) * X.at(3,3) \ - Xm[pos<0,2>::n4] * Xm[pos<1,0>::n4] * Xm[pos<2,3>::n4] * Xm[pos<3
- X.at(0,0) * X.at(1,2) * X.at(2,1) * X.at(3,3) \ ,1>::n4] \
- X.at(0,1) * X.at(1,0) * X.at(2,2) * X.at(3,3) \ + Xm[pos<0,0>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,3>::n4] * Xm[pos<3
+ X.at(0,0) * X.at(1,1) * X.at(2,2) * X.at(3,3) \ ,1>::n4] \
+ Xm[pos<0,3>::n4] * Xm[pos<1,1>::n4] * Xm[pos<2,0>::n4] * Xm[pos<3
,2>::n4] \
- Xm[pos<0,1>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,0>::n4] * Xm[pos<3
,2>::n4] \
- Xm[pos<0,3>::n4] * Xm[pos<1,0>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3
,2>::n4] \
+ Xm[pos<0,0>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3
,2>::n4] \
+ Xm[pos<0,1>::n4] * Xm[pos<1,0>::n4] * Xm[pos<2,3>::n4] * Xm[pos<3
,2>::n4] \
- Xm[pos<0,0>::n4] * Xm[pos<1,1>::n4] * Xm[pos<2,3>::n4] * Xm[pos<3
,2>::n4] \
- Xm[pos<0,2>::n4] * Xm[pos<1,1>::n4] * Xm[pos<2,0>::n4] * Xm[pos<3
,3>::n4] \
+ Xm[pos<0,1>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,0>::n4] * Xm[pos<3
,3>::n4] \
+ Xm[pos<0,2>::n4] * Xm[pos<1,0>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3
,3>::n4] \
- Xm[pos<0,0>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3
,3>::n4] \
- Xm[pos<0,1>::n4] * Xm[pos<1,0>::n4] * Xm[pos<2,2>::n4] * Xm[pos<3
,3>::n4] \
+ Xm[pos<0,0>::n4] * Xm[pos<1,1>::n4] * Xm[pos<2,2>::n4] * Xm[pos<3
,3>::n4] \
; ;
return val; return val;
} }
break;
default: default:
return eT(0); return eT(0);
; ;
} }
} }
//! immediate determinant of a matrix using ATLAS or LAPACK //! immediate determinant of a matrix using ATLAS or LAPACK
template<typename eT> template<typename eT>
inline inline
skipping to change at line 660 skipping to change at line 735
} }
} }
return ( (sign < 0) ? -val : val ); return ( (sign < 0) ? -val : val );
} }
#else #else
{ {
arma_ignore(X); arma_ignore(X);
arma_ignore(make_copy); arma_ignore(make_copy);
arma_ignore(tmp); arma_ignore(tmp);
arma_stop("det(): need ATLAS or LAPACK"); arma_stop("det(): use of ATLAS or LAPACK needs to enabled");
return eT(0); return eT(0);
} }
#endif #endif
} }
//! immediate log determinant of a matrix using ATLAS or LAPACK //! immediate log determinant of a matrix using ATLAS or LAPACK
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
auxlib::log_det(eT& out_val, typename get_pod_type<eT>::result& out_sign, c onst Base<eT,T1>& X) auxlib::log_det(eT& out_val, typename get_pod_type<eT>::result& out_sign, c onst Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
Mat<eT> tmp(X.get_ref()); Mat<eT> tmp(X.get_ref());
arma_debug_check( (tmp.is_square() == false), "log_det(): given matrix is not square" ); arma_debug_check( (tmp.is_square() == false), "log_det(): given matrix is not square" );
if(tmp.is_empty())
{
out_val = eT(0);
out_sign = T(1);
return;
}
podarray<int> ipiv(tmp.n_rows); podarray<int> ipiv(tmp.n_rows);
atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp. memptr(), tmp.n_rows, ipiv.memptr()); atlas::clapack_getrf(atlas::CblasColMajor, tmp.n_rows, tmp.n_cols, tmp. memptr(), tmp.n_rows, ipiv.memptr());
// on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero
s32 sign = (is_complex<eT>::value == false) ? ( (access::tmp_real( tmp. at(0,0) ) < T(0)) ? -1 : +1 ) : +1; s32 sign = (is_complex<eT>::value == false) ? ( (access::tmp_real( tmp. at(0,0) ) < T(0)) ? -1 : +1 ) : +1;
eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_re al( tmp.at(0,0) ) < T(0)) ? tmp.at(0,0)*T(-1) : tmp.at(0,0) ) : std::log( t mp.at(0,0) ); eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_re al( tmp.at(0,0) ) < T(0)) ? tmp.at(0,0)*T(-1) : tmp.at(0,0) ) : std::log( t mp.at(0,0) );
for(u32 i=1; i < tmp.n_rows; ++i) for(u32 i=1; i < tmp.n_rows; ++i)
skipping to change at line 714 skipping to change at line 796
} }
out_val = val; out_val = val;
out_sign = T(sign); out_sign = T(sign);
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
{ {
Mat<eT> tmp(X.get_ref()); Mat<eT> tmp(X.get_ref());
arma_debug_check( (tmp.is_square() == false), "log_det(): given matrix is not square" ); arma_debug_check( (tmp.is_square() == false), "log_det(): given matrix is not square" );
if(tmp.is_empty())
{
out_val = eT(0);
out_sign = T(1);
return;
}
podarray<blas_int> ipiv(tmp.n_rows); podarray<blas_int> ipiv(tmp.n_rows);
blas_int info = 0; blas_int info = 0;
blas_int n_rows = blas_int(tmp.n_rows); blas_int n_rows = blas_int(tmp.n_rows);
blas_int n_cols = blas_int(tmp.n_cols); blas_int n_cols = blas_int(tmp.n_cols);
lapack::getrf(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr(), & info); lapack::getrf(&n_rows, &n_cols, tmp.memptr(), &n_rows, ipiv.memptr(), & info);
// on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero // on output tmp appears to be L+U_alt, where U_alt is U with the main diagonal set to zero
skipping to change at line 748 skipping to change at line 837
{ {
sign *= -1; sign *= -1;
} }
} }
out_val = val; out_val = val;
out_sign = T(sign); out_sign = T(sign);
} }
#else #else
{ {
arma_stop("log_det(): need ATLAS or LAPACK"); arma_stop("log_det(): use of ATLAS or LAPACK needs to enabled");
out_val = eT(0); out_val = eT(0);
out_sign = T(0); out_sign = T(0);
} }
#endif #endif
} }
//! immediate LU decomposition of a matrix using ATLAS or LAPACK //! immediate LU decomposition of a matrix using ATLAS or LAPACK
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
auxlib::lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, const Base<eT, T1>& X) auxlib::lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, const Base<eT, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
U = X.get_ref(); U = X.get_ref();
if(U.is_empty()) if(U.is_empty())
{ {
ipiv.reset();
L.reset(); L.reset();
U.reset();
ipiv.reset();
return; return;
} }
const u32 U_n_rows = U.n_rows; const u32 U_n_rows = U.n_rows;
const u32 U_n_cols = U.n_cols; const u32 U_n_cols = U.n_cols;
#if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK)
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
skipping to change at line 824 skipping to change at line 914
for(u32 row = (col+1); row < U_n_rows; ++row) for(u32 row = (col+1); row < U_n_rows; ++row)
{ {
L.at(row,col) = U.at(row,col); L.at(row,col) = U.at(row,col);
U.at(row,col) = eT(0); U.at(row,col) = eT(0);
} }
} }
} }
#else #else
{ {
arma_ignore(L);
arma_ignore(ipiv);
arma_ignore(U_n_rows); arma_ignore(U_n_rows);
arma_ignore(U_n_cols); arma_ignore(U_n_cols);
arma_stop("lu(): need ATLAS or LAPACK"); arma_stop("lu(): use of ATLAS or LAPACK needs to enabled");
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
auxlib::lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X) auxlib::lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
podarray<blas_int> ipiv1; podarray<blas_int> ipiv1;
auxlib::lu(L, U, ipiv1, X); auxlib::lu(L, U, ipiv1, X);
if(U.is_empty())
{
L.reset();
U.reset();
P.reset();
return;
}
const u32 n = ipiv1.n_elem; const u32 n = ipiv1.n_elem;
const u32 P_rows = U.n_rows; const u32 P_rows = U.n_rows;
podarray<blas_int> ipiv2(P_rows); podarray<blas_int> ipiv2(P_rows);
const blas_int* ipiv1_mem = ipiv1.memptr(); const blas_int* ipiv1_mem = ipiv1.memptr();
blas_int* ipiv2_mem = ipiv2.memptr(); blas_int* ipiv2_mem = ipiv2.memptr();
for(u32 i=0; i<P_rows; ++i) for(u32 i=0; i<P_rows; ++i)
{ {
skipping to change at line 894 skipping to change at line 990
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
auxlib::lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X) auxlib::lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
podarray<blas_int> ipiv1; podarray<blas_int> ipiv1;
auxlib::lu(L, U, ipiv1, X); auxlib::lu(L, U, ipiv1, X);
if(U.is_empty())
{
L.reset();
U.reset();
return;
}
const u32 n = ipiv1.n_elem; const u32 n = ipiv1.n_elem;
const u32 P_rows = U.n_rows; const u32 P_rows = U.n_rows;
podarray<blas_int> ipiv2(P_rows); podarray<blas_int> ipiv2(P_rows);
const blas_int* ipiv1_mem = ipiv1.memptr(); const blas_int* ipiv1_mem = ipiv1.memptr();
blas_int* ipiv2_mem = ipiv2.memptr(); blas_int* ipiv2_mem = ipiv2.memptr();
for(u32 i=0; i<P_rows; ++i) for(u32 i=0; i<P_rows; ++i)
{ {
skipping to change at line 943 skipping to change at line 1046
auxlib::eig_sym(Col<eT>& eigval, const Base<eT,T1>& X) auxlib::eig_sym(Col<eT>& eigval, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is not square"); arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is not square");
if(A.is_empty())
{
eigval.reset();
return true;
}
// rudimentary "better-than-nothing" test for symmetry // rudimentary "better-than-nothing" test for symmetry
//arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" ); //arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" );
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = A.n_rows; blas_int n_rows = A.n_rows;
blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1); blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1);
eigval.set_size(A.n_rows); eigval.set_size( static_cast<u32>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<u32>(lwork) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr( ), work.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr( ), work.memptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): need LAPACK"); arma_stop("eig_sym(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//! immediate eigenvalues of a hermitian complex matrix using LAPACK //! immediate eigenvalues of a hermitian complex matrix using LAPACK
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X) auxlib::eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is not hermitian"); arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is not hermitian");
if(A.is_empty())
{
eigval.reset();
return true;
}
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = A.n_rows; blas_int n_rows = A.n_rows;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork
eigval.set_size(A.n_rows); eigval.set_size( static_cast<u32>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<u32>(lwork) );
podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows - 2)) ); podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows - 2)) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(), work.memptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(), work.memptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): need LAPACK"); arma_stop("eig_sym(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//! immediate eigenvalues and eigenvectors of a symmetric real matrix using LAPACK //! immediate eigenvalues and eigenvectors of a symmetric real matrix using LAPACK
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X) auxlib::eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
eigvec = X.get_ref(); eigvec = X.get_ref();
arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not square" ); arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not square" );
if(eigvec.is_empty())
{
eigval.reset();
eigvec.reset();
return true;
}
// rudimentary "better-than-nothing" test for symmetry // rudimentary "better-than-nothing" test for symmetry
//arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" ); //arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl ib::eig(): given matrix is not symmetric" );
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = eigvec.n_rows; blas_int n_rows = eigvec.n_rows;
blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1); blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1);
eigval.set_size(eigvec.n_rows); eigval.set_size( static_cast<u32>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<u32>(lwork) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me mptr(), work.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me mptr(), work.memptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(eigvec); arma_ignore(eigvec);
arma_ignore(X); arma_stop("eig_sym(): use of LAPACK needs to enabled");
arma_stop("eig_sym(): need LAPACK");
return false; return false;
} }
#endif #endif
} }
//! immediate eigenvalues and eigenvectors of a hermitian complex matrix us ing LAPACK //! immediate eigenvalues and eigenvectors of a hermitian complex matrix us ing LAPACK
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Base< std::complex<T>,T1>& X) auxlib::eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Base< std::complex<T>,T1>& X)
skipping to change at line 1076 skipping to change at line 1198
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
eigvec = X.get_ref(); eigvec = X.get_ref();
arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not hermitian" ); arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not hermitian" );
if(eigvec.is_empty())
{
eigval.reset();
eigvec.reset();
return true;
}
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = eigvec.n_rows; blas_int n_rows = eigvec.n_rows;
blas_int lda = eigvec.n_rows; blas_int lda = eigvec.n_rows;
blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1); // TODO: auto matically find best size of lwork
eigval.set_size(eigvec.n_rows); eigval.set_size( static_cast<u32>(n_rows) );
podarray<eT> work( static_cast<u32>(lwork) ); podarray<eT> work( static_cast<u32>(lwork) );
podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows - 2)) ); podarray<T> rwork( static_cast<u32>((std::max)(blas_int(1), 3*n_rows - 2)) );
blas_int info; blas_int info;
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt r(), work.memptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt r(), work.memptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(eigvec); arma_ignore(eigvec);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): need LAPACK"); arma_stop("eig_sym(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//! Eigenvalues and eigenvectors of a general square real matrix using LAPA CK. //! Eigenvalues and eigenvectors of a general square real matrix using LAPA CK.
//! The argument 'side' specifies which eigenvectors should be calculated //! The argument 'side' specifies which eigenvectors should be calculated
//! (see code for mode details). //! (see code for mode details).
template<typename T, typename T1> template<typename T, typename T1>
inline inline
skipping to change at line 1125 skipping to change at line 1254
Mat<T>& l_eigvec, Mat<T>& l_eigvec,
Mat<T>& r_eigvec, Mat<T>& r_eigvec,
const Base<T,T1>& X, const Base<T,T1>& X,
const char side const char side
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<T> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is
not square" );
char jobvl; char jobvl;
char jobvr; char jobvr;
switch(side) switch(side)
{ {
case 'l': // left case 'l': // left
jobvl = 'V'; jobvl = 'V';
jobvr = 'N'; jobvr = 'N';
break; break;
skipping to change at line 1155 skipping to change at line 1281
jobvr = 'V'; jobvr = 'V';
break; break;
case 'n': // neither case 'n': // neither
jobvl = 'N'; jobvl = 'N';
jobvr = 'N'; jobvr = 'N';
break; break;
default: default:
arma_stop("eig_gen(): parameter 'side' is invalid"); arma_stop("eig_gen(): parameter 'side' is invalid");
return false;
}
Mat<T> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is
not square" );
if(A.is_empty())
{
eigval.reset();
l_eigvec.reset();
r_eigvec.reset();
return true;
} }
u32 A_n_rows = A.n_rows; u32 A_n_rows = A.n_rows;
blas_int n_rows = A_n_rows; blas_int n_rows = A_n_rows;
blas_int lda = A_n_rows; blas_int lda = A_n_rows;
blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
skipping to change at line 1194 skipping to change at line 1332
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(l_eigvec); arma_ignore(l_eigvec);
arma_ignore(r_eigvec); arma_ignore(r_eigvec);
arma_ignore(X); arma_ignore(X);
arma_ignore(side); arma_ignore(side);
arma_stop("eig_gen(): need LAPACK"); arma_stop("eig_gen(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//! Eigenvalues and eigenvectors of a general square complex matrix using L APACK //! Eigenvalues and eigenvectors of a general square complex matrix using L APACK
//! The argument 'side' specifies which eigenvectors should be calculated //! The argument 'side' specifies which eigenvectors should be calculated
//! (see code for mode details). //! (see code for mode details).
template<typename T, typename T1> template<typename T, typename T1>
inline inline
skipping to change at line 1221 skipping to change at line 1359
const Base< std::complex<T>, T1 >& X, const Base< std::complex<T>, T1 >& X,
const char side const char side
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is
not square" );
char jobvl; char jobvl;
char jobvr; char jobvr;
switch(side) switch(side)
{ {
case 'l': // left case 'l': // left
jobvl = 'V'; jobvl = 'V';
jobvr = 'N'; jobvr = 'N';
break; break;
skipping to change at line 1251 skipping to change at line 1386
jobvr = 'V'; jobvr = 'V';
break; break;
case 'n': // neither case 'n': // neither
jobvl = 'N'; jobvl = 'N';
jobvr = 'N'; jobvr = 'N';
break; break;
default: default:
arma_stop("eig_gen(): parameter 'side' is invalid"); arma_stop("eig_gen(): parameter 'side' is invalid");
return false;
}
Mat<eT> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is
not square" );
if(A.is_empty())
{
eigval.reset();
l_eigvec.reset();
r_eigvec.reset();
return true;
} }
u32 A_n_rows = A.n_rows; u32 A_n_rows = A.n_rows;
blas_int n_rows = A_n_rows; blas_int n_rows = A_n_rows;
blas_int lda = A_n_rows; blas_int lda = A_n_rows;
blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork blas_int lwork = (std::max)(blas_int(1), 4*n_rows); // TODO: automati cally find best size of lwork
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
skipping to change at line 1280 skipping to change at line 1427
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(l_eigvec); arma_ignore(l_eigvec);
arma_ignore(r_eigvec); arma_ignore(r_eigvec);
arma_ignore(X); arma_ignore(X);
arma_ignore(side); arma_ignore(side);
arma_stop("eig_gen(): need LAPACK"); arma_stop("eig_gen(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::chol(Mat<eT>& out, const Base<eT,T1>& X) auxlib::chol(Mat<eT>& out, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "chol(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "chol(): given matrix is not square" );
if(out.is_empty())
{
return true;
}
const u32 out_n_rows = out.n_rows; const u32 out_n_rows = out.n_rows;
char uplo = 'U'; char uplo = 'U';
blas_int n = out_n_rows; blas_int n = out_n_rows;
blas_int info; blas_int info;
lapack::potrf(&uplo, &n, out.memptr(), &n, &info); lapack::potrf(&uplo, &n, out.memptr(), &n, &info);
for(u32 col=0; col<out_n_rows; ++col) for(u32 col=0; col<out_n_rows; ++col)
{ {
skipping to change at line 1322 skipping to change at line 1474
{ {
colptr[row] = eT(0); colptr[row] = eT(0);
} }
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(X); arma_stop("chol(): use of LAPACK needs to enabled");
arma_stop("chol(): need LAPACK");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X) auxlib::qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
R = X.get_ref(); R = X.get_ref();
if(R.is_empty()) if(R.is_empty())
{ {
Q.reset(); Q.reset();
return false; R.reset();
return true;
} }
const u32 R_n_rows = R.n_rows; const u32 R_n_rows = R.n_rows;
const u32 R_n_cols = R.n_cols; const u32 R_n_cols = R.n_cols;
blas_int m = static_cast<blas_int>(R_n_rows); blas_int m = static_cast<blas_int>(R_n_rows);
blas_int n = static_cast<blas_int>(R_n_cols); blas_int n = static_cast<blas_int>(R_n_cols);
blas_int work_len = (std::max)(blas_int(1),n); blas_int work_len = (std::max)(blas_int(1),n);
blas_int work_len_tmp; blas_int work_len_tmp;
blas_int k = (std::min)(m,n); blas_int k = (std::min)(m,n);
skipping to change at line 1423 skipping to change at line 1575
lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len, &info); lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() , &work_len, &info);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(Q); arma_ignore(Q);
arma_ignore(R); arma_ignore(R);
arma_ignore(X); arma_ignore(X);
arma_stop("qr(): need LAPACK"); arma_stop("qr(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, u32& X_n_rows, u32& X_n_cols) auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, u32& X_n_rows, u32& X_n_cols)
{ {
skipping to change at line 1446 skipping to change at line 1598
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
X_n_rows = A.n_rows; X_n_rows = A.n_rows;
X_n_cols = A.n_cols; X_n_cols = A.n_cols;
if(A.is_empty()) if(A.is_empty())
{ {
S.reset(); S.reset();
return false; X_n_rows = 0;
X_n_cols = 0;
return true;
} }
Mat<eT> U(1, 1); Mat<eT> U(1, 1);
Mat<eT> V(1, A.n_cols); Mat<eT> V(1, A.n_cols);
char jobu = 'N'; char jobu = 'N';
char jobvt = 'N'; char jobvt = 'N';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
skipping to change at line 1513 skipping to change at line 1667
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(S); arma_ignore(S);
arma_ignore(X); arma_ignore(X);
arma_ignore(X_n_rows); arma_ignore(X_n_rows);
arma_ignore(X_n_cols); arma_ignore(X_n_cols);
arma_stop("svd(): need LAPACK"); arma_stop("svd(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X, u32& X_n_rows, u 32& X_n_cols) auxlib::svd(Col<T>& S, const Base<std::complex<T>, T1>& X, u32& X_n_rows, u 32& X_n_cols)
{ {
skipping to change at line 1538 skipping to change at line 1692
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
X_n_rows = A.n_rows; X_n_rows = A.n_rows;
X_n_cols = A.n_cols; X_n_cols = A.n_cols;
if(A.is_empty()) if(A.is_empty())
{ {
S.reset(); S.reset();
return false; X_n_rows = 0;
X_n_cols = 0;
return true;
} }
Mat<eT> U(1, 1); Mat<eT> U(1, 1);
Mat<eT> V(1, A.n_cols); Mat<eT> V(1, A.n_cols);
char jobu = 'N'; char jobu = 'N';
char jobvt = 'N'; char jobvt = 'N';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
skipping to change at line 1608 skipping to change at line 1764
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(S); arma_ignore(S);
arma_ignore(X); arma_ignore(X);
arma_ignore(X_n_rows); arma_ignore(X_n_rows);
arma_ignore(X_n_cols); arma_ignore(X_n_cols);
arma_stop("svd(): need LAPACK"); arma_stop("svd(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd(Col<eT>& S, const Base<eT,T1>& X) auxlib::svd(Col<eT>& S, const Base<eT,T1>& X)
{ {
skipping to change at line 1652 skipping to change at line 1808
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
if(A.is_empty()) if(A.is_empty())
{ {
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
return false; return true;
} }
U.set_size(A.n_rows, A.n_rows); U.set_size(A.n_rows, A.n_rows);
V.set_size(A.n_cols, A.n_cols); V.set_size(A.n_cols, A.n_cols);
char jobu = 'A'; char jobu = 'A';
char jobvt = 'A'; char jobvt = 'A';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
skipping to change at line 1708 skipping to change at line 1864
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork, work.memptr(), &lwork,
&info &info
); );
op_trans::apply(V,V); // op_trans will work out that an in-place tra nspose can be done op_strans::apply(V,V); // op_strans will work out that an in-place t ranspose can be done
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
arma_stop("svd(): need LAPACK"); arma_stop("svd(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V , const Base< std::complex<T>, T1>& X) auxlib::svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V , const Base< std::complex<T>, T1>& X)
{ {
skipping to change at line 1743 skipping to change at line 1899
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
if(A.is_empty()) if(A.is_empty())
{ {
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
return false; return true;
} }
U.set_size(A.n_rows, A.n_rows); U.set_size(A.n_rows, A.n_rows);
V.set_size(A.n_cols, A.n_cols); V.set_size(A.n_cols, A.n_cols);
char jobu = 'A'; char jobu = 'A';
char jobvt = 'A'; char jobvt = 'A';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
skipping to change at line 1813 skipping to change at line 1969
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
arma_stop("svd(): need LAPACK"); arma_stop("svd(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//! Solve a system of linear equations. //! Solve a system of linear equations.
//! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows //! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty()) if(A.is_empty() || B.is_empty())
{ {
out.reset(); out.reset();
return false; A.reset();
return true;
} }
else
#if defined(ARMA_USE_LAPACK)
{ {
u32 A_n_rows = A.n_rows; const u32 A_n_rows = A.n_rows;
blas_int n = A_n_rows; bool status = false;
blas_int lda = A_n_rows;
blas_int ldb = A_n_rows;
blas_int nrhs = B.n_cols;
blas_int info;
podarray<blas_int> ipiv(A_n_rows); if(A_n_rows <= 4)
{
Mat<eT> A_inv;
out = B; status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows);
lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.memptr if(status == true)
(), &ldb, &info); {
out.set_size(A_n_rows, B.n_cols);
return (info == 0); gemm_emul<false,false,false,false>::apply(out, A_inv, B);
}
#else return true;
{ }
arma_ignore(out); }
arma_ignore(A);
arma_ignore(B); if( (A_n_rows > 4) || (status == false) )
arma_stop("solve(): need LAPACK"); {
return false; #if defined(ARMA_USE_LAPACK)
{
blas_int n = A_n_rows;
blas_int lda = A_n_rows;
blas_int ldb = A_n_rows;
blas_int nrhs = B.n_cols;
blas_int info;
podarray<blas_int> ipiv(A_n_rows);
out = B;
lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.me
mptr(), &ldb, &info);
return (info == 0);
}
#else
{
arma_stop("solve(): use of LAPACK needs to enabled");
return false;
}
#endif
}
} }
#endif
return true;
} }
//! Solve an over-determined system. //! Solve an over-determined system.
//! Assumes that A.n_rows > A.n_cols and B.n_rows = A.n_rows //! Assumes that A.n_rows > A.n_cols and B.n_rows = A.n_rows
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) auxlib::solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty())
{
out.reset();
return false;
}
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
if(A.is_empty() || B.is_empty())
{
out.reset();
A.reset();
return true;
}
char trans = 'N'; char trans = 'N';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldb = A.n_rows; blas_int ldb = A.n_rows;
blas_int nrhs = B.n_cols; blas_int nrhs = B.n_cols;
blas_int lwork = n + (std::max)(n, nrhs); blas_int lwork = n + (std::max)(n, nrhs);
blas_int info; blas_int info;
skipping to change at line 1924 skipping to change at line 2104
arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols );
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
arma_ignore(B); arma_ignore(B);
arma_stop("solve(): need LAPACK"); arma_stop("solve(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//! Solve an under-determined system. //! Solve an under-determined system.
//! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows //! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) auxlib::solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty())
{
out.reset();
return false;
}
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
if(A.is_empty() || B.is_empty())
{
out.reset();
A.reset();
return true;
}
char trans = 'N'; char trans = 'N';
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldb = A.n_cols; blas_int ldb = A.n_cols;
blas_int nrhs = B.n_cols; blas_int nrhs = B.n_cols;
blas_int lwork = m + (std::max)(m,nrhs); blas_int lwork = m + (std::max)(m,nrhs);
blas_int info; blas_int info;
skipping to change at line 2003 skipping to change at line 2184
arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols );
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
arma_ignore(B); arma_ignore(B);
arma_stop("solve(): need LAPACK"); arma_stop("solve(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
// //
// solve_tr // solve_tr
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const u3 2 layout) auxlib::solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const u3 2 layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty())
{
out.reset();
return false;
}
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
if(A.is_empty() || B.is_empty())
{
out.reset();
return true;
}
out = B; out = B;
char uplo = (layout == 0) ? 'U' : 'L'; char uplo = (layout == 0) ? 'U' : 'L';
char trans = 'N'; char trans = 'N';
char diag = 'N'; char diag = 'N';
blas_int n = blas_int(A.n_rows); blas_int n = blas_int(A.n_rows);
blas_int nrhs = blas_int(B.n_cols); blas_int nrhs = blas_int(B.n_cols);
blas_int info = 0; blas_int info = 0;
lapack::trtrs<eT>(&uplo, &trans, &diag, &n, &nrhs, A.memptr(), &n, out. memptr(), &n, &info); lapack::trtrs<eT>(&uplo, &trans, &diag, &n, &nrhs, A.memptr(), &n, out. memptr(), &n, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
arma_ignore(B); arma_ignore(B);
arma_ignore(layout); arma_ignore(layout);
arma_stop("solve(): need LAPACK"); arma_stop("solve(): use of LAPACK needs to enabled");
return false; return false;
} }
#endif #endif
} }
//
// Schur decomposition
template<typename eT>
inline
bool
auxlib::schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
arma_debug_check( (A.is_square() == false), "schur_dec(): matrix A is n
ot square" );
if(A.is_empty())
{
Z.reset();
T.reset();
return true;
}
const u32 A_n_rows = A.n_rows;
char jobvs = 'V'; // get Schur vectors (Z)
char sort = 'N'; // do not sort eigenvalues/vecto
rs
blas_int* select = 0; // pointer to sorting function
blas_int n = blas_int(A_n_rows);
blas_int sdim = 0; // output for sorting
blas_int lwork = 3 * n; // workspace must be at least 3
* n (if set to -1, optimal size is output in work(0) and nothing else is do
ne
podarray<eT> work( static_cast<u32>(lwork) );
podarray<blas_int> bwork(A_n_rows);
blas_int info = 0;
Z.set_size(A_n_rows, A_n_rows);
T = A;
podarray<eT> wr(A_n_rows); // output for eigenvalues
podarray<eT> wi(A_n_rows); // output for eigenvalues
lapack::gees(&jobvs, &sort, select, &n, T.memptr(), &n, &sdim, wr.mempt
r(), wi.memptr(), Z.memptr(), &n, work.memptr(), &lwork, bwork.memptr(), &i
nfo);
return (info == 0);
}
#else
{
arma_ignore(Z);
arma_ignore(T);
arma_stop("schur_dec(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
template<typename cT>
inline
bool
auxlib::schur_dec(Mat<std::complex<cT> >& Z, Mat<std::complex<cT> >& T, con
st Mat<std::complex<cT> >& A)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
arma_debug_check( (A.is_square() == false), "schur_dec(): matrix A is n
ot square" );
if(A.is_empty())
{
Z.reset();
T.reset();
return true;
}
typedef std::complex<cT> eT;
const u32 A_n_rows = A.n_rows;
char jobvs = 'V'; // get Schur vectors (Z)
char sort = 'N'; // do not sort eigenvalues/vect
ors
blas_int* select = 0; // pointer to sorting function
blas_int n = blas_int(A_n_rows);
blas_int sdim = 0; // output for sorting
blas_int lwork = 3 * n; // workspace must be at least 3
* n (if set to -1, optimal size is output in work(0) and nothing else is d
one
podarray<eT> work( static_cast<u32>(lwork) );
podarray<blas_int> bwork(A_n_rows);
blas_int info = 0;
Z.set_size(A_n_rows, A_n_rows);
T = A;
podarray<eT> w(A_n_rows); // output for eigenvalues
podarray<cT> rwork(A_n_rows);
lapack::cx_gees(&jobvs, &sort, select, &n, T.memptr(), &n, &sdim, w.mem
ptr(), Z.memptr(), &n, work.memptr(), &lwork, rwork.memptr(), bwork.memptr(
), &info);
return (info == 0);
}
#else
{
arma_ignore(Z);
arma_ignore(T);
arma_stop("schur_dec(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
//
// syl (solution of the Sylvester equation AX + XB = C)
template<typename eT>
inline
bool
auxlib::syl(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& B, const Mat<eT>&
C)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.is_square() == false), "syl(): matrix A is not squar
e" );
arma_debug_check( (B.is_square() == false), "syl(): matrix B is not squar
e" );
arma_debug_check( (C.n_rows != A.n_rows) || (C.n_cols != B.n_cols), "syl(
): matrices are not conformant" );
if(A.is_empty() || B.is_empty() || C.is_empty())
{
X.reset();
return true;
}
bool status;
#if defined(ARMA_USE_LAPACK)
{
Mat<eT> Z1, Z2, T1, T2;
status = auxlib::schur_dec(Z1, T1, A);
if(status == false)
{
return false;
}
status = auxlib::schur_dec(Z2, T2, B);
if(status == false)
{
return false;
}
char trana = 'N';
char tranb = 'N';
blas_int isgn = +1;
blas_int m = blas_int(T1.n_rows);
blas_int n = blas_int(T2.n_cols);
eT scale = eT(0);
blas_int info = 0;
Mat<eT> Y = trans(Z1) * C * Z2;
lapack::trsyl<eT>(&trana, &tranb, &isgn, &m, &n, T1.memptr(), &m, T2.me
mptr(), &n, Y.memptr(), &m, &scale, &info);
//Y /= scale;
Y /= (-scale);
X = Z1 * Y * trans(Z2);
status = (info == 0);
}
#else
{
arma_stop("syl(): use of LAPACK needs to be enabled");
return false;
}
#endif
if(status == false)
{
arma_print("syl(): equation appears to be singular" );
X.reset();
}
return status;
}
//
// lyap (solution of the continuous Lyapunov equation AX + XA^H + Q = 0)
template<typename eT>
inline
bool
auxlib::lyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.is_square() == false), "lyap(): matrix A is not squa
re");
arma_debug_check( (Q.is_square() == false), "lyap(): matrix Q is not squa
re");
arma_debug_check( (A.n_rows != Q.n_rows), "lyap(): matrices A and Q hav
e different dimensions");
Mat<eT> htransA;
op_htrans::apply_noalias(htransA, A);
const Mat<eT> mQ = -Q;
return auxlib::syl(X, A, htransA, mQ);
}
//
// dlyap (solution of the discrete Lyapunov equation AXA^H - X + Q = 0)
template<typename eT>
inline
bool
auxlib::dlyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.is_square() == false), "dlyap(): matrix A is not squ
are");
arma_debug_check( (Q.is_square() == false), "dlyap(): matrix Q is not squ
are");
arma_debug_check( (A.n_rows != Q.n_rows), "dlyap(): matrices A and Q ha
ve different dimensions");
const Col<eT> vecQ = reshape(Q, Q.n_elem, 1);
const Mat<eT> M = eye< Mat<eT> >(Q.n_elem, Q.n_elem) - kron(conj(A), A);
Col<eT> vecX;
const bool status = solve(vecX, M, vecQ);
if(status == true)
{
X = reshape(vecX, Q.n_rows, Q.n_cols);
return true;
}
else
{
X.reset();
return false;
}
}
//! @} //! @}
 End of changes. 80 change blocks. 
247 lines changed or deleted 768 lines changed or added


 compiler_setup.hpp   compiler_setup.hpp 
skipping to change at line 79 skipping to change at line 79
#if (ARMA_GCC_VERSION >= 40200) #if (ARMA_GCC_VERSION >= 40200)
#if defined(_GLIBCXX_USE_C99_MATH_TR1) && defined(_GLIBCXX_USE_C99_COMP LEX_TR1) #if defined(_GLIBCXX_USE_C99_MATH_TR1) && defined(_GLIBCXX_USE_C99_COMP LEX_TR1)
#define ARMA_HAVE_STD_TR1 #define ARMA_HAVE_STD_TR1
#endif #endif
#endif #endif
#if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__GXX_EXPERIMENTAL_CXX0X__)
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#endif #endif
#if defined(__clang__)
#undef ARMA_HAVE_STD_TR1
#endif
#if (ARMA_GCC_VERSION >= 40300) #if (ARMA_GCC_VERSION >= 40300)
#undef arma_hot #undef arma_hot
#undef arma_cold #undef arma_cold
#define arma_hot __attribute__((hot)) #define arma_hot __attribute__((hot))
#define arma_cold __attribute__((cold)) #define arma_cold __attribute__((cold))
#endif #endif
#undef ARMA_GCC_VERSION #undef ARMA_GCC_VERSION
skipping to change at line 139 skipping to change at line 143
#undef ARMA_HAVE_STD_ISNAN #undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#endif #endif
// //
// whoever defined macros with the names "min" and "max" should be permanen tly removed from the gene pool // whoever defined macros with the names "min" and "max" should be permanen tly removed from the gene pool
#if defined(min) #if defined(min)
#undef min #undef min
#if defined(_MSC_VER) #if defined(__GNUG__)
#pragma message ("detected min macro and undefined it; you may wish to #warning "detected 'min' macro and undefined it; you may wish t
define NOMINMAX before including any windows header") o define NOMINMAX before including any windows header"
#elif defined(_MSC_VER)
#pragma message ("detected 'min' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header")
#endif #endif
#endif #endif
#if defined(max) #if defined(max)
#undef max #undef max
#if defined(_MSC_VER) #if defined(__GNUG__)
#pragma message ("detected max macro and undefined it; you may wish to #warning "detected 'max' macro and undefined it; you may wish t
define NOMINMAX before including any windows header") o define NOMINMAX before including any windows header"
#elif defined(_MSC_VER)
#pragma message ("detected 'max' macro and undefined it; you may wish t
o define NOMINMAX before including any windows header")
#endif #endif
#endif #endif
 End of changes. 3 change blocks. 
6 lines changed or deleted 16 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 212 skipping to change at line 212
arma_hot arma_hot
arma_check(const bool state, const T1& x, const T2& y) arma_check(const bool state, const T1& x, const T2& y)
{ {
if(state==true) if(state==true)
{ {
arma_stop( std::string(x) + std::string(y) ); arma_stop( std::string(x) + std::string(y) );
} }
} }
// //
// arma_set_error
arma_inline
void
arma_hot
arma_set_error(bool& err_state, char*& err_msg, const bool expression, cons
t char* message)
{
if(expression == true)
{
err_state = true;
err_msg = const_cast<char*>(message);
}
}
//
// functions for generating strings indicating size errors // functions for generating strings indicating size errors
inline inline
std::string std::string
arma_cold arma_cold
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_rows, const u32 B_n_cols, const char* x) arma_incompat_size_string(const 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 << 'x' << A_ n_cols << " and " << B_n_rows << 'x' << B_n_cols; tmp << x << ": incompatible matrix dimensions: " << A_n_rows << 'x' << A_ n_cols << " and " << B_n_rows << 'x' << B_n_cols;
skipping to change at line 826 skipping to change at line 841
#define ARMA_FNSIG BOOST_CURRENT_FUNCTION #define ARMA_FNSIG BOOST_CURRENT_FUNCTION
#else #else
#define ARMA_FNSIG "(unknown)" #define ARMA_FNSIG "(unknown)"
#endif #endif
#if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) #if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG)
#define arma_debug_print arma_print #define arma_debug_print arma_print
#define arma_debug_warn arma_warn #define arma_debug_warn arma_warn
#define arma_debug_check arma_check #define arma_debug_check arma_check
#define arma_debug_set_error arma_set_error
#define arma_debug_assert_same_size arma_assert_same_size #define arma_debug_assert_same_size arma_assert_same_size
#define arma_debug_assert_mul_size arma_assert_mul_size #define arma_debug_assert_mul_size arma_assert_mul_size
#define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat #define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat
#else #else
#undef ARMA_EXTRA_DEBUG #undef ARMA_EXTRA_DEBUG
#define arma_debug_print true ? (void)0 : arma_print #define arma_debug_print true ? (void)0 : arma_print
#define arma_debug_warn true ? (void)0 : arma_warn #define arma_debug_warn true ? (void)0 : arma_warn
#define arma_debug_check true ? (void)0 : arma_check #define arma_debug_check true ? (void)0 : arma_check
#define arma_debug_set_error true ? (void)0 : arma_set_error
#define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s ize #define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s ize
#define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si ze #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si ze
#define arma_debug_assert_cube_as_mat true ? (void)0 : arma_debug_assert_ cube_as_mat #define arma_debug_assert_cube_as_mat true ? (void)0 : arma_debug_assert_ cube_as_mat
#endif #endif
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint #define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint
#define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint #define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint
 End of changes. 4 change blocks. 
0 lines changed or deleted 19 lines changed or added


 diagmat_proxy.hpp   diagmat_proxy.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 25 skipping to change at line 25
template<typename T1> template<typename T1>
class diagmat_proxy class diagmat_proxy
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Base<typename T1::elem_type,T1>& X) inline diagmat_proxy(const Base<typename T1::elem_type,T1>& X)
: P (X.get_ref()) : P ( X.get_ref() )
, P_is_vec( (P.get_n_rows() == 1) || (P.get_n_cols() == 1) ) , P_is_vec( (P.get_n_rows() == 1) || (P.get_n_cols() == 1) )
, n_elem ( P_is_vec ? P.get_n_elem() : P.get_n_rows() ) , n_elem ( P_is_vec ? P.get_n_elem() : (std::min)(P.get_n_elem(), P.ge t_n_rows()) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (P_is_vec == false) && (P.get_n_rows() != P.get_n_col arma_debug_check
s()), "diagmat(): only vectors and square matrices are accepted" ); (
(P_is_vec == false) && (P.get_n_rows() != P.get_n_cols()),
"diagmat(): only vectors and square matrices are accepted"
);
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline
eturn P_is_vec ? P[i] : P.at(i,i); elem_type
} operator[](const u32 i) const
arma_inline elem_type at (const u32 row, const u32 col) const { r {
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); if( (Proxy<T1>::prefer_at_operator == true) || (P_is_vec == false) )
} {
return P.at(i,i);
}
else
{
return P[i];
}
}
arma_inline
elem_type
at(const u32 row, const u32 col) const
{
if(row == col)
{
if( (Proxy<T1>::prefer_at_operator == true) || (P_is_vec == false) )
{
return P.at(row,row);
}
else
{
return P[row];
}
}
else
{
return elem_type(0);
}
}
const Proxy<T1> P; const Proxy<T1> P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Mat<eT> > class diagmat_proxy< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Mat<eT>& X) inline diagmat_proxy(const Mat<eT>& X)
: P(X) : P(X)
, P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) ) , P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) )
, n_elem( P_is_vec ? P.n_elem : P.n_rows ) , n_elem( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (P_is_vec == false) && (P.n_rows != P.n_cols), "diagm
at(): only vectors and square matrices are accepted" ); arma_debug_check
(
(P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted"
);
} }
arma_inline elem_type operator[] (const u32 i) const { r eturn P_is_vec ? P[i] : P.at(i,i); } arma_inline elem_type operator[] (const u32 i) const { r eturn P_is_vec ? P[i] : P.at(i,i); }
arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); } arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); }
const Mat<eT>& P; const Mat<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
skipping to change at line 83 skipping to change at line 124
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Row<eT>& X) inline diagmat_proxy(const Row<eT>& X)
: P(X) : P(X)
, P_is_vec(true) , P_is_vec(true)
, n_elem(P.n_elem) , n_elem(P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const u32 i) const { r
eturn P_is_vec ? P[i] : P.at(i,i); eturn P[i];
} }
arma_inline elem_type at (const u32 row, const u32 col) const { r arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); eturn (row == col) ? P[row] : elem_type(0); }
}
const Row<eT>& P; const Row<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Col<eT> > class diagmat_proxy< Col<eT> >
{ {
public: public:
skipping to change at line 107 skipping to change at line 148
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Col<eT>& X) inline diagmat_proxy(const Col<eT>& X)
: P(X) : P(X)
, P_is_vec(true) , P_is_vec(true)
, n_elem(P.n_elem) , n_elem(P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const u32 i) const { r
eturn P_is_vec ? P[i] : P.at(i,i); eturn P[i]; }
} arma_inline elem_type at (const u32 row, const u32 col) const { r
arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? P[row] : elem_type(0); }
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0);
}
const Col<eT>& P; const Col<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
template<typename T1> template<typename T1>
class diagmat_proxy_check class diagmat_proxy_check
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy_check(const Base<typename T1::elem_type,T1>& X, cons t Mat<typename T1::elem_type>& out) inline diagmat_proxy_check(const Base<typename T1::elem_type,T1>& X, cons t Mat<typename T1::elem_type>& out)
: P(X.get_ref()) : P(X.get_ref())
, P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) ) , P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) )
, n_elem( P_is_vec ? P.n_elem : P.n_rows ) , n_elem( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(out); arma_ignore(out);
arma_debug_check( (P_is_vec == false) && (P.n_rows != P.n_cols), "diagm
at(): only vectors and square matrices are accepted" ); arma_debug_check
(
(P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted"
);
} }
arma_inline elem_type operator[] (const u32 i) const { r eturn P_is_vec ? P[i] : P.at(i,i); } arma_inline elem_type operator[] (const u32 i) const { r eturn P_is_vec ? P[i] : P.at(i,i); }
arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); } arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); }
const Mat<elem_type> P; const Mat<elem_type> P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
skipping to change at line 153 skipping to change at line 199
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy_check(const Mat<eT>& X, const Mat<eT>& out) inline diagmat_proxy_check(const Mat<eT>& X, const Mat<eT>& out)
: P_local ( (&X == &out) ? new Mat<eT>(X) : 0 ) : P_local ( (&X == &out) ? new Mat<eT>(X) : 0 )
, P ( (&X == &out) ? (*P_local) : X ) , P ( (&X == &out) ? (*P_local) : X )
, P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) ) , P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) )
, n_elem ( P_is_vec ? P.n_elem : P.n_rows ) , n_elem ( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (P_is_vec == false) && (P.n_rows != P.n_cols), "diagm arma_debug_check
at(): only vectors and square matrices are accepted" ); (
(P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted"
);
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local)
{ {
delete P_local; delete P_local;
} }
} }
skipping to change at line 202 skipping to change at line 252
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local)
{ {
delete P_local; delete P_local;
} }
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const u32 i) const { r
eturn P_is_vec ? P[i] : P.at(i,i); eturn P[i]; }
} arma_inline elem_type at (const u32 row, const u32 col) const { r
arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? P[row] : elem_type(0); }
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0);
}
const Row<eT>* P_local; const Row<eT>* P_local;
const Row<eT>& P; const Row<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy_check< Col<eT> > class diagmat_proxy_check< Col<eT> >
{ {
skipping to change at line 236 skipping to change at line 286
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local)
{ {
delete P_local; delete P_local;
} }
} }
arma_inline elem_type operator[] (const u32 i) const { r arma_inline elem_type operator[] (const u32 i) const { r
eturn P_is_vec ? P[i] : P.at(i,i); eturn P[i]; }
} arma_inline elem_type at (const u32 row, const u32 col) const { r
arma_inline elem_type at (const u32 row, const u32 col) const { r eturn (row == col) ? P[row] : elem_type(0); }
eturn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0);
}
const Col<eT>* P_local; const Col<eT>* P_local;
const Col<eT>& P; const Col<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const u32 n_elem; const u32 n_elem;
}; };
//! @} //! @}
 End of changes. 15 change blocks. 
45 lines changed or deleted 80 lines changed or added


 diagview_meat.hpp   diagview_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 79 skipping to change at line 79
const u32 x_row_offset = x.row_offset; const u32 x_row_offset = x.row_offset;
const u32 x_col_offset = x.col_offset; const u32 x_col_offset = x.col_offset;
for(u32 i=0; i<t_n_elem; ++i) for(u32 i=0; i<t_n_elem; ++i)
{ {
t_m.at(i + t_row_offset, i + t_col_offset) = x_m.at(i + x_row_offset, i + x_col_offset); t_m.at(i + t_row_offset, i + t_col_offset) = x_m.at(i + x_row_offset, i + x_col_offset);
} }
} }
template<typename eT>
inline
void
diagview<eT>::operator+=(const eT val)
{
arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem;
const u32 t_row_offset = row_offset;
const u32 t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i)
{
t_m.at( i + t_row_offset, i + t_col_offset) += val;
}
}
template<typename eT>
inline
void
diagview<eT>::operator-=(const eT val)
{
arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem;
const u32 t_row_offset = row_offset;
const u32 t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i)
{
t_m.at( i + t_row_offset, i + t_col_offset) -= val;
}
}
template<typename eT>
inline
void
diagview<eT>::operator*=(const eT val)
{
arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem;
const u32 t_row_offset = row_offset;
const u32 t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i)
{
t_m.at( i + t_row_offset, i + t_col_offset) *= val;
}
}
template<typename eT>
inline
void
diagview<eT>::operator/=(const eT val)
{
arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr);
const u32 t_n_elem = n_elem;
const u32 t_row_offset = row_offset;
const u32 t_col_offset = col_offset;
for(u32 i=0; i<t_n_elem; ++i)
{
t_m.at( i + t_row_offset, i + t_col_offset) /= val;
}
}
//! set a diagonal of our matrix using data from a foreign object //! set a diagonal of our matrix using data from a foreign object
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator= (const Base<eT,T1>& o) diagview<eT>::operator= (const Base<eT,T1>& o)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(o.get_ref()); const unwrap<T1> tmp(o.get_ref());
skipping to change at line 263 skipping to change at line 339
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const bool alias = (&actual_out == &in_m); const bool alias = (&actual_out == &in_m);
Mat<eT>* tmp = (alias) ? new Mat<eT> : 0; Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
Mat<eT>& out = (alias) ? (*tmp) : actual_out; Mat<eT>& out = (alias) ? (*tmp) : actual_out;
const u32 in_n_elem = in.n_elem; const u32 in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const u32 in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const u32 in_col_offset = in.col_offset;
out.set_size(in_n_elem,1); out.set_size( in_n_elem, in.n_cols );
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(u32 i=0; i<in_n_elem; ++i)
{ {
out_mem[i] = in_m.at(i+in_row_offset, i+in_col_offset); out_mem[i] = in_m.at(i+in_row_offset, i+in_col_offset);
} }
if(alias) if(alias)
{ {
actual_out = out; actual_out = out;
delete tmp; delete tmp;
} }
} }
//! X += Y.diagview(...) //! X += Y.diagview(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::plus_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::plus_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, 1, "additi on"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "addition");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const u32 in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const u32 in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const u32 in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(u32 i=0; i<in_n_elem; ++i)
skipping to change at line 311 skipping to change at line 387
} }
//! X -= Y.diagview(...) //! X -= Y.diagview(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::minus_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::minus_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, 1, "subtra ction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "subtraction");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const u32 in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const u32 in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const u32 in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(u32 i=0; i<in_n_elem; ++i)
skipping to change at line 335 skipping to change at line 411
} }
//! X %= Y.submat(...) //! X %= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::schur_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::schur_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, 1, "elemen t-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "element-wise multiplication");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const u32 in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const u32 in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const u32 in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(u32 i=0; i<in_n_elem; ++i)
skipping to change at line 359 skipping to change at line 435
} }
//! X /= Y.diagview(...) //! X /= Y.diagview(...)
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::div_inplace(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::div_inplace(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, 1, "elemen t-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, in.n_rows, in.n_cols, "element-wise division");
const Mat<eT>& in_m = in.m; const Mat<eT>& in_m = in.m;
const u32 in_n_elem = in.n_elem; const u32 in_n_elem = in.n_elem;
const u32 in_row_offset = in.row_offset; const u32 in_row_offset = in.row_offset;
const u32 in_col_offset = in.col_offset; const u32 in_col_offset = in.col_offset;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 i=0; i<in_n_elem; ++i) for(u32 i=0; i<in_n_elem; ++i)
skipping to change at line 394 skipping to change at line 470
arma_inline arma_inline
eT eT
diagview<eT>::operator[](const u32 i) const diagview<eT>::operator[](const u32 i) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const u32 row, const u32 col) diagview<eT>::at(const u32 i)
{ {
return (*m_ptr).at(row+row_offset, row+col_offset); return (*m_ptr).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::at(const u32 row, const u32 col) const diagview<eT>::at(const u32 i) const
{ {
return m.at(row+row_offset, row+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator()(const u32 i) diagview<eT>::operator()(const u32 i)
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" );
return (*m_ptr).at(i+row_offset, i+col_offset); return (*m_ptr).at(i+row_offset, i+col_offset);
skipping to change at line 430 skipping to change at line 506
diagview<eT>::operator()(const u32 i) const diagview<eT>::operator()(const u32 i) const
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" );
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const u32 row, const u32 col)
{
return (*m_ptr).at(row+row_offset, row+col_offset);
}
template<typename eT>
arma_inline
eT
diagview<eT>::at(const u32 row, const u32 col) const
{
return m.at(row+row_offset, row+col_offset);
}
template<typename eT>
arma_inline
eT&
diagview<eT>::operator()(const u32 row, const u32 col) diagview<eT>::operator()(const u32 row, const u32 col)
{ {
arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" ); arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" );
return (*m_ptr).at(row+row_offset, row+col_offset); return (*m_ptr).at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
 End of changes. 13 change blocks. 
12 lines changed or deleted 104 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 27 skipping to change at line 27
//! Generate the first line of the header used for saving matrices in text format. //! Generate the first line of the header used for saving matrices in text format.
//! Format: "ARMA_MAT_TXT_ABXYZ". //! Format: "ARMA_MAT_TXT_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_txt_header(const Mat<eT>& x) diskio::gen_txt_header(const Mat<eT>& x)
{ {
arma_type_check<diskio::is_supported_type<eT>::value == false>::apply(); arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_IU001"); return std::string("ARMA_MAT_TXT_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 61 skipping to change at line 61
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_IU004"); return std::string("ARMA_MAT_TXT_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_IS004"); return std::string("ARMA_MAT_TXT_IS004");
} }
else else
if(is_u64<eT>::value == true)
{
return std::string("ARMA_MAT_TXT_IU008");
}
else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_FN004"); return std::string("ARMA_MAT_TXT_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_MAT_TXT_FN008"); return std::string("ARMA_MAT_TXT_FN008");
} }
else else
skipping to change at line 97 skipping to change at line 102
//! Generate the first line of the header used for saving matrices in binar y format. //! Generate the first line of the header used for saving matrices in binar y format.
//! Format: "ARMA_MAT_BIN_ABXYZ". //! Format: "ARMA_MAT_BIN_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_bin_header(const Mat<eT>& x) diskio::gen_bin_header(const Mat<eT>& x)
{ {
arma_type_check<diskio::is_supported_type<eT>::value == false>::apply(); arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_IU001"); return std::string("ARMA_MAT_BIN_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 131 skipping to change at line 136
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_IU004"); return std::string("ARMA_MAT_BIN_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_IS004"); return std::string("ARMA_MAT_BIN_IS004");
} }
else else
if(is_u64<eT>::value == true)
{
return std::string("ARMA_MAT_BIN_IU008");
}
else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_FN004"); return std::string("ARMA_MAT_BIN_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_MAT_BIN_FN008"); return std::string("ARMA_MAT_BIN_FN008");
} }
else else
skipping to change at line 167 skipping to change at line 177
//! Generate the first line of the header used for saving cubes in text for mat. //! Generate the first line of the header used for saving cubes in text for mat.
//! Format: "ARMA_CUB_TXT_ABXYZ". //! Format: "ARMA_CUB_TXT_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_txt_header(const Cube<eT>& x) diskio::gen_txt_header(const Cube<eT>& x)
{ {
arma_type_check<diskio::is_supported_type<eT>::value == false>::apply(); arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_IU001"); return std::string("ARMA_CUB_TXT_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 201 skipping to change at line 211
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_IU004"); return std::string("ARMA_CUB_TXT_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_IS004"); return std::string("ARMA_CUB_TXT_IS004");
} }
else else
if(is_u64<eT>::value == true)
{
return std::string("ARMA_CUB_TXT_IU008");
}
else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_FN004"); return std::string("ARMA_CUB_TXT_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_CUB_TXT_FN008"); return std::string("ARMA_CUB_TXT_FN008");
} }
else else
skipping to change at line 237 skipping to change at line 252
//! Generate the first line of the header used for saving cubes in binary f ormat. //! Generate the first line of the header used for saving cubes in binary f ormat.
//! Format: "ARMA_CUB_BIN_ABXYZ". //! Format: "ARMA_CUB_BIN_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types). //! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types). //! B is one of: U (for unsigned types), S (for signed types), N (for not a ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes. //! XYZ specifies the width of each element in terms of bytes, e.g. "008" i ndicates eight bytes.
template<typename eT> template<typename eT>
inline inline
std::string std::string
diskio::gen_bin_header(const Cube<eT>& x) diskio::gen_bin_header(const Cube<eT>& x)
{ {
arma_type_check<diskio::is_supported_type<eT>::value == false>::apply(); arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
arma_ignore(x); arma_ignore(x);
if(is_u8<eT>::value == true) if(is_u8<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_IU001"); return std::string("ARMA_CUB_BIN_IU001");
} }
else else
if(is_s8<eT>::value == true) if(is_s8<eT>::value == true)
{ {
skipping to change at line 271 skipping to change at line 286
if(is_u32<eT>::value == true) if(is_u32<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_IU004"); return std::string("ARMA_CUB_BIN_IU004");
} }
else else
if(is_s32<eT>::value == true) if(is_s32<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_IS004"); return std::string("ARMA_CUB_BIN_IS004");
} }
else else
if(is_u64<eT>::value == true)
{
return std::string("ARMA_CUB_BIN_IU008");
}
else
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_FN004"); return std::string("ARMA_CUB_BIN_FN004");
} }
else else
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
return std::string("ARMA_CUB_BIN_FN008"); return std::string("ARMA_CUB_BIN_FN008");
} }
else else
skipping to change at line 524 skipping to change at line 544
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 cell_width; u32 cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(8); f.precision(10);
cell_width = 16; cell_width = 18;
} }
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
skipping to change at line 642 skipping to change at line 662
f << diskio::gen_txt_header(x) << '\n'; f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << '\n'; f << x.n_rows << ' ' << x.n_cols << '\n';
u32 cell_width; u32 cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(8); f.precision(10);
cell_width = 16; cell_width = 18;
} }
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
skipping to change at line 862 skipping to change at line 882
u32 f_n_cols = 0; u32 f_n_cols = 0;
bool f_n_cols_found = false; bool f_n_cols_found = false;
std::string line_string; std::string line_string;
std::string token; std::string token;
while( (f.good() == true) && (load_okay == true) ) while( (f.good() == true) && (load_okay == true) )
{ {
std::getline(f, line_string); std::getline(f, line_string);
if(line_string.size() == 0) if(line_string.size() == 0)
{
break; break;
}
std::stringstream line_stream(line_string); std::stringstream line_stream(line_string);
u32 line_n_cols = 0; u32 line_n_cols = 0;
while (line_stream >> token) while (line_stream >> token)
line_n_cols++; {
++line_n_cols;
}
if(f_n_cols_found == false) if(f_n_cols_found == false)
{ {
f_n_cols = line_n_cols; f_n_cols = line_n_cols;
f_n_cols_found = true; f_n_cols_found = true;
} }
else else
{ {
if(line_n_cols != f_n_cols) if(line_n_cols != f_n_cols)
{ {
skipping to change at line 898 skipping to change at line 924
if(load_okay == true) if(load_okay == true)
{ {
f.clear(); f.clear();
f.seekg(0, ios::beg); f.seekg(0, ios::beg);
//f.seekg(start); //f.seekg(start);
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
eT val; eT val;
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; (row < x.n_rows) && (load_okay == true); ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; (col < x.n_cols) && (load_okay == true); ++col)
{ {
// f >> token;
// x.at(row,col) = eT( strtod(token.c_str(), 0) );
f >> val; f >> val;
x.at(row,col) = val;
if(f.fail() == false)
{
x.at(row,col) = val;
}
else
{
load_okay = false;
err_msg = "couldn't interpret data in ";
//break;
}
} }
} }
} }
if(f.good() == false) // an empty file indicates an empty matrix
if( (f_n_cols_found == false) && (load_okay == true) )
{ {
load_okay = false; x.reset();
} }
return load_okay; return load_okay;
} }
//! Load a matrix in binary format (no header); //! Load a matrix in binary format (no header);
//! the matrix is assumed to have one column //! the matrix is assumed to have one column
template<typename eT> template<typename eT>
inline inline
bool bool
skipping to change at line 1386 skipping to change at line 1420
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 cell_width; u32 cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(8); f.precision(10);
cell_width = 16; cell_width = 18;
} }
for(u32 slice=0; slice < x.n_slices; ++slice) for(u32 slice=0; slice < x.n_slices; ++slice)
{ {
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
skipping to change at line 1507 skipping to change at line 1541
f << diskio::gen_txt_header(x) << '\n'; f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n'; f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
u32 cell_width; u32 cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
f.precision(8); f.precision(10);
cell_width = 16; cell_width = 18;
} }
for(u32 slice=0; slice < x.n_slices; ++slice) for(u32 slice=0; slice < x.n_slices; ++slice)
{ {
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f.put(' '); f.put(' ');
skipping to change at line 1600 skipping to change at line 1634
bool bool
diskio::load_raw_ascii(Cube<eT>& x, const std::string& name, std::string& e rr_msg) diskio::load_raw_ascii(Cube<eT>& x, const std::string& name, std::string& e rr_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
const bool load_okay = diskio::load_raw_ascii(tmp, name, err_msg); const bool load_okay = diskio::load_raw_ascii(tmp, name, err_msg);
if(load_okay == true) if(load_okay == true)
{ {
x.set_size(tmp.n_rows, tmp.n_cols, 1); if(tmp.is_empty() == false)
// make sure the loaded matrix was not empty
if(x.n_slices > 0)
{ {
x.set_size(tmp.n_rows, tmp.n_cols, 1);
x.slice(0) = tmp; x.slice(0) = tmp;
} }
else
{
x.reset();
}
} }
return load_okay; return load_okay;
} }
//! Load a cube as raw text (no header, human readable). //! Load a cube as raw text (no header, human readable).
//! NOTE: this is much slower than reading a file with a header. //! NOTE: this is much slower than reading a file with a header.
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_raw_ascii(Cube<eT>& x, std::istream& f, std::string& err_msg) diskio::load_raw_ascii(Cube<eT>& x, std::istream& f, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
const bool load_okay = diskio::load_raw_ascii(tmp, f, err_msg); const bool load_okay = diskio::load_raw_ascii(tmp, f, err_msg);
if(load_okay == true) if(load_okay == true)
{ {
x.set_size(tmp.n_rows, tmp.n_cols, 1); if(tmp.is_empty() == false)
// make sure the loaded matrix was not empty
if(x.n_slices > 0)
{ {
x.set_size(tmp.n_rows, tmp.n_cols, 1);
x.slice(0) = tmp; x.slice(0) = tmp;
} }
else
{
x.reset();
}
} }
return load_okay; return load_okay;
} }
//! Load a cube in binary format (no header); //! Load a cube in binary format (no header);
//! the cube is assumed to have one slice with one column //! the cube is assumed to have one slice with one column
template<typename eT> template<typename eT>
inline inline
bool bool
 End of changes. 29 change blocks. 
29 lines changed or deleted 69 lines changed or added


 eGlueCube_meat.hpp   eGlueCube_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 92 skipping to change at line 92
eGlueCube<T1,T2,eglue_type>::operator[] (const u32 i) const eGlueCube<T1,T2,eglue_type>::operator[] (const u32 i) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; }
else
{
arma_stop("eGlueCube::operator[]: unhandled eglue_type");
return eT();
}
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlueCube<T1,T2,eglue_type>::at(const u32 row, const u32 col, const u32 sli ce) const eGlueCube<T1,T2,eglue_type>::at(const u32 row, const u32 col, const u32 sli ce) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col,slice) + P2.at(row,col,slice); } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col,slice) + P2.at(row,col,slice); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col,slice) - P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col,slice) - P2.at(row,col,slice); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col,slice) / P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col,slice) / P2.at(row,col,slice); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col,slice) * P2.at(row,col,slice); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col,slice) * P2.at(row,col,slice); }
else
{
arma_stop("eGlueCube::at(): unhandled eglue_type");
return eT();
}
} }
//! @} //! @}
 End of changes. 3 change blocks. 
12 lines changed or deleted 2 lines changed or added


 eGlue_meat.hpp   eGlue_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 77 skipping to change at line 77
eGlue<T1,T2,eglue_type>::operator[] (const u32 i) const eGlue<T1,T2,eglue_type>::operator[] (const u32 i) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 [i] + P2[i]; }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 [i] - P2[i]; }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 [i] / P2[i]; }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 [i] * P2[i]; }
else
{
arma_stop("eGlue::operator[]: unhandled eglue_type");
return eT();
}
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlue<T1,T2,eglue_type>::at(const u32 row, const u32 col) const eGlue<T1,T2,eglue_type>::at(const u32 row, const u32 col) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col) + P2.at(row,col); } if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 .at(row,col) + P2.at(row,col); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col) - P2.at(row,col); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 .at(row,col) - P2.at(row,col); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col) / P2.at(row,col); } else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 .at(row,col) / P2.at(row,col); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col) * P2.at(row,col); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 .at(row,col) * P2.at(row,col); }
else
{
arma_stop("eGlue::at(): unhandled eglue_type");
return eT();
}
} }
//! @} //! @}
 End of changes. 3 change blocks. 
12 lines changed or deleted 2 lines changed or added


 eglue_core_meat.hpp   eglue_core_meat.hpp 
skipping to change at line 44 skipping to change at line 44
inline static const char* text() { return "element-wise division"; } inline static const char* text() { return "element-wise division"; }
}; };
class eglue_schur : public eglue_core<eglue_schur> class eglue_schur : public eglue_core<eglue_schur>
{ {
public: public:
inline static const char* text() { return "element-wise multiplication"; } inline static const char* text() { return "element-wise multiplication"; }
}; };
#undef arma_applier #undef arma_applier_1
#undef arma_applier_2
#undef arma_applier_3
#undef operatorA #undef operatorA
#undef operatorB #undef operatorB
#define arma_applier(operatorA, operatorB) \ #define arma_applier_1(operatorA, operatorB) \
{\ {\
u32 i,j;\ u32 i,j;\
\ \
for(i=0, j=1; j<n_elem; i+=2, j+=2)\ for(i=0, j=1; j<n_elem; i+=2, j+=2)\
{\ {\
eT tmp_i = P1[i];\ eT tmp_i = P1[i];\
eT tmp_j = P1[j];\ eT tmp_j = P1[j];\
\ \
tmp_i operatorB##= P2[i];\ tmp_i operatorB##= P2[i];\
tmp_j operatorB##= P2[j];\ tmp_j operatorB##= P2[j];\
skipping to change at line 70 skipping to change at line 72
out_mem[i] operatorA tmp_i;\ out_mem[i] operatorA tmp_i;\
out_mem[j] operatorA tmp_j;\ out_mem[j] operatorA tmp_j;\
}\ }\
\ \
if(i < n_elem)\ if(i < n_elem)\
{\ {\
out_mem[i] operatorA P1[i] operatorB P2[i];\ out_mem[i] operatorA P1[i] operatorB P2[i];\
}\ }\
} }
#define arma_applier_2(operatorA, operatorB) \
{\
u32 count = 0;\
\
for(u32 col=0; col<n_cols; ++col)\
{\
u32 i,j;\
\
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\
eT tmp_i = P1.at(i,col);\
eT tmp_j = P1.at(j,col);\
\
tmp_i operatorB##= P2.at(i,col);\
tmp_j operatorB##= P2.at(j,col);\
\
out_mem[count ] operatorA tmp_i;\
out_mem[count+1] operatorA tmp_j;\
}\
\
if(i < n_rows)\
{\
out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\
++count;\
}\
}\
}
#define arma_applier_3(operatorA, operatorB) \
{\
u32 count = 0;\
\
for(u32 slice=0; slice<n_slices; ++slice)\
{\
for(u32 col=0; col<n_cols; ++col)\
{\
u32 i,j;\
\
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\
eT tmp_i = P1.at(i,col,slice);\
eT tmp_j = P1.at(j,col,slice);\
\
tmp_i operatorB##= P2.at(i,col,slice);\
tmp_j operatorB##= P2.at(j,col,slice);\
\
out_mem[count ] operatorA tmp_i;\
out_mem[count+1] operatorA tmp_j;\
}\
\
if(i < n_rows)\
{\
out_mem[count] operatorA P1.at(i,col,slice) operatorB P2.at(i,col,s
lice);\
++count;\
}\
}\
}\
}
// //
// matrices // matrices
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply(Mat<typename T1::elem_type>& out, const eGlue <T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply(Mat<typename T1::elem_type>& out, const eGlue <T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(x.get_n_rows(), x.get_n_cols()); typedef typename T1::elem_type eT;
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
2>::prefer_at_accessor);
const u32 n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols();
out.set_size(n_rows, n_cols);
eT* out_mem = out.memptr();
if(prefer_at_accessor == false)
{
const u32 n_elem = out.n_elem;
typedef typename T1::elem_type eT; typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typedef typename Proxy<T1>::ea_type ea_type1; typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
typedef typename Proxy<T2>::ea_type ea_type2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ea_type1 P1 = x.P1.get_ea(); plier_1(=, +); }
ea_type2 P2 = x.P2.get_ea(); else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_1(=, -); }
eT* out_mem = out.memptr(); else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
const u32 n_elem = out.n_elem; plier_1(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl plier_1(=, *); }
ier(=, +); } }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl
ier(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl
ier(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl
ier(=, *); }
else else
{ {
arma_stop("eglue_core::apply_proxy(): unhandled eglue_type"); const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_2(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_2(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_2(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_2(=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out , const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out , const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "addition"); arma_debug_assert_same_size(out, x.P1, "addition");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; eT* out_mem = out.memptr();
ea_type1 P1 = x.P1.get_ea(); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
ea_type2 P2 = x.P2.get_ea(); 2>::prefer_at_accessor);
eT* out_mem = out.memptr(); if(prefer_at_accessor == false)
const u32 n_elem = out.n_elem; {
const u32 n_elem = out.n_elem;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(+=, +); } typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
ier(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ier(+=, /); } plier_1(+=, +); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
ier(+=, *); } plier_1(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_1(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_1(+=, *); }
}
else else
{ {
arma_stop("eglue_core::apply_inplace_plus(): unhandled eglue_type"); const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_2(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_2(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_2(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_2(+=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "subtraction"); arma_debug_assert_same_size(out, x.P1, "subtraction");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; eT* out_mem = out.memptr();
ea_type1 P1 = x.P1.get_ea(); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
ea_type2 P2 = x.P2.get_ea(); 2>::prefer_at_accessor);
eT* out_mem = out.memptr(); if(prefer_at_accessor == false)
const u32 n_elem = out.n_elem; {
const u32 n_elem = out.n_elem;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(-=, +); } typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
ier(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ier(-=, /); } plier_1(-=, +); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
ier(-=, *); } plier_1(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_1(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_1(-=, *); }
}
else else
{ {
arma_stop("eglue_core::apply_inplace_minus(): unhandled eglue_type"); const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_2(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_2(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_2(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_2(-=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "element-wise multiplication"); arma_debug_assert_same_size(out, x.P1, "element-wise multiplication");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; eT* out_mem = out.memptr();
ea_type1 P1 = x.P1.get_ea(); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
ea_type2 P2 = x.P2.get_ea(); 2>::prefer_at_accessor);
eT* out_mem = out.memptr(); if(prefer_at_accessor == false)
const u32 n_elem = out.n_elem; {
const u32 n_elem = out.n_elem;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(*=, +); } typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
ier(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ier(*=, /); } plier_1(*=, +); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
ier(*=, *); } plier_1(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_1(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_1(*=, *); }
}
else else
{ {
arma_stop("eglue_core::apply_inplace_schur(): unhandled eglue_type"); const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_2(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_2(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_2(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_2(*=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "element-wise division"); arma_debug_assert_same_size(out, x.P1, "element-wise division");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; eT* out_mem = out.memptr();
ea_type1 P1 = x.P1.get_ea(); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
ea_type2 P2 = x.P2.get_ea(); 2>::prefer_at_accessor);
eT* out_mem = out.memptr(); if(prefer_at_accessor == false)
const u32 n_elem = out.n_elem; {
const u32 n_elem = out.n_elem;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(/=, +); } typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
ier(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ier(/=, /); } plier_1(/=, +); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
ier(/=, *); } plier_1(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_1(/=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_1(/=, *); }
}
else else
{ {
arma_stop("eglue_core::apply_inplace_div(): unhandled eglue_type"); const u32 n_rows = out.n_rows;
const u32 n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_2(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_2(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_2(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_2(*=, *); }
} }
} }
// //
// cubes // cubes
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlu eCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlu eCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out.set_size(x.get_n_rows(), x.get_n_cols(), x.get_n_slices()); typedef typename T1::elem_type eT;
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro
xyCube<T2>::prefer_at_accessor);
const u32 n_rows = x.get_n_rows();
const u32 n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
eT* out_mem = out.memptr();
if(prefer_at_accessor == false)
{
const u32 n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
typedef typename T1::elem_type eT; if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
typedef typename ProxyCube<T1>::ea_type ea_type1; plier_1(=, +); }
typedef typename ProxyCube<T2>::ea_type ea_type2; else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_1(=, -); }
ea_type1 P1 = x.P1.get_ea(); else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
ea_type2 P2 = x.P2.get_ea(); plier_1(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
eT* out_mem = out.memptr(); plier_1(=, *); }
const u32 n_elem = out.n_elem; }
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl
ier(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl
ier(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl
ier(=, *); }
else else
{ {
arma_stop("eglue_core::apply(): unhandled eglue_type"); const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_3(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_3(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_3(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_3(=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& ou t, const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& ou t, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.get_n const u32 n_rows = x.get_n_rows();
_rows(), x.get_n_cols(), x.get_n_slices(), "addition"); const u32 n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows,
n_cols, n_slices, "addition");
typedef typename T1::elem_type eT;
eT* out_mem = out.memptr();
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro
xyCube<T2>::prefer_at_accessor);
typedef typename T1::elem_type eT; if(prefer_at_accessor == false)
typedef typename ProxyCube<T1>::ea_type ea_type1; {
typedef typename ProxyCube<T2>::ea_type ea_type2; const u32 n_elem = out.n_elem;
ea_type1 P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
ea_type2 P2 = x.P2.get_ea(); typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
const u32 n_elem = out.n_elem; if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
eT* out_mem = out.memptr(); plier_1(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl plier_1(+=, -); }
ier(+=, +); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl plier_1(+=, /); }
ier(+=, -); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl plier_1(+=, *); }
ier(+=, /); } }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl
ier(+=, *); }
else else
{ {
arma_stop("eglue_core::apply_inplace_plus(): unhandled eglue_type"); const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_3(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_3(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_3(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_3(+=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.get_n const u32 n_rows = x.get_n_rows();
_rows(), x.get_n_cols(), x.get_n_slices(), "subtraction"); const u32 n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows,
n_cols, n_slices, "subtraction");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type1;
typedef typename ProxyCube<T2>::ea_type ea_type2; eT* out_mem = out.memptr();
ea_type1 P1 = x.P1.get_ea(); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro
ea_type2 P2 = x.P2.get_ea(); xyCube<T2>::prefer_at_accessor);
const u32 n_elem = out.n_elem; if(prefer_at_accessor == false)
eT* out_mem = out.memptr(); {
const u32 n_elem = out.n_elem;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(-=, +); } typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
ier(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ier(-=, /); } plier_1(-=, +); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
ier(-=, *); } plier_1(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_1(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_1(-=, *); }
}
else else
{ {
arma_stop("eglue_core::apply_inplace_minus(): unhandled eglue_type"); const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_3(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_3(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_3(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_3(-=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& o ut, const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.get_n const u32 n_rows = x.get_n_rows();
_rows(), x.get_n_cols(), x.get_n_slices(), "element-wise multiplication"); const u32 n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows,
n_cols, n_slices, "element-wise multiplication");
typedef typename T1::elem_type eT;
eT* out_mem = out.memptr();
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro
xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false)
{
const u32 n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
typedef typename T1::elem_type eT; if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
typedef typename ProxyCube<T1>::ea_type ea_type1; plier_1(*=, +); }
typedef typename ProxyCube<T2>::ea_type ea_type2; else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_1(*=, -); }
ea_type1 P1 = x.P1.get_ea(); else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
ea_type2 P2 = x.P2.get_ea(); plier_1(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
const u32 n_elem = out.n_elem; plier_1(*=, *); }
eT* out_mem = out.memptr(); }
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl
ier(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl
ier(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl
ier(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl
ier(*=, *); }
else else
{ {
arma_stop("eglue_core::apply_inplace_schur(): unhandled eglue_type"); const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_3(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_3(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_3(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_3(*=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out , const eGlueCube<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out , const eGlueCube<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.get_n const u32 n_rows = x.get_n_rows();
_rows(), x.get_n_cols(), x.get_n_slices(), "element-wise division"); const u32 n_cols = x.get_n_cols();
const u32 n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows,
n_cols, n_slices, "element-wise division");
typedef typename T1::elem_type eT;
eT* out_mem = out.memptr();
typedef typename T1::elem_type eT; const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro
typedef typename ProxyCube<T1>::ea_type ea_type1; xyCube<T2>::prefer_at_accessor);
typedef typename ProxyCube<T2>::ea_type ea_type2;
if(prefer_at_accessor == false)
ea_type1 P1 = x.P1.get_ea(); {
ea_type2 P2 = x.P2.get_ea(); const u32 n_elem = out.n_elem;
const u32 n_elem = out.n_elem; typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
eT* out_mem = out.memptr(); typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_appl if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
ier(/=, +); } plier_1(/=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
ier(/=, -); } plier_1(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
ier(/=, /); } plier_1(/=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_appl else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
ier(/=, *); } plier_1(/=, *); }
}
else else
{ {
arma_stop("eglue_core::apply_inplace_div(): unhandled eglue_type"); const ProxyCube<T1>& P1 = x.P1;
const ProxyCube<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap
plier_3(/=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap
plier_3(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap
plier_3(/=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap
plier_3(/=, *); }
} }
} }
#undef arma_applier #undef arma_applier_1
#undef arma_applier_2
#undef arma_applier_3
//! @} //! @}
 End of changes. 30 change blocks. 
203 lines changed or deleted 452 lines changed or added


 eop_core_meat.hpp   eop_core_meat.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup eop_core //! \addtogroup eop_core
//! @{ //! @{
#undef arma_applier_1
#undef arma_applier_2
#undef arma_applier_3
#undef operatorA
#define arma_applier_1(operatorA) \
{\
u32 i,j;\
\
for(i=0, j=1; j<n_elem; i+=2, j+=2)\
{\
eT tmp_i = P[i];\
eT tmp_j = P[j];\
\
tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\
out_mem[i] operatorA tmp_i;\
out_mem[j] operatorA tmp_j;\
}\
\
if(i < n_elem)\
{\
out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\
}\
}
#define arma_applier_2(operatorA) \
{\
u32 count = 0;\
\
for(u32 col=0; col<n_cols; ++col)\
{\
u32 i,j;\
\
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\
eT tmp_i = P.at(i,col);\
eT tmp_j = P.at(j,col);\
\
tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\
out_mem[count ] operatorA tmp_i;\
out_mem[count+1] operatorA tmp_j;\
}\
\
if(i < n_rows)\
{\
out_mem[count] operatorA eop_core<eop_type>::process(P.at(i,col), k);
\
++count;\
}\
}\
}
#define arma_applier_3(operatorA) \
{\
u32 count = 0;\
\
for(u32 slice=0; slice<n_slices; ++slice)\
{\
for(u32 col=0; col<n_cols; ++col)\
{\
u32 i,j;\
\
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
{\
eT tmp_i = P.at(i,col,slice);\
eT tmp_j = P.at(j,col,slice);\
\
tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\
out_mem[count ] operatorA tmp_i;\
out_mem[count+1] operatorA tmp_j;\
}\
\
if(i < n_rows)\
{\
out_mem[count] operatorA eop_core<eop_type>::process(P.at(i,col,sli
ce), k);\
++count;\
}\
}\
}\
}
// //
// matrices // matrices
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, e op_type>& x) eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, e op_type>& x)
{ {
skipping to change at line 46 skipping to change at line 132
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
if(is_same_type<eop_type, eop_ones_diag>::value == true) { out.eye (); } if(is_same_type<eop_type, eop_ones_diag>::value == true) { out.eye (); }
else if(is_same_type<eop_type, eop_ones_full>::value == true) { out.one s(); } else if(is_same_type<eop_type, eop_ones_full>::value == true) { out.one s(); }
else if(is_same_type<eop_type, eop_zeros >::value == true) { out.zer os(); } else if(is_same_type<eop_type, eop_zeros >::value == true) { out.zer os(); }
else if(is_same_type<eop_type, eop_randu >::value == true) { out.ran du(); } else if(is_same_type<eop_type, eop_randu >::value == true) { out.ran du(); }
else if(is_same_type<eop_type, eop_randn >::value == true) { out.ran dn(); } else if(is_same_type<eop_type, eop_randn >::value == true) { out.ran dn(); }
} }
else else
{ {
typedef typename Proxy<T1>::ea_type ea_type; const eT k = x.aux;
eT* out_mem = out.memptr();
const eT k = x.aux;
ea_type P = x.P.get_ea();
eT* out_mem = out.memptr();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename Proxy<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] = tmp_i; arma_applier_1(=);
out_mem[j] = tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] = eop_core<eop_type>::process(P[i], k); const Proxy<T1>& P = x.P;
arma_applier_2(=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, co nst eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, co nst eOp<T1, eop_type>& x)
skipping to change at line 110 skipping to change at line 190
else else
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] += eop_aux::generate<eT,eop_type>(); out_mem[i] += eop_aux::generate<eT,eop_type>();
} }
} }
} }
else else
{ {
typedef typename Proxy<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux; if(Proxy<T1>::prefer_at_accessor == false)
ea_type P = x.P.get_ea();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename Proxy<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] += tmp_i; arma_applier_1(+=);
out_mem[j] += tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] += eop_core<eop_type>::process(P[i], k); const Proxy<T1>& P = x.P;
arma_applier_2(+=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x)
skipping to change at line 173 skipping to change at line 247
else else
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] -= eop_aux::generate<eT,eop_type>(); out_mem[i] -= eop_aux::generate<eT,eop_type>();
} }
} }
} }
else else
{ {
typedef typename Proxy<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux;
ea_type P = x.P.get_ea();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename Proxy<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] -= tmp_i; arma_applier_1(-=);
out_mem[j] -= tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] -= eop_core<eop_type>::process(P[i], k); const Proxy<T1>& P = x.P;
arma_applier_2(-=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, c onst eOp<T1, eop_type>& x)
skipping to change at line 237 skipping to change at line 305
else else
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] *= eop_aux::generate<eT,eop_type>(); out_mem[i] *= eop_aux::generate<eT,eop_type>();
} }
} }
} }
else else
{ {
typedef typename Proxy<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux;
ea_type P = x.P.get_ea();
u32 i,j; if(Proxy<T1>::prefer_at_accessor == false)
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename Proxy<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] *= tmp_i; arma_applier_1(*=);
out_mem[j] *= tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] *= eop_core<eop_type>::process(P[i], k); const Proxy<T1>& P = x.P;
arma_applier_2(*=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, con st eOp<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, con st eOp<T1, eop_type>& x)
skipping to change at line 303 skipping to change at line 365
else else
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= eop_aux::generate<eT,eop_type>(); out_mem[i] /= eop_aux::generate<eT,eop_type>();
} }
} }
} }
else else
{ {
typedef typename Proxy<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux;
ea_type P = x.P.get_ea();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename Proxy<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] /= tmp_i; arma_applier_1(/=);
out_mem[j] /= tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] /= eop_core<eop_type>::process(P[i], k); const Proxy<T1>& P = x.P;
arma_applier_2(/=);
} }
} }
} }
// //
// cubes // cubes
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
skipping to change at line 356 skipping to change at line 412
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
if(is_same_type<eop_type, eop_ones_full>::value == true) { out.one s(); } if(is_same_type<eop_type, eop_ones_full>::value == true) { out.one s(); }
else if(is_same_type<eop_type, eop_zeros >::value == true) { out.zer os(); } else if(is_same_type<eop_type, eop_zeros >::value == true) { out.zer os(); }
else if(is_same_type<eop_type, eop_randu >::value == true) { out.ran du(); } else if(is_same_type<eop_type, eop_randu >::value == true) { out.ran du(); }
else if(is_same_type<eop_type, eop_randn >::value == true) { out.ran dn(); } else if(is_same_type<eop_type, eop_randn >::value == true) { out.ran dn(); }
} }
else else
{ {
typedef typename ProxyCube<T1>::ea_type ea_type; const eT k = x.aux;
eT* out_mem = out.memptr();
const eT k = x.aux; if(ProxyCube<T1>::prefer_at_accessor == false)
ea_type P = x.P.get_ea();
eT* out_mem = out.memptr();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
out_mem[i] = eop_core<eop_type>::process(P[i], k); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
out_mem[j] = eop_core<eop_type>::process(P[j], k);
}
if(i < n_elem) arma_applier_1(=);
}
else
{ {
out_mem[i] = eop_core<eop_type>::process(P[i], k); const ProxyCube<T1>& P = x.P;
arma_applier_3(=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, c onst eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, c onst eOpCube<T1, eop_type>& x)
skipping to change at line 406 skipping to change at line 459
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] += eop_aux::generate<eT,eop_type>(); out_mem[i] += eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
typedef typename ProxyCube<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux;
ea_type P = x.P.get_ea();
u32 i,j; if(ProxyCube<T1>::prefer_at_accessor == false)
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] += tmp_i; arma_applier_1(+=);
out_mem[j] += tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] += eop_core<eop_type>::process(P[i], k); const ProxyCube<T1>& P = x.P;
arma_applier_3(+=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
skipping to change at line 458 skipping to change at line 505
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] -= eop_aux::generate<eT,eop_type>(); out_mem[i] -= eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
typedef typename ProxyCube<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux; if(ProxyCube<T1>::prefer_at_accessor == false)
ea_type P = x.P.get_ea();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] -= tmp_i; arma_applier_1(-=);
out_mem[j] -= tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] -= eop_core<eop_type>::process(P[i], k); const ProxyCube<T1>& P = x.P;
arma_applier_3(-=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
skipping to change at line 510 skipping to change at line 551
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] *= eop_aux::generate<eT,eop_type>(); out_mem[i] *= eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
typedef typename ProxyCube<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux;
ea_type P = x.P.get_ea();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] *= tmp_i; arma_applier_1(*=);
out_mem[j] *= tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] *= eop_core<eop_type>::process(P[i], k); const ProxyCube<T1>& P = x.P;
arma_applier_3(*=);
} }
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, co nst eOpCube<T1, eop_type>& x) eop_core<eop_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, co nst eOpCube<T1, eop_type>& x)
skipping to change at line 562 skipping to change at line 597
if(is_generator<eop_type>::value == true) if(is_generator<eop_type>::value == true)
{ {
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
out_mem[i] /= eop_aux::generate<eT,eop_type>(); out_mem[i] /= eop_aux::generate<eT,eop_type>();
} }
} }
else else
{ {
typedef typename ProxyCube<T1>::ea_type ea_type; const eT k = x.aux;
const eT k = x.aux; if(ProxyCube<T1>::prefer_at_accessor == false)
ea_type P = x.P.get_ea();
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = eop_core<eop_type>::process(P[i], k); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
const eT tmp_j = eop_core<eop_type>::process(P[j], k);
out_mem[i] /= tmp_i; arma_applier_1(/=);
out_mem[j] /= tmp_j;
} }
else
if(i < n_elem)
{ {
out_mem[i] /= eop_core<eop_type>::process(P[i], k); const ProxyCube<T1>& P = x.P;
arma_applier_3(/=);
} }
} }
} }
// //
// common // common
template<typename eop_type> template<typename eop_type>
template<typename eT> template<typename eT>
arma_hot arma_hot
skipping to change at line 708 skipping to change at line 737
template<> template<typename eT> arma_hot arma_pure arma_inline eT template<> template<typename eT> arma_hot arma_pure arma_inline eT
eop_core<eop_pow >::process(const eT val, const eT k) { return eop_aux::pow(val, k); } eop_core<eop_pow >::process(const eT val, const eT k) { return eop_aux::pow(val, k); }
template<> template<typename eT> arma_hot arma_pure arma_inline eT template<> template<typename eT> arma_hot arma_pure arma_inline eT
eop_core<eop_floor >::process(const eT val, const eT ) { return eop_aux::floor(val); } eop_core<eop_floor >::process(const eT val, const eT ) { return eop_aux::floor(val); }
template<> template<typename eT> arma_hot arma_pure arma_inline eT template<> template<typename eT> arma_hot arma_pure arma_inline eT
eop_core<eop_ceil >::process(const eT val, const eT ) { return eop_aux::ceil(val); } eop_core<eop_ceil >::process(const eT val, const eT ) { return eop_aux::ceil(val); }
#undef arma_applier_1
#undef arma_applier_2
#undef arma_applier_3
//! @} //! @}
 End of changes. 61 change blocks. 
140 lines changed or deleted 175 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
skipping to change at line 128 skipping to change at line 128
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const diagview<eT>& X) accu(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const u32 n_elem = X.n_elem;
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
return val; return val;
} }
//! accumulate the elements of a subview (submatrix) //! accumulate the elements of a subview (submatrix)
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview<eT>& S) accu(const subview<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 S_n_rows = S.n_rows; if(S.n_elem > 0)
const u32 S_n_cols = S.n_cols; {
const u32 S_n_rows = S.n_rows;
const u32 S_n_cols = S.n_cols;
eT val = eT(0); eT val = eT(0);
for(u32 col=0; col<S_n_cols; ++col) for(u32 col=0; col<S_n_cols; ++col)
{
val += arrayops::accumulate( S.colptr(col), S_n_rows );
}
return val;
}
else
{ {
val += arrayops::accumulate( S.colptr(col), S_n_rows ); return eT(0);
} }
return val;
} }
//! accumulate the elements of a subview_row //! accumulate the elements of a subview_row
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview_row<eT>& S) accu(const subview_row<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& X = S.m; const Mat<eT>& X = S.m;
const u32 row = S.aux_row1; const u32 row = S.aux_row1;
const u32 start_col = S.aux_col1; const u32 start_col = S.aux_col1;
const u32 end_col_plus_1 = start_col + S.n_cols; const u32 end_col_plus_1 = start_col + S.n_cols;
// in future versions, S.n_cols might be equal to zero, // S.n_cols might be equal to zero,
// hence the loop below has a "less than" condition // hence the loop below has a "less than" condition
eT val = eT(0); eT val = eT(0);
for(u32 col=start_col; col<end_col_plus_1; ++col) u32 i,j;
for(i=start_col, j=start_col+1; j < end_col_plus_1; i+=2, j+=2)
{
val += X.at(row,i);
val += X.at(row,j);
}
if(i < end_col_plus_1)
{ {
val += X.at(row,col); val += X.at(row,i);
} }
return val; return val;
} }
//! accumulate the elements of a subview_col //! accumulate the elements of a subview_col
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
 End of changes. 9 change blocks. 
10 lines changed or deleted 26 lines changed or added


 fn_det.hpp   fn_det.hpp 
skipping to change at line 43 skipping to change at line 43
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det(const Op<T1, op_diagmat>& X) det(const Op<T1, op_diagmat>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const diagmat_proxy<T1> A(X.m); const diagmat_proxy<T1> A(X.m);
arma_debug_check( (A.n_elem == 0), "det(): given object has no elements" if(A.n_elem == 0)
); {
return eT(1);
}
eT val = A[0]; eT val = A[0];
for(u32 i=1; i<A.n_elem; ++i) for(u32 i=1; i<A.n_elem; ++i)
{ {
val *= A[i]; val *= A[i];
} }
return val; return val;
} }
skipping to change at line 79 skipping to change at line 82
arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" ); arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" );
return eT(1) / tmp; return eT(1) / tmp;
} }
//! determinant of trans(A) //! determinant of trans(A)
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det(const Op<T1,op_trans>& in, const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0) det(const Op<T1,op_htrans>& in, const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
 End of changes. 2 change blocks. 
3 lines changed or deleted 5 lines changed or added


 fn_diagmat.hpp   fn_diagmat.hpp 
skipping to change at line 17 skipping to change at line 17
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_diagmat //! \addtogroup fn_diagmat
//! @{ //! @{
//! interpret a matrix or a vector as a diagonal matrix (i.e. off-diagonal entries are zero) //! interpret a matrix or a vector as a diagonal matrix (i.e. off-diagonal entries are zero)
// TODO: allow placement of vector onto a sub- or super- diagonal
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_diagmat> const Op<T1, op_diagmat>
diagmat(const Base<typename T1::elem_type,T1>& X) diagmat(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_diagmat>(X.get_ref()); return Op<T1, op_diagmat>(X.get_ref());
} }
// TODO:
// create "op_diagmat2", to allow placement of vector onto a sub- or super-
diagonal.
// op_diagmat2 is required, as other code assumes that op_diagmat indicates
only the main diagonal)
//! @} //! @}
 End of changes. 2 change blocks. 
1 lines changed or deleted 6 lines changed or added


 fn_elem.hpp   fn_elem.hpp 
skipping to change at line 317 skipping to change at line 317
abs(const BaseCube< std::complex<typename T1::pod_type>,T1>& X, const typen ame arma_cx_only<typename T1::elem_type>::result* junk = 0) abs(const BaseCube< std::complex<typename T1::pod_type>,T1>& X, const typen ame arma_cx_only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return mtOpCube<typename T1::pod_type, T1, op_abs>( X.get_ref() ); return mtOpCube<typename T1::pod_type, T1, op_abs>( X.get_ref() );
} }
// //
// fabs
// NOTE: this function is deprecated and will be removed in version 1.3.0
template<typename T1>
arma_inline
const eOp<T1, eop_abs>
fabs(const Base<typename T1::pod_type,T1>& X, const typename arma_not_cx<ty
pename T1::elem_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
arma_print("fabs() is deprecated and will be removed; use abs() instead")
;
return eOp<T1, eop_abs>(X.get_ref());
}
template<typename T1>
arma_inline
const eOpCube<T1, eop_abs>
fabs(const BaseCube<typename T1::pod_type,T1>& X, const typename arma_not_c
x<typename T1::elem_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
arma_print("fabs() is deprecated and will be removed; use abs() instead")
;
return eOpCube<T1, eop_abs>(X.get_ref());
}
template<typename T1>
inline
const mtOp<typename T1::pod_type, T1, op_abs>
fabs(const Base<std::complex<typename T1::pod_type>, T1>& X, const typename
arma_cx_only<typename T1::elem_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
arma_print("fabs() is deprecated and will be removed; use abs() instead")
;
return mtOp<typename T1::pod_type, T1, op_abs>( X.get_ref() );
}
template<typename T1>
arma_inline
const mtOpCube<typename T1::pod_type, T1, op_abs>
fabs(const BaseCube< std::complex<typename T1::pod_type>,T1>& X, const type
name arma_cx_only<typename T1::elem_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
arma_print("fabs() is deprecated and will be removed; use abs() instead")
;
return abs(X);
}
//
// square // square
template<typename T1> template<typename T1>
arma_inline arma_inline
const eOp<T1, eop_square> const eOp<T1, eop_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 eOp<T1, eop_square>(A.get_ref()); return eOp<T1, eop_square>(A.get_ref());
skipping to change at line 484 skipping to change at line 432
return A.m; return A.m;
} }
// TODO: this needs a more elaborate template restriction mechanism to work properly, // TODO: this needs a more elaborate template restriction mechanism to work properly,
// i.e. an overloaded version of thus function should do nothing if t he input type is non-complex // i.e. an overloaded version of thus function should do nothing if t he input type is non-complex
// //
// //! the conjugate of the transpose of a complex matrix is the same as th e hermitian transpose // //! the conjugate of the transpose of a complex matrix is the same as th e hermitian transpose
// template<typename T1> // template<typename T1>
// arma_inline // arma_inline
// const Op<T1, op_htrans> // const Op<T1, op_htrans>
// conj(const Op<T1, op_trans>& A) // conj(const Op<T1, op_strans>& A)
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// return Op<T1, op_htrans>(A.m); // return Op<T1, op_htrans>(A.m);
// } // }
// pow // pow
template<typename T1> template<typename T1>
arma_inline arma_inline
 End of changes. 2 change blocks. 
61 lines changed or deleted 1 lines changed or added


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


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


 fn_max.hpp   fn_max.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 42 skipping to change at line 42
//! Immediate 'find the maximum value in a row vector' operation //! Immediate 'find the maximum value in a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const Row<eT>& A) max(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements" ); const u32 A_n_elem = A.n_elem;
return op_max::direct_max(A.mem, A.n_elem); arma_debug_check( (A_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(A.mem, A_n_elem);
} }
//! Immediate 'find the maximum value in a column vector' operation //! Immediate 'find the maximum value in a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const Col<eT>& A) max(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements" const u32 A_n_elem = A.n_elem;
);
arma_debug_check( (A_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(A.mem, A.n_elem); return op_max::direct_max(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find maximum value' operation, //! Immediate 'find maximum value' operation,
//! invoked, for example, by: max(max(A)) //! invoked, for example, by: max(max(A))
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
max(const Op<T1, op_max>& in) max(const Op<T1, op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("max(): two consecutive max() calls detected"); arma_extra_debug_print("max(): two consecutive max() calls detected");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.m); const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M; const Mat<eT>& X = tmp1.M;
arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements" const u32 X_n_elem = X.n_elem;
);
arma_debug_check( (X_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(X.mem, X.n_elem); return op_max::direct_max(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op< Op<T1, op_max>, op_max> const Op< Op<T1, op_max>, op_max>
max(const Op<T1, op_max>& in, const u32 dim) max(const Op<T1, op_max>& in, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_max>, op_max>(in, dim, 0); return Op< Op<T1, op_max>, op_max>(in, dim, 0);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const subview_row<eT>& A) max(const subview_row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(A); return op_max::direct_max(A);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const subview_col<eT>& A) max(const subview_col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(A); return op_max::direct_max(A.colptr(0), A.n_rows);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const Op<subview<eT>, op_max>& in) max(const Op<subview<eT>, op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("max(): two consecutive max() calls detected"); arma_extra_debug_print("max(): two consecutive max() calls detected");
const subview<eT>& X = in.m; const subview<eT>& X = in.m;
arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(X); return op_max::direct_max(X);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const diagview<eT>& A) max(const diagview<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" );
return op_max::direct_max(A); return op_max::direct_max(A);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
max(const subview_elem1<eT,T1>& A) max(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> X(A); const Mat<eT> X(A);
arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements" const u32 X_n_elem = X.n_elem;
);
arma_debug_check( (X_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(X.mem, X.n_elem); return op_max::direct_max(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 14 change blocks. 
18 lines changed or deleted 27 lines changed or added


 fn_mean.hpp   fn_mean.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 35 skipping to change at line 35
//! Immediate 'find the mean value of a row vector' operation //! Immediate 'find the mean value of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const Row<eT>& A) mean(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements" ); const u32 A_n_elem = A.n_elem;
return op_mean::direct_mean(A.mem, A.n_elem); arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements"
);
return op_mean::direct_mean(A.mem, A_n_elem);
} }
//! Immediate 'find the mean value of a column vector' operation //! Immediate 'find the mean value of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const Col<eT>& A) mean(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements" const u32 A_n_elem = A.n_elem;
);
arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements"
);
return op_mean::direct_mean(A.mem, A.n_elem); return op_mean::direct_mean(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find mean value' operation, //! Immediate 'find mean value' operation,
//! invoked, for example, by: mean(mean(A)) //! invoked, for example, by: mean(mean(A))
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
mean(const Op<T1, op_mean>& in) mean(const Op<T1, op_mean>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("mean(): two consecutive mean() calls detected"); arma_extra_debug_print("mean(): two consecutive mean() calls detected");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.m); const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M; const Mat<eT>& X = tmp1.M;
arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements" ); const u32 X_n_elem = X.n_elem;
return op_mean::direct_mean(X.mem, X.n_elem); arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements"
);
return op_mean::direct_mean(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op< Op<T1, op_mean>, op_mean> const Op< Op<T1, op_mean>, op_mean>
mean(const Op<T1, op_mean>& in, const u32 dim) mean(const Op<T1, op_mean>& in, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_mean>, op_mean>(in, dim, 0); return Op< Op<T1, op_mean>, op_mean>(in, dim, 0);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const subview_row<eT>& A) mean(const subview_row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(A); const eT mu = accu(A) / eT(A.n_cols);
return is_finite(mu) ? mu : op_mean::direct_mean_robust(A);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const subview_col<eT>& A) mean(const subview_col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(A); return op_mean::direct_mean(A.colptr(0), A.n_rows);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const Op<subview<eT>, op_mean>& in) mean(const Op<subview<eT>, op_mean>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("mean(): two consecutive mean() calls detected"); arma_extra_debug_print("mean(): two consecutive mean() calls detected");
const subview<eT>& X = in.m; const subview<eT>& X = in.m;
arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(X); return op_mean::direct_mean(X);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const diagview<eT>& A) mean(const diagview<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "mean(): given object has no elements" );
return op_mean::direct_mean(A); return op_mean::direct_mean(A);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
mean(const subview_elem1<eT,T1>& A) mean(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> X(A); const Mat<eT> X(A);
arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements" const u32 X_n_elem = X.n_elem;
);
arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements"
);
return op_mean::direct_mean(X.mem, X.n_elem); return op_mean::direct_mean(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 15 change blocks. 
18 lines changed or deleted 30 lines changed or added


 fn_median.hpp   fn_median.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 35 skipping to change at line 35
//! Immediate 'find the median value of a row vector' operation //! Immediate 'find the median value of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const Row<eT>& A) median(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); const u32 A_n_elem = A.n_elem;
return op_median::direct_median(A.mem, A.n_elem); arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
return op_median::direct_median(A.mem, A_n_elem);
} }
//! Immediate 'find the median value of a column vector' operation //! Immediate 'find the median value of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const Col<eT>& A) median(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element const u32 A_n_elem = A.n_elem;
s" );
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
return op_median::direct_median(A.mem, A.n_elem); return op_median::direct_median(A.mem, A_n_elem);
} }
//! Immediate 'find the median value of a row vector' operation (complex nu mber version) //! Immediate 'find the median value of a row vector' operation (complex nu mber version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const Row< std::complex<T> >& A) median(const Row< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element const u32 A_n_elem = A.n_elem;
s" );
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
u32 index1; u32 index1;
u32 index2; u32 index2;
op_median::direct_cx_median_index(index1, index2, A.mem, A.n_elem); op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem);
return (A.mem[index1] + A.mem[index2]) / T(2); return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem [index1], A.mem[index2] );
} }
//! Immediate 'find the median value of a column vector' operation (complex number version) //! Immediate 'find the median value of a column vector' operation (complex number version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const Col< std::complex<T> >& A) median(const Col< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element const u32 A_n_elem = A.n_elem;
s" );
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
u32 index1; u32 index1;
u32 index2; u32 index2;
op_median::direct_cx_median_index(index1, index2, A.mem, A.n_elem); op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem);
return (A.mem[index1] + A.mem[index2]) / T(2); return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem [index1], A.mem[index2] );
} }
//! find the median value of a subview_row //! find the median value of a subview_row
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const subview_row<eT>& A) median(const subview_row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
return op_median::direct_median(A); return op_median::direct_median(A);
} }
//! find the median value of a subview_col //! find the median value of a subview_col
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const subview_col<eT>& A) median(const subview_col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
return op_median::direct_median(A); return op_median::direct_median(A.colptr(0), A.n_rows);
} }
//! find the median value of a subview_row (complex number version) //! find the median value of a subview_row (complex number version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const subview_row< std::complex<T> >& A) median(const subview_row< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
u32 index1; u32 index1;
u32 index2; u32 index2;
op_median::direct_cx_median_index(index1, index2, A); op_median::direct_cx_median_index(index1, index2, A);
return (A[index1] + A[index2]) / T(2); return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]);
} }
//! find the median value of a subview_col (complex number version) //! find the median value of a subview_col (complex number version)
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const subview_col< std::complex<T> >& A) median(const subview_col< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
u32 index1; u32 index1;
u32 index2; u32 index2;
op_median::direct_cx_median_index(index1, index2, A); op_median::direct_cx_median_index(index1, index2, A);
return (A[index1] + A[index2]) / T(2); return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const diagview<eT>& A) median(const diagview<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
return op_median::direct_median(A); return op_median::direct_median(A);
} }
template<typename T> template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> std::complex<T>
median(const diagview< std::complex<T> >& A) median(const diagview< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "median(): given object has no element s" );
u32 index1; u32 index1;
u32 index2; u32 index2;
op_median::direct_cx_median_index(index1, index2, A); op_median::direct_cx_median_index(index1, index2, A);
return (A[index1] + A[index2]) / T(2); return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1], A[index2]);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
median(const subview_elem1<eT,T1>& A) median(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 21 change blocks. 
25 lines changed or deleted 34 lines changed or added


 fn_min.hpp   fn_min.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 42 skipping to change at line 42
//! Immediate 'find the minimum value in a row vector' operation //! Immediate 'find the minimum value in a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const Row<eT>& A) min(const Row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements" ); const u32 A_n_elem = A.n_elem;
return op_min::direct_min(A.mem, A.n_elem); arma_debug_check( (A_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(A.mem, A_n_elem);
} }
//! Immediate 'find the minimum value in a column vector' //! Immediate 'find the minimum value in a column vector'
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const Col<eT>& A) min(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements" const u32 A_n_elem = A.n_elem;
);
arma_debug_check( (A_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(A.mem, A.n_elem); return op_min::direct_min(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find minimum value' operation, //! Immediate 'find minimum value' operation,
//! invoked, for example, by: min(min(A)) //! invoked, for example, by: min(min(A))
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
min(const Op<T1, op_min>& in) min(const Op<T1, op_min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("min(): two consecutive min() calls detected"); arma_extra_debug_print("min(): two consecutive min() calls detected");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(in.m); const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M; const Mat<eT>& X = tmp1.M;
arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" const u32 X_n_elem = X.n_elem;
);
arma_debug_check( (X_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(X.mem, X.n_elem); return op_min::direct_min(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
inline inline
const Op< Op<T1, op_min>, op_min> const Op< Op<T1, op_min>, op_min>
min(const Op<T1, op_min>& in, const u32 dim) min(const Op<T1, op_min>& in, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_min>, op_min>(in, dim, 0); return Op< Op<T1, op_min>, op_min>(in, dim, 0);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const subview_row<eT>& A) min(const subview_row<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(A); return op_min::direct_min(A);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const subview_col<eT>& A) min(const subview_col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(A); return op_min::direct_min(A.colptr(0), A.n_rows);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const diagview<eT>& A) min(const diagview<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(A); return op_min::direct_min(A);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const Op<subview<eT>, op_min>& in) min(const Op<subview<eT>, op_min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("min(): two consecutive min() calls detected"); arma_extra_debug_print("min(): two consecutive min() calls detected");
const subview<eT>& X = in.m; const subview<eT>& X = in.m;
arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" ); arma_debug_check( (X.n_elem == 0), "min(): given object has no elements" );
return op_min::direct_min(X); return op_min::direct_min(X);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT eT
min(const subview_elem1<eT,T1>& A) min(const subview_elem1<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT> X(A); const Mat<eT> X(A);
arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" const u32 X_n_elem = X.n_elem;
);
arma_debug_check( (X_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(X.mem, X.n_elem); return op_min::direct_min(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 14 change blocks. 
18 lines changed or deleted 27 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_ones //! \addtogroup fn_ones
//! @{ //! @{
//! Generate a vector with all elements set to one
arma_inline arma_inline
const eOp<colvec, eop_ones_full> const eOp<vec, eop_ones_full>
ones(const u32 n_elem) ones(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_ones_full>(n_elem, 1); return eOp<vec, eop_ones_full>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_ones_full> const eOp<vec_type, eop_ones_full>
ones(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::resu lt* junk = 0) ones(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), c onst typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_ones_full>(1, n_elem); return eOp<vec_type, eop_ones_full>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_ones_full>(n_elem, 1); return eOp<vec_type, eop_ones_full>(n_elem, 1);
} }
} }
//! Delayed generation of a dense matrix with all elements set to one
arma_inline arma_inline
const eOp<mat, eop_ones_full> const eOp<mat, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols) ones(const u32 n_rows, const u32 n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_full>(n_rows, n_cols); return eOp<mat, eop_ones_full>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_ones_full> const eOp<mat_type, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_on ly<mat_type>::result* junk = 0) ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_on ly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_ones_full>(n_rows, n_cols); return eOp<mat_type, eop_ones_full>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_ones_full> const eOpCube<cube, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices) ones(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_ones_full>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_ones_full>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_ones_full> const eOpCube<cube_type, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0) ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_ones_full>(n_rows, n_cols, n_slices); return eOpCube<cube_type, eop_ones_full>(n_rows, n_cols, n_slices);
} }
//! Delayed generation of a matrix with the elements along the main diagona
l set to one
//! and off-diagonal elements set to zero
arma_inline
const eOp<mat, eop_ones_diag>
eye(const u32 n_rows, const u32 n_cols)
{
arma_extra_debug_sigprint();
return eOp<mat, eop_ones_diag>(n_rows, n_cols);
}
template<typename mat_type>
arma_inline
const eOp<mat_type, eop_ones_diag>
eye(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_onl
y<mat_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return eOp<mat_type, eop_ones_diag>(n_rows, n_cols);
}
//! @} //! @}
 End of changes. 10 change blocks. 
36 lines changed or deleted 7 lines changed or added


 fn_prod.hpp   fn_prod.hpp 
skipping to change at line 43 skipping to change at line 43
//! \brief //! \brief
//! Immediate 'product of all values' operation for a row vector //! Immediate 'product of all values' operation for a row vector
template<typename eT> template<typename eT>
inline inline
eT eT
prod(const Row<eT>& X) prod(const Row<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements"
);
return arrayops::product(X.memptr(), X.n_elem); return arrayops::product(X.memptr(), X.n_elem);
} }
//! \brief //! \brief
//! Immediate 'product of all values' operation for a column vector //! Immediate 'product of all values' operation for a column vector
template<typename eT> template<typename eT>
inline inline
eT eT
prod(const Col<eT>& X) prod(const Col<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements"
);
return arrayops::product(X.memptr(), X.n_elem); return arrayops::product(X.memptr(), X.n_elem);
} }
//! \brief //! \brief
//! Immediate 'product of all values' operation, //! Immediate 'product of all values' operation,
//! invoked, for example, by: prod(prod(A)) //! invoked, for example, by: prod(prod(A))
template<typename T1> template<typename T1>
inline inline
typename T1::elem_type typename T1::elem_type
prod(const Op<T1, op_prod>& in) prod(const Op<T1, op_prod>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("prod(): two consecutive prod() calls detected"); arma_extra_debug_print("prod(): two consecutive prod() calls detected");
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;
arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements" return arrayops::product( X.memptr(), X.n_elem );
);
return arrayops::product(X.memptr(), X.n_elem);
} }
template<typename T1> template<typename T1>
inline inline
const Op<Op<T1, op_prod>, op_prod> const Op<Op<T1, op_prod>, op_prod>
prod(const Op<T1, op_prod>& in, const u32 dim) prod(const Op<T1, op_prod>& in, const u32 dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<Op<T1, op_prod>, op_prod>(in, dim, 0); return Op<Op<T1, op_prod>, op_prod>(in, dim, 0);
} }
//! product of all values of a subview_row //! product of all values of a subview_row
template<typename eT> template<typename eT>
inline inline
eT eT
prod(const subview_row<eT>& S) prod(const subview_row<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (S.n_elem < 1), "prod(): given object has no elements"
);
const Mat<eT>& X = S.m; const Mat<eT>& X = S.m;
const u32 row = S.aux_row1; const u32 row = S.aux_row1;
const u32 start_col = S.aux_col1; const u32 start_col = S.aux_col1;
const u32 end_col_plus_1 = start_col + S.n_cols; const u32 end_col_plus_1 = start_col + S.n_cols;
eT val = eT(1); eT val = eT(1);
for(u32 col=start_col; col<end_col_plus_1; ++col) for(u32 col=start_col; col<end_col_plus_1; ++col)
{ {
skipping to change at line 128 skipping to change at line 120
} }
//! product of all values of a subview_col //! product of all values of a subview_col
template<typename eT> template<typename eT>
inline inline
eT eT
prod(const subview_col<eT>& S) prod(const subview_col<eT>& S)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (S.n_elem < 1), "prod(): given object has no elements"
);
return arrayops::product( S.colptr(0), S.n_rows ); return arrayops::product( S.colptr(0), S.n_rows );
} }
//! product of all values of a diagview //! product of all values of a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
prod(const diagview<eT>& X) prod(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements" ); const u32 X_n_elem = X.n_elem;
const u32 n_elem = X.n_elem; eT val = eT(1);
eT val = X[0];
for(u32 i=1; i<n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
val *= X[i]; val *= X[i];
} }
return val; return val;
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
 End of changes. 8 change blocks. 
21 lines changed or deleted 4 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 44 skipping to change at line 44
randn(const u32 n_elem) randn(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randn>(n_elem, 1); return eOp<colvec, eop_randn>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_randn> const eOp<vec_type, eop_randn>
randn(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0) randn(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_randn>(1, n_elem); return eOp<vec_type, eop_randn>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_randn>(n_elem, 1); return eOp<vec_type, eop_randn>(n_elem, 1);
} }
} }
 End of changes. 3 change blocks. 
5 lines changed or deleted 5 lines changed or added


 fn_randu.hpp   fn_randu.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 44 skipping to change at line 44
randu(const u32 n_elem) randu(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randu>(n_elem, 1); return eOp<colvec, eop_randu>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_randu> const eOp<vec_type, eop_randu>
randu(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0) randu(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_randu>(1, n_elem); return eOp<vec_type, eop_randu>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_randu>(n_elem, 1); return eOp<vec_type, eop_randu>(n_elem, 1);
} }
} }
skipping to change at line 76 skipping to change at line 76
return eOp<mat, eop_randu>(n_rows, n_cols); return eOp<mat, eop_randu>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_randu> const eOp<mat_type, eop_randu>
randu(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0) randu(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_randu>(n_rows, n_cols); return eOp<mat_type, eop_randu>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_randu> const eOpCube<cube, eop_randu>
randu(const u32 n_rows, const u32 n_cols, const u32 n_slices) randu(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_randu>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_randu>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_randu> const eOpCube<cube_type, eop_randu>
randu(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0) randu(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_randu>(n_rows, n_cols, n_slices); return eOpCube<cube_type, eop_randu>(n_rows, n_cols, n_slices);
} }
//! @} //! @}
 End of changes. 5 change blocks. 
7 lines changed or deleted 5 lines changed or added


 fn_stddev.hpp   fn_stddev.hpp 
skipping to change at line 35 skipping to change at line 35
//! Immediate 'find the standard deviation of a row vector' operation //! Immediate 'find the standard deviation of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const Row<eT>& A, const u32 norm_type = 0) stddev(const Row<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given vector has no element s" ); const u32 A_n_elem = A.n_elem;
return std::sqrt( op_var::direct_var(A.mem, A.n_elem, norm_type) ); arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element
s" );
return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) );
} }
//! Immediate 'find the standard deviation of a column vector' operation //! Immediate 'find the standard deviation of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const Col<eT>& A, const u32 norm_type = 0) stddev(const Col<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given vector has no element const u32 A_n_elem = A.n_elem;
s" );
arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element
s" );
return std::sqrt( op_var::direct_var(A.mem, A.n_elem, norm_type) ); return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) );
} }
//! find the standard deviation of a subview_row //! find the standard deviation of a subview_row
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const subview_row<eT>& A, const u32 norm_type = 0) stddev(const subview_row<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A, norm_type) ); return std::sqrt( op_var::direct_var(A, norm_type) );
} }
//! find the standard deviation of a subview_col //! find the standard deviation of a subview_col
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const subview_col<eT>& A, const u32 norm_type = 0) stddev(const subview_col<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A, norm_type) ); return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) );
} }
//! find the standard deviation of a diagview //! find the standard deviation of a diagview
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const diagview<eT>& A, const u32 norm_type = 0) stddev(const diagview<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given vector has no element s" ); arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element s" );
return std::sqrt( op_var::direct_var(A, norm_type) ); return std::sqrt( op_var::direct_var(A, norm_type) );
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
stddev(const subview_elem1<eT,T1>& A, const u32 norm_type = 0) stddev(const subview_elem1<eT,T1>& A, const u32 norm_type = 0)
{ {
 End of changes. 8 change blocks. 
9 lines changed or deleted 14 lines changed or added


 fn_trans.hpp   fn_trans.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_trans //! \addtogroup fn_trans
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_trans> const Op<T1, op_htrans>
trans(const Base<typename T1::elem_type,T1>& X) trans(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_trans>(X.get_ref()); return Op<T1, op_htrans>(X.get_ref());
} }
//! two consecutive transpose operations cancel each other //! two consecutive transpose operations cancel each other
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
trans(const Op<T1, op_trans>& X) trans(const Op<T1, op_htrans>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("trans(): removing op_trans"); arma_extra_debug_print("trans(): removing op_htrans");
return X.m; return X.m;
} }
//! transpose of a diagonal matrix (which is square) does nothing
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_diagmat> arma_deprecated
trans(const Op<T1, op_diagmat>& X) const Op<T1, op_htrans>
htrans(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("trans(): not applying op_trans to diagonal matrix ");
return X; return Op<T1, op_htrans>(X.get_ref());
}
//! two consecutive hermitian transpose operations cancel each other
template<typename T1>
arma_inline
const T1&
htrans(const Op<T1, op_htrans>& X)
{
arma_extra_debug_sigprint();
arma_extra_debug_print("htrans(): removing op_htrans");
return X.m;
} }
//! @} //! @}
 End of changes. 9 change blocks. 
11 lines changed or deleted 22 lines changed or added


 fn_var.hpp   fn_var.hpp 
skipping to change at line 35 skipping to change at line 35
//! Immediate 'find the variance of a row vector' operation //! Immediate 'find the variance of a row vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const Row<eT>& A, const u32 norm_type = 0) var(const Row<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); const u32 A_n_elem = A.n_elem;
return op_var::direct_var(A.mem, A.n_elem, norm_type); arma_debug_check( (A_n_elem == 0), "var(): given object has no elements"
);
return op_var::direct_var(A.mem, A_n_elem, norm_type);
} }
//! Immediate 'find the variance of a column vector' operation //! Immediate 'find the variance of a column vector' operation
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const Col<eT>& A, const u32 norm_type = 0) var(const Col<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" const u32 A_n_elem = A.n_elem;
);
arma_debug_check( (A_n_elem == 0), "var(): given object has no elements"
);
return op_var::direct_var(A.mem, A.n_elem, norm_type); return op_var::direct_var(A.mem, A_n_elem, norm_type);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const subview_row<eT>& A, const u32 norm_type = 0) var(const subview_row<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A, norm_type); return op_var::direct_var(A, norm_type);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const subview_col<eT>& A, const u32 norm_type = 0) var(const subview_col<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A, norm_type); return op_var::direct_var(A.colptr(0), A.n_rows, norm_type);
} }
template<typename eT> template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const diagview<eT>& A, const u32 norm_type = 0) var(const diagview<eT>& A, const u32 norm_type = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given vector has no elements" ); arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
return op_var::direct_var(A, norm_type); return op_var::direct_var(A, norm_type);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
var(const subview_elem1<eT,T1>& A, const u32 norm_type = 0) var(const subview_elem1<eT,T1>& A, const u32 norm_type = 0)
{ {
 End of changes. 8 change blocks. 
9 lines changed or deleted 14 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 29 skipping to change at line 29
zeros(const u32 n_elem) zeros(const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_zeros>(n_elem, 1); return eOp<colvec, eop_zeros>(n_elem, 1);
} }
template<typename vec_type> template<typename vec_type>
arma_inline arma_inline
const eOp<vec_type, eop_zeros> const eOp<vec_type, eop_zeros>
zeros(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res ult* junk = 0) zeros(const u32 n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<vec_type>::value == true)
{ {
return eOp<vec_type, eop_zeros>(1, n_elem); return eOp<vec_type, eop_zeros>(1, n_elem);
} }
else else
{ {
return eOp<vec_type, eop_zeros>(n_elem, 1); return eOp<vec_type, eop_zeros>(n_elem, 1);
} }
} }
skipping to change at line 61 skipping to change at line 61
return eOp<mat, eop_zeros>(n_rows, n_cols); return eOp<mat, eop_zeros>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_zeros> const eOp<mat_type, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0) zeros(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOp<mat_type, eop_zeros>(n_rows, n_cols); return eOp<mat_type, eop_zeros>(n_rows, n_cols);
} }
arma_inline arma_inline
const eOpCube<cube, eop_zeros> const eOpCube<cube, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_zeros>(n_rows, n_cols, n_slices); return eOpCube<cube, eop_zeros>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_zeros> const eOpCube<cube_type, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam e arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return eOpCube<cube_type, eop_zeros>(n_rows, n_cols, n_slices); return eOpCube<cube_type, eop_zeros>(n_rows, n_cols, n_slices);
} }
//! @} //! @}
 End of changes. 5 change blocks. 
7 lines changed or deleted 5 lines changed or added


 gemm.hpp   gemm.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup gemm //! \addtogroup gemm
//! @{ //! @{
//! \brief //! for small square matrices with n_rows <= 4
//! Partial emulation of ATLAS/BLAS gemm(), using caching for speedup. template<const bool do_trans_A=false, const bool use_alpha=false, const boo
//! Matrix 'C' is assumed to have been set to the correct size (i.e. taking l use_beta=false>
into account transposes) class gemm_emul_tinysq
{
public:
template<typename eT>
arma_hot
inline
static
void
apply
(
Mat<eT>& C,
const Mat<eT>& A,
const Mat<eT>& B,
const eT alpha = eT(1),
const eT beta = eT(0)
)
{
arma_extra_debug_sigprint();
switch(A.n_rows)
{
case 4:
gemv_emul_tiny<do_trans_A, use_alpha, use_beta>::apply( C.colptr(3)
, A, B.colptr(3), alpha, beta );
case 3:
gemv_emul_tiny<do_trans_A, use_alpha, use_beta>::apply( C.colptr(2)
, A, B.colptr(2), alpha, beta );
case 2:
gemv_emul_tiny<do_trans_A, use_alpha, use_beta>::apply( C.colptr(1)
, A, B.colptr(1), alpha, beta );
case 1:
gemv_emul_tiny<do_trans_A, use_alpha, use_beta>::apply( C.colptr(0)
, A, B.colptr(0), alpha, beta );
default:
;
}
}
};
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false>
class gemm_emul_cache class gemm_emul_large
{ {
public: public:
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
apply apply
( (
skipping to change at line 54 skipping to change at line 93
const u32 B_n_rows = B.n_rows; const u32 B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const u32 B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (do_trans_A == false) && (do_trans_B == false) )
{ {
arma_aligned podarray<eT> tmp(A_n_cols); arma_aligned podarray<eT> tmp(A_n_cols);
eT* A_rowdata = tmp.memptr(); eT* A_rowdata = tmp.memptr();
for(u32 row_A=0; row_A < A_n_rows; ++row_A) for(u32 row_A=0; row_A < A_n_rows; ++row_A)
{ {
tmp.copy_row(A, row_A);
for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{
A_rowdata[col_A] = A.at(row_A,col_A);
}
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{ {
// const eT* B_coldata = B.colptr(col_B);
//
// eT acc = eT(0);
// for(u32 i=0; i < B_n_rows; ++i)
// {
// acc += A_rowdata[i] * B_coldata[i];
// }
const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col ptr(col_B)); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col ptr(col_B));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,col_B) = acc; C.at(row_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
C.at(row_A,col_B) = alpha * acc; C.at(row_A,col_B) = alpha * acc;
skipping to change at line 106 skipping to change at line 133
if( (do_trans_A == true) && (do_trans_B == false) ) if( (do_trans_A == true) && (do_trans_B == false) )
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{ {
// col_A is interpreted as row_A when storing the results in matrix C // col_A is interpreted as row_A when storing the results in matrix C
const eT* A_coldata = A.colptr(col_A); const eT* A_coldata = A.colptr(col_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{ {
// const eT* B_coldata = B.colptr(col_B);
//
// eT acc = eT(0);
// for(u32 i=0; i < B_n_rows; ++i)
// {
// acc += A_coldata[i] * B_coldata[i];
// }
const eT acc = op_dot::direct_dot_arma(B_n_rows, A_coldata, B.col ptr(col_B)); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_coldata, B.col ptr(col_B));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,col_B) = acc; C.at(col_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
C.at(col_A,col_B) = alpha * acc; C.at(col_A,col_B) = alpha * acc;
skipping to change at line 142 skipping to change at line 161
{ {
C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B);
} }
} }
} }
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) ) if( (do_trans_A == false) && (do_trans_B == true) )
{ {
Mat<eT> B_tmp = trans(B); Mat<eT> BB;
gemm_emul_cache<false, false, use_alpha, use_beta>::apply(C, A, B_tmp op_strans::apply_noalias(BB, B);
, alpha, beta);
gemm_emul_large<false, false, use_alpha, use_beta>::apply(C, A, BB, a
lpha, beta);
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) ) if( (do_trans_A == true) && (do_trans_B == true) )
{ {
// mat B_tmp = trans(B); // mat B_tmp = trans(B);
// dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta); // dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta);
// By using the trans(A)*trans(B) = trans(B*A) equivalency, // By using the trans(A)*trans(B) = trans(B*A) equivalency,
// transpose operations are not needed // transpose operations are not needed
arma_aligned podarray<eT> tmp(B.n_cols); arma_aligned podarray<eT> tmp(B.n_cols);
eT* B_rowdata = tmp.memptr(); eT* B_rowdata = tmp.memptr();
for(u32 row_B=0; row_B < B_n_rows; ++row_B) for(u32 row_B=0; row_B < B_n_rows; ++row_B)
{ {
tmp.copy_row(B, row_B);
for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{
B_rowdata[col_B] = B.at(row_B,col_B);
}
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{ {
// const eT* A_coldata = A.colptr(col_A);
//
// eT acc = eT(0);
// for(u32 i=0; i < A_n_rows; ++i)
// {
// acc += B_rowdata[i] * A_coldata[i];
// }
const eT acc = op_dot::direct_dot_arma(A_n_rows, B_rowdata, A.col ptr(col_A)); const eT acc = op_dot::direct_dot_arma(A_n_rows, B_rowdata, A.col ptr(col_A));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(col_A,row_B) = acc; C.at(col_A,row_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
C.at(col_A,row_B) = alpha * acc; C.at(col_A,row_B) = alpha * acc;
skipping to change at line 205 skipping to change at line 214
} }
} }
} }
} }
} }
}; };
//! Partial emulation of ATLAS/BLAS gemm(), non-cached version.
//! Matrix 'C' is assumed to have been set to the correct size (i.e. taking
into account transposes)
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false>
class gemm_emul_simple class gemm_emul
{ {
public: public:
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
apply apply
( (
Mat<eT>& C, Mat<eT>& C,
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& B,
const eT alpha = eT(1), const eT alpha = eT(1),
const eT beta = eT(0) const eT beta = eT(0),
const typename arma_not_cx<eT>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
const u32 A_n_rows = A.n_rows; const u32 A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const u32 A_n_cols = A.n_cols;
const u32 B_n_rows = B.n_rows; const u32 B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const u32 B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) )
{ {
for(u32 row_A = 0; row_A < A_n_rows; ++row_A) if(do_trans_B == false)
{ {
for(u32 col_B = 0; col_B < B_n_cols; ++col_B) gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, B, a
{ lpha, beta);
const eT* B_coldata = B.colptr(col_B); }
else
eT acc = eT(0); {
for(u32 i = 0; i < B_n_rows; ++i) Mat<eT> BB(A_n_rows, A_n_rows);
{ op_strans::apply_noalias_tinysq(BB, B);
acc += A.at(row_A,i) * B_coldata[i];
}
if( (use_alpha == false) && (use_beta == false) ) gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, BB,
{ alpha, beta);
C.at(row_A,col_B) = acc;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
C.at(row_A,col_B) = alpha * acc;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
C.at(row_A,col_B) = acc + beta*C.at(row_A,col_B);
}
else
if( (use_alpha == true) && (use_beta == true) )
{
C.at(row_A,col_B) = alpha*acc + beta*C.at(row_A,col_B);
}
}
} }
} }
else else
if( (do_trans_A == true) && (do_trans_B == false) )
{ {
for(u32 col_A=0; col_A < A_n_cols; ++col_A) gemm_emul_large<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C
{ , A, B, alpha, beta);
// col_A is interpreted as row_A when storing the results in matrix }
C }
const eT* A_coldata = A.colptr(col_A);
for(u32 col_B=0; col_B < B_n_cols; ++col_B) template<typename eT>
{ arma_hot
const eT* B_coldata = B.colptr(col_B); inline
static
void
apply
(
Mat<eT>& C,
const Mat<eT>& A,
const Mat<eT>& B,
const eT alpha = eT(1),
const eT beta = eT(0),
const typename arma_cx_only<eT>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
eT acc = eT(0); // "better than nothing" handling of hermitian transposes for complex n
for(u32 i=0; i < B_n_rows; ++i) umber matrices
{
acc += A_coldata[i] * B_coldata[i];
}
if( (use_alpha == false) && (use_beta == false) ) Mat<eT> tmp_A;
{ Mat<eT> tmp_B;
C.at(col_A,col_B) = acc;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
C.at(col_A,col_B) = alpha * acc;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
C.at(col_A,col_B) = acc + beta*C.at(col_A,col_B);
}
else
if( (use_alpha == true) && (use_beta == true) )
{
C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B);
}
} if(do_trans_A)
}
}
else
if( (do_trans_A == false) && (do_trans_B == true) )
{ {
for(u32 row_A = 0; row_A < A_n_rows; ++row_A) op_htrans::apply_noalias(tmp_A, A);
{
for(u32 row_B = 0; row_B < B_n_rows; ++row_B)
{
eT acc = eT(0);
for(u32 i = 0; i < B_n_cols; ++i)
{
acc += A.at(row_A,i) * B.at(row_B,i);
}
if( (use_alpha == false) && (use_beta == false) )
{
C.at(row_A,row_B) = acc;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
C.at(row_A,row_B) = alpha * acc;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
C.at(row_A,row_B) = acc + beta*C.at(row_A,row_B);
}
else
if( (use_alpha == true) && (use_beta == true) )
{
C.at(row_A,row_B) = alpha*acc + beta*C.at(row_A,row_B);
}
}
}
} }
else
if( (do_trans_A == true) && (do_trans_B == true) )
{
for(u32 row_B=0; row_B < B_n_rows; ++row_B)
{
for(u32 col_A=0; col_A < A_n_cols; ++col_A) if(do_trans_B)
{ {
const eT* A_coldata = A.colptr(col_A); op_htrans::apply_noalias(tmp_B, B);
}
eT acc = eT(0); const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A;
for(u32 i=0; i < A_n_rows; ++i) const Mat<eT>& BB = (do_trans_B == false) ? B : tmp_B;
{
acc += B.at(row_B,i) * A_coldata[i];
}
if( (use_alpha == false) && (use_beta == false) ) const u32 A_n_rows = AA.n_rows;
{ const u32 A_n_cols = AA.n_cols;
C.at(col_A,row_B) = acc;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
C.at(col_A,row_B) = alpha * acc;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
C.at(col_A,row_B) = acc + beta*C.at(col_A,row_B);
}
else
if( (use_alpha == true) && (use_beta == true) )
{
C.at(col_A,row_B) = alpha*acc + beta*C.at(col_A,row_B);
}
} const u32 B_n_rows = BB.n_rows;
} const u32 B_n_cols = BB.n_cols;
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows)
&& (B_n_rows == B_n_cols) )
{
gemm_emul_tinysq<false, use_alpha, use_beta>::apply(C, AA, BB, alpha,
beta);
}
else
{
gemm_emul_large<false, false, use_alpha, use_beta>::apply(C, AA, BB,
alpha, beta);
} }
} }
}; };
//! \brief //! \brief
//! Wrapper for ATLAS/BLAS dgemm function, using template arguments to cont rol the arguments passed to dgemm. //! Wrapper for ATLAS/BLAS dgemm function, using template arguments to cont rol the arguments passed to dgemm.
//! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes) //! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes)
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false>
skipping to change at line 408 skipping to change at line 334
public: public:
template<typename eT> template<typename eT>
inline inline
static static
void void
apply_blas_type( Mat<eT>& C, const Mat<eT>& A, const Mat<eT>& B, const eT alpha = eT(1), const eT beta = eT(0) ) apply_blas_type( Mat<eT>& C, const Mat<eT>& A, const Mat<eT>& B, const eT alpha = eT(1), const eT beta = eT(0) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if( ((A.n_elem < 64u) && (B.n_elem < 64u)) ) if( (A.n_elem <= 48u) && (B.n_elem <= 48u) )
{ {
gemm_emul_simple<do_trans_A, do_trans_B, use_alpha, use_beta>::apply( C,A,B,alpha,beta); gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B,a lpha,beta);
} }
else else
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
arma_extra_debug_print("atlas::cblas_gemm()"); arma_extra_debug_print("atlas::cblas_gemm()");
atlas::cblas_gemm<eT> atlas::cblas_gemm<eT>
( (
atlas::CblasColMajor, atlas::CblasColMajor,
(do_trans_A) ? atlas::CblasTrans : atlas::CblasNoTrans, (do_trans_A) ? ( is_complex<eT>::value ? CblasConjTrans : atlas::
(do_trans_B) ? atlas::CblasTrans : atlas::CblasNoTrans, CblasTrans ) : atlas::CblasNoTrans,
(do_trans_B) ? ( is_complex<eT>::value ? CblasConjTrans : atlas::
CblasTrans ) : atlas::CblasNoTrans,
C.n_rows, C.n_rows,
C.n_cols, C.n_cols,
(do_trans_A) ? A.n_rows : A.n_cols, (do_trans_A) ? A.n_rows : A.n_cols,
(use_alpha) ? alpha : eT(1), (use_alpha) ? alpha : eT(1),
A.mem, A.mem,
(do_trans_A) ? A.n_rows : C.n_rows, (do_trans_A) ? A.n_rows : C.n_rows,
B.mem, B.mem,
(do_trans_B) ? C.n_cols : ( (do_trans_A) ? A.n_rows : A.n_cols ), (do_trans_B) ? C.n_cols : ( (do_trans_A) ? A.n_rows : A.n_cols ),
(use_beta) ? beta : eT(0), (use_beta) ? beta : eT(0),
C.memptr(), C.memptr(),
C.n_rows C.n_rows
); );
} }
#elif defined(ARMA_USE_BLAS) #elif defined(ARMA_USE_BLAS)
{ {
arma_extra_debug_print("blas::gemm()"); arma_extra_debug_print("blas::gemm()");
const char trans_A = (do_trans_A) ? 'T' : 'N'; const char trans_A = (do_trans_A) ? ( is_complex<eT>::value ? 'C' :
const char trans_B = (do_trans_B) ? 'T' : 'N'; 'T' ) : 'N';
const char trans_B = (do_trans_B) ? ( is_complex<eT>::value ? 'C' :
'T' ) : 'N';
const blas_int m = C.n_rows; const blas_int m = C.n_rows;
const blas_int n = C.n_cols; const blas_int n = C.n_cols;
const blas_int k = (do_trans_A) ? A.n_rows : A.n_cols; const blas_int k = (do_trans_A) ? A.n_rows : A.n_cols;
const eT local_alpha = (use_alpha) ? alpha : eT(1); const eT local_alpha = (use_alpha) ? alpha : eT(1);
const blas_int lda = (do_trans_A) ? k : m; const blas_int lda = (do_trans_A) ? k : m;
const blas_int ldb = (do_trans_B) ? n : k; const blas_int ldb = (do_trans_B) ? n : k;
skipping to change at line 476 skipping to change at line 402
&lda, &lda,
B.mem, B.mem,
&ldb, &ldb,
&local_beta, &local_beta,
C.memptr(), C.memptr(),
&m &m
); );
} }
#else #else
{ {
gemm_emul_cache<do_trans_A, do_trans_B, use_alpha, use_beta>::apply (C,A,B,alpha,beta); gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B ,alpha,beta);
} }
#endif #endif
} }
} }
//! immediate multiplication of matrices A and B, storing the result in C //! immediate multiplication of matrices A and B, storing the result in C
template<typename eT> template<typename eT>
inline inline
static static
void void
apply( Mat<eT>& C, const Mat<eT>& A, const Mat<eT>& B, const eT alpha = e T(1), const eT beta = eT(0) ) apply( Mat<eT>& C, const Mat<eT>& A, const Mat<eT>& B, const eT alpha = e T(1), const eT beta = eT(0) )
{ {
if( (A.n_elem <= 64u) && (B.n_elem <= 64u) ) gemm_emul<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C,A,B,alp
{ ha,beta);
gemm_emul_simple<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(
C,A,B,alpha,beta);
}
else
{
gemm_emul_cache<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C
,A,B,alpha,beta);
}
} }
arma_inline arma_inline
static static
void void
apply apply
( (
Mat<float>& C, Mat<float>& C,
const Mat<float>& A, const Mat<float>& A,
const Mat<float>& B, const Mat<float>& B,
 End of changes. 36 change blocks. 
201 lines changed or deleted 132 lines changed or added


 gemm_mixed.hpp   gemm_mixed.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup gemm_mixed //! \addtogroup gemm_mixed
//! @{ //! @{
//! \brief //! \brief
//! Matrix multplication where the matrices have different element types. //! Matrix multplication where the matrices have differing element types.
//! Uses caching for speedup. //! Uses caching for speedup.
//! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes) //! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes)
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false>
class gemm_mixed_cache class gemm_mixed_large
{ {
public: public:
template<typename out_eT, typename in_eT1, typename in_eT2> template<typename out_eT, typename in_eT1, typename in_eT2>
arma_hot arma_hot
inline inline
static static
void void
apply apply
( (
skipping to change at line 55 skipping to change at line 55
const u32 B_n_rows = B.n_rows; const u32 B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols; const u32 B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (do_trans_A == false) && (do_trans_B == false) )
{ {
podarray<in_eT1> tmp(A_n_cols); podarray<in_eT1> tmp(A_n_cols);
in_eT1* A_rowdata = tmp.memptr(); in_eT1* A_rowdata = tmp.memptr();
for(u32 row_A=0; row_A < A_n_rows; ++row_A) for(u32 row_A=0; row_A < A_n_rows; ++row_A)
{ {
tmp.copy_row(A, row_A);
for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{
A_rowdata[col_A] = A.at(row_A,col_A);
}
for(u32 col_B=0; col_B < B_n_cols; ++col_B) for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{ {
const in_eT2* B_coldata = B.colptr(col_B); const in_eT2* B_coldata = B.colptr(col_B);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < B_n_rows; ++i) for(u32 i=0; i < B_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(A_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(A_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(B_coldata[i]);
} }
skipping to change at line 139 skipping to change at line 135
{ {
C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); C.at(col_A,col_B) = alpha*acc + beta*C.at(col_A,col_B);
} }
} }
} }
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) ) if( (do_trans_A == false) && (do_trans_B == true) )
{ {
Mat<in_eT2> B_tmp = trans(B); Mat<in_eT2> B_tmp;
gemm_mixed_cache<false, false, use_alpha, use_beta>::apply(C, A, B_tm
p, alpha, beta); op_strans::apply_noalias(B_tmp, B);
gemm_mixed_large<false, false, use_alpha, use_beta>::apply(C, A, B_tm
p, alpha, beta);
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) ) if( (do_trans_A == true) && (do_trans_B == true) )
{ {
// mat B_tmp = trans(B); // mat B_tmp = trans(B);
// dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta); // dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta);
// By using the trans(A)*trans(B) = trans(B*A) equivalency, // By using the trans(A)*trans(B) = trans(B*A) equivalency,
// transpose operations are not needed // transpose operations are not needed
podarray<in_eT2> tmp(B.n_cols); podarray<in_eT2> tmp(B_n_cols);
in_eT2* B_rowdata = tmp.memptr(); in_eT2* B_rowdata = tmp.memptr();
for(u32 row_B=0; row_B < B_n_rows; ++row_B) for(u32 row_B=0; row_B < B_n_rows; ++row_B)
{ {
tmp.copy_row(B, row_B);
for(u32 col_B=0; col_B < B_n_cols; ++col_B)
{
B_rowdata[col_B] = B.at(row_B,col_B);
}
for(u32 col_A=0; col_A < A_n_cols; ++col_A) for(u32 col_A=0; col_A < A_n_cols; ++col_A)
{ {
const in_eT1* A_coldata = A.colptr(col_A); const in_eT1* A_coldata = A.colptr(col_A);
out_eT acc = out_eT(0); out_eT acc = out_eT(0);
for(u32 i=0; i < A_n_rows; ++i) for(u32 i=0; i < A_n_rows; ++i)
{ {
acc += upgrade_val<in_eT1,in_eT2>::apply(B_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(A_coldata[i]); acc += upgrade_val<in_eT1,in_eT2>::apply(B_rowdata[i]) * upgrad e_val<in_eT1,in_eT2>::apply(A_coldata[i]);
} }
skipping to change at line 204 skipping to change at line 199
} }
} }
}; };
//! Matrix multplication where the matrices have different element types. //! Matrix multplication where the matrices have different element types.
//! Simple version (no caching). //! Simple version (no caching).
//! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes) //! Matrix 'C' is assumed to have been set to the correct size (i.e. taking into account transposes)
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false>
class gemm_mixed_simple class gemm_mixed_small
{ {
public: public:
template<typename out_eT, typename in_eT1, typename in_eT2> template<typename out_eT, typename in_eT1, typename in_eT2>
arma_hot arma_hot
inline inline
static static
void void
apply apply
( (
skipping to change at line 391 skipping to change at line 386
} }
} }
} }
} }
}; };
//! \brief //! \brief
//! Matrix multplication where the matrices have different element types. //! Matrix multplication where the matrices have differing element types.
template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false> template<const bool do_trans_A=false, const bool do_trans_B=false, const bo ol use_alpha=false, const bool use_beta=false>
class gemm_mixed class gemm_mixed
{ {
public: public:
//! immediate multiplication of matrices A and B, storing the result in C //! immediate multiplication of matrices A and B, storing the result in C
template<typename out_eT, typename in_eT1, typename in_eT2> template<typename out_eT, typename in_eT1, typename in_eT2>
inline inline
static static
skipping to change at line 414 skipping to change at line 409
( (
Mat<out_eT>& C, Mat<out_eT>& C,
const Mat<in_eT1>& A, const Mat<in_eT1>& A,
const Mat<in_eT2>& B, const Mat<in_eT2>& B,
const out_eT alpha = out_eT(1), const out_eT alpha = out_eT(1),
const out_eT beta = out_eT(0) const out_eT beta = out_eT(0)
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if( (A.n_elem <= 64u) && (B.n_elem <= 64u) ) Mat<in_eT1> tmp_A;
Mat<in_eT2> tmp_B;
const bool predo_trans_A = ( (do_trans_A == true) && (is_complex<in_eT1
>::value == true) );
const bool predo_trans_B = ( (do_trans_B == true) && (is_complex<in_eT2
>::value == true) );
if(do_trans_A)
{
op_htrans::apply_noalias(tmp_A, A);
}
if(do_trans_B)
{
op_htrans::apply_noalias(tmp_B, B);
}
const Mat<in_eT1>& AA = (predo_trans_A == false) ? A : tmp_A;
const Mat<in_eT2>& BB = (predo_trans_B == false) ? B : tmp_B;
if( (AA.n_elem <= 64u) && (BB.n_elem <= 64u) )
{ {
gemm_mixed_simple<do_trans_A, do_trans_B, use_alpha, use_beta>::apply (C,A,B,alpha,beta); gemm_mixed_small<((predo_trans_A) ? false : do_trans_A), ((predo_tran s_B) ? false : do_trans_B), use_alpha, use_beta>::apply(C, AA, BB, alpha, b eta);
} }
else else
{ {
gemm_mixed_cache<do_trans_A, do_trans_B, use_alpha, use_beta>::apply( C,A,B,alpha,beta); gemm_mixed_large<((predo_trans_A) ? false : do_trans_A), ((predo_tran s_B) ? false : do_trans_B), use_alpha, use_beta>::apply(C, AA, BB, alpha, b eta);
} }
} }
}; };
//! @} //! @}
 End of changes. 12 change blocks. 
23 lines changed or deleted 39 lines changed or added


 gemv.hpp   gemv.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup gemv //! \addtogroup gemv
//! @{ //! @{
//! for tiny square matrices with n_rows <= 4
template<const bool do_trans_A=false, const bool use_alpha=false, const boo
l use_beta=false>
class gemv_emul_tiny
{
public:
template<const u32 row, const u32 col>
struct pos
{
static const u32 n2 = (do_trans_A == false) ? (row + col*2) : (col + ro
w*2);
static const u32 n3 = (do_trans_A == false) ? (row + col*3) : (col + ro
w*3);
static const u32 n4 = (do_trans_A == false) ? (row + col*4) : (col + ro
w*4);
};
template<typename eT, const u32 i>
arma_hot
arma_inline
static
void
assign(eT* y, const eT acc, const eT alpha, const eT beta)
{
if(use_beta == false)
{
y[i] = (use_alpha == false) ? acc : alpha*acc;
}
else
{
const eT tmp = y[i];
y[i] = beta*tmp + ( (use_alpha == false) ? acc : alpha*acc );
}
}
template<typename eT>
arma_hot
inline
static
void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0) )
{
arma_extra_debug_sigprint();
const eT* Am = A.memptr();
switch(A.n_rows)
{
case 1:
{
const eT acc = Am[0] * x[0];
assign<eT, 0>(y, acc, alpha, beta);
}
break;
case 2:
{
const eT x0 = x[0];
const eT x1 = x[1];
const eT acc0 = Am[pos<0,0>::n2]*x0 + Am[pos<0,1>::n2]*x1;
const eT acc1 = Am[pos<1,0>::n2]*x0 + Am[pos<1,1>::n2]*x1;
assign<eT, 0>(y, acc0, alpha, beta);
assign<eT, 1>(y, acc1, alpha, beta);
}
break;
case 3:
{
const eT x0 = x[0];
const eT x1 = x[1];
const eT x2 = x[2];
const eT acc0 = Am[pos<0,0>::n3]*x0 + Am[pos<0,1>::n3]*x1 + Am[pos<
0,2>::n3]*x2;
const eT acc1 = Am[pos<1,0>::n3]*x0 + Am[pos<1,1>::n3]*x1 + Am[pos<
1,2>::n3]*x2;
const eT acc2 = Am[pos<2,0>::n3]*x0 + Am[pos<2,1>::n3]*x1 + Am[pos<
2,2>::n3]*x2;
assign<eT, 0>(y, acc0, alpha, beta);
assign<eT, 1>(y, acc1, alpha, beta);
assign<eT, 2>(y, acc2, alpha, beta);
}
break;
case 4:
{
const eT x0 = x[0];
const eT x1 = x[1];
const eT x2 = x[2];
const eT x3 = x[3];
const eT acc0 = Am[pos<0,0>::n4]*x0 + Am[pos<0,1>::n4]*x1 + Am[pos<
0,2>::n4]*x2 + Am[pos<0,3>::n4]*x3;
const eT acc1 = Am[pos<1,0>::n4]*x0 + Am[pos<1,1>::n4]*x1 + Am[pos<
1,2>::n4]*x2 + Am[pos<1,3>::n4]*x3;
const eT acc2 = Am[pos<2,0>::n4]*x0 + Am[pos<2,1>::n4]*x1 + Am[pos<
2,2>::n4]*x2 + Am[pos<2,3>::n4]*x3;
const eT acc3 = Am[pos<3,0>::n4]*x0 + Am[pos<3,1>::n4]*x1 + Am[pos<
3,2>::n4]*x2 + Am[pos<3,3>::n4]*x3;
assign<eT, 0>(y, acc0, alpha, beta);
assign<eT, 1>(y, acc1, alpha, beta);
assign<eT, 2>(y, acc2, alpha, beta);
assign<eT, 3>(y, acc3, alpha, beta);
}
break;
default:
;
}
}
};
//! \brief //! \brief
//! Partial emulation of ATLAS/BLAS gemv(). //! Partial emulation of ATLAS/BLAS gemv().
//! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose) //! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose)
template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false>
class gemv_arma class gemv_emul_large
{ {
public: public:
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) ) apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 A_n_rows = A.n_rows; const u32 A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols; const u32 A_n_cols = A.n_cols;
if(do_trans_A == false) if(do_trans_A == false)
{ {
for(u32 row=0; row < A_n_rows; ++row) for(u32 row=0; row < A_n_rows; ++row)
{ {
eT acc = eT(0); eT acc = eT(0);
for(u32 col=0; col < A_n_cols; ++col)
for(u32 i=0; i < A_n_cols; ++i)
{ {
acc += A.at(row,col) * x[col]; acc += A.at(row,i) * x[i];
} }
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
y[row] = acc; y[row] = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
y[row] = alpha * acc; y[row] = alpha * acc;
skipping to change at line 112 skipping to change at line 221
{ {
y[col] = alpha*acc + beta*y[col]; y[col] = alpha*acc + beta*y[col];
} }
} }
} }
} }
}; };
template<const bool do_trans_A=false, const bool use_alpha=false, const boo
l use_beta=false>
class gemv_emul
{
public:
template<typename eT>
arma_hot
inline
static
void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0), const typename arma_not_cx<eT>::result* junk = 0 )
{
arma_extra_debug_sigprint();
arma_ignore(junk);
if( A.n_rows > 4 )
{
gemv_emul_large<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alph
a, beta);
}
else
{
gemv_emul_tiny<do_trans_A, use_alpha, use_beta>::apply(y, A, x, alpha
, beta);
}
}
template<typename eT>
arma_hot
inline
static
void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons
t eT beta = eT(0), const typename arma_cx_only<eT>::result* junk = 0 )
{
arma_extra_debug_sigprint();
Mat<eT> tmp_A;
if(do_trans_A)
{
op_htrans::apply_noalias(tmp_A, A);
}
const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A;
if( AA.n_rows > 4 )
{
gemv_emul_large<false, use_alpha, use_beta>::apply(y, AA, x, alpha, b
eta);
}
else
{
gemv_emul_tiny<false, use_alpha, use_beta>::apply(y, AA, x, alpha, be
ta);
}
}
};
//! \brief //! \brief
//! Wrapper for ATLAS/BLAS gemv function, using template arguments to contr ol the arguments passed to gemv. //! Wrapper for ATLAS/BLAS gemv function, using template arguments to contr ol the arguments passed to gemv.
//! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose) //! 'y' is assumed to have been set to the correct size (i.e. taking into a ccount the transpose)
template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false> template<const bool do_trans_A=false, const bool use_alpha=false, const boo l use_beta=false>
class gemv class gemv
{ {
public: public:
template<typename eT> template<typename eT>
inline inline
static static
void void
apply_blas_type( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = e T(1), const eT beta = eT(0) ) apply_blas_type( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = e T(1), const eT beta = eT(0) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.n_elem <= 256u) if(A.n_elem <= 64u)
{ {
gemv_arma<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta); gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta);
} }
else else
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
arma_extra_debug_print("atlas::cblas_gemv()"); arma_extra_debug_print("atlas::cblas_gemv()");
atlas::cblas_gemv<eT> atlas::cblas_gemv<eT>
( (
atlas::CblasColMajor, atlas::CblasColMajor,
(do_trans_A) ? atlas::CblasTrans : atlas::CblasNoTrans, (do_trans_A) ? ( is_complex<eT>::value ? CblasConjTrans : atlas:: CblasTrans ) : atlas::CblasNoTrans,
A.n_rows, A.n_rows,
A.n_cols, A.n_cols,
(use_alpha) ? alpha : eT(1), (use_alpha) ? alpha : eT(1),
A.mem, A.mem,
A.n_rows, A.n_rows,
x, x,
1, 1,
(use_beta) ? beta : eT(0), (use_beta) ? beta : eT(0),
y, y,
1 1
); );
} }
#elif defined(ARMA_USE_BLAS) #elif defined(ARMA_USE_BLAS)
{ {
arma_extra_debug_print("blas::gemv()"); arma_extra_debug_print("blas::gemv()");
const char trans_A = (do_trans_A) ? 'T' : 'N'; const char trans_A = (do_trans_A) ? ( is_complex<eT>::valu e ? 'C' : 'T' ) : 'N';
const blas_int m = A.n_rows; const blas_int m = A.n_rows;
const blas_int n = A.n_cols; const blas_int n = A.n_cols;
const eT local_alpha = (use_alpha) ? alpha : eT(1); const eT local_alpha = (use_alpha) ? alpha : eT(1);
//const blas_int lda = A.n_rows; //const blas_int lda = A.n_rows;
const blas_int inc = 1; const blas_int inc = 1;
const eT local_beta = (use_beta) ? beta : eT(0); const eT local_beta = (use_beta) ? beta : eT(0);
arma_extra_debug_print( arma_boost::format("blas::gemv(): trans_A = %c") % trans_A ); arma_extra_debug_print( arma_boost::format("blas::gemv(): trans_A = %c") % trans_A );
blas::gemv<eT> blas::gemv<eT>
skipping to change at line 186 skipping to change at line 349
&m, // lda &m, // lda
x, x,
&inc, &inc,
&local_beta, &local_beta,
y, y,
&inc &inc
); );
} }
#else #else
{ {
gemv_arma<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta) ; gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta) ;
} }
#endif #endif
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
static static
void void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) ) apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0) )
{ {
gemv_arma<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta); gemv_emul<do_trans_A, use_alpha, use_beta>::apply(y,A,x,alpha,beta);
} }
arma_inline arma_inline
static static
void void
apply apply
( (
float* y, float* y,
const Mat<float>& A, const Mat<float>& A,
const float* x, const float* x,
 End of changes. 12 change blocks. 
14 lines changed or deleted 196 lines changed or added


 glue_conv_meat.hpp   glue_conv_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 33 skipping to change at line 33
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> A_tmp(X.A, out); const unwrap_check<T1> A_tmp(X.A, out);
const unwrap_check<T2> B_tmp(X.B, out); const unwrap_check<T2> B_tmp(X.B, out);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), "co arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), "co
nv(): inputs must be vectors" ); nv(): inputs must be vectors" );
arma_debug_check( ( (A.n_elem == 0 ) || (B.n_elem == 0 ) ), "co
nv(): zero-length input given" );
const Mat<eT>& h = (A.n_elem <= B.n_elem) ? A : B; const Mat<eT>& h = (A.n_elem <= B.n_elem) ? A : B;
const Mat<eT>& x = (A.n_elem <= B.n_elem) ? B : A; const Mat<eT>& x = (A.n_elem <= B.n_elem) ? B : A;
const u32 h_n_elem = h.n_elem; const u32 h_n_elem = h.n_elem;
const u32 x_n_elem = x.n_elem; const u32 x_n_elem = x.n_elem;
const u32 out_n_elem = h_n_elem + x_n_elem - 1; const u32 out_n_elem = h_n_elem + x_n_elem - 1;
if( (h_n_elem == 0) || (x_n_elem == 0) )
{
out.reset();
return;
}
(A.n_cols == 1) ? out.set_size(out_n_elem, 1) : out.set_size(1, out_n_ele m); (A.n_cols == 1) ? out.set_size(out_n_elem, 1) : out.set_size(1, out_n_ele m);
const eT* h_mem = h.memptr(); const eT* h_mem = h.memptr();
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 out_i = 0; out_i < (h_n_elem-1); ++out_i) for(u32 out_i = 0; out_i < (h_n_elem-1); ++out_i)
{ {
eT acc = eT(0); eT acc = eT(0);
 End of changes. 3 change blocks. 
6 lines changed or deleted 10 lines changed or added


 glue_cor_meat.hpp   glue_cor_meat.hpp 
skipping to change at line 24 skipping to change at line 24
//! \addtogroup glue_cor //! \addtogroup glue_cor
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
glue_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, cons t u32 norm_type) glue_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, cons t u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty() || B.is_empty() )
{
out.reset();
return;
}
if(A.is_vec() && B.is_vec()) if(A.is_vec() && B.is_vec())
{ {
arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" ); arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" );
const eT* A_ptr = A.memptr(); const eT* A_ptr = A.memptr();
const eT* B_ptr = B.memptr(); const eT* B_ptr = B.memptr();
eT A_acc = eT(0); eT A_acc = eT(0);
eT B_acc = eT(0); eT B_acc = eT(0);
eT out_acc = eT(0); eT out_acc = eT(0);
skipping to change at line 83 skipping to change at line 89
template<typename T> template<typename T>
inline inline
void void
glue_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, const Mat< std::complex<T> >& B, const u32 norm_type) glue_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T > >& A, const Mat< std::complex<T> >& B, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(A.is_empty() || B.is_empty() )
{
out.reset();
return;
}
if(A.is_vec() && B.is_vec()) if(A.is_vec() && B.is_vec())
{ {
arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" ); arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of element s in the two vectors must match" );
const eT* A_ptr = A.memptr(); const eT* A_ptr = A.memptr();
const eT* B_ptr = B.memptr(); const eT* B_ptr = B.memptr();
eT A_acc = eT(0); eT A_acc = eT(0);
eT B_acc = eT(0); eT B_acc = eT(0);
eT out_acc = eT(0); eT out_acc = eT(0);
 End of changes. 2 change blocks. 
0 lines changed or deleted 12 lines changed or added


 glue_cross_meat.hpp   glue_cross_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_cross //! \addtogroup glue_cross
//! @{ //! @{
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_cross::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue _cross>& X) glue_cross::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue _cross>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2;
const unwrap<T1> A_tmp(X.A); const Proxy<T1> A(X.A);
const unwrap<T2> B_tmp(X.B); const Proxy<T2> B(X.B);
const Mat<eT>& A = A_tmp.M; arma_debug_check( ((A.get_n_elem() != 3) || (B.get_n_elem() != 3)), "cros
const Mat<eT>& B = B_tmp.M; s(): input vectors must have 3 elements" );
arma_debug_check( ((A.n_elem != 3) || (B.n_elem != 3)), "cross(): input v ectors must have 3 elements" ); out.set_size(A.get_n_rows(), A.get_n_cols());
out.set_size(A.n_rows, A.n_cols); eT* out_mem = out.memptr();
ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea();
eT* out_ptr = out.memptr(); const eT ax = PA[0];
const eT* A_ptr = A.memptr(); const eT ay = PA[1];
const eT* B_ptr = B.memptr(); const eT az = PA[2];
// out_ptr[0] = A_ptr[1]*B_ptr[2] - A_ptr[2]*B_ptr[1]; const eT bx = PB[0];
// out_ptr[1] = A_ptr[2]*B_ptr[0] - A_ptr[0]*B_ptr[2]; const eT by = PB[1];
// out_ptr[2] = A_ptr[0]*B_ptr[1] - A_ptr[1]*B_ptr[0]; const eT bz = PB[2];
const eT ax = A_ptr[0]; out_mem[0] = ay*bz - az*by;
const eT ay = A_ptr[1]; out_mem[1] = az*bx - ax*bz;
const eT az = A_ptr[2]; out_mem[2] = ax*by - ay*bx;
const eT bx = B_ptr[0];
const eT by = B_ptr[1];
const eT bz = B_ptr[2];
out_ptr[0] = ay*bz - az*by;
out_ptr[1] = az*bx - ax*bz;
out_ptr[2] = ax*by - ay*bx;
} }
//! @} //! @}
 End of changes. 9 change blocks. 
26 lines changed or deleted 22 lines changed or added


 glue_join_meat.hpp   glue_join_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 33 skipping to change at line 33
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> A_tmp(X.A); const unwrap<T1> A_tmp(X.A);
const unwrap<T2> B_tmp(X.B); const unwrap<T2> B_tmp(X.B);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
const u32 join_type = X.aux_u32; const u32 join_type = X.aux_u32;
if(A.n_elem == 0)
{
out = B;
return;
}
if(B.n_elem == 0)
{
out = A;
return;
}
if(join_type == 0) if(join_type == 0)
{ {
arma_debug_check( (A.n_cols != B.n_cols), "join_cols(): number of colum ns must be the same" ); arma_debug_check( (A.n_cols != B.n_cols), "join_cols(): number of colum ns must be the same" );
} }
else else
{ {
arma_debug_check( (A.n_rows != B.n_rows), "join_rows(): number of rows must be the same" ); arma_debug_check( (A.n_rows != B.n_rows), "join_rows(): number of rows must be the same" );
} }
if( (&out != &A) && (&out != &B) ) if( (&out != &A) && (&out != &B) )
{ {
if(join_type == 0) // join columns (i.e. result matrix has more rows) if(join_type == 0) // join columns (i.e. result matrix has more rows)
{ {
out.set_size(A.n_rows + B.n_rows, A.n_cols); out.set_size(A.n_rows + B.n_rows, A.n_cols);
out.submat(0, 0, A.n_rows-1, out.n_cols-1) = A; if( out.n_elem > 0 )
out.submat(A.n_rows, 0, out.n_rows-1, out.n_cols-1) = B; {
out.submat(0, 0, A.n_rows-1, out.n_cols-1) = A;
out.submat(A.n_rows, 0, out.n_rows-1, out.n_cols-1) = B;
}
} }
else // join rows (i.e. result matrix has more columns) else // join rows (i.e. result matrix has more columns)
{ {
out.set_size(A.n_rows, A.n_cols + B.n_cols); out.set_size(A.n_rows, A.n_cols + B.n_cols);
out.submat(0, 0, out.n_rows-1, A.n_cols-1 ) = A; if( out.n_elem > 0 )
out.submat(0, A.n_cols, out.n_rows-1, out.n_cols-1) = B; {
out.submat(0, 0, out.n_rows-1, A.n_cols-1) = A;
out.submat(0, A.n_cols, out.n_rows-1, out.n_cols-1) = B;
}
} }
} }
else // we have aliasing else // we have aliasing
{ {
Mat<eT> C; Mat<eT> C;
if(join_type == 0) if(join_type == 0)
{ {
C.set_size(A.n_rows + B.n_rows, A.n_cols); C.set_size(A.n_rows + B.n_rows, A.n_cols);
C.submat(0, 0, A.n_rows-1, C.n_cols-1) = A; if( C.n_elem > 0 )
C.submat(A.n_rows, 0, C.n_rows-1, C.n_cols-1) = B; {
C.submat(0, 0, A.n_rows-1, C.n_cols-1) = A;
C.submat(A.n_rows, 0, C.n_rows-1, C.n_cols-1) = B;
}
} }
else else
{ {
C.set_size(A.n_rows, A.n_cols + B.n_cols); C.set_size(A.n_rows, A.n_cols + B.n_cols);
C.submat(0, 0, C.n_rows-1, A.n_cols-1) = A; if( C.n_elem > 0 )
C.submat(0, A.n_cols, C.n_rows-1, C.n_cols-1) = B; {
C.submat(0, 0, C.n_rows-1, A.n_cols-1) = A;
C.submat(0, A.n_cols, C.n_rows-1, C.n_cols-1) = B;
}
} }
out.steal_mem(C); out.steal_mem(C);
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
 End of changes. 6 change blocks. 
22 lines changed or deleted 22 lines changed or added


 glue_times_meat.hpp   glue_times_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 132 skipping to change at line 132
void void
glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X) glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(X, out); const unwrap_check<T1> tmp(X, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
arma_debug_assert_mul_size(out, B, "matrix multiply"); arma_debug_assert_mul_size(out, B, "matrix multiplication");
if(out.n_cols == B.n_cols) const u32 out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols;
if(out_n_cols == B.n_cols)
{ {
podarray<eT> tmp(out.n_cols); // size of resulting matrix is the same as 'out'
podarray<eT> tmp(out_n_cols);
eT* tmp_rowdata = tmp.memptr(); eT* tmp_rowdata = tmp.memptr();
for(u32 out_row=0; out_row < out.n_rows; ++out_row) for(u32 row=0; row < out_n_rows; ++row)
{ {
for(u32 out_col=0; out_col < out.n_cols; ++out_col) tmp.copy_row(out, row);
{
tmp_rowdata[out_col] = out.at(out_row,out_col);
}
for(u32 B_col=0; B_col < B.n_cols; ++B_col) for(u32 col=0; col < out_n_cols; ++col)
{ {
const eT* B_coldata = B.colptr(B_col); out.at(row,col) = op_dot::direct_dot( out_n_cols, tmp_rowdata, B.co
lptr(col) );
eT val = eT(0);
for(u32 i=0; i < B.n_rows; ++i)
{
val += tmp_rowdata[i] * B_coldata[i];
}
out.at(out_row,B_col) = val;
} }
} }
} }
else else
{ {
const Mat<eT> tmp(out); const Mat<eT> tmp(out);
glue_times::apply(out, tmp, B, eT(1), false, false, false); glue_times::apply(out, tmp, B, eT(1), false, false, false);
} }
skipping to change at line 190 skipping to change at line 185
const partial_unwrap_check<T2> tmp2(X.B, out); const partial_unwrap_check<T2> tmp2(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const eT alpha = tmp1.val * tmp2.val * ( (sign > s32(0)) ? eT(1) : eT(-1) ); const eT alpha = tmp1.val * tmp2.val * ( (sign > s32(0)) ? eT(1) : eT(-1) );
const bool do_trans_A = tmp1.do_trans; const bool do_trans_A = tmp1.do_trans;
const bool do_trans_B = tmp2.do_trans; const bool do_trans_B = tmp2.do_trans;
const bool use_alpha = tmp1.do_times | tmp2.do_times | (sign < s32(0)); const bool use_alpha = tmp1.do_times | tmp2.do_times | (sign < s32(0));
arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multiply "); arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli cation");
const u32 result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const u32 result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const u32 result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const u32 result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "matrix addition"); arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "addition");
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == false if(out.n_elem > 0)
) )
{
if(A.n_rows == 1)
{
gemv<true, false, true>::apply(out.memptr(), B, A.memptr(), a
lpha, eT(1));
}
else
if(B.n_cols == 1)
{
gemv<false, false, true>::apply(out.memptr(), A, B.memptr(), a
lpha, eT(1));
}
else
{
gemm<false, false, false, true>::apply(out, A, B, alpha, eT(1));
}
}
else
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == true)
)
{
if(A.n_rows == 1)
{
gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), al
pha, eT(1));
}
else
if(B.n_cols == 1)
{
gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), al
pha, eT(1));
}
else
{
gemm<false, false, true, true>::apply(out, A, B, alpha, eT(1));
}
}
else
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == false)
)
{ {
if(A.n_cols == 1) if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == fal se) )
{ {
gemv<true, false, true>::apply(out.memptr(), B, A.memptr(), al if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
pha, eT(1)); {
} gemv<true, false, true>::apply(out.memptr(), B, A.memptr(),
else alpha, eT(1));
if(B.n_cols == 1) }
{ else
gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), al if(B.n_cols == 1)
pha, eT(1)); {
} gemv<false, false, true>::apply(out.memptr(), A, B.memptr(),
else alpha, eT(1));
{ }
gemm<true, false, false, true>::apply(out, A, B, alpha, eT(1)); else
} {
} gemm<false, false, false, true>::apply(out, A, B, alpha, eT(1));
else }
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true)
)
{
if(A.n_cols == 1)
{
gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), alp
ha, eT(1));
}
else
if(B.n_cols == 1)
{
gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), alp
ha, eT(1));
}
else
{
gemm<true, false, true, true>::apply(out, A, B, alpha, eT(1));
}
}
else
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == false)
)
{
if(A.n_rows == 1)
{
gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), al
pha, eT(1));
}
else
if(B.n_rows == 1)
{
gemv<false, false, true>::apply(out.memptr(), A, B.memptr(), al
pha, eT(1));
} }
else else
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == tru e) )
{ {
gemm<false, true, false, true>::apply(out, A, B, alpha, eT(1)); if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
} {
} gemv<true, true, true>::apply(out.memptr(), B, A.memptr(),
else alpha, eT(1));
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true) }
) else
{ if(B.n_cols == 1)
if(A.n_rows == 1) {
{ gemv<false, true, true>::apply(out.memptr(), A, B.memptr(),
gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), alp alpha, eT(1));
ha, eT(1)); }
else
{
gemm<false, false, true, true>::apply(out, A, B, alpha, eT(1));
}
} }
else else
if(B.n_rows == 1) if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == fals e) )
{ {
gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), alp if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
ha, eT(1)); {
gemv<true, false, true>::apply(out.memptr(), B, A.memptr(),
alpha, eT(1));
}
else
if(B.n_cols == 1)
{
gemv<true, false, true>::apply(out.memptr(), A, B.memptr(),
alpha, eT(1));
}
else
{
gemm<true, false, false, true>::apply(out, A, B, alpha, eT(1));
}
} }
else else
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true ) )
{ {
gemm<false, true, true, true>::apply(out, A, B, alpha, eT(1)); if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
} {
} gemv<true, true, true>::apply(out.memptr(), B, A.memptr(), a
else lpha, eT(1));
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false) }
) else
{ if(B.n_cols == 1)
if(A.n_cols == 1) {
{ gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), a
gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), alp lpha, eT(1));
ha, eT(1)); }
else
{
gemm<true, false, true, true>::apply(out, A, B, alpha, eT(1));
}
} }
else else
if(B.n_rows == 1) if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == fals e) )
{ {
gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), alp if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
ha, eT(1)); {
gemv<false, false, true>::apply(out.memptr(), B, A.memptr(),
alpha, eT(1));
}
else
if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{
gemv<false, false, true>::apply(out.memptr(), A, B.memptr(),
alpha, eT(1));
}
else
{
gemm<false, true, false, true>::apply(out, A, B, alpha, eT(1));
}
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true ) )
{ {
gemm<true, true, false, true>::apply(out, A, B, alpha, eT(1)); if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
} {
} gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), a
else lpha, eT(1));
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) ) }
{ else
if(A.n_cols == 1) if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{ {
gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), alph gemv<false, true, true>::apply(out.memptr(), A, B.memptr(), a
a, eT(1)); lpha, eT(1));
}
else
{
gemm<false, true, true, true>::apply(out, A, B, alpha, eT(1));
}
} }
else else
if(B.n_rows == 1) if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false ) )
{ {
gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), alph if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
a, eT(1)); {
gemv<false, false, true>::apply(out.memptr(), B, A.memptr(), a
lpha, eT(1));
}
else
if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{
gemv<true, false, true>::apply(out.memptr(), A, B.memptr(), a
lpha, eT(1));
}
else
{
gemm<true, true, false, true>::apply(out, A, B, alpha, eT(1));
}
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) )
{ {
gemm<true, true, true, true>::apply(out, A, B, alpha, eT(1)); if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
{
gemv<false, true, true>::apply(out.memptr(), B, A.memptr(), al
pha, eT(1));
}
else
if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{
gemv<true, true, true>::apply(out.memptr(), A, B.memptr(), al
pha, eT(1));
}
else
{
gemm<true, true, true, true>::apply(out, A, B, alpha, eT(1));
}
} }
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
u32 u32
glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, const bool do_trans_A, const bool do_trans_B) glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, const bool do_trans_A, const bool do_trans_B)
{ {
skipping to change at line 363 skipping to change at line 361
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& B,
const eT alpha, const eT alpha,
const bool do_trans_A, const bool do_trans_A,
const bool do_trans_B, const bool do_trans_B,
const bool use_alpha const bool use_alpha
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multiply "); arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli cation");
const u32 final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const u32 final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const u32 final_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const u32 final_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
out.set_size(final_n_rows, final_n_cols); out.set_size(final_n_rows, final_n_cols);
// TODO: thoroughly test all combinations if( (A.n_elem > 0) && (B.n_elem > 0) )
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == false
) )
{
if(A.n_rows == 1)
{
gemv<true, false, false>::apply(out.memptr(), B, A.memptr());
}
else
if(B.n_cols == 1)
{
gemv<false, false, false>::apply(out.memptr(), A, B.memptr());
}
else
{
gemm<false, false, false, false>::apply(out, A, B);
}
}
else
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == true)
)
{
if(A.n_rows == 1)
{
gemv<true, true, false>::apply(out.memptr(), B, A.memptr(), a
lpha);
}
else
if(B.n_cols == 1)
{
gemv<false, true, false>::apply(out.memptr(), A, B.memptr(), a
lpha);
}
else
{
gemm<false, false, true, false>::apply(out, A, B, alpha);
}
}
else
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == false)
)
{
if(A.n_cols == 1)
{
gemv<true, false, false>::apply(out.memptr(), B, A.memptr());
}
else
if(B.n_cols == 1)
{
gemv<true, false, false>::apply(out.memptr(), A, B.memptr());
}
else
{
gemm<true, false, false, false>::apply(out, A, B);
}
}
else
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true)
)
{ {
if(A.n_cols == 1) if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == fal se) )
{ {
gemv<true, true, false>::apply(out.memptr(), B, A.memptr(), al if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
pha); {
} gemv<true, false, false>::apply(out.memptr(), B, A.memptr()
else );
if(B.n_cols == 1) }
{ else
gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), al if(B.n_cols == 1)
pha); {
gemv<false, false, false>::apply(out.memptr(), A, B.memptr()
);
}
else
{
gemm<false, false, false, false>::apply(out, A, B);
}
} }
else else
if( (do_trans_A == false) && (do_trans_B == false) && (use_alpha == tru e) )
{ {
gemm<true, false, true, false>::apply(out, A, B, alpha); if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
} {
} gemv<true, true, false>::apply(out.memptr(), B, A.memptr(),
else alpha);
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == false) }
) else
{ if(B.n_cols == 1)
if(A.n_rows == 1) {
{ gemv<false, true, false>::apply(out.memptr(), A, B.memptr(),
gemv<false, false, false>::apply(out.memptr(), B, A.memptr()); alpha);
}
else
{
gemm<false, false, true, false>::apply(out, A, B, alpha);
}
} }
else else
if(B.n_rows == 1) if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == fals e) )
{ {
gemv<false, false, false>::apply(out.memptr(), A, B.memptr()); if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
{
gemv<true, false, false>::apply(out.memptr(), B, A.memptr())
;
}
else
if(B.n_cols == 1)
{
gemv<true, false, false>::apply(out.memptr(), A, B.memptr())
;
}
else
{
gemm<true, false, false, false>::apply(out, A, B);
}
} }
else else
if( (do_trans_A == true) && (do_trans_B == false) && (use_alpha == true ) )
{ {
gemm<false, true, false, false>::apply(out, A, B); if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
} {
} gemv<true, true, false>::apply(out.memptr(), B, A.memptr(),
else alpha);
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true) }
) else
{ if(B.n_cols == 1)
if(A.n_rows == 1) {
{ gemv<true, true, false>::apply(out.memptr(), A, B.memptr(),
gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), al alpha);
pha); }
else
{
gemm<true, false, true, false>::apply(out, A, B, alpha);
}
} }
else else
if(B.n_rows == 1) if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == fals e) )
{ {
gemv<false, true, false>::apply(out.memptr(), A, B.memptr(), al if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
pha); {
gemv<false, false, false>::apply(out.memptr(), B, A.memptr())
;
}
else
if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{
gemv<false, false, false>::apply(out.memptr(), A, B.memptr())
;
}
else
{
gemm<false, true, false, false>::apply(out, A, B);
}
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) && (use_alpha == true ) )
{ {
gemm<false, true, true, false>::apply(out, A, B, alpha); if( (A.n_rows == 1) && (is_complex<eT>::value == false) )
} {
} gemv<false, true, false>::apply(out.memptr(), B, A.memptr(),
else alpha);
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false) }
) else
{ if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
if(A.n_cols == 1) {
{ gemv<false, true, false>::apply(out.memptr(), A, B.memptr(),
gemv<false, false, false>::apply(out.memptr(), B, A.memptr()); alpha);
}
else
{
gemm<false, true, true, false>::apply(out, A, B, alpha);
}
} }
else else
if(B.n_rows == 1) if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == false ) )
{ {
gemv<true, false, false>::apply(out.memptr(), A, B.memptr()); if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
{
gemv<false, false, false>::apply(out.memptr(), B, A.memptr());
}
else
if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{
gemv<true, false, false>::apply(out.memptr(), A, B.memptr());
}
else
{
gemm<true, true, false, false>::apply(out, A, B);
}
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) )
{ {
gemm<true, true, false, false>::apply(out, A, B); if( (A.n_cols == 1) && (is_complex<eT>::value == false) )
{
gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), a
lpha);
}
else
if( (B.n_rows == 1) && (is_complex<eT>::value == false) )
{
gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), a
lpha);
}
else
{
gemm<true, true, true, false>::apply(out, A, B, alpha);
}
} }
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) && (use_alpha == true) )
{ {
if(A.n_cols == 1) out.zeros();
{
gemv<false, true, false>::apply(out.memptr(), B, A.memptr(), alp
ha);
}
else
if(B.n_rows == 1)
{
gemv<true, true, false>::apply(out.memptr(), A, B.memptr(), alp
ha);
}
else
{
gemm<true, true, true, false>::apply(out, A, B, alpha);
}
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
glue_times::apply glue_times::apply
( (
Mat<eT>& out, Mat<eT>& out,
const Mat<eT>& A, const Mat<eT>& A,
skipping to change at line 607 skipping to change at line 610
typedef typename strip_diagmat<T1>::stored_type T1_stripped; typedef typename strip_diagmat<T1>::stored_type T1_stripped;
typedef typename strip_diagmat<T2>::stored_type T2_stripped; typedef typename strip_diagmat<T2>::stored_type T2_stripped;
if( (S1.do_diagmat == true) && (S2.do_diagmat == false) ) if( (S1.do_diagmat == true) && (S2.do_diagmat == false) )
{ {
const diagmat_proxy_check<T1_stripped> A(S1.M, out); const diagmat_proxy_check<T1_stripped> A(S1.M, out);
const unwrap_check<T2> tmp(X.B, out); const unwrap_check<T2> tmp(X.B, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_rows, B.n_cols, "mat rix multiply"); arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_rows, B.n_cols, "mat rix multiplication");
out.set_size(A.n_elem, B.n_cols); out.set_size(A.n_elem, B.n_cols);
for(u32 col=0; col<B.n_cols; ++col) for(u32 col=0; col<B.n_cols; ++col)
{ {
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
const eT* B_coldata = B.colptr(col); const eT* B_coldata = B.colptr(col);
for(u32 row=0; row<B.n_rows; ++row) for(u32 row=0; row<B.n_rows; ++row)
{ {
skipping to change at line 630 skipping to change at line 633
} }
} }
else else
if( (S1.do_diagmat == false) && (S2.do_diagmat == true) ) if( (S1.do_diagmat == false) && (S2.do_diagmat == true) )
{ {
const unwrap_check<T1> tmp(X.A, out); const unwrap_check<T1> tmp(X.A, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const diagmat_proxy_check<T2_stripped> B(S2.M, out); const diagmat_proxy_check<T2_stripped> B(S2.M, out);
arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_elem, B.n_elem, "mat rix multiply"); arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_elem, B.n_elem, "mat rix multiplication");
out.set_size(A.n_rows, B.n_elem); out.set_size(A.n_rows, B.n_elem);
for(u32 col=0; col<A.n_cols; ++col) for(u32 col=0; col<A.n_cols; ++col)
{ {
const eT val = B[col]; const eT val = B[col];
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
const eT* A_coldata = A.colptr(col); const eT* A_coldata = A.colptr(col);
skipping to change at line 653 skipping to change at line 656
out_coldata[row] = A_coldata[row] * val; out_coldata[row] = A_coldata[row] * val;
} }
} }
} }
else else
if( (S1.do_diagmat == true) && (S2.do_diagmat == true) ) if( (S1.do_diagmat == true) && (S2.do_diagmat == true) )
{ {
const diagmat_proxy_check<T1_stripped> A(S1.M, out); const diagmat_proxy_check<T1_stripped> A(S1.M, out);
const diagmat_proxy_check<T2_stripped> B(S2.M, out); const diagmat_proxy_check<T2_stripped> B(S2.M, out);
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "mat rix multiply"); arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "mat rix multiplication");
out.zeros(A.n_elem, A.n_elem); out.zeros(A.n_elem, A.n_elem);
for(u32 i=0; i<A.n_elem; ++i) for(u32 i=0; i<A.n_elem; ++i)
{ {
out.at(i,i) = A[i] * B[i]; out.at(i,i) = A[i] * B[i];
} }
} }
} }
 End of changes. 50 change blocks. 
283 lines changed or deleted 279 lines changed or added


 glue_toeplitz_meat.hpp   glue_toeplitz_meat.hpp 
skipping to change at line 78 skipping to change at line 78
arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), " toeplitz(): input arguments must be vectors" ); arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), " toeplitz(): input arguments must be vectors" );
const u32 A_N = A.n_elem; const u32 A_N = A.n_elem;
const u32 B_N = B.n_elem; const u32 B_N = B.n_elem;
const eT* A_mem = A.memptr(); const eT* A_mem = A.memptr();
const eT* B_mem = B.memptr(); const eT* B_mem = B.memptr();
out.set_size(A_N, B_N); out.set_size(A_N, B_N);
if( out.is_empty() )
{
return;
}
for(u32 col=0; col<B_N; ++col) for(u32 col=0; col<B_N; ++col)
{ {
eT* col_mem = out.colptr(col); eT* col_mem = out.colptr(col);
u32 i = 0; u32 i = 0;
for(u32 row=col; row<A_N; ++row, ++i) for(u32 row=col; row<A_N; ++row, ++i)
{ {
col_mem[row] = A_mem[i]; col_mem[row] = A_mem[i];
} }
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 5 lines changed or added


 op_cor_meat.hpp   op_cor_meat.hpp 
skipping to change at line 24 skipping to change at line 24
//! \addtogroup op_cor //! \addtogroup op_cor
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
op_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const u32 norm_type) op_cor::direct_cor(Mat<eT>& out, const Mat<eT>& A, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(A.is_empty())
{
out.reset();
return;
}
if(A.is_vec()) if(A.is_vec())
{ {
out.set_size(1,1); out.set_size(1,1);
out[0] = eT(1); out[0] = eT(1);
} }
else else
{ {
const u32 N = A.n_rows; const u32 N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
skipping to change at line 53 skipping to change at line 59
template<typename T> template<typename T>
inline inline
void void
op_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const u32 norm_type) op_cor::direct_cor(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(A.is_empty())
{
out.reset();
return;
}
if(A.is_vec()) if(A.is_vec())
{ {
out.set_size(1,1); out.set_size(1,1);
out[0] = eT(1); out[0] = eT(1);
} }
else else
{ {
const u32 N = A.n_rows; const u32 N = A.n_rows;
const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
 End of changes. 2 change blocks. 
0 lines changed or deleted 12 lines changed or added


 op_cumsum_meat.hpp   op_cumsum_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
void void
op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_mat>& in) op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_mat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "cumsum(): given matrix has no element
s" );
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or 1");
out.copy_size(X); out.copy_size(X);
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
skipping to change at line 90 skipping to change at line 88
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const u32 n_elem = X.n_elem; const u32 n_elem = X.n_elem;
arma_debug_check( (n_elem == 0), "cumsum(): given vector has no elements"
);
out.copy_size(X); out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.memptr(); const eT* X_mem = X.memptr();
eT acc = eT(0); eT acc = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
acc += X_mem[i]; acc += X_mem[i];
 End of changes. 3 change blocks. 
8 lines changed or deleted 2 lines changed or added


 op_diagmat_meat.hpp   op_diagmat_meat.hpp 
skipping to change at line 69 skipping to change at line 69
} }
} }
else else
{ {
// generate a diagonal matrix out of a matrix // generate a diagonal matrix out of a matrix
arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is not square" );
const u32 N = A.n_rows; const u32 N = A.n_rows;
out.set_size(N,N); out.zeros(N,N);
for(u32 col=0; col<N; ++col) for(u32 i=0; i<N; ++i)
{ {
for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); } out.at(i,i) = A.at(i,i);
out.at(col,col) = A.at(col,col);
for(u32 row=col+1; row<N; ++row) { out.at(row,col) = eT(0); }
} }
} }
} }
//! @} //! @}
 End of changes. 3 change blocks. 
7 lines changed or deleted 3 lines changed or added


 op_htrans_meat.hpp   op_htrans_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_htrans //! \addtogroup op_htrans
//! @{ //! @{
//! Immediate transpose of a complex matrix template<typename eT>
template<typename T> arma_inline
void
op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm
a_not_cx<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
op_strans::apply_noalias(out, A);
}
template<typename eT>
inline inline
void void
op_htrans::apply_noalias(Mat< std::complex<T> >& out, const Mat< std::compl ex<T> >& A) op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_cx_only<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
const u32 A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols;
out.set_size(A.n_cols, A.n_rows); out.set_size(A_n_cols, A_n_rows);
for(u32 in_row = 0; in_row<A.n_rows; ++in_row) for(u32 in_row = 0; in_row < A_n_rows; ++in_row)
{ {
const u32 out_col = in_row; const u32 out_col = in_row;
for(u32 in_col = 0; in_col<A.n_cols; ++in_col) for(u32 in_col = 0; in_col < A_n_cols; ++in_col)
{ {
const u32 out_row = in_col; const u32 out_row = in_col;
out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) ); out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) );
} }
} }
} }
//! Immediate transpose of a complex matrix template<typename eT>
template<typename T> arma_inline
inline
void void
op_htrans::apply(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A) op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx <eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename std::complex<T> eT; op_strans::apply(out, A);
}
template<typename eT>
inline
void
op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_onl
y<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
if(&out != &A) if(&out != &A)
{ {
op_htrans::apply_noalias(out, A); op_htrans::apply_noalias(out, A);
} }
else else
{ {
if(out.n_rows == out.n_cols) if(out.n_rows == out.n_cols)
{ {
arma_extra_debug_print("doing in-place hermitian transpose of a squar e matrix"); arma_extra_debug_print("doing in-place hermitian transpose of a squar e matrix");
skipping to change at line 87 skipping to change at line 110
} }
else else
{ {
const Mat<eT> A_copy = A; const Mat<eT> A_copy = A;
op_htrans::apply_noalias(out, A_copy); op_htrans::apply_noalias(out, A_copy);
} }
} }
} }
template<typename T, typename T1> template<typename T1>
inline inline
void void
op_htrans::apply(Mat< std::complex<T> >& out, const Op<T1,op_htrans>& in) op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename T1::elem_type eT;
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;
op_htrans::apply(out, A); op_htrans::apply(out, A);
} }
template<typename T1>
inline
void
op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trim
at>, op_htrans>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m.m);
const Mat<eT>& A = tmp.M;
const bool upper = in.m.aux_u32_a;
op_trimat::apply_htrans(out, A, upper);
}
template<typename T1>
inline
void
op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2>
& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
op_htrans::apply(out, tmp.M);
arrayops::inplace_mul( out.memptr(), in.aux, out.n_elem );
}
//! @} //! @}
 End of changes. 15 change blocks. 
18 lines changed or deleted 76 lines changed or added


 op_inv_meat.hpp   op_inv_meat.hpp 
skipping to change at line 90 skipping to change at line 90
template<typename T1> template<typename T1>
inline inline
void void
op_inv_tr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_tr>& X) op_inv_tr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_tr>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
auxlib::inv_tr(out, X.m, X.aux_u32_a); auxlib::inv_tr(out, X.m, X.aux_u32_a);
} }
//! inverse of T1 (symmetric matrices)
template<typename T1>
inline
void
op_inv_sym::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_sym>
& X)
{
arma_extra_debug_sigprint();
auxlib::inv_sym(out, X.m, X.aux_u32_a);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 12 lines changed or added


 op_max_meat.hpp   op_max_meat.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_max //! \addtogroup op_max
//! @{ //! @{
//! find the maximum value in an array
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_max::direct_max(const eT* const X, const u32 n_elem) op_max::direct_max(const eT* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = (n_elem != 1) ? priv::most_neg<eT>() : X[0]; eT max_val = (n_elem != 1) ? priv::most_neg<eT>() : X[0];
skipping to change at line 129 skipping to change at line 128
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
} }
//! find the maximum value in a subview
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const subview<eT>& X) op_max::direct_max(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
eT max_val = (X_n_elem != 1) ? priv::most_neg<eT>() : X[0];
eT max_val = (X_n_elem != 1) ? priv::most_neg<eT>() : X[0];
for(u32 i=0; i<X_n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
return max_val; return max_val;
} }
//! find the maximum value in a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const diagview<eT>& X) op_max::direct_max(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
eT max_val = (X_n_elem != 1) ? priv::most_neg<eT>() : X[0];
eT max_val = (X_n_elem != 1) ? priv::most_neg<eT>() : X[0];
for(u32 i=0; i<X_n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
eT tmp_val = X[i]; eT tmp_val = X[i];
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
} }
} }
skipping to change at line 193 skipping to change at line 192
void void
op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in) op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements"
);
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_max::apply(), dim = 0"); arma_extra_debug_print("op_max::apply(), dim = 0");
out.set_size(1, X_n_cols); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out[col] = op_max::direct_max( X.colptr(col), X_n_rows ); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col)
{
out_mem[col] = op_max::direct_max( X.colptr(col), X_n_rows );
}
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_max::apply(), dim = 1"); arma_extra_debug_print("op_max::apply(), dim = 1");
out.set_size(X_n_rows, 1); out.set_size( X_n_rows, (X_n_cols > 0) ? 1 : 0 );
for(u32 row=0; row<X_n_rows; ++row) if(X_n_cols > 0)
{ {
out[row] = op_max::direct_max( X, row ); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row)
{
out_mem[row] = op_max::direct_max( X, row );
}
} }
} }
} }
//! Find the maximum value in an array (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const std::complex<T>* const X, const u32 n_elem) op_max::direct_max(const std::complex<T>* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; u32 index = 0;
T max_val = (n_elem != 1) ? priv::most_neg<T>() : std::abs(X[0]); T max_val = (n_elem != 1) ? priv::most_neg<T>() : std::abs(X[0]);
skipping to change at line 303 skipping to change at line 309
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = col; index = col;
} }
} }
return X.at(row,index); return X.at(row,index);
} }
//! Find the maximum value in a subview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const subview< std::complex<T> >& X) op_max::direct_max(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
u32 index = 0;
T max_val = (X_n_elem != 1) ? priv::most_neg<T>() : std::abs(X[0 u32 index = 0;
]); T max_val = (X_n_elem != 1) ? priv::most_neg<T>() : std::abs(X[0]);
for(u32 i=0; i<X_n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
} }
return X[index]; return X[index];
} }
//! Find the maximum value in a diagview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const diagview< std::complex<T> >& X) op_max::direct_max(const diagview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
u32 index = 0;
T max_val = (X_n_elem != 1) ? priv::most_neg<T>() : std::abs(X[0 u32 index = 0;
]); T max_val = (X_n_elem != 1) ? priv::most_neg<T>() : std::abs(X[0]);
for(u32 i=0; i<X_n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val > max_val) if(tmp_val > max_val)
{ {
max_val = tmp_val; max_val = tmp_val;
index = i; index = i;
} }
 End of changes. 17 change blocks. 
23 lines changed or deleted 26 lines changed or added


 op_mean_meat.hpp   op_mean_meat.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_mean //! \addtogroup op_mean
//! @{ //! @{
//! find the mean value of an array
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_mean::direct_mean(const eT* const X, const u32 n_elem) op_mean::direct_mean(const eT* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
skipping to change at line 55 skipping to change at line 54
for(u32 col=0; col<X_n_cols; ++col) for(u32 col=0; col<X_n_cols; ++col)
{ {
val += X.at(row,col); val += X.at(row,col);
} }
const eT result = val / T(X_n_cols); const eT result = val / T(X_n_cols);
return arma_isfinite(result) ? result : direct_mean_robust(X, row); return arma_isfinite(result) ? result : direct_mean_robust(X, row);
} }
//! find the mean value of a subview
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const subview<eT>& X) op_mean::direct_mean(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
eT val = eT(0);
eT val = eT(0);
for(u32 i=0; i<X_n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
const eT result = val / T(X_n_elem); const eT result = val / T(X_n_elem);
return arma_isfinite(result) ? result : direct_mean_robust(X); return arma_isfinite(result) ? result : direct_mean_robust(X);
} }
//! find the mean value of a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const diagview<eT>& X) op_mean::direct_mean(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
eT val = eT(0);
eT val = eT(0);
for(u32 i=0; i<X_n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
val += X[i]; val += X[i];
} }
const eT result = val / T(X_n_elem); const eT result = val / T(X_n_elem);
return arma_isfinite(result) ? result : direct_mean_robust(X); return arma_isfinite(result) ? result : direct_mean_robust(X);
} }
skipping to change at line 118 skipping to change at line 117
op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in) op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements"
);
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1 "); arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1 ");
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 0"); arma_extra_debug_print("op_mean::apply(), dim = 0");
out.set_size(1, X_n_cols); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out[col] = op_mean::direct_mean( X.colptr(col), X_n_rows ); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col)
{
out_mem[col] = op_mean::direct_mean( X.colptr(col), X_n_rows );
}
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 1"); arma_extra_debug_print("op_mean::apply(), dim = 1");
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
for(u32 row=0; row<X_n_rows; ++row) if(X_n_cols > 0)
{ {
out[row] = op_mean::direct_mean( X, row ); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row)
{
out_mem[row] = op_mean::direct_mean( X, row );
}
} }
} }
} }
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_mean::direct_mean_robust(const eT* const X, const u32 n_elem) op_mean::direct_mean_robust(const eT* const X, const u32 n_elem)
{ {
 End of changes. 12 change blocks. 
14 lines changed or deleted 20 lines changed or added


 op_median_meat.hpp   op_median_meat.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_median //! \addtogroup op_median
//! @{ //! @{
template<typename eT>
arma_inline
eT
op_median::robust_mean(const eT A, const eT B)
{
return A + (B - A)/eT(2);
}
//! find the median value of a std::vector (contents is modified) //! find the median value of a std::vector (contents is modified)
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(std::vector<eT>& X) op_median::direct_median(std::vector<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::sort(X.begin(), X.end());
const u32 n_elem = X.size(); const u32 n_elem = X.size();
const u32 half = n_elem/2; const u32 half = n_elem/2;
std::sort(X.begin(), X.end());
if((n_elem % 2) == 0) if((n_elem % 2) == 0)
{ {
return (X[half-1] + X[half]) / eT(2); return op_median::robust_mean(X[half-1], X[half]);
} }
else else
{ {
return X[half]; return X[half];
} }
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(const eT* X, const u32 n_elem) op_median::direct_median(const eT* X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector<eT> tmp(X, X+n_elem); std::vector<eT> tmp(X, X+n_elem);
return op_median::direct_median(tmp); return op_median::direct_median(tmp);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(const subview<eT>& X) op_median::direct_median(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector<eT> tmp(X.n_elem); const u32 X_n_elem = X.n_elem;
for(u32 i=0; i<X.n_elem; ++i) std::vector<eT> tmp(X_n_elem);
for(u32 i=0; i<X_n_elem; ++i)
{ {
tmp[i] = X[i]; tmp[i] = X[i];
} }
return op_median::direct_median(tmp); return op_median::direct_median(tmp);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_median::direct_median(const diagview<eT>& X) op_median::direct_median(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector<eT> tmp(X.n_elem); const u32 X_n_elem = X.n_elem;
std::vector<eT> tmp(X_n_elem);
for(u32 i=0; i<X.n_elem; ++i) for(u32 i=0; i<X_n_elem; ++i)
{ {
tmp[i] = X[i]; tmp[i] = X[i];
} }
return op_median::direct_median(tmp); return op_median::direct_median(tmp);
} }
//! \brief //! \brief
//! For each row or for each column, find the median value. //! For each row or for each column, find the median value.
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
skipping to change at line 98 skipping to change at line 111
template<typename T1> template<typename T1>
inline inline
void void
op_median::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in) op_median::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "median(): given matrix has no element const u32 X_n_rows = X.n_rows;
s" ); const u32 X_n_cols = X.n_cols;
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // column-wise if(dim == 0) // in each column
{ {
arma_extra_debug_print("op_median::apply(), dim = 0"); arma_extra_debug_print("op_median::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size((X_n_rows > 0) ? 1 : 0, X_n_cols);
std::vector<eT> tmp_vec(X.n_rows);
for(u32 col=0; col<X.n_cols; ++col) if(X_n_rows > 0)
{ {
const eT* colmem = X.colptr(col); std::vector<eT> tmp_vec(X_n_rows);
for(u32 row=0; row<X.n_rows; ++row) for(u32 col=0; col<X_n_cols; ++col)
{ {
tmp_vec[row] = colmem[row]; const eT* colmem = X.colptr(col);
}
for(u32 row=0; row<X_n_rows; ++row)
{
tmp_vec[row] = colmem[row];
}
out[col] = op_median::direct_median(tmp_vec); out[col] = op_median::direct_median(tmp_vec);
}
} }
} }
else else
if(dim == 1) // row-wise if(dim == 1) // in each row
{ {
arma_extra_debug_print("op_median::apply(), dim = 1"); arma_extra_debug_print("op_median::apply(), dim = 1");
out.set_size(X.n_rows, 1); out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
std::vector<eT> tmp_vec(X.n_cols);
for(u32 row=0; row<X.n_rows; ++row) if(X_n_cols > 0)
{ {
for(u32 col=0; col<X.n_cols; ++col) std::vector<eT> tmp_vec(X_n_cols);
for(u32 row=0; row<X_n_rows; ++row)
{ {
tmp_vec[col] = X.at(row,col); for(u32 col=0; col<X_n_cols; ++col)
} {
tmp_vec[col] = X.at(row,col);
}
out[row] = op_median::direct_median(tmp_vec); out[row] = op_median::direct_median(tmp_vec);
}
} }
} }
}
template<typename T>
arma_inline
std::complex<T>
op_median::robust_mean(const std::complex<T>& A, const std::complex<T>& B)
{
return A + (B - A)/T(2);
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index(u32& out_index1, u32& out_index2, std::ve op_median::direct_cx_median_index
ctor< arma_cx_median_packet<T> >& X) (
u32& out_index1,
u32& out_index2,
std::vector< arma_cx_median_packet<T> >& X
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::sort(X.begin(), X.end());
const u32 n_elem = X.size(); const u32 n_elem = X.size();
const u32 half = n_elem/2; const u32 half = n_elem/2;
std::sort(X.begin(), X.end());
if((n_elem % 2) == 0) if((n_elem % 2) == 0)
{ {
out_index1 = X[half-1].index; out_index1 = X[half-1].index;
out_index2 = X[half].index; out_index2 = X[half ].index;
} }
else else
{ {
out_index1 = X[half].index; out_index1 = X[half].index;
out_index2 = X[half].index; out_index2 = out_index1;
} }
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index(u32& out_index1, u32& out_index2, const s op_median::direct_cx_median_index
td::complex<T>* X, const u32 n_elem) (
u32& out_index1,
u32& out_index2,
const std::complex<T>* X,
const u32 n_elem
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector< arma_cx_median_packet<T> > tmp(n_elem); std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
tmp[i].val = std::abs(X[i]); tmp[i].val = std::abs(X[i]);
tmp[i].index = i; tmp[i].index = i;
} }
op_median::direct_cx_median_index(out_index1, out_index2, tmp); op_median::direct_cx_median_index(out_index1, out_index2, tmp);
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index(u32& out_index1, u32& out_index2, const s op_median::direct_cx_median_index
ubview< std::complex<T> >&X) (
u32& out_index1,
u32& out_index2,
const subview< std::complex<T> >&X
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const u32 n_elem = X.n_elem;
std::vector< arma_cx_median_packet<T> > tmp(n_elem); std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
tmp[i].val = std::abs(X[i]); tmp[i].val = std::abs(X[i]);
tmp[i].index = i; tmp[i].index = i;
} }
op_median::direct_cx_median_index(out_index1, out_index2, tmp); op_median::direct_cx_median_index(out_index1, out_index2, tmp);
} }
template<typename T> template<typename T>
inline inline
void void
op_median::direct_cx_median_index(u32& out_index1, u32& out_index2, const d op_median::direct_cx_median_index
iagview< std::complex<T> >&X) (
u32& out_index1,
u32& out_index2,
const diagview< std::complex<T> >&X
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 n_elem = X.n_elem; const u32 n_elem = X.n_elem;
std::vector< arma_cx_median_packet<T> > tmp(n_elem); std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
tmp[i].val = std::abs(X[i]); tmp[i].val = std::abs(X[i]);
skipping to change at line 239 skipping to change at line 286
//! Implementation for complex numbers //! Implementation for complex numbers
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_median::apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in) op_median::apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check();
arma_type_check< is_same_type<eT, typename T1::elem_type>::value == false
>::apply();
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "median(): given matrix has no element const u32 X_n_rows = X.n_rows;
s" ); const u32 X_n_cols = X.n_cols;
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "median(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // column-wise if(dim == 0) // in each column
{ {
arma_extra_debug_print("op_median::apply(), dim = 0"); arma_extra_debug_print("op_median::apply(), dim = 0");
out.set_size(1, X.n_cols); out.set_size((X_n_rows > 0) ? 1 : 0, X_n_cols);
std::vector< arma_cx_median_packet<T> > tmp_vec(X.n_rows);
for(u32 col=0; col<X.n_cols; ++col) if(X_n_rows > 0)
{ {
const eT* colmem = X.colptr(col); std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_rows);
for(u32 row=0; row<X.n_rows; ++row) for(u32 col=0; col<X_n_cols; ++col)
{ {
tmp_vec[row].val = std::abs(colmem[row]); const eT* colmem = X.colptr(col);
tmp_vec[row].index = row;
}
u32 index1; for(u32 row=0; row<X_n_rows; ++row)
u32 index2; {
op_median::direct_cx_median_index(index1, index2, tmp_vec); tmp_vec[row].val = std::abs(colmem[row]);
tmp_vec[row].index = row;
}
u32 index1;
u32 index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[col] = (colmem[index1] + colmem[index2]) / T(2); out[col] = op_median::robust_mean(colmem[index1], colmem[index2]);
}
} }
} }
else else
if(dim == 1) // row-wise if(dim == 1) // in each row
{ {
arma_extra_debug_print("op_median::apply(), dim = 1"); arma_extra_debug_print("op_median::apply(), dim = 1");
out.set_size(X.n_rows, 1); out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
std::vector< arma_cx_median_packet<T> > tmp_vec(X.n_cols);
for(u32 row=0; row<X.n_rows; ++row) if(X_n_cols > 0)
{ {
for(u32 col=0; col<X.n_cols; ++col) std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_cols);
for(u32 row=0; row<X_n_rows; ++row)
{ {
tmp_vec[col].val = std::abs(X.at(row,col)); for(u32 col=0; col<X_n_cols; ++col)
tmp_vec[row].index = col; {
tmp_vec[col].val = std::abs(X.at(row,col));
tmp_vec[row].index = col;
}
if(X_n_cols > 0)
{
u32 index1;
u32 index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[row] = op_median::robust_mean( X.at(row,index1), X.at(row,ind
ex2) );
}
else
{
out[row] = eT(0);
}
} }
u32 index1;
u32 index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[row] = ( X.at(row,index1) + X.at(row,index2) ) / T(2);
} }
} }
} }
//! @} //! @}
 End of changes. 54 change blocks. 
77 lines changed or deleted 134 lines changed or added


 op_min_meat.hpp   op_min_meat.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_min //! \addtogroup op_min
//! @{ //! @{
//! Find the minimum value in an array
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_min::direct_min(const eT* const X, const u32 n_elem) op_min::direct_min(const eT* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = (n_elem != 1) ? priv::most_pos<eT>() : X[0]; eT min_val = (n_elem != 1) ? priv::most_pos<eT>() : X[0];
skipping to change at line 129 skipping to change at line 128
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
} }
//! find the minimum value in a subview
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const subview<eT>& X) op_min::direct_min(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
eT min_val = (X_n_elem != 1) ? priv::most_pos<eT>() : X[0]; eT min_val = (X_n_elem != 1) ? priv::most_pos<eT>() : X[0];
skipping to change at line 154 skipping to change at line 152
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
} }
} }
return min_val; return min_val;
} }
//! find the minimum value in a diagview
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const diagview<eT>& X) op_min::direct_min(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
eT min_val = (X_n_elem != 1) ? priv::most_pos<eT>() : X[0]; eT min_val = (X_n_elem != 1) ? priv::most_pos<eT>() : X[0];
skipping to change at line 191 skipping to change at line 188
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! The dimension, for which the minima are found, is set via the min() fun ction. //! The dimension, for which the minima are found, is set via the min() fun ction.
template<typename T1> template<typename T1>
inline void op_min::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ min>& in) inline void op_min::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements"
);
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) // min in each column if(dim == 0) // min in each column
{ {
arma_extra_debug_print("op_min::apply(), dim = 0"); arma_extra_debug_print("op_min::apply(), dim = 0");
out.set_size(1, X_n_cols); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out[col] = op_min::direct_min( X.colptr(col), X_n_rows ); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col)
{
out_mem[col] = op_min::direct_min( X.colptr(col), X_n_rows );
}
} }
} }
else else
if(dim == 1) // min in each row if(dim == 1) // min in each row
{ {
arma_extra_debug_print("op_min::apply(), dim = 1"); arma_extra_debug_print("op_min::apply(), dim = 1");
out.set_size(X_n_rows, 1); out.set_size( X_n_rows, (X_n_cols > 0) ? 1 : 0 );
for(u32 row=0; row<X_n_rows; ++row) if(X_n_cols > 0)
{ {
out[row] = op_min::direct_min( X, row ); eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row)
{
out_mem[row] = op_min::direct_min( X, row );
}
} }
} }
} }
//! Find the minimum value in an array (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const std::complex<T>* const X, const u32 n_elem) op_min::direct_min(const std::complex<T>* const X, const u32 n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 index = 0; u32 index = 0;
T min_val = (n_elem != 1) ? priv::most_pos<T>() : std::abs(X[0]); T min_val = (n_elem != 1) ? priv::most_pos<T>() : std::abs(X[0]);
skipping to change at line 303 skipping to change at line 307
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = col; index = col;
} }
} }
return X.at(row,index); return X.at(row,index);
} }
//! Find the minimum value in a subview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const subview< std::complex<T> >& X) op_min::direct_min(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
u32 index = 0; u32 index = 0;
T min_val = (X_n_elem != 1) ? priv::most_pos<T>() : std::abs(X[0 ]); T min_val = (X_n_elem != 1) ? priv::most_pos<T>() : std::abs(X[0 ]);
skipping to change at line 329 skipping to change at line 332
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
} }
return X[index]; return X[index];
} }
//! Find the minimum value in a diagview (version for complex numbers)
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const diagview< std::complex<T> >& X) op_min::direct_min(const diagview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 X_n_elem = X.n_elem; const u32 X_n_elem = X.n_elem;
u32 index = 0; u32 index = 0;
T min_val = (X_n_elem != 1) ? priv::most_pos<T>() : std::abs(X[0 ]); T min_val = (X_n_elem != 1) ? priv::most_pos<T>() : std::abs(X[0 ]);
 End of changes. 13 change blocks. 
16 lines changed or deleted 17 lines changed or added


 op_pinv_meat.hpp   op_pinv_meat.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 103 skipping to change at line 103
const u32 n_rows = A.n_rows; const u32 n_rows = A.n_rows;
const u32 n_cols = A.n_cols; const u32 n_cols = A.n_cols;
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
// SVD decomposition // SVD decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
Mat<eT> V; Mat<eT> V;
const bool status = (n_cols > n_rows) ? svd(U,s,V,htrans(A)) : svd(U,s,V, A); const bool status = (n_cols > n_rows) ? svd(U,s,V,trans(A)) : svd(U,s,V,A );
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
return; return;
} }
// set tolerance to default if it hasn't been specified as an argument // set tolerance to default if it hasn't been specified as an argument
if(tol == T(0)) if(tol == T(0))
{ {
skipping to change at line 144 skipping to change at line 144
{ {
// s = s.rows(0,count-1); // s = s.rows(0,count-1);
s.shed_rows(count, s_n_rows-1); s.shed_rows(count, s_n_rows-1);
} }
// set the elements of s equal to their reciprocals // set the elements of s equal to their reciprocals
s = T(1) / s; s = T(1) / s;
if(n_rows >= n_cols) if(n_rows >= n_cols)
{ {
out = ( V.n_cols > count ? V.cols(0,count-1) : V ) * diagmat(s) * htr ans( U.n_cols > count ? U.cols(0,count-1) : U ); out = ( V.n_cols > count ? V.cols(0,count-1) : V ) * diagmat(s) * tra ns( U.n_cols > count ? U.cols(0,count-1) : U );
} }
else else
{ {
out = ( U.n_cols > count ? U.cols(0,count-1) : U ) * diagmat(s) * htr ans( V.n_cols > count ? V.cols(0,count-1) : V ); out = ( U.n_cols > count ? U.cols(0,count-1) : U ) * diagmat(s) * tra ns( V.n_cols > count ? V.cols(0,count-1) : V );
} }
} }
else else
{ {
out.zeros(n_cols, n_rows); out.zeros(n_cols, n_rows);
} }
} }
template<typename T1> template<typename T1>
inline inline
 End of changes. 4 change blocks. 
5 lines changed or deleted 5 lines changed or added


 op_prod_meat.hpp   op_prod_meat.hpp 
skipping to change at line 35 skipping to change at line 35
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "prod(): incorrect usage. dim must be 0 or 1 "); arma_debug_check( (dim > 1), "prod(): incorrect usage. dim must be 0 or 1 ");
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem < 1), "prod(): give object has no elements");
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the product in each colu mn) if(dim == 0) // traverse across rows (i.e. find the product in each colu mn)
{ {
out.set_size(1, X_n_cols); out.set_size((X_n_rows > 0) ? 1 : 0, X_n_cols);
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out.at(0,col) = arrayops::product(X.colptr(col), X_n_rows); eT* out_mem = out.memptr();
for(u32 col=0; col < X_n_cols; ++col)
{
out_mem[col] = arrayops::product(X.colptr(col), X_n_rows);
}
} }
} }
else // traverse across columns (i.e. find the product in each row) else // traverse across columns (i.e. find the product in each row)
{ {
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
for(u32 row=0; row < X_n_rows; ++row) if(X_n_cols > 0)
{ {
eT val = X.at(row,0); eT* out_mem = out.memptr();
for(u32 col=1; col < X_n_cols; ++col) for(u32 row=0; row < X_n_rows; ++row)
{ {
val *= X.at(row,col); eT val = X.at(row,0);
}
out.at(row,0) = val; for(u32 col=1; col < X_n_cols; ++col)
} {
val *= X.at(row,col);
}
out_mem[row] = val;
}
}
} }
} }
//! @} //! @}
 End of changes. 12 change blocks. 
14 lines changed or deleted 20 lines changed or added


 op_repmat_meat.hpp   op_repmat_meat.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 31 skipping to change at line 31
void void
op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>& in) op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "op_repmat::apply(): given object has
no elements" );
const u32 copies_per_row = in.aux_u32_a; const u32 copies_per_row = in.aux_u32_a;
const u32 copies_per_col = in.aux_u32_b; const u32 copies_per_col = in.aux_u32_b;
out.set_size(X.n_rows * copies_per_row, X.n_cols * copies_per_col); const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols;
out.set_size(X_n_rows * copies_per_row, X_n_cols * copies_per_col);
const u32 out_n_rows = out.n_rows;
const u32 out_n_cols = out.n_cols;
for(u32 col = 0; col < out.n_cols; col += X.n_cols) if( (out_n_rows > 0) && (out_n_cols > 0) )
{ {
for(u32 row = 0; row < out.n_rows; row += X.n_rows) for(u32 col = 0; col < out_n_cols; col += X_n_cols)
{ {
out.submat(row, col, row+X.n_rows-1, col+X.n_cols-1) = X; for(u32 row = 0; row < out_n_rows; row += X_n_rows)
{
out.submat(row, col, row+X_n_rows-1, col+X_n_cols-1) = X;
}
} }
} }
} }
//! @} //! @}
 End of changes. 6 change blocks. 
9 lines changed or deleted 15 lines changed or added


 op_reshape_meat.hpp   op_reshape_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 69 skipping to change at line 69
else else
{ {
unwrap_check< Mat<eT> > tmp(A, out); unwrap_check< Mat<eT> > tmp(A, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i = 0; u32 i = 0;
for(u32 row=0; row<B.n_rows; ++row) const u32 B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols;
for(u32 row=0; row<B_n_rows; ++row)
{ {
for(u32 col=0; col<B.n_cols; ++col) for(u32 col=0; col<B_n_cols; ++col)
{ {
out_mem[i] = B.at(row,col); out_mem[i] = B.at(row,col);
++i; ++i;
} }
} }
} }
} }
else else
{ {
skipping to change at line 100 skipping to change at line 103
if(in.aux == eT(0)) if(in.aux == eT(0))
{ {
arrayops::copy( out_mem, B.memptr(), n_elem_to_copy ); arrayops::copy( out_mem, B.memptr(), n_elem_to_copy );
} }
else else
{ {
u32 row = 0; u32 row = 0;
u32 col = 0; u32 col = 0;
const u32 B_n_cols = B.n_cols;
for(u32 i=0; i<n_elem_to_copy; ++i) for(u32 i=0; i<n_elem_to_copy; ++i)
{ {
out_mem[i] = B.at(row,col); out_mem[i] = B.at(row,col);
++col; ++col;
if(col >= B.n_cols) if(col >= B_n_cols)
{ {
col = 0; col = 0;
++row; ++row;
} }
} }
} }
for(u32 i=n_elem_to_copy; i<in_n_elem; ++i) for(u32 i=n_elem_to_copy; i<in_n_elem; ++i)
{ {
out_mem[i] = eT(0); out_mem[i] = eT(0);
skipping to change at line 182 skipping to change at line 187
else else
{ {
unwrap_cube_check< Cube<eT> > tmp(A, out); unwrap_cube_check< Cube<eT> > tmp(A, out);
const Cube<eT>& B = tmp.M; const Cube<eT>& B = tmp.M;
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
u32 i = 0; u32 i = 0;
for(u32 slice=0; slice<B.n_slices; ++slice) const u32 B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols;
const u32 B_n_slices = B.n_slices;
for(u32 slice=0; slice<B_n_slices; ++slice)
{ {
for(u32 row=0; row<B.n_rows; ++row) for(u32 row=0; row<B_n_rows; ++row)
{ {
for(u32 col=0; col<B.n_cols; ++col) for(u32 col=0; col<B_n_cols; ++col)
{ {
out_mem[i] = B.at(row,col,slice); out_mem[i] = B.at(row,col,slice);
++i; ++i;
} }
} }
} }
} }
} }
else else
skipping to change at line 217 skipping to change at line 226
if(in.aux == eT(0)) if(in.aux == eT(0))
{ {
arrayops::copy( out_mem, B.memptr(), n_elem_to_copy ); arrayops::copy( out_mem, B.memptr(), n_elem_to_copy );
} }
else else
{ {
u32 row = 0; u32 row = 0;
u32 col = 0; u32 col = 0;
u32 slice = 0; u32 slice = 0;
const u32 B_n_rows = B.n_rows;
const u32 B_n_cols = B.n_cols;
for(u32 i=0; i<n_elem_to_copy; ++i) for(u32 i=0; i<n_elem_to_copy; ++i)
{ {
out_mem[i] = B.at(row,col,slice); out_mem[i] = B.at(row,col,slice);
++col; ++col;
if(col >= B.n_cols) if(col >= B_n_cols)
{ {
col = 0; col = 0;
++row; ++row;
if(row >= B.n_rows) if(row >= B_n_rows)
{ {
row = 0; row = 0;
++slice; ++slice;
} }
} }
} }
} }
for(u32 i=n_elem_to_copy; i<in_n_elem; ++i) for(u32 i=n_elem_to_copy; i<in_n_elem; ++i)
{ {
 End of changes. 11 change blocks. 
10 lines changed or deleted 22 lines changed or added


 op_shuffle_meat.hpp   op_shuffle_meat.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 29 skipping to change at line 29
void void
op_shuffle::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_shuffle> & in) op_shuffle::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_shuffle> & 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;
if(X.is_empty())
{
out.copy_size(X);
return;
}
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
const u32 N = (dim == 0) ? X.n_rows : X.n_cols; const u32 N = (dim == 0) ? X.n_rows : X.n_cols;
// see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet_ ascend" // see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet_ ascend"
// and the associated "operator<" // and the associated "operator<"
std::vector< arma_sort_index_packet_ascend<int,u32> > packet_vec(N); std::vector< arma_sort_index_packet_ascend<int,u32> > packet_vec(N);
for(u32 i=0; i<N; ++i) for(u32 i=0; i<N; ++i)
{ {
packet_vec[i].val = std::rand(); packet_vec[i].val = std::rand();
 End of changes. 2 change blocks. 
2 lines changed or deleted 8 lines changed or added


 op_stddev_meat.hpp   op_stddev_meat.hpp 
skipping to change at line 36 skipping to change at line 36
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
typedef typename T1::pod_type out_eT; typedef typename T1::pod_type out_eT;
const unwrap_check_mixed<T1> tmp(in.m, out); const unwrap_check_mixed<T1> tmp(in.m, out);
const Mat<in_eT>& X = tmp.M; const Mat<in_eT>& X = tmp.M;
const u32 norm_type = in.aux_u32_a; const u32 norm_type = in.aux_u32_a;
const u32 dim = in.aux_u32_b; const u32 dim = in.aux_u32_b;
arma_debug_check( (X.n_elem == 0), "stddev(): given matrix has no element s" );
arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type must be 0 or 1"); arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type must be 0 or 1");
arma_debug_check( (dim > 1), "stddev(): incorrect usage. dim must b e 0 or 1" ); arma_debug_check( (dim > 1), "stddev(): incorrect usage. dim must b e 0 or 1" );
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 0"); arma_extra_debug_print("op_stddev::apply(), dim = 0");
out.set_size(1, X_n_cols); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out[col] = std::sqrt( op_var::direct_var( X.colptr(col), X_n_rows, no out_eT* out_mem = out.memptr();
rm_type ) );
for(u32 col=0; col<X_n_cols; ++col)
{
out_mem[col] = std::sqrt( op_var::direct_var( X.colptr(col), X_n_ro
ws, norm_type ) );
}
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 1"); arma_extra_debug_print("op_stddev::apply(), dim = 1");
out.set_size(X_n_rows, 1); out.set_size( X_n_rows, (X_n_cols > 0) ? 1 : 0 );
podarray<in_eT> tmp(X_n_cols); if(X_n_cols > 0)
{
podarray<in_eT> tmp(X_n_cols);
in_eT* tmp_mem = tmp.memptr(); in_eT* tmp_mem = tmp.memptr();
out_eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(u32 row=0; row<X_n_rows; ++row)
{
for(u32 col=0; col<X_n_cols; ++col)
{ {
tmp_mem[col] = X.at(row,col); tmp.copy_row(X, row);
}
out[row] = std::sqrt( op_var::direct_var(tmp_mem, X_n_cols, norm_type out_mem[row] = std::sqrt( op_var::direct_var( tmp_mem, X_n_cols, no
) ); rm_type) );
}
} }
} }
} }
//! @} //! @}
 End of changes. 10 change blocks. 
15 lines changed or deleted 20 lines changed or added


 op_sum_meat.hpp   op_sum_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 35 skipping to change at line 35
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 dim = in.aux_u32_a; const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" );
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem < 1), "sum(): given object has no elements");
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the sum in each column) if(dim == 0) // traverse across rows (i.e. find the sum in each column)
{ {
out.set_size(1, X_n_cols); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out.at(0,col) = arrayops::accumulate( X.colptr(col), X_n_rows ); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col)
{
out_mem[col] = arrayops::accumulate( X.colptr(col), X_n_rows );
}
} }
} }
else // traverse across columns (i.e. find the sum in each row) else // traverse across columns (i.e. find the sum in each row)
{ {
out.set_size(X_n_rows, 1); out.set_size( X_n_rows, (X_n_cols > 0) ? 1 : 0 );
for(u32 row=0; row<X_n_rows; ++row) if(X_n_cols > 0)
{ {
eT val = eT(0); eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col) for(u32 row=0; row<X_n_rows; ++row)
{ {
val += X.at(row,col); eT val = eT(0);
}
out.at(row,0) = val; for(u32 col=0; col<X_n_cols; ++col)
} {
val += X.at(row,col);
}
out_mem[row] = val;
}
}
} }
} }
//! @} //! @}
 End of changes. 13 change blocks. 
16 lines changed or deleted 22 lines changed or added


 op_trimat_meat.hpp   op_trimat_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// Copyright (C) 2011 Ryan Curtin
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_trimat //! \addtogroup op_trimat
//! @{ //! @{
template<typename eT>
inline
void
op_trimat::fill_zeros(Mat<eT>& out, const bool upper)
{
arma_extra_debug_sigprint();
const u32 N = out.n_rows;
if(upper)
{
// upper triangular: set all elements below the diagonal to zero
for(u32 i=0; i<N; ++i)
{
eT* data = out.colptr(i);
arrayops::inplace_set( &data[i+1], eT(0), (N-(i+1)) );
}
}
else
{
// lower triangular: set all elements above the diagonal to zero
for(u32 i=1; i<N; ++i)
{
eT* data = out.colptr(i);
arrayops::inplace_set( data, eT(0), i );
}
}
}
template<typename T1> template<typename T1>
inline inline
void void
op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimat>& in) op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( ((A.n_elem > 0) && (A.is_square() == false)), "trimatu( )/trimatl(): given matrix must be square" ); arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" );
const u32 N = A.n_rows; const u32 N = A.n_rows;
const bool upper = (in.aux_u32_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(in.aux_u32_a == 0) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(u32 i=0; i<N; ++i) for(u32 i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( out_data, A_data, i+1 ); arrayops::copy( out_data, A_data, i+1 );
} }
} }
skipping to change at line 60 skipping to change at line 95
for(u32 i=0; i<N; ++i) for(u32 i=0; i<N; ++i)
{ {
const eT* A_data = A.colptr(i); const eT* A_data = A.colptr(i);
eT* out_data = out.colptr(i); eT* out_data = out.colptr(i);
arrayops::copy( &out_data[i], &A_data[i], N-i ); arrayops::copy( &out_data[i], &A_data[i], N-i );
} }
} }
} }
if(in.aux_u32_a == 0) op_trimat::fill_zeros(out, upper);
}
template<typename T1>
inline
void
op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<Op<T1, op_htran
s>, op_trimat>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m.m);
const Mat<eT>& A = tmp.M;
const bool upper = (in.aux_u32_a == 0);
op_trimat::apply_htrans(out, A, upper);
}
template<typename eT>
inline
void
op_trimat::apply_htrans
(
Mat<eT>& out,
const Mat<eT>& A,
const bool upper,
const typename arma_not_cx<eT>::result* junk
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
// This specialisation is for trimatl(trans(X)) = trans(trimatu(X)) and a
lso
// trimatu(trans(X)) = trans(trimatl(X)). We want to avoid the creation
of an
// extra temporary.
// It doesn't matter if the input and output matrices are the same; we wi
ll
// pull data from the upper or lower triangular to the lower or upper
// triangular (respectively) and then set the rest to 0, so overwriting i
ssues
// aren't present.
arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m
atrix must be square" );
const u32 N = A.n_rows;
if(&out != &A)
{ {
// upper triangular: set all elements below the diagonal to zero out.copy_size(A);
}
for(u32 i=0; i<N; ++i) // We can't really get away with any array copy operations here,
// unfortunately...
if(upper)
{
// Upper triangular: but since we're transposing, we're taking the lowe
r
// triangular and putting it in the upper half.
for(u32 row = 0; row < N; ++row)
{ {
eT* data = out.colptr(i); eT* out_colptr = out.colptr(row);
arrayops::inplace_set( &data[i+1], eT(0), (N-(i+1)) ); for(u32 col = 0; col <= row; ++col)
{
//out.at(col, row) = A.at(row, col);
out_colptr[col] = A.at(row, col);
}
} }
} }
else else
{ {
// lower triangular: set all elements above the diagonal to zero // Lower triangular: but since we're transposing, we're taking the uppe
r
// triangular and putting it in the lower half.
for(u32 row = 0; row < N; ++row)
{
for(u32 col = row; col < N; ++col)
{
out.at(col, row) = A.at(row, col);
}
}
}
for(u32 i=1; i<N; ++i) op_trimat::fill_zeros(out, upper);
}
template<typename eT>
inline
void
op_trimat::apply_htrans
(
Mat<eT>& out,
const Mat<eT>& A,
const bool upper,
const typename arma_cx_only<eT>::result* junk
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m
atrix must be square" );
const u32 N = A.n_rows;
if(&out != &A)
{
out.copy_size(A);
}
if(upper)
{
// Upper triangular: but since we're transposing, we're taking the lowe
r
// triangular and putting it in the upper half.
for(u32 row = 0; row < N; ++row)
{ {
eT* data = out.colptr(i); eT* out_colptr = out.colptr(row);
arrayops::inplace_set( data, eT(0), i ); for(u32 col = 0; col <= row; ++col)
{
//out.at(col, row) = std::conj( A.at(row, col) );
out_colptr[col] = std::conj( A.at(row, col) );
}
}
}
else
{
// Lower triangular: but since we're transposing, we're taking the uppe
r
// triangular and putting it in the lower half.
for(u32 row = 0; row < N; ++row)
{
for(u32 col = row; col < N; ++col)
{
out.at(col, row) = std::conj( A.at(row, col) );
}
} }
} }
op_trimat::fill_zeros(out, upper);
} }
//! @} //! @}
 End of changes. 15 change blocks. 
14 lines changed or deleted 176 lines changed or added


 op_var_meat.hpp   op_var_meat.hpp 
skipping to change at line 24 skipping to change at line 24
//! @{ //! @{
//! find the variance of an array //! find the variance of an array
template<typename eT> template<typename eT>
inline inline
eT eT
op_var::direct_var(const eT* const X, const u32 n_elem, const u32 norm_type ) op_var::direct_var(const eT* const X, const u32 n_elem, const u32 norm_type )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(n_elem > 1) if(n_elem >= 2)
{ {
const eT acc1 = op_mean::direct_mean(X, n_elem); const eT acc1 = op_mean::direct_mean(X, n_elem);
eT acc2 = eT(0); eT acc2 = eT(0);
eT acc3 = eT(0); eT acc3 = eT(0);
u32 i,j; u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
skipping to change at line 76 skipping to change at line 76
//! find the variance of an array (version for complex numbers) //! find the variance of an array (version for complex numbers)
template<typename T> template<typename T>
inline inline
T T
op_var::direct_var(const std::complex<T>* const X, const u32 n_elem, const u32 norm_type) op_var::direct_var(const std::complex<T>* const X, const u32 n_elem, const u32 norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
if(n_elem > 1) if(n_elem >= 2)
{ {
const eT acc1 = op_mean::direct_mean(X, n_elem); const eT acc1 = op_mean::direct_mean(X, n_elem);
T acc2 = T(0); T acc2 = T(0);
eT acc3 = eT(0); eT acc3 = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
const eT tmp = acc1 - X[i]; const eT tmp = acc1 - X[i];
skipping to change at line 177 skipping to change at line 177
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
typedef typename T1::pod_type out_eT; typedef typename T1::pod_type out_eT;
const unwrap_check_mixed<T1> tmp(in.m, out); const unwrap_check_mixed<T1> tmp(in.m, out);
const Mat<in_eT>& X = tmp.M; const Mat<in_eT>& X = tmp.M;
const u32 norm_type = in.aux_u32_a; const u32 norm_type = in.aux_u32_a;
const u32 dim = in.aux_u32_b; const u32 dim = in.aux_u32_b;
arma_debug_check( (X.n_elem == 0), "var(): given matrix has no elements" );
arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus t be 0 or 1"); arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus t be 0 or 1");
arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0 or 1" );
const u32 X_n_rows = X.n_rows; const u32 X_n_rows = X.n_rows;
const u32 X_n_cols = X.n_cols; const u32 X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
{ {
arma_extra_debug_print("op_var::apply(), dim = 0"); arma_extra_debug_print("op_var::apply(), dim = 0");
out.set_size(1, X_n_cols); out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
for(u32 col=0; col<X_n_cols; ++col) if(X_n_rows > 0)
{ {
out[col] = op_var::direct_var( X.colptr(col), X_n_rows, norm_type ); out_eT* out_mem = out.memptr();
for(u32 col=0; col<X_n_cols; ++col)
{
out_mem[col] = op_var::direct_var( X.colptr(col), X_n_rows, norm_ty
pe );
}
} }
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_var::apply(), dim = 1"); arma_extra_debug_print("op_var::apply(), dim = 1");
out.set_size(X_n_rows, 1); out.set_size( X_n_rows, (X_n_cols > 0) ? 1 : 0 );
podarray<in_eT> tmp(X_n_cols); if(X_n_cols > 0)
{
podarray<in_eT> tmp(X_n_cols);
in_eT* tmp_mem = tmp.memptr(); in_eT* tmp_mem = tmp.memptr();
out_eT* out_mem = out.memptr();
for(u32 row=0; row<X_n_rows; ++row) for(u32 row=0; row<X_n_rows; ++row)
{
for(u32 col=0; col<X_n_cols; ++col)
{ {
tmp_mem[col] = X.at(row,col); tmp.copy_row(X, row);
}
out[row] = op_var::direct_var(tmp_mem, X_n_cols, norm_type); out_mem[row] = op_var::direct_var( tmp_mem, X_n_cols, norm_type );
}
} }
} }
} }
//! find the variance of an array (robust but slow) //! find the variance of an array (robust but slow)
template<typename eT> template<typename eT>
inline inline
eT eT
op_var::direct_var_robust(const eT* const X, const u32 n_elem, const u32 no rm_type) op_var::direct_var_robust(const eT* const X, const u32 n_elem, const u32 no rm_type)
{ {
 End of changes. 12 change blocks. 
15 lines changed or deleted 21 lines changed or added


 operator_times.hpp   operator_times.hpp 
skipping to change at line 73 skipping to change at line 73
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scala r_times>('j', X.get_ref(), k); return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scala r_times>('j', X.get_ref(), k);
} }
//! scalar * trans(T1) //! scalar * trans(T1)
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_trans2> const Op<T1, op_htrans2>
operator* operator*
(const typename T1::elem_type k, const Op<T1, op_trans>& X) (const typename T1::elem_type k, const Op<T1, op_htrans>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_trans2>(X.m, k); return Op<T1, op_htrans2>(X.m, k);
} }
//! trans(T1) * scalar //! trans(T1) * scalar
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_trans2> const Op<T1, op_htrans2>
operator* operator*
(const Op<T1, op_trans>& X, const typename T1::elem_type k) (const Op<T1, op_htrans>& X, const typename T1::elem_type k)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_trans2>(X.m, k); return Op<T1, op_htrans2>(X.m, k);
} }
//! Base * diagmat //! Base * diagmat
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_inline
const Glue<T1, Op<T2, op_diagmat>, glue_times_diag> const Glue<T1, Op<T2, op_diagmat>, glue_times_diag>
operator* operator*
(const Base<typename T2::elem_type,T1>& X, const Op<T2, op_diagmat>& Y) (const Base<typename T2::elem_type,T1>& X, const Op<T2, op_diagmat>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 podarray_meat.hpp   podarray_meat.hpp 
skipping to change at line 197 skipping to change at line 197
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
podarray<eT>::memptr() const podarray<eT>::memptr() const
{ {
return mem; return mem;
} }
template<typename eT> template<typename eT>
arma_hot
inline
void
podarray<eT>::copy_row(const Mat<eT>& A, const u32 row)
{
const u32 cols = A.n_cols;
// note: this function assumes that the podarray has been set to the corr
ect size beforehand
eT* out = memptr();
switch(cols)
{
default:
{
u32 i,j;
for(i=0, j=1; j < cols; i+=2, j+=2)
{
out[i] = A.at(row, i);
out[j] = A.at(row, j);
}
if(i < cols)
{
out[i] = A.at(row, i);
}
}
break;
case 8:
out[7] = A.at(row, 7);
case 7:
out[6] = A.at(row, 6);
case 6:
out[5] = A.at(row, 5);
case 5:
out[4] = A.at(row, 4);
case 4:
out[3] = A.at(row, 3);
case 3:
out[2] = A.at(row, 2);
case 2:
out[1] = A.at(row, 1);
case 1:
out[0] = A.at(row, 0);
}
}
template<typename eT>
inline inline
void void
podarray<eT>::init(const u32 new_n_elem) podarray<eT>::init(const u32 new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(n_elem == new_n_elem) if(n_elem == new_n_elem)
{ {
return; return;
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 56 lines changed or added


 promote_type.hpp   promote_type.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 40 skipping to change at line 40
arma_inline static void check() {} arma_inline static void check() {}
}; };
template<typename T> struct promote_type<T, T> : public promo te_type_ok { typedef T result; }; template<typename T> struct promote_type<T, T> : public promo te_type_ok { typedef T result; };
template<typename T> struct promote_type<std::complex<T>, T> : public promo te_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, T> : public promo te_type_ok { typedef std::complex<T> result; };
template<> struct promote_type<std::complex<double>, std::complex<float> > : public promote_type_ok { typedef std::complex<double> result; }; template<> struct promote_type<std::complex<double>, std::complex<float> > : public promote_type_ok { typedef std::complex<double> result; };
template<> struct promote_type<std::complex<double>, float> : public promote_type_ok { typedef std::complex<double> result; }; template<> struct promote_type<std::complex<double>, float> : public promote_type_ok { typedef std::complex<double> result; };
template<> struct promote_type<std::complex<float>, double> : public promote_type_ok { typedef std::complex<double> result; }; template<> struct promote_type<std::complex<float>, double> : public promote_type_ok { typedef std::complex<double> result; };
template<typename T> struct promote_type<std::complex<T>, u64> : public pro mote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<std::complex<T>, s32> : public pro mote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, s32> : public pro mote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<std::complex<T>, u32> : public pro mote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, u32> : public pro mote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<std::complex<T>, s16> : public pro mote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, s16> : public pro mote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<std::complex<T>, u16> : public pro mote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, u16> : public pro mote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<std::complex<T>, s8> : public pro mote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, s8> : public pro mote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<std::complex<T>, u8> : public pro mote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<std::complex<T>, u8> : public pro mote_type_ok { typedef std::complex<T> result; };
template<> struct promote_type<double, float> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, float> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, u64 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, s32 > : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, s32 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, u32 > : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, u32 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, s16 > : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, s16 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, u16 > : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, u16 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, s8 > : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, s8 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<double, u8 > : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<double, u8 > : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<float, u64> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<float, s32> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<float, s32> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<float, u32> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<float, u32> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<float, s16> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<float, s16> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<float, u16> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<float, u16> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<float, s8 > : public promote_type_ok { typed ef float result; }; template<> struct promote_type<float, s8 > : public promote_type_ok { typed ef float result; };
template<> struct promote_type<float, u8 > : public promote_type_ok { typed ef float result; }; template<> struct promote_type<float, u8 > : public promote_type_ok { typed ef float result; };
template<> struct promote_type<u64, u32> : public promote_type_ok { typedef
u64 result; };
template<> struct promote_type<u64, u16> : public promote_type_ok { typedef
u64 result; };
template<> struct promote_type<u64, u8 > : public promote_type_ok { typedef
u64 result; };
template<> struct promote_type<s32, u32> : public promote_type_ok { typedef s32 result; }; // float ? template<> struct promote_type<s32, u32> : public promote_type_ok { typedef s32 result; }; // float ?
template<> struct promote_type<s32, s16> : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<s32, s16> : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<s32, u16> : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<s32, u16> : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<s32, s8 > : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<s32, s8 > : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<s32, u8 > : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<s32, u8 > : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<u32, s16> : public promote_type_ok { typedef s32 result; }; // float ? template<> struct promote_type<u32, s16> : public promote_type_ok { typedef s32 result; }; // float ?
template<> struct promote_type<u32, u16> : public promote_type_ok { typedef u32 result; }; template<> struct promote_type<u32, u16> : public promote_type_ok { typedef u32 result; };
template<> struct promote_type<u32, s8 > : public promote_type_ok { typedef s32 result; }; // float ? template<> struct promote_type<u32, s8 > : public promote_type_ok { typedef s32 result; }; // float ?
template<> struct promote_type<u32, u8 > : public promote_type_ok { typedef u32 result; }; template<> struct promote_type<u32, u8 > : public promote_type_ok { typedef u32 result; };
skipping to change at line 91 skipping to change at line 98
// //
// mirrored versions // mirrored versions
template<typename T> struct promote_type<T, std::complex<T> > : public prom ote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<T, std::complex<T> > : public prom ote_type_ok { typedef std::complex<T> result; };
template<> struct promote_type<std::complex<float>, std::complex<double> > : public promote_type_ok { typedef std::complex<double> result; }; template<> struct promote_type<std::complex<float>, std::complex<double> > : public promote_type_ok { typedef std::complex<double> result; };
template<> struct promote_type<float, std::complex<double> > : public promote_type_ok { typedef std::complex<double> result; }; template<> struct promote_type<float, std::complex<double> > : public promote_type_ok { typedef std::complex<double> result; };
template<> struct promote_type<double, std::complex<float> > : public promote_type_ok { typedef std::complex<double> result; }; template<> struct promote_type<double, std::complex<float> > : public promote_type_ok { typedef std::complex<double> result; };
template<typename T> struct promote_type<u64, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<s32, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<s32, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<u32, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<u32, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<s16, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<s16, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<u16, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<u16, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<s8, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<s8, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<typename T> struct promote_type<u8, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; }; template<typename T> struct promote_type<u8, std::complex<T> > : public pr omote_type_ok { typedef std::complex<T> result; };
template<> struct promote_type<float, double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<float, double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<u64 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<s32 , double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<s32 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<u32 , double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<u32 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<s16 , double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<s16 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<u16 , double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<u16 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<s8 , double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<s8 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<u8 , double> : public promote_type_ok { ty pedef double result; }; template<> struct promote_type<u8 , double> : public promote_type_ok { ty pedef double result; };
template<> struct promote_type<u64, float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<s32, float> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<s32, float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<u32, float> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<u32, float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<s16, float> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<s16, float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<u16, float> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<u16, float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<s8 , float> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<s8 , float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<u8 , float> : public promote_type_ok { typed ef float result; }; template<> struct promote_type<u8 , float> : public promote_type_ok { typed ef float result; };
template<> struct promote_type<u32, u64> : public promote_type_ok { typedef
u64 result; };
template<> struct promote_type<u16, u64> : public promote_type_ok { typedef
u64 result; };
template<> struct promote_type<u8, u64> : public promote_type_ok { typedef
u64 result; };
template<> struct promote_type<u32, s32> : public promote_type_ok { typedef s32 result; }; // float ? template<> struct promote_type<u32, s32> : public promote_type_ok { typedef s32 result; }; // float ?
template<> struct promote_type<s16, s32> : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<s16, s32> : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<u16, s32> : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<u16, s32> : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<s8 , s32> : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<s8 , s32> : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<u8 , s32> : public promote_type_ok { typedef s32 result; }; template<> struct promote_type<u8 , s32> : public promote_type_ok { typedef s32 result; };
template<> struct promote_type<s16, u32> : public promote_type_ok { typedef s32 result; }; // float ? template<> struct promote_type<s16, u32> : public promote_type_ok { typedef s32 result; }; // float ?
template<> struct promote_type<u16, u32> : public promote_type_ok { typedef u32 result; }; template<> struct promote_type<u16, u32> : public promote_type_ok { typedef u32 result; };
template<> struct promote_type<s8 , u32> : public promote_type_ok { typedef s32 result; }; // float ? template<> struct promote_type<s8 , u32> : public promote_type_ok { typedef s32 result; }; // float ?
template<> struct promote_type<u8 , u32> : public promote_type_ok { typedef u32 result; }; template<> struct promote_type<u8 , u32> : public promote_type_ok { typedef u32 result; };
 End of changes. 9 change blocks. 
2 lines changed or deleted 22 lines changed or added


 running_stat_meat.hpp   running_stat_meat.hpp 
skipping to change at line 157 skipping to change at line 157
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for complex numbers)
template<typename eT> template<typename eT>
inline inline
void void
running_stat<eT>::operator() (const std::complex< typename running_stat<eT> ::T >& sample) running_stat<eT>::operator() (const std::complex< typename running_stat<eT> ::T >& sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
isnt_same_type<eT, std::complex< typename running_stat<eT>::T > >::check( ); arma_type_check< is_same_type<eT, std::complex< typename running_stat<eT> ::T > >::value == false >::apply();
if( arma_isfinite(sample) == false ) if( arma_isfinite(sample) == false )
{ {
arma_print("running_stat: sample ignored as it is non-finite" ); arma_print("running_stat: sample ignored as it is non-finite" );
return; return;
} }
running_stat_aux::update_stats(*this, sample); running_stat_aux::update_stats(*this, sample);
} }
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 subview_cube_meat.hpp   subview_cube_meat.hpp 
skipping to change at line 988 skipping to change at line 988
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (t.n_elem == 0) || (x.n_elem == 0) )
{ {
return false; return false;
} }
else else
{ {
const u32 t_aux_row1 = t.aux_row1; const u32 t_row_start = t.aux_row1;
const u32 t_aux_row2 = t_aux_row1 + t.n_rows - 1; const u32 t_row_end_p1 = t_row_start + t.n_rows;
const u32 t_aux_col1 = t.aux_col1; const u32 t_col_start = t.aux_col1;
const u32 t_aux_col2 = t_aux_col1 + t.n_cols - 1; const u32 t_col_end_p1 = t_col_start + t.n_cols;
const u32 t_aux_slice1 = t.aux_slice1; const u32 t_slice_start = t.aux_slice1;
const u32 t_aux_slice2 = t_aux_slice1 + t.n_slices - 1; const u32 t_slice_end_p1 = t_slice_start + t.n_slices;
const u32 x_aux_row1 = x.aux_row1; const u32 x_row_start = x.aux_row1;
const u32 x_aux_row2 = x_aux_row1 + x.n_rows - 1; const u32 x_row_end_p1 = x_row_start + x.n_rows;
const u32 x_aux_col1 = x.aux_col1;
const u32 x_aux_col2 = x_aux_col1 + x.n_cols - 1;
const u32 x_aux_slice1 = x.aux_slice1;
const u32 x_aux_slice2 = x_aux_slice1 + x.n_slices - 1;
const bool row_overlap =
(
( (x_aux_row1 >= t_aux_row1) && (x_aux_row1 <= t_aux_row2) )
||
( (x_aux_row2 >= t_aux_row1) && (x_aux_row2 <= t_aux_row2) )
);
const bool col_overlap =
(
( (x_aux_col1 >= t_aux_col1) && (x_aux_col1 <= t_aux_col2) )
||
( (x_aux_col2 >= t_aux_col1) && (x_aux_col2 <= t_aux_col2) )
);
const bool slice_overlap =
(
( (x_aux_slice1 >= t_aux_slice1) && (x_aux_slice1 <= t_aux_slice2)
)
||
( (x_aux_slice2 >= t_aux_slice1) && (x_aux_slice2 <= t_aux_slice2)
)
);
const bool overlap = ( (row_overlap == true) && (col_overlap == true) const u32 x_col_start = x.aux_col1;
&& (slice_overlap == true) ); const u32 x_col_end_p1 = x_col_start + x.n_cols;
return overlap; const u32 x_slice_start = x.aux_slice1;
const u32 x_slice_end_p1 = x_slice_start + x.n_slices;
const bool outside_rows = ( (x_row_start >= t_row_end_p1 ) || (t
_row_start >= x_row_end_p1 ) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1 ) || (t
_col_start >= x_col_end_p1 ) );
const bool outside_slices = ( (x_slice_start >= t_slice_end_p1) || (t
_slice_start >= x_slice_end_p1) );
return ( (outside_rows == false) && (outside_cols == false) && (outsi
de_slices == false) );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview_cube<eT>::check_overlap(const Mat<eT>& x) const subview_cube<eT>::check_overlap(const Mat<eT>& x) const
{ {
const subview_cube<eT>& t = *this; const subview_cube<eT>& t = *this;
 End of changes. 6 change blocks. 
40 lines changed or deleted 22 lines changed or added


 subview_elem1_meat.hpp   subview_elem1_meat.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 59 skipping to change at line 59
Mat<eT>& m_local = *m_ptr; Mat<eT>& m_local = *m_ptr;
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const u32 m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = tmp.M;
arma_debug_check arma_debug_check
( (
( (aa.n_elem > 0) && (aa.is_vec() == false) ), ( aa.is_vec() == false ),
"Mat::elem(): given object isn't a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const u32* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const u32 aa_n_elem = aa.n_elem;
u32 i,j; u32 i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{ {
const u32 ii = aa_mem[i]; const u32 ii = aa_mem[i];
const u32 jj = aa_mem[j]; const u32 jj = aa_mem[j];
skipping to change at line 128 skipping to change at line 128
const Mat<eT>& x_m_local = x.m; const Mat<eT>& x_m_local = x.m;
const unwrap_check_mixed<T1> t_tmp(t.a.get_ref(), t_m_local); const unwrap_check_mixed<T1> t_tmp(t.a.get_ref(), t_m_local);
const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), t_m_local); const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), t_m_local);
const umat& t_aa = t_tmp.M; const umat& t_aa = t_tmp.M;
const umat& x_aa = x_tmp.M; const umat& x_aa = x_tmp.M;
arma_debug_check arma_debug_check
( (
( ( (t_aa.n_elem > 0) && (t_aa.is_vec() == false) ) || ( (x_aa.n_elem ( (t_aa.is_vec() == false) || (x_aa.is_vec() == false) ),
> 0) && (x_aa.is_vec() == false) ) ), "Mat::elem(): given object is not a vector"
"Mat::elem(): given object isn't a vector"
); );
const u32* t_aa_mem = t_aa.memptr(); const u32* t_aa_mem = t_aa.memptr();
const u32* x_aa_mem = x_aa.memptr(); const u32* x_aa_mem = x_aa.memptr();
const u32 t_aa_n_elem = t_aa.n_elem; const u32 t_aa_n_elem = t_aa.n_elem;
arma_debug_check( (t_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mism atch" ); arma_debug_check( (t_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mism atch" );
eT* t_m_mem = t_m_local.memptr(); eT* t_m_mem = t_m_local.memptr();
skipping to change at line 205 skipping to change at line 205
Mat<eT>& m_local = *m_ptr; Mat<eT>& m_local = *m_ptr;
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const u32 m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = tmp.M;
arma_debug_check arma_debug_check
( (
( (aa.n_elem > 0) && (aa.is_vec() == false) ), ( aa.is_vec() == false ),
"Mat::elem(): given object isn't a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const u32* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const u32 aa_n_elem = aa.n_elem;
const Proxy<T2> P(x.get_ref()); const Proxy<T2> P(x.get_ref());
arma_debug_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size misma tch" ); arma_debug_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size misma tch" );
if(P.is_alias(m) == false) if(P.is_alias(m) == false)
skipping to change at line 510 skipping to change at line 510
void void
subview_elem1<eT,T1>::extract(Mat<eT>& actual_out, const subview_elem1<eT,T 1>& in) subview_elem1<eT,T1>::extract(Mat<eT>& actual_out, const subview_elem1<eT,T 1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_check_mixed<T1> tmp1(in.a.get_ref(), actual_out); const unwrap_check_mixed<T1> tmp1(in.a.get_ref(), actual_out);
const umat& aa = tmp1.M; const umat& aa = tmp1.M;
arma_debug_check arma_debug_check
( (
( (aa.n_elem > 0) && (aa.is_vec() == false) ), ( aa.is_vec() == false ),
"Mat::elem(): given object isn't a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const u32* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const u32 aa_n_elem = aa.n_elem;
const Mat<eT>& m_local = in.m; const Mat<eT>& m_local = in.m;
const eT* m_mem = m_local.memptr(); const eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const u32 m_n_elem = m_local.n_elem;
skipping to change at line 574 skipping to change at line 574
void void
subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in) subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp1(in.a.get_ref()); const unwrap<T1> tmp1(in.a.get_ref());
const umat& aa = tmp1.M; const umat& aa = tmp1.M;
arma_debug_check arma_debug_check
( (
( (aa.n_elem > 0) && (aa.is_vec() == false) ), ( aa.is_vec() == false ),
"Mat::elem(): given object isn't a vector" "Mat::elem(): given object is not a vector"
); );
const u32* aa_mem = aa.memptr(); const u32* aa_mem = aa.memptr();
const u32 aa_n_elem = aa.n_elem; const u32 aa_n_elem = aa.n_elem;
const unwrap_check< Mat<eT> > tmp2(in.m, out); const unwrap_check< Mat<eT> > tmp2(in.m, out);
const Mat<eT>& m_local = tmp2.M; const Mat<eT>& m_local = tmp2.M;
const eT* m_mem = m_local.memptr(); const eT* m_mem = m_local.memptr();
const u32 m_n_elem = m_local.n_elem; const u32 m_n_elem = m_local.n_elem;
 End of changes. 6 change blocks. 
13 lines changed or deleted 12 lines changed or added


 subview_field_meat.hpp   subview_field_meat.hpp 
skipping to change at line 247 skipping to change at line 247
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (t.n_elem == 0) || (x.n_elem == 0) )
{ {
return false; return false;
} }
else else
{ {
const u32 t_aux_row1 = t.aux_row1; const u32 t_row_start = t.aux_row1;
const u32 t_aux_row2 = t_aux_row1 + t.n_rows - 1; const u32 t_row_end_p1 = t_row_start + t.n_rows;
const u32 t_aux_col1 = t.aux_col1; const u32 t_col_start = t.aux_col1;
const u32 t_aux_col2 = t_aux_col1 + t.n_cols - 1; const u32 t_col_end_p1 = t_col_start + t.n_cols;
const u32 x_aux_row1 = x.aux_row1; const u32 x_row_start = x.aux_row1;
const u32 x_aux_row2 = x_aux_row1 + x.n_rows - 1; const u32 x_row_end_p1 = x_row_start + x.n_rows;
const u32 x_aux_col1 = x.aux_col1; const u32 x_col_start = x.aux_col1;
const u32 x_aux_col2 = x_aux_col1 + x.n_cols - 1; const u32 x_col_end_p1 = x_col_start + x.n_cols;
const bool row_overlap =
(
( (x_aux_row1 >= t_aux_row1) && (x_aux_row1 <= t_aux_row2) )
||
( (x_aux_row2 >= t_aux_row1) && (x_aux_row2 <= t_aux_row2) )
);
const bool col_overlap =
(
( (x_aux_col1 >= t_aux_col1) && (x_aux_col1 <= t_aux_col2) )
||
( (x_aux_col2 >= t_aux_col1) && (x_aux_col2 <= t_aux_col2) )
);
const bool overlap = ( (row_overlap == true) && (col_overlap == true) const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s
); tart >= x_row_end_p1) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s
tart >= x_col_end_p1) );
return overlap; return ( (outside_rows == false) && (outside_cols == false) );
} }
} }
} }
//! X = Y.subfield(...) //! X = Y.subfield(...)
template<typename oT> template<typename oT>
inline inline
void void
subview_field<oT>::extract(field<oT>& actual_out, const subview_field<oT>& in) subview_field<oT>::extract(field<oT>& actual_out, const subview_field<oT>& in)
{ {
 End of changes. 6 change blocks. 
25 lines changed or deleted 13 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// Copyright (C) 2011 James Sanders
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 24 skipping to change at line 25
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
subview<eT>::~subview() subview<eT>::~subview()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline inline
subview<eT>::subview(const Mat<eT>& in_m, const u32 in_row1, const u32 in_c ol1, const u32 in_n_rows, const u32 in_n_cols) subview<eT>::subview(const Mat<eT>& in_m, const u32 in_row1, const u32 in_c ol1, const u32 in_n_rows, const u32 in_n_cols)
: m(in_m) : m(in_m)
, m_ptr(0) , m_ptr(0)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline inline
subview<eT>::subview(Mat<eT>& in_m, const u32 in_row1, const u32 in_col1, c onst u32 in_n_rows, const u32 in_n_cols) subview<eT>::subview(Mat<eT>& in_m, const u32 in_row1, const u32 in_col1, c onst u32 in_n_rows, const u32 in_n_cols)
: m(in_m) : m(in_m)
, m_ptr(&in_m) , m_ptr(&in_m)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 63 skipping to change at line 64
void void
subview<eT>::operator+= (const eT val) subview<eT>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const u32 local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const u32 local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
for(u32 col=0; col<local_n_cols; ++col) Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols;
u32 i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
at(0, col) += val; X.at(row, i) += val;
X.at(row, j) += val;
}
if(i < end_col_plus1)
{
X.at(row, i) += val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(u32 col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_plus( colptr(col), val, local_n_rows ); arrayops::inplace_plus( colptr(col), val, local_n_rows );
} }
} }
} }
skipping to change at line 89 skipping to change at line 104
void void
subview<eT>::operator-= (const eT val) subview<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const u32 local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const u32 local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
for(u32 col=0; col<local_n_cols; ++col) Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols;
u32 i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{
X.at(row, i) -= val;
X.at(row, j) -= val;
}
if(i < end_col_plus1)
{ {
at(0, col) -= val; X.at(row, i) -= val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(u32 col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_minus( colptr(col), val, local_n_rows ); arrayops::inplace_minus( colptr(col), val, local_n_rows );
} }
} }
} }
skipping to change at line 115 skipping to change at line 144
void void
subview<eT>::operator*= (const eT val) subview<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const u32 local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const u32 local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
for(u32 col=0; col<local_n_cols; ++col) Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols;
u32 i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{
X.at(row, i) *= val;
X.at(row, j) *= val;
}
if(i < end_col_plus1)
{ {
at(0, col) *= val; X.at(row, i) *= val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(u32 col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_mul( colptr(col), val, local_n_rows ); arrayops::inplace_mul( colptr(col), val, local_n_rows );
} }
} }
} }
skipping to change at line 141 skipping to change at line 184
void void
subview<eT>::operator/= (const eT val) subview<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const u32 local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const u32 local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
for(u32 col=0; col<local_n_cols; ++col) Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols;
u32 i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{
X.at(row, i) /= val;
X.at(row, j) /= val;
}
if(i < end_col_plus1)
{ {
at(0, col) /= val; X.at(row, i) /= val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(u32 col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_div( colptr(col), val, local_n_rows ); arrayops::inplace_div( colptr(col), val, local_n_rows );
} }
} }
} }
skipping to change at line 185 skipping to change at line 242
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
at(0,col) = x_mem[col]; A.at(row, start_col+i) = x_mem[i];
A.at(row, start_col+j) = x_mem[j];
}
if(i < t_n_cols)
{
A.at(row, start_col+i) = x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) = tmp1;
A.at(row, start_col+j) = tmp2;
}
if(i < t_n_cols)
{ {
at(0,col) = P[col]; A.at(row, start_col+i) = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i ) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; u32 i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
skipping to change at line 262 skipping to change at line 348
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
A.at(row, start_col+i) += x_mem[i];
A.at(row, start_col+j) += x_mem[j];
}
if(i < t_n_cols)
{ {
at(0,col) += x_mem[col]; A.at(row, start_col+i) += x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) += tmp1;
A.at(row, start_col+j) += tmp2;
}
if(i < t_n_cols)
{ {
at(0,col) += P[col]; A.at(row, start_col+i) += (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; u32 i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
skipping to change at line 337 skipping to change at line 452
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
A.at(row, start_col+i) -= x_mem[i];
A.at(row, start_col+j) -= x_mem[j];
}
if(i < t_n_cols)
{ {
at(0,col) -= x_mem[col]; A.at(row, start_col+i) -= x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) -= tmp1;
A.at(row, start_col+j) -= tmp2;
}
if(i < t_n_cols)
{ {
at(0,col) -= P[col]; A.at(row, start_col+i) -= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; u32 i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
skipping to change at line 414 skipping to change at line 558
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
A.at(row, start_col+i) *= x_mem[i];
A.at(row, start_col+j) *= x_mem[j];
}
if(i < t_n_cols)
{ {
at(0,col) *= x_mem[col]; A.at(row, start_col+i) *= x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
at(0,col) *= P[col]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) *= tmp1;
A.at(row, start_col+j) *= tmp2;
}
if(i < t_n_cols)
{
A.at(row, start_col+i) *= (Proxy<T1>::prefer_at_accessor) ? P.at(0,
i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; u32 i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
skipping to change at line 491 skipping to change at line 664
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
at(0,col) /= x_mem[col]; A.at(row, start_col+i) /= x_mem[i];
A.at(row, start_col+j) /= x_mem[j];
}
if(i < t_n_cols)
{
A.at(row, start_col+i) /= x_mem[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
A.at(row, start_col+i) /= tmp1;
A.at(row, start_col+j) /= tmp2;
}
if(i < t_n_cols)
{ {
at(0,col) /= P[col]; A.at(row, start_col+i) /= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i];
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
eT* t_col_data = t.colptr(col); eT* t_col_data = t.colptr(col);
u32 i,j; u32 i,j;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(i=0, j=1; j<t_n_rows; i+=2, j+=2)
skipping to change at line 561 skipping to change at line 763
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix"); arma_debug_assert_same_size(t, x, "insert into submatrix");
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1;
const u32 row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
t.at(0,col) = x.at(0,col); const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) = tmp1;
A.at(row_A, start_col_A + j) = tmp2;
}
if(i < t_n_cols)
{
A.at(row_A, start_col_A + i) = B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
skipping to change at line 603 skipping to change at line 825
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "addition"); arma_debug_assert_same_size(t, x, "addition");
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1;
const u32 row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) += tmp1;
A.at(row_A, start_col_A + j) += tmp2;
}
if(i < t_n_cols)
{ {
t.at(0,col) += x.at(0,col); A.at(row_A, start_col_A + i) += B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
skipping to change at line 645 skipping to change at line 887
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "subtraction"); arma_debug_assert_same_size(t, x, "subtraction");
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1;
const u32 row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) -= tmp1;
A.at(row_A, start_col_A + j) -= tmp2;
}
if(i < t_n_cols)
{ {
t.at(0,col) -= x.at(0,col); A.at(row_A, start_col_A + i) -= B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
skipping to change at line 688 skipping to change at line 950
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise multiplication"); arma_debug_assert_same_size(t, x, "element-wise multiplication");
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1;
const u32 row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) *= tmp1;
A.at(row_A, start_col_A + j) *= tmp2;
}
if(i < t_n_cols)
{ {
t.at(0,col) *= x.at(0,col); A.at(row_A, start_col_A + i) *= B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
skipping to change at line 731 skipping to change at line 1013
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise division"); arma_debug_assert_same_size(t, x, "element-wise division");
const u32 t_n_rows = t.n_rows; const u32 t_n_rows = t.n_rows;
const u32 t_n_cols = t.n_cols; const u32 t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
for(u32 col=0; col<t_n_cols; ++col) Mat<eT>& A = *(t.m_ptr);
const Mat<eT>& B = x.m;
const u32 row_A = t.aux_row1;
const u32 row_B = x.aux_row1;
const u32 start_col_A = t.aux_col1;
const u32 start_col_B = x.aux_col1;
u32 i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{
const eT tmp1 = B.at(row_B, start_col_B + i);
const eT tmp2 = B.at(row_B, start_col_B + j);
A.at(row_A, start_col_A + i) /= tmp1;
A.at(row_A, start_col_A + j) /= tmp2;
}
if(i < t_n_cols)
{ {
t.at(0,col) /= x.at(0,col); A.at(row_A, start_col_A + i) /= B.at(row_B, start_col_B + i);
} }
} }
else else
{ {
for(u32 col=0; col<t_n_cols; ++col) for(u32 col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
skipping to change at line 764 skipping to change at line 1066
void void
subview<eT>::fill(const eT val) subview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const u32 local_n_cols = n_cols; const u32 local_n_cols = n_cols;
const u32 local_n_rows = n_rows; const u32 local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
for(u32 col=0; col<local_n_cols; ++col) Mat<eT>& X = (*m_ptr);
const u32 row = aux_row1;
const u32 start_col = aux_col1;
const u32 end_col_plus1 = start_col + local_n_cols;
u32 i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
at(0,col) = val; X.at(row, i) = val;
X.at(row, j) = val;
}
if(i < end_col_plus1)
{
X.at(row, i) = val;
} }
} }
else else
{ {
for(u32 col=0; col<local_n_cols; ++col) for(u32 col=0; col<local_n_cols; ++col)
{ {
arrayops::inplace_set( colptr(col), val, local_n_rows ); arrayops::inplace_set( colptr(col), val, local_n_rows );
} }
} }
} }
skipping to change at line 789 skipping to change at line 1105
inline inline
void void
subview<eT>::zeros() subview<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
(*this).fill(eT(0)); (*this).fill(eT(0));
} }
template<typename eT> template<typename eT>
arma_inline inline
void
subview<eT>::ones()
{
arma_extra_debug_sigprint();
(*this).fill(eT(1));
}
template<typename eT>
inline
void
subview<eT>::eye()
{
arma_extra_debug_sigprint();
fill(eT(0));
const u32 N = (std::min)(n_rows, n_cols);
for(u32 i=0; i<N; ++i)
{
at(i,i) = eT(1);
}
}
template<typename eT>
inline
eT& eT&
subview<eT>::operator[](const u32 i) subview<eT>::operator[](const u32 i)
{ {
const u32 in_col = i / n_rows; const u32 in_col = i / n_rows;
const u32 in_row = i % n_rows; const u32 in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline inline
eT eT
subview<eT>::operator[](const u32 i) const subview<eT>::operator[](const u32 i) const
{ {
const u32 in_col = i / n_rows; const u32 in_col = i / n_rows;
const u32 in_row = i % n_rows; const u32 in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline inline
eT& eT&
subview<eT>::operator()(const u32 i) subview<eT>::operator()(const u32 i)
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const u32 in_col = i / n_rows; const u32 in_col = i / n_rows;
const u32 in_row = i % n_rows; const u32 in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline inline
eT eT
subview<eT>::operator()(const u32 i) const subview<eT>::operator()(const u32 i) const
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const u32 in_col = i / n_rows; const u32 in_col = i / n_rows;
const u32 in_row = i % n_rows; const u32 in_row = i % n_rows;
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline inline
eT& eT&
subview<eT>::operator()(const u32 in_row, const u32 in_col) subview<eT>::operator()(const u32 in_row, const u32 in_col)
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline inline
eT eT
subview<eT>::operator()(const u32 in_row, const u32 in_col) const subview<eT>::operator()(const u32 in_row, const u32 in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline inline
eT& eT&
subview<eT>::at(const u32 in_row, const u32 in_col) subview<eT>::at(const u32 in_row, const u32 in_col)
{ {
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] ); return access::rw( (*m_ptr).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline inline
eT eT
subview<eT>::at(const u32 in_row, const u32 in_col) const subview<eT>::at(const u32 in_row, const u32 in_col) const
{ {
const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
skipping to change at line 911 skipping to change at line 1254
const subview<eT>& t = *this; const subview<eT>& t = *this;
if(&t.m != &x.m) if(&t.m != &x.m)
{ {
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (t.n_elem == 0) || (x.n_elem == 0) )
{ {
// if t.n_elem is 0, t.n_rows or t.n_cols is 0
// if x.n_elem is 0, x.n_rows or x.n_cols is 0
return false; return false;
} }
else else
{ {
// at this stage we have a guarantee that: const u32 t_row_start = t.aux_row1;
// t.n_rows > 0, t.n_cols > 0 const u32 t_row_end_p1 = t_row_start + t.n_rows;
// and
// x.n_rows > 0, x.n_cols > 0 const u32 t_col_start = t.aux_col1;
const u32 t_col_end_p1 = t_col_start + t.n_cols;
const u32 t_aux_row1 = t.aux_row1;
const u32 t_aux_row2 = t_aux_row1 + t.n_rows - 1;
const u32 t_aux_col1 = t.aux_col1;
const u32 t_aux_col2 = t_aux_col1 + t.n_cols - 1;
const u32 x_aux_row1 = x.aux_row1;
const u32 x_aux_row2 = x_aux_row1 + x.n_rows - 1;
const u32 x_aux_col1 = x.aux_col1;
const u32 x_aux_col2 = x_aux_col1 + x.n_cols - 1;
const bool row_overlap =
(
( (x_aux_row1 >= t_aux_row1) && (x_aux_row1 <= t_aux_row2) )
||
( (x_aux_row2 >= t_aux_row1) && (x_aux_row2 <= t_aux_row2) )
);
const bool col_overlap =
(
( (x_aux_col1 >= t_aux_col1) && (x_aux_col1 <= t_aux_col2) )
||
( (x_aux_col2 >= t_aux_col1) && (x_aux_col2 <= t_aux_col2) )
);
const bool overlap = ( (row_overlap == true) && (col_overlap == true) const u32 x_row_start = x.aux_row1;
); const u32 x_row_end_p1 = x_row_start + x.n_rows;
return overlap; const u32 x_col_start = x.aux_col1;
const u32 x_col_end_p1 = x_col_start + x.n_cols;
const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s
tart >= x_row_end_p1) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s
tart >= x_col_end_p1) );
return ( (outside_rows == false) && (outside_cols == false) );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview<eT>::is_vec() const subview<eT>::is_vec() const
{ {
return ( (n_rows == 1) || (n_cols == 1) ); return ( (n_rows <= 1) || (n_cols <= 1) );
} }
//! X = Y.submat(...) //! X = Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::extract(Mat<eT>& actual_out, const subview<eT>& in) subview<eT>::extract(Mat<eT>& actual_out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 995 skipping to change at line 1318
if(in.is_vec() == true) if(in.is_vec() == true)
{ {
if(n_cols == 1) // a column vector if(n_cols == 1) // a column vector
{ {
arma_extra_debug_print("subview::extract(): copying col (going across rows)"); arma_extra_debug_print("subview::extract(): copying col (going across rows)");
// in.colptr(0) the first column of the subview, taking into account any row offset // in.colptr(0) the first column of the subview, taking into account any row offset
arrayops::copy( out.memptr(), in.colptr(0), n_rows ); arrayops::copy( out.memptr(), in.colptr(0), n_rows );
} }
else // a row vector else // a row vector (possibly empty)
{ {
arma_extra_debug_print("subview::extract(): copying row (going across columns)"); arma_extra_debug_print("subview::extract(): copying row (going across columns)");
const Mat<eT>& X = in.m; const Mat<eT>& X = in.m;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const u32 row = in.aux_row1; const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1; const u32 start_col = in.aux_col1;
for(u32 i=0; i<n_cols; ++i) u32 i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{ {
out_mem[i] = X.at(row, i+start_col); const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j);
out_mem[i] = tmp1;
out_mem[j] = tmp2;
}
if(i < n_cols)
{
out_mem[i] = X.at(row, start_col+i);
} }
} }
} }
else // general submatrix else // general submatrix
{ {
arma_extra_debug_print("subview::extract(): general submatrix"); arma_extra_debug_print("subview::extract(): general submatrix");
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), in.colptr(col), n_rows ); arrayops::copy( out.colptr(col), in.colptr(col), n_rows );
skipping to change at line 1039 skipping to change at line 1374
//! X += Y.submat(...) //! X += Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "addition"); arma_debug_assert_same_size(out, in, "addition");
const u32 n_rows = out.n_rows; const u32 n_rows = in.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<n_cols; ++col) const Mat<eT>& X = in.m;
const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1;
u32 i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j);
out_mem[i] += tmp1;
out_mem[j] += tmp2;
}
if(i < n_cols)
{ {
out_mem[col] += in.at(0,col); out_mem[i] += X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(u32 col=0; col<n_cols; ++col)
{ {
arrayops::inplace_plus(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_plus(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
skipping to change at line 1070 skipping to change at line 1420
//! X -= Y.submat(...) //! X -= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "subtraction"); arma_debug_assert_same_size(out, in, "subtraction");
const u32 n_rows = out.n_rows; const u32 n_rows = in.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<n_cols; ++col) const Mat<eT>& X = in.m;
const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1;
u32 i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j);
out_mem[i] -= tmp1;
out_mem[j] -= tmp2;
}
if(i < n_cols)
{ {
out_mem[col] -= in.at(0,col); out_mem[i] -= X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(u32 col=0; col<n_cols; ++col)
{ {
arrayops::inplace_minus(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_minus(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
skipping to change at line 1101 skipping to change at line 1466
//! X %= Y.submat(...) //! X %= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise multiplication"); arma_debug_assert_same_size(out, in, "element-wise multiplication");
const u32 n_rows = out.n_rows; const u32 n_rows = in.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<n_cols; ++col) const Mat<eT>& X = in.m;
const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1;
u32 i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j);
out_mem[i] *= tmp1;
out_mem[j] *= tmp2;
}
if(i < n_cols)
{ {
out_mem[col] *= in.at(0,col); out_mem[i] *= X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(u32 col=0; col<n_cols; ++col)
{ {
arrayops::inplace_mul(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_mul(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
skipping to change at line 1132 skipping to change at line 1512
//! X /= Y.submat(...) //! X /= Y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in) subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, in, "element-wise division"); arma_debug_assert_same_size(out, in, "element-wise division");
const u32 n_rows = out.n_rows; const u32 n_rows = in.n_rows;
const u32 n_cols = out.n_cols; const u32 n_cols = in.n_cols;
if(n_rows == 1) if(n_rows == 1)
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(u32 col=0; col<n_cols; ++col) const Mat<eT>& X = in.m;
const u32 row = in.aux_row1;
const u32 start_col = in.aux_col1;
u32 i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp1 = X.at(row, start_col+i);
const eT tmp2 = X.at(row, start_col+j);
out_mem[i] /= tmp1;
out_mem[j] /= tmp2;
}
if(i < n_cols)
{ {
out_mem[col] /= in.at(0,col); out_mem[i] /= X.at(row, start_col+i);
} }
} }
else else
{ {
for(u32 col=0; col<n_cols; ++col) for(u32 col=0; col<n_cols; ++col)
{ {
arrayops::inplace_div(out.colptr(col), in.colptr(col), n_rows); arrayops::inplace_div(out.colptr(col), in.colptr(col), n_rows);
} }
} }
} }
// //! creation of subview (row vector)
//
//
template<typename eT> template<typename eT>
arma_inline inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col) subview_row<eT>
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1) subview<eT>::row(const u32 row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" );
const u32 base_row = aux_row1 + row_num;
return subview_row<eT>(*m_ptr, base_row, aux_col1, n_cols);
} }
//! creation of subview (row vector)
template<typename eT> template<typename eT>
arma_inline inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col) const subview_row<eT>
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1) subview<eT>::row(const u32 row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" );
const u32 base_row = aux_row1 + row_num;
return subview_row<eT>(m, base_row, aux_col1, n_cols);
} }
template<typename eT> template<typename eT>
arma_inline inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col, const u subview_row<eT>
32 in_row1, const u32 in_n_rows) subview<eT>::operator()(const u32 row_num, const span& col_span)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
}
template<typename eT> const bool col_all = col_span.whole;
arma_inline
const u32 local_n_cols = n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
const u32 base_col1 = aux_col1 + in_col1;
const u32 base_row = aux_row1 + row_num;
arma_debug_check
(
(row_num >= n_rows)
||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols))
)
,
"subview::operator(): indices out of bounds or incorrectly used"
);
return subview_row<eT>(*m_ptr, base_row, base_col1, submat_n_cols);
}
template<typename eT>
inline
const subview_row<eT>
subview<eT>::operator()(const u32 row_num, const span& col_span) const
{
arma_extra_debug_sigprint();
const bool col_all = col_span.whole;
const u32 local_n_cols = n_cols;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
const u32 base_col1 = aux_col1 + in_col1;
const u32 base_row = aux_row1 + row_num;
arma_debug_check
(
(row_num >= n_rows)
||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols))
)
,
"subview::operator(): indices out of bounds or incorrectly used"
);
return subview_row<eT>(m, base_row, base_col1, submat_n_cols);
}
//! creation of subview (column vector)
template<typename eT>
inline
subview_col<eT>
subview<eT>::col(const u32 col_num)
{
arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds");
const u32 base_col = aux_col1 + col_num;
return subview_col<eT>(*m_ptr, base_col, aux_row1, n_rows);
}
//! creation of subview (column vector)
template<typename eT>
inline
const subview_col<eT>
subview<eT>::col(const u32 col_num) const
{
arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds");
const u32 base_col = aux_col1 + col_num;
return subview_col<eT>(m, base_col, aux_row1, n_rows);
}
template<typename eT>
inline
subview_col<eT>
subview<eT>::operator()(const span& row_span, const u32 col_num)
{
arma_extra_debug_sigprint();
const bool row_all = row_span.whole;
const u32 local_n_rows = n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
const u32 base_row1 = aux_row1 + in_row1;
const u32 base_col = aux_col1 + col_num;
arma_debug_check
(
(col_num >= n_cols)
||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows))
)
,
"subview::operator(): indices out of bounds or incorrectly used"
);
return subview_col<eT>(*m_ptr, base_col, base_row1, submat_n_rows);
}
template<typename eT>
inline
const subview_col<eT>
subview<eT>::operator()(const span& row_span, const u32 col_num) const
{
arma_extra_debug_sigprint();
const bool row_all = row_span.whole;
const u32 local_n_rows = n_rows;
const u32 in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
const u32 base_row1 = aux_row1 + in_row1;
const u32 base_col = aux_col1 + col_num;
arma_debug_check
(
(col_num >= n_cols)
||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows))
)
,
"subview::operator(): indices out of bounds or incorrectly used"
);
return subview_col<eT>(m, base_col, base_row1, submat_n_rows);
}
//! create a Col object which uses memory from an existing matrix object.
//! this approach is currently not alias safe
//! and does not take into account that the parent matrix object could be d
eleted.
//! if deleted memory is accessed by the created Col object,
//! it will cause memory corruption and/or a crash
template<typename eT>
inline
Col<eT>
subview<eT>::unsafe_col(const u32 col_num)
{
arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::unsafe_col(): out of bound
s");
return Col<eT>(colptr(col_num), n_rows, false, true);
}
//! create a Col object which uses memory from an existing matrix object.
//! this approach is currently not alias safe
//! and does not take into account that the parent matrix object could be d
eleted.
//! if deleted memory is accessed by the created Col object,
//! it will cause memory corruption and/or a crash
template<typename eT>
inline
const Col<eT>
subview<eT>::unsafe_col(const u32 col_num) const
{
arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::unsafe_col(): out of bound
s");
return Col<eT>(const_cast<eT*>(colptr(col_num)), n_rows, false, true);
}
//! creation of subview (submatrix comprised of specified row vectors)
template<typename eT>
inline
subview<eT>
subview<eT>::rows(const u32 in_row1, const u32 in_row2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 > in_row2) || (in_row2 >= n_rows),
"subview::rows(): indices out of bounds or incorrectly used"
);
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = aux_row1 + in_row1;
return subview<eT>(*m_ptr, base_row1, aux_col1, subview_n_rows, n_cols );
}
//! creation of subview (submatrix comprised of specified row vectors)
template<typename eT>
inline
const subview<eT>
subview<eT>::rows(const u32 in_row1, const u32 in_row2) const
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 > in_row2) || (in_row2 >= n_rows),
"subview::rows(): indices out of bounds or incorrectly used"
);
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = aux_row1 + in_row1;
return subview<eT>(m, base_row1, aux_col1, subview_n_rows, n_cols );
}
//! creation of subview (submatrix comprised of specified column vectors)
template<typename eT>
inline
subview<eT>
subview<eT>::cols(const u32 in_col1, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_col1 > in_col2) || (in_col2 >= n_cols),
"subview::cols(): indices out of bounds or incorrectly used"
);
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, aux_row1, base_col1, n_rows, subview_n_cols);
}
//! creation of subview (submatrix comprised of specified column vectors)
template<typename eT>
inline
const subview<eT>
subview<eT>::cols(const u32 in_col1, const u32 in_col2) const
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_col1 > in_col2) || (in_col2 >= n_cols),
"subview::cols(): indices out of bounds or incorrectly used"
);
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = aux_col1 + in_col1;
return subview<eT>(m, aux_row1, base_col1, n_rows, subview_n_cols);
}
//! creation of subview (submatrix)
template<typename eT>
inline
subview<eT>
subview<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2
, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (
in_col2 >= n_cols),
"subview::submat(): indices out of bounds or incorrectly used"
);
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, base_row1, base_col1, subview_n_rows, subview_
n_cols);
}
//! creation of subview (generic submatrix)
template<typename eT>
inline
const subview<eT>
subview<eT>::submat(const u32 in_row1, const u32 in_col1, const u32 in_row2
, const u32 in_col2) const
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (
in_col2 >= n_cols),
"subview::submat(): indices out of bounds or incorrectly used"
);
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1;
return subview<eT>(m, base_row1, base_col1, subview_n_rows, subview_n_col
s);
}
//! creation of subview (submatrix)
template<typename eT>
inline
subview<eT>
subview<eT>::submat(const span& row_span, const span& col_span)
{
arma_extra_debug_sigprint();
const bool row_all = row_span.whole;
const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
arma_debug_check
(
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows))
)
||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols))
)
,
"subview::submat(): indices out of bounds or incorrectly used"
);
const u32 base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, base_row1, base_col1, submat_n_rows, submat_n_
cols);
}
//! creation of subview (generic submatrix)
template<typename eT>
inline
const subview<eT>
subview<eT>::submat(const span& row_span, const span& col_span) const
{
arma_extra_debug_sigprint();
const bool row_all = row_span.whole;
const bool col_all = col_span.whole;
const u32 local_n_rows = n_rows;
const u32 local_n_cols = n_cols;
const u32 in_row1 = row_all ? 0 : row_span.a;
const u32 in_row2 = row_span.b;
const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
const u32 in_col1 = col_all ? 0 : col_span.a;
const u32 in_col2 = col_span.b;
const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
arma_debug_check
(
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows))
)
||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols))
)
,
"subview::submat(): indices out of bounds or incorrectly used"
);
const u32 base_row1 = aux_row1 + in_row1;
const u32 base_col1 = aux_col1 + in_col1;
return subview<eT>(m, base_row1, base_col1, submat_n_rows, submat_n_cols)
;
}
template<typename eT>
inline
subview<eT>
subview<eT>::operator()(const span& row_span, const span& col_span)
{
arma_extra_debug_sigprint();
return (*this).submat(row_span, col_span);
}
template<typename eT>
inline
const subview<eT>
subview<eT>::operator()(const span& row_span, const span& col_span) const
{
arma_extra_debug_sigprint();
return (*this).submat(row_span, col_span);
}
//! creation of diagview (diagonal)
template<typename eT>
inline
diagview<eT>
subview<eT>::diag(const s32 in_id)
{
arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0;
const u32 col_offset = (in_id > 0) ? u32( in_id) : 0;
arma_debug_check
(
(row_offset >= n_rows) || (col_offset >= n_cols),
"subview::diag(): requested diagonal out of bounds"
);
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
const u32 base_row_offset = aux_row1 + row_offset;
const u32 base_col_offset = aux_col1 + col_offset;
return diagview<eT>(*m_ptr, base_row_offset, base_col_offset, len);
}
//! creation of diagview (diagonal)
template<typename eT>
inline
const diagview<eT>
subview<eT>::diag(const s32 in_id) const
{
arma_extra_debug_sigprint();
const u32 row_offset = (in_id < 0) ? -in_id : 0;
const u32 col_offset = (in_id > 0) ? in_id : 0;
arma_debug_check
(
(row_offset >= n_rows) || (col_offset >= n_cols),
"subview::diag(): requested diagonal out of bounds"
);
const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
const u32 base_row_offset = aux_row1 + row_offset;
const u32 base_col_offset = aux_col1 + col_offset;
return diagview<eT>(m, base_row_offset, base_col_offset, len);
}
template<typename eT>
inline
void
subview<eT>::swap_rows(const u32 in_row1, const u32 in_row2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_row1 >= n_rows) || (in_row2 >= n_rows),
"subview::swap_rows(): out of bounds"
);
eT* mem = (*m_ptr).memptr();
for(u32 col=0; col<n_cols; ++col)
{
const u32 offset = (aux_col1 + col) * m.n_rows;
const u32 pos1 = aux_row1 + in_row1 + offset;
const u32 pos2 = aux_row1 + in_row2 + offset;
const eT tmp = mem[pos1];
access::rw(mem[pos1]) = mem[pos2];
access::rw(mem[pos2]) = tmp;
}
}
template<typename eT>
inline
void
subview<eT>::swap_cols(const u32 in_col1, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(in_col1 >= n_cols) || (in_col2 >= n_cols),
"subview::swap_cols(): out of bounds"
);
eT* ptr1 = colptr(in_col1);
eT* ptr2 = colptr(in_col2);
for(u32 row=0; row<n_rows; ++row)
{
const eT tmp = ptr1[row];
ptr1[row] = ptr2[row];
ptr2[row] = tmp;
}
}
// template<typename eT>
// inline
// subview<eT>::iter::iter(const subview<eT>& S)
// : mem (S.m.mem)
// , n_rows (S.m.n_rows)
// , row_start (S.aux_row1)
// , row_end_p1(row_start + S.n_rows)
// , row (row_start)
// , col (S.aux_col1)
// , i (row + col*n_rows)
// {
// arma_extra_debug_sigprint();
// }
//
//
//
// template<typename eT>
// arma_inline
// eT
// subview<eT>::iter::operator*() const
// {
// return mem[i];
// }
//
//
//
// template<typename eT>
// inline
// void
// subview<eT>::iter::operator++()
// {
// ++row;
//
// if(row < row_end_p1)
// {
// ++i;
// }
// else
// {
// row = row_start;
// ++col;
//
// i = row + col*n_rows;
// }
// }
//
//
//
// template<typename eT>
// inline
// void
// subview<eT>::iter::operator++(int)
// {
// operator++();
// }
//
//
//
template<typename eT>
inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col, const u
32 in_row1, const u32 in_n_rows)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col, const u32 in_ row1, const u32 in_n_rows) subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col, const u32 in_ row1, const u32 in_n_rows)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1) : subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_col<eT>::operator=(const subview<eT>& X) subview_col<eT>::operator=(const subview<eT>& X)
skipping to change at line 1223 skipping to change at line 2210
inline inline
void void
subview_col<eT>::operator=(const Base<eT,T1>& X) subview_col<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
} }
template<typename eT>
inline
subview_col<eT>
subview_col<eT>::rows(const u32 in_row1, const u32 in_row2)
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row
s) ), "subview_col::rows(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview
_n_rows);
}
template<typename eT>
inline
const subview_col<eT>
subview_col<eT>::rows(const u32 in_row1, const u32 in_row2) const
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row
s) ), "subview_col::rows(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows
);
}
template<typename eT>
inline
subview_col<eT>
subview_col<eT>::subvec(const u32 in_row1, const u32 in_row2)
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row
s) ), "subview_col::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview
_n_rows);
}
template<typename eT>
inline
const subview_col<eT>
subview_col<eT>::subvec(const u32 in_row1, const u32 in_row2) const
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row
s) ), "subview_col::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_rows = in_row2 - in_row1 + 1;
const u32 base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows
);
}
// //
// //
// //
template<typename eT> template<typename eT>
arma_inline inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row) subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row)
: subview<eT>(in_m, in_row, 0, 1, in_m.n_cols) : subview<eT>(in_m, in_row, 0, 1, in_m.n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row) subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row)
: subview<eT>(in_m, in_row, 0, 1, in_m.n_cols) : subview<eT>(in_m, in_row, 0, 1, in_m.n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row, const u 32 in_col1, const u32 in_n_cols) subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row, const u 32 in_col1, const u32 in_n_cols)
: subview<eT>(in_m, in_row, in_col1, 1, in_n_cols) : subview<eT>(in_m, in_row, in_col1, 1, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row, const u32 in_ col1, const u32 in_n_cols) subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row, const u32 in_ col1, const u32 in_n_cols)
: subview<eT>(in_m, in_row, in_col1, 1, in_n_cols) : subview<eT>(in_m, in_row, in_col1, 1, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
void void
subview_row<eT>::operator=(const subview<eT>& X) subview_row<eT>::operator=(const subview<eT>& X)
skipping to change at line 1293 skipping to change at line 2344
inline inline
void void
subview_row<eT>::operator=(const Base<eT,T1>& X) subview_row<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
} }
template<typename eT>
inline
subview_row<eT>
subview_row<eT>::cols(const u32 in_col1, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col
s) ), "subview_row::cols(): indices out of bounds or incorrectly used" );
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview
_n_cols);
}
template<typename eT>
inline
const subview_row<eT>
subview_row<eT>::cols(const u32 in_col1, const u32 in_col2) const
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col
s) ), "subview_row::cols(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols
);
}
template<typename eT>
inline
subview_row<eT>
subview_row<eT>::subvec(const u32 in_col1, const u32 in_col2)
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col
s) ), "subview_row::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview
_n_cols);
}
template<typename eT>
inline
const subview_row<eT>
subview_row<eT>::subvec(const u32 in_col1, const u32 in_col2) const
{
arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col
s) ), "subview_row::subvec(): indices out of bounds or incorrectly used");
const u32 subview_n_cols = in_col2 - in_col1 + 1;
const u32 base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols
);
}
//! @} //! @}
 End of changes. 87 change blocks. 
127 lines changed or deleted 1280 lines changed or added


 traits.hpp   traits.hpp 
skipping to change at line 325 skipping to change at line 325
// //
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>
{ static const bool value = true; }; { static const bool value = true; };
template<typename T1, typename T2>
struct isnt_same_type
{
static const bool value = true;
inline static void check()
{
arma_static_assert<false> ERROR___TYPE_MISMATCH;
ERROR___TYPE_MISMATCH = ERROR___TYPE_MISMATCH;
}
};
template<typename T1>
struct isnt_same_type<T1,T1>
{
static const bool value = false;
arma_inline static void check() {}
};
// //
// //
// //
template<typename T1> template<typename T1>
struct is_u8 struct is_u8
{ static const bool value = false; }; { static const bool value = false; };
template<> template<>
struct is_u8<u8> struct is_u8<u8>
skipping to change at line 398 skipping to change at line 378
template<typename T1> template<typename T1>
struct is_s32 struct is_s32
{ static const bool value = false; }; { static const bool value = false; };
template<> template<>
struct is_s32<s32> struct is_s32<s32>
{ static const bool value = true; }; { static const bool value = true; };
template<typename T1> template<typename T1>
struct is_u64
{ static const bool value = false; };
template<>
struct is_u64<u64>
{ static const bool value = true; };
template<typename T1>
struct is_float struct is_float
{ static const bool value = false; }; { static const bool value = false; };
template<> template<>
struct is_float<float> struct is_float<float>
{ static const bool value = true; }; { static const bool value = true; };
template<typename T1> template<typename T1>
struct is_double struct is_double
{ static const bool value = false; }; { static const bool value = false; };
skipping to change at line 474 skipping to change at line 462
template<typename T1> template<typename T1>
struct is_supported_elem_type struct is_supported_elem_type
{ {
static const bool value = \ static const bool value = \
is_u8<T1>::value || is_u8<T1>::value ||
is_s8<T1>::value || is_s8<T1>::value ||
is_u16<T1>::value || is_u16<T1>::value ||
is_s16<T1>::value || is_s16<T1>::value ||
is_u32<T1>::value || is_u32<T1>::value ||
is_s32<T1>::value || is_s32<T1>::value ||
is_u64<T1>::value ||
is_float<T1>::value || is_float<T1>::value ||
is_double<T1>::value || is_double<T1>::value ||
is_supported_complex_float<T1>::value || is_supported_complex_float<T1>::value ||
is_supported_complex_double<T1>::value; is_supported_complex_double<T1>::value;
}; };
template<typename T1> template<typename T1>
struct isnt_supported_elem_type
{
static const bool value = true;
inline static void check()
{
arma_static_assert<false> ERROR___UNSUPPORTED_ELEMENT_TYPE;
ERROR___UNSUPPORTED_ELEMENT_TYPE = ERROR___UNSUPPORTED_ELEMENT_TYPE;
}
};
struct isnt_supported_elem_type_false
{
static const bool value = false;
arma_inline static void check() {}
};
template<> struct isnt_supported_elem_type< u8 > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< s8 > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< u16 > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< s16 > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< u32 > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< s32 > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< float > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< double > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< std::complex<float> > : public
isnt_supported_elem_type_false {};
template<> struct isnt_supported_elem_type< std::complex<double> > : public
isnt_supported_elem_type_false {};
template<typename T1>
struct is_supported_blas_type struct is_supported_blas_type
{ {
static const bool value = \ static const bool value = \
is_float<T1>::value || is_float<T1>::value ||
is_double<T1>::value || is_double<T1>::value ||
is_supported_complex_float<T1>::value || is_supported_complex_float<T1>::value ||
is_supported_complex_double<T1>::value; is_supported_complex_double<T1>::value;
}; };
template<typename T> template<typename T>
 End of changes. 4 change blocks. 
60 lines changed or deleted 9 lines changed or added


 unwrap.hpp   unwrap.hpp 
skipping to change at line 449 skipping to change at line 449
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1> template<typename T1>
class partial_unwrap< Op<T1, op_trans> > class partial_unwrap< Op<T1, op_htrans> >
{ {
public: public:
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
partial_unwrap(const Op<T1,op_trans>& A) partial_unwrap(const Op<T1,op_htrans>& A)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 478 skipping to change at line 478
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Mat<eT>, op_trans> > class partial_unwrap< Op< Mat<eT>, op_htrans> >
{ {
public: public:
inline inline
partial_unwrap(const Op< Mat<eT>, op_trans>& A) partial_unwrap(const Op< Mat<eT>, op_htrans>& A)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 505 skipping to change at line 505
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Row<eT>, op_trans> > class partial_unwrap< Op< Row<eT>, op_htrans> >
{ {
public: public:
inline inline
partial_unwrap(const Op< Row<eT>, op_trans>& A) partial_unwrap(const Op< Row<eT>, op_htrans>& A)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 532 skipping to change at line 532
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Col<eT>, op_trans> > class partial_unwrap< Op< Col<eT>, op_htrans> >
{ {
public: public:
inline inline
partial_unwrap(const Op< Col<eT>, op_trans>& A) partial_unwrap(const Op< Col<eT>, op_htrans>& A)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 559 skipping to change at line 559
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1> template<typename T1>
class partial_unwrap< Op<T1, op_trans2> > class partial_unwrap< Op<T1, op_htrans2> >
{ {
public: public:
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
partial_unwrap(const Op<T1,op_trans2>& A) partial_unwrap(const Op<T1,op_htrans2>& A)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 588 skipping to change at line 588
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Mat<eT>, op_trans2> > class partial_unwrap< Op< Mat<eT>, op_htrans2> >
{ {
public: public:
inline inline
partial_unwrap(const Op< Mat<eT>, op_trans2>& A) partial_unwrap(const Op< Mat<eT>, op_htrans2>& A)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 615 skipping to change at line 615
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Row<eT>, op_trans2> > class partial_unwrap< Op< Row<eT>, op_htrans2> >
{ {
public: public:
inline inline
partial_unwrap(const Op< Row<eT>, op_trans2>& A) partial_unwrap(const Op< Row<eT>, op_htrans2>& A)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 642 skipping to change at line 642
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Col<eT>, op_trans2> > class partial_unwrap< Op< Col<eT>, op_htrans2> >
{ {
public: public:
inline inline
partial_unwrap(const Op< Col<eT>, op_trans2>& A) partial_unwrap(const Op< Col<eT>, op_htrans2>& A)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap() ~partial_unwrap()
skipping to change at line 915 skipping to change at line 915
// the order below is important // the order below is important
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1> template<typename T1>
class partial_unwrap_check< Op<T1, op_trans> > class partial_unwrap_check< Op<T1, op_htrans> >
{ {
public: public:
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
partial_unwrap_check(const Op<T1,op_trans>& A, const Mat<eT>& B) partial_unwrap_check(const Op<T1,op_htrans>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(B); arma_ignore(B);
} }
inline inline
skipping to change at line 945 skipping to change at line 945
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Mat<eT>, op_trans> > class partial_unwrap_check< Op< Mat<eT>, op_htrans> >
{ {
public: public:
inline inline
partial_unwrap_check(const Op< Mat<eT>, op_trans>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Mat<eT>, op_htrans>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 980 skipping to change at line 980
// the order below is important // the order below is important
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Row<eT>, op_trans> > class partial_unwrap_check< Op< Row<eT>, op_htrans> >
{ {
public: public:
inline inline
partial_unwrap_check(const Op< Row<eT>, op_trans>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Row<eT>, op_htrans>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1015 skipping to change at line 1015
// the order below is important // the order below is important
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Col<eT>, op_trans> > class partial_unwrap_check< Op< Col<eT>, op_htrans> >
{ {
public: public:
inline inline
partial_unwrap_check(const Op< Col<eT>, op_trans>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Col<eT>, op_htrans>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(false) , do_times(false)
, val (1) , val (1)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1050 skipping to change at line 1050
// the order below is important // the order below is important
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1> template<typename T1>
class partial_unwrap_check< Op<T1, op_trans2> > class partial_unwrap_check< Op<T1, op_htrans2> >
{ {
public: public:
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
partial_unwrap_check(const Op<T1,op_trans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op<T1,op_htrans2>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 1079 skipping to change at line 1079
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Mat<eT>, op_trans2> > class partial_unwrap_check< Op< Mat<eT>, op_htrans2> >
{ {
public: public:
inline inline
partial_unwrap_check(const Op< Mat<eT>, op_trans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1114 skipping to change at line 1114
// the order below is important // the order below is important
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Row<eT>, op_trans2> > class partial_unwrap_check< Op< Row<eT>, op_htrans2> >
{ {
public: public:
inline inline
partial_unwrap_check(const Op< Row<eT>, op_trans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Row<eT>, op_htrans2>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1149 skipping to change at line 1149
// the order below is important // the order below is important
const bool do_trans; const bool do_trans;
const bool do_times; const bool do_times;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Col<eT>, op_trans2> > class partial_unwrap_check< Op< Col<eT>, op_htrans2> >
{ {
public: public:
inline inline
partial_unwrap_check(const Op< Mat<eT>, op_trans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B)
: do_trans(true) : do_trans(true)
, do_times(true) , do_times(true)
, val (A.aux) , val (A.aux)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
 End of changes. 32 change blocks. 
32 lines changed or deleted 32 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/