Col_meat.hpp   Col_meat.hpp 
skipping to change at line 126 skipping to change at line 126
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
return *this; return *this;
} }
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const std::initializer_list<eT>& list) Col<eT>::Col(const std::initializer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(list); Mat<eT>::operator=(list);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
} }
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const std::initializer_list<eT>& list) Col<eT>::operator=(const std::initializer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(list); Mat<eT>::operator=(list);
std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) ); std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const eT val) Col<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 820 skipping to change at line 820
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<eT>::operator=(X); Col<eT>::operator=(X);
return *this; return *this;
} }
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list) Col<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list
: Col<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local )
_extra : Mat<eT>::mem_local) ) : Col<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_loc
{ al_extra : Mat<eT>::mem_local) )
arma_extra_debug_sigprint_this(this); {
arma_extra_debug_sigprint_this(this);
(*this).operator=(list); (*this).operator=(list);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>& li Col<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>&
st) list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = list.size(); const uword N = list.size();
arma_debug_check( (N > fixed_n_elem), "Col::fixed: initialiser list is to o long" ); arma_debug_check( (N > fixed_n_elem), "Col::fixed: initialiser list is too long" );
eT* this_mem = (*this).memptr(); eT* this_mem = (*this).memptr();
arrayops::copy( this_mem, list.begin(), N ); arrayops::copy( this_mem, list.begin(), N );
for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); } for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) Col<eT>::fixed<fixed_n_elem>::operator[] (const uword ii)
{ {
 End of changes. 20 change blocks. 
47 lines changed or deleted 48 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 2268 skipping to change at line 2268
return (*this).fill(eT(1)); return (*this).fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randu() Cube<eT>::randu()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = n_elem; eop_aux_randu<eT>::fill( memptr(), n_elem );
eT* ptr = memptr();
uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
ptr[i] = eT(eop_aux_randu<eT>());
ptr[j] = eT(eop_aux_randu<eT>());
}
if(i < N)
{
ptr[i] = eT(eop_aux_randu<eT>());
}
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randu(const uword in_rows, const uword in_cols, const uword in_sl ices) Cube<eT>::randu(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2306 skipping to change at line 2292
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randn() Cube<eT>::randn()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = n_elem; eop_aux_randn<eT>::fill( memptr(), n_elem );
eT* ptr = memptr();
for(uword i=0; i<N; ++i)
{
ptr[i] = eT(eop_aux_randn<eT>());
}
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randn(const uword in_rows, const uword in_cols, const uword in_sl ices) Cube<eT>::randn(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 2 change blocks. 
22 lines changed or deleted 2 lines changed or added


 Mat_bones.hpp   Mat_bones.hpp 
skipping to change at line 133 skipping to change at line 133
template<typename T1> inline const Mat& operator/=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator/=(const subview_elem1<eT ,T1>& X);
template<typename T1, typename T2> inline Mat(const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline Mat(const sub view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator= (const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline const Mat& operator= (const sub view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator+=(const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline const Mat& operator+=(const sub view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator-=(const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline const Mat& operator-=(const sub view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator*=(const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline const Mat& operator*=(const sub view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator%=(const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline const Mat& operator%=(const sub view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator/=(const sub view_elem2<eT,T1,T2>& X); template<typename T1, typename T2> inline const Mat& operator/=(const sub view_elem2<eT,T1,T2>& X);
// Operators on sparse matrices (and subviews).
template<typename T1> inline explicit Mat(const SpBase<eT, T1>&
m);
template<typename T1> inline const Mat& operator=(const SpBase<eT, T1>&
m);
template<typename T1> inline const Mat& operator+=(const SpBase<eT, T1>&
m);
template<typename T1> inline const Mat& operator-=(const SpBase<eT, T1>&
m);
template<typename T1> inline const Mat& operator*=(const SpBase<eT, T1>&
m);
template<typename T1> inline const Mat& operator%=(const SpBase<eT, T1>&
m);
template<typename T1> inline const Mat& operator/=(const SpBase<eT, T1>&
m);
inline mat_injector<Mat> operator<<(const eT val); inline mat_injector<Mat> operator<<(const eT val);
inline mat_injector<Mat> operator<<(const injector_end_of_row<>& x); inline mat_injector<Mat> operator<<(const injector_end_of_row<>& x);
arma_inline subview_row<eT> row(const uword row_num); arma_inline subview_row<eT> row(const uword row_num);
arma_inline const subview_row<eT> row(const uword row_num) const; arma_inline const subview_row<eT> row(const uword row_num) const;
inline subview_row<eT> operator()(const uword row_num, const s pan& col_span); inline subview_row<eT> operator()(const uword row_num, const s pan& col_span);
inline const subview_row<eT> operator()(const uword row_num, const s pan& col_span) const; inline const subview_row<eT> operator()(const uword row_num, const s pan& col_span) const;
arma_inline subview_col<eT> col(const uword col_num); arma_inline subview_col<eT> col(const uword col_num);
skipping to change at line 184 skipping to change at line 193
template<typename T1, typename T2> arma_inline subview_elem2<eT,T1, T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci); template<typename T1, typename T2> arma_inline subview_elem2<eT,T1, T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci);
template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1, T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const; template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1, T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const;
template<typename T1> arma_inline subview_elem2<eT,T1,T1> rows(cons t Base<uword,T1>& ri); template<typename T1> arma_inline subview_elem2<eT,T1,T1> rows(cons t Base<uword,T1>& ri);
template<typename T1> arma_inline const subview_elem2<eT,T1,T1> rows(cons t Base<uword,T1>& ri) const; template<typename T1> arma_inline const subview_elem2<eT,T1,T1> rows(cons t Base<uword,T1>& ri) const;
template<typename T2> arma_inline subview_elem2<eT,T2,T2> cols(cons t Base<uword,T2>& ci); template<typename T2> arma_inline subview_elem2<eT,T2,T2> cols(cons t Base<uword,T2>& ci);
template<typename T2> arma_inline const subview_elem2<eT,T2,T2> cols(cons t Base<uword,T2>& ci) const; template<typename T2> arma_inline const subview_elem2<eT,T2,T2> cols(cons t Base<uword,T2>& ci) const;
arma_inline subview_each1< Mat<eT>, 0 > each_col();
arma_inline subview_each1< Mat<eT>, 1 > each_row();
template<typename T1> inline subview_each2< Mat<eT>, 0, T1 > each_col(con
st Base<uword, T1>& indices);
template<typename T1> inline subview_each2< Mat<eT>, 1, T1 > each_row(con
st Base<uword, T1>& indices);
arma_inline diagview<eT> diag(const sword in_id = 0); arma_inline diagview<eT> diag(const sword in_id = 0);
arma_inline const diagview<eT> diag(const sword in_id = 0) const; arma_inline const diagview<eT> diag(const sword in_id = 0) const;
inline void swap_rows(const uword in_row1, const uword in_row2); inline void swap_rows(const uword in_row1, const uword in_row2);
inline void swap_cols(const uword in_col1, const uword in_col2); inline void swap_cols(const uword in_col1, const uword in_col2);
inline void shed_row(const uword row_num); inline void shed_row(const uword row_num);
inline void shed_col(const uword col_num); inline void shed_col(const uword col_num);
inline void shed_rows(const uword in_row1, const uword in_row2); inline void shed_rows(const uword in_row1, const uword in_row2);
 End of changes. 2 change blocks. 
0 lines changed or deleted 24 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 413 skipping to change at line 413
} }
++urow; ++urow;
line_start = line_end+1; line_start = line_end+1;
} }
} }
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const std::initializer_list<eT>& list) Mat<eT>::Mat(const std::initializer_list<eT>& list)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
, n_elem(0) , n_elem(0)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
, mem() , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(list); init(list);
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const std::initializer_list<eT>& list) Mat<eT>::operator=(const std::initializer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(list); init(list);
return *this; return *this;
} }
#endif #endif
//! Set the matrix to be equal to the specified scalar. //! Set the matrix to be equal to the specified scalar.
//! NOTE: the size of the matrix will be 1x1 //! NOTE: the size of the matrix will be 1x1
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eT val) Mat<eT>::operator=(const eT val)
{ {
skipping to change at line 1773 skipping to change at line 1773
Mat<eT>::operator/=(const subview_elem2<eT,T1,T2>& X) Mat<eT>::operator/=(const subview_elem2<eT,T1,T2>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_elem2<eT,T1,T2>::div_inplace(*this, X); subview_elem2<eT,T1,T2>::div_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1>
inline
Mat<eT>::Mat(const SpBase<eT, T1>& m)
: n_rows(0)
, n_cols(0)
, n_elem(0)
, vec_state(0)
, mem_state(0)
, mem()
{
arma_extra_debug_sigprint_this(this);
const SpProxy<T1> p(m.get_ref());
access::rw(n_rows) = p.get_n_rows();
access::rw(n_cols) = p.get_n_cols();
access::rw(n_elem) = p.get_n_elem();
init_cold();
fill(eT(0));
// Iterate over each nonzero element and set it.
for(typename SpProxy<T1>::const_iterator_type it = p.begin(); it.pos() <
p.get_n_nonzero(); ++it)
{
at(it.row(), it.col()) = (*it);
}
}
template<typename eT>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::operator=(const SpBase<eT, T1>& m)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(m.get_ref());
init_warm(p.get_n_rows(), p.get_n_cols());
fill(eT(0));
for(typename SpProxy<T1>::const_iterator_type it = p.begin(); it.pos() <
p.get_n_nonzero(); ++it)
{
at(it.row(), it.col()) = (*it);
}
return *this;
}
template<typename eT>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::operator+=(const SpBase<eT, T1>& m)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(m.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "addition");
for(typename SpProxy<T1>::const_iterator_type it = p.begin(); it.pos() <
p.get_n_nonzero(); ++it)
{
at(it.row(), it.col()) += (*it);
}
return *this;
}
template<typename eT>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::operator-=(const SpBase<eT, T1>& m)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(m.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "subtraction");
for(typename SpProxy<T1>::const_iterator_type it = p.begin(); it.pos() <
p.get_n_nonzero(); ++it)
{
at(it.row(), it.col()) -= (*it);
}
return *this;
}
template<typename eT>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::operator*=(const SpBase<eT, T1>& m)
{
arma_extra_debug_sigprint();
Mat<eT> z;
z = (*this) * m.get_ref();
steal_mem(z);
return *this;
}
template<typename eT>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::operator%=(const SpBase<eT, T1>& m)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(m.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "element-wise multiplication");
typename SpProxy<T1>::const_iterator_type it = p.begin();
// We have to zero everything that isn't being used.
arrayops::inplace_set(memptr(), eT(0), (it.col() * n_rows) + it.row());
while(it.pos() < p.get_n_nonzero())
{
const uword cur_loc = (it.col() * n_rows) + it.row();
access::rw(mem[cur_loc]) *= (*it);
++it;
const uword next_loc = (it.pos() == p.get_n_nonzero())
? (p.get_n_cols() * n_rows)
: (it.col() * n_rows) + it.row();
arrayops::inplace_set(memptr() + cur_loc + 1, eT(0), (next_loc - cur_lo
c - 1));
}
return *this;
}
template<typename eT>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::operator/=(const SpBase<eT, T1>& m)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(m.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "element-wise division");
// If you use this method, you are probably stupid or misguided, but for
completeness it is implemented.
// Unfortunately the best way to do this is loop over every element.
for(uword c = 0; c < n_cols; ++c)
{
for(uword r = 0; r < n_rows; ++r)
{
at(r, c) /= p.at(r, c);
}
}
return *this;
}
template<typename eT>
inline inline
mat_injector< Mat<eT> > mat_injector< Mat<eT> >
Mat<eT>::operator<<(const eT val) Mat<eT>::operator<<(const eT val)
{ {
return mat_injector< Mat<eT> >(*this, val); return mat_injector< Mat<eT> >(*this, val);
} }
template<typename eT> template<typename eT>
inline inline
mat_injector< Mat<eT> > mat_injector< Mat<eT> >
skipping to change at line 2320 skipping to change at line 2486
template<typename T2> template<typename T2>
arma_inline arma_inline
const subview_elem2<eT,T2,T2> const subview_elem2<eT,T2,T2>
Mat<eT>::cols(const Base<uword,T2>& ci) const Mat<eT>::cols(const Base<uword,T2>& ci) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return subview_elem2<eT,T2,T2>(*this, ci, ci, true, false); return subview_elem2<eT,T2,T2>(*this, ci, ci, true, false);
} }
template<typename eT>
arma_inline
subview_each1< Mat<eT>, 0 >
Mat<eT>::each_col()
{
arma_extra_debug_sigprint();
return subview_each1< Mat<eT>, 0>(*this);
}
template<typename eT>
arma_inline
subview_each1< Mat<eT>, 1 >
Mat<eT>::each_row()
{
arma_extra_debug_sigprint();
return subview_each1< Mat<eT>, 1>(*this);
}
template<typename eT>
template<typename T1>
inline
subview_each2< Mat<eT>, 0, T1 >
Mat<eT>::each_col(const Base<uword, T1>& indices)
{
arma_extra_debug_sigprint();
return subview_each2< Mat<eT>, 0, T1 >(*this, indices);
}
template<typename eT>
template<typename T1>
inline
subview_each2< Mat<eT>, 1, T1 >
Mat<eT>::each_row(const Base<uword, T1>& indices)
{
arma_extra_debug_sigprint();
return subview_each2< Mat<eT>, 1, T1 >(*this, indices);
}
//! 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 sword in_id) Mat<eT>::diag(const sword in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword row_offset = (in_id < 0) ? uword(-in_id) : 0; const uword row_offset = (in_id < 0) ? uword(-in_id) : 0;
const uword col_offset = (in_id > 0) ? uword( in_id) : 0; const uword col_offset = (in_id > 0) ? uword( in_id) : 0;
skipping to change at line 4220 skipping to change at line 4428
return fill(eT(1)); return fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu() Mat<eT>::randu()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = n_elem; eop_aux_randu<eT>::fill( memptr(), n_elem );
eT* ptr = memptr();
uword ii,jj;
for(ii=0, jj=1; jj < N; ii+=2, jj+=2)
{
const eT tmp_ii = eT(eop_aux_randu<eT>());
const eT tmp_jj = eT(eop_aux_randu<eT>());
ptr[ii] = tmp_ii;
ptr[jj] = tmp_jj;
}
if(ii < N)
{
ptr[ii] = eT(eop_aux_randu<eT>());
}
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu(const uword in_elem) Mat<eT>::randu(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 4273 skipping to change at line 4464
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn() Mat<eT>::randn()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = n_elem; eop_aux_randn<eT>::fill( memptr(), n_elem );
eT* ptr = memptr();
for(uword ii=0; ii<N; ++ii)
{
ptr[ii] = eT(eop_aux_randn<eT>());
}
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn(const uword in_elem) Mat<eT>::randn(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 5233 skipping to change at line 5418
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
return *this; return *this;
} }
#endif #endif
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::initializer_li Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::initializer_
st<eT>& list) list<eT>& list)
: Mat<eT>( arma_fixed_indicator(), fixed_n_rows, fixed_n_cols, 0, ((use_e : Mat<eT>( arma_fixed_indicator(), fixed_n_rows, fixed_n_cols, 0, ((use
xtra) ? mem_local_extra : mem_local) ) _extra) ? mem_local_extra : mem_local) )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
(*this).operator=(list); (*this).operator=(list);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::initialize Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::initiali
r_list<eT>& list) zer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = list.size(); const uword N = list.size();
arma_debug_check( (N > fixed_n_elem), "Mat::fixed: initialiser list is to o long" ); arma_debug_check( (N > fixed_n_elem), "Mat::fixed: initialiser list is too long" );
eT* this_mem = (*this).memptr(); eT* this_mem = (*this).memptr();
arrayops::copy( this_mem, list.begin(), N ); arrayops::copy( this_mem, list.begin(), N );
for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); } for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword ii) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword ii)
{ {
 End of changes. 18 change blocks. 
73 lines changed or deleted 268 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 102 skipping to change at line 102
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
return *this; return *this;
} }
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const std::initializer_list<eT>& list) Row<eT>::Row(const std::initializer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(list); Mat<eT>::operator=(list);
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const std::initializer_list<eT>& list) Row<eT>::operator=(const std::initializer_list<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::operator=(list); Mat<eT>::operator=(list);
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const eT val) Row<eT>::operator=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 760 skipping to change at line 760
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(X); Row<eT>::operator=(X);
return *this; return *this;
} }
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list) Row<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list
: Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local )
_extra : Mat<eT>::mem_local) ) : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_loc
{ al_extra : Mat<eT>::mem_local) )
arma_extra_debug_sigprint_this(this); {
arma_extra_debug_sigprint_this(this);
(*this).operator=(list); (*this).operator=(list);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>& li Row<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>&
st) list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword N = list.size(); const uword N = list.size();
arma_debug_check( (N > fixed_n_elem), "Row::fixed: initialiser list is to o long" ); arma_debug_check( (N > fixed_n_elem), "Row::fixed: initialiser list is too long" );
eT* this_mem = (*this).memptr(); eT* this_mem = (*this).memptr();
arrayops::copy( this_mem, list.begin(), N ); arrayops::copy( this_mem, list.begin(), N );
for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); } for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii)
{ {
 End of changes. 15 change blocks. 
42 lines changed or deleted 43 lines changed or added


 access.hpp   access.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup access //! \addtogroup access
//! @{ //! @{
class access class access
{ {
public: public:
//! internal function to allow modification of data declared as read-only //! internal function to allow modification of data declared as read-only
template<typename T1> arma_inline static T1& rw(const T1& x) { return con template<typename T1> arma_inline static T1& rw (const T1& x) { r
st_cast<T1&>(x); } eturn const_cast<T1& >(x); }
template<typename T1> arma_inline static T1*& rwp(const T1* const& x) { r
eturn const_cast<T1*&>(x); }
//! internal function to allow modification of
//! internal function to obtain the real part of either a plain number or a complex number //! internal function to obtain the real part of either a plain number or a complex number
template<typename eT> arma_inline static const eT& tmp_real(const eT& X) { return X; } template<typename eT> arma_inline static const eT& tmp_real(const eT& X) { return X; }
template<typename T> arma_inline static const T tmp_real(const std::co mplex<T>& X) { return X.real(); } template<typename T> arma_inline static const T tmp_real(const std::co mplex<T>& X) { return X.real(); }
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
2 lines changed or deleted 6 lines changed or added


 arma_config.hpp   arma_config.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 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 24 skipping to change at line 24
//! @{ //! @{
struct arma_config struct arma_config
{ {
#if defined(ARMA_MAT_PREALLOC) #if defined(ARMA_MAT_PREALLOC)
static const uword mat_prealloc = (sword(ARMA_MAT_PREALLOC) > 0) ? uwor d(ARMA_MAT_PREALLOC) : 1; static const uword mat_prealloc = (sword(ARMA_MAT_PREALLOC) > 0) ? uwor d(ARMA_MAT_PREALLOC) : 1;
#else #else
static const uword mat_prealloc = 16; static const uword mat_prealloc = 16;
#endif #endif
// TODO: place ARMA_SPMAT_CHUNKSIZE in confg.hpp and config.hpp.cmake
#if defined(ARMA_SPMAT_CHUNKSIZE)
static const uword spmat_chunksize = (sword(ARMA_SPMAT_CHUNKSIZE) > 0)
? uword(ARMA_SPMAT_CHUNKSIZE) : 256;
#else
static const uword spmat_chunksize = 256;
#endif
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
static const bool atlas = true; static const bool atlas = true;
#else #else
static const bool atlas = false; static const bool atlas = false;
#endif #endif
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
static const bool lapack = true; static const bool lapack = true;
#else #else
static const bool lapack = false; static const bool lapack = false;
 End of changes. 2 change blocks. 
2 lines changed or deleted 10 lines changed or added


 arma_ostream_bones.hpp   arma_ostream_bones.hpp 
skipping to change at line 38 skipping to change at line 38
inline void restore(std::ostream& o) const; inline void restore(std::ostream& o) const;
}; };
class arma_ostream class arma_ostream
{ {
public: public:
template<typename eT> inline static std::streamsize modify_stream(std::os tream& o, const eT* data, const uword n_elem); template<typename eT> inline static std::streamsize modify_stream(std::os tream& o, const eT* data, const uword n_elem);
template<typename T> inline static std::streamsize modify_stream(std::os tream& o, const std::complex<T>* data, const uword n_elem); template<typename T> inline static std::streamsize modify_stream(std::os tream& o, const std::complex<T>* data, const uword n_elem);
template<typename eT> inline static std::streamsize modify_stream(std::os
tream& o, typename SpMat<eT>::const_iterator begin, const uword n_elem, con
st typename arma_not_cx<eT>::result* junk = 0);
template<typename T> inline static std::streamsize modify_stream(std::os
tream& o, typename SpMat<T>::const_iterator begin, const uword n_elem, cons
t typename arma_cx_only<T>::result* junk = 0);
template<typename eT> inline static void print_elem_zero(std::ostream& o) ; template<typename eT> inline static void print_elem_zero(std::ostream& o) ;
template<typename eT> arma_inline static void print_elem(std::ostream& o, const eT& x); template<typename eT> arma_inline static void print_elem(std::ostream& o, const eT& x);
template<typename T> inline static void print_elem(std::ostream& o, const std::complex<T>& x); template<typename T> inline static void print_elem(std::ostream& o, const std::complex<T>& x);
template<typename eT> inline static void print(std::ostream& o, const Ma t<eT>& m, const bool modify); template<typename eT> inline static void print(std::ostream& o, const Ma t<eT>& m, const bool modify);
template<typename eT> inline static void print(std::ostream& o, const Cub e<eT>& m, const bool modify); template<typename eT> inline static void print(std::ostream& o, const Cub e<eT>& m, const bool modify);
template<typename oT> inline static void print(std::ostream& o, const fie ld<oT>& m); template<typename oT> inline static void print(std::ostream& o, const fie ld<oT>& m);
template<typename oT> inline static void print(std::ostream& o, const sub view_field<oT>& m); template<typename oT> inline static void print(std::ostream& o, const sub view_field<oT>& m);
template<typename eT> inline static void print_dense(std::ostream& o, con
st SpMat<eT>& m, const bool modify);
template<typename eT> inline static void print(std::ostream& o, const SpM
at<eT>& m, const bool modify);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 11 lines changed or added


 arma_ostream_meat.hpp   arma_ostream_meat.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2012 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)
skipping to change at line 151 skipping to change at line 152
std::streamsize cell_width; std::streamsize cell_width;
o.precision(3); o.precision(3);
cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1; cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1;
return cell_width; return cell_width;
} }
template<typename eT> template<typename eT>
inline inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, typename SpMat<eT>::const_iter
ator begin, const uword n_elem, const typename arma_not_cx<eT>::result* jun
k)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
o.unsetf(ios::showbase);
o.unsetf(ios::uppercase);
o.unsetf(ios::showpos);
o.fill(' ');
std::streamsize cell_width;
bool use_layout_B = false;
bool use_layout_C = false;
for(typename SpMat<eT>::const_iterator it = begin; it.pos() < n_elem; ++i
t)
{
const eT val = *it;
if(
val >= eT(+100) ||
( (is_signed<eT>::value == true) && (val <= eT(-100)) ) ||
( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT
(+1e-4)) ) ||
( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == tr
ue) && (val < eT(0)) && (val >= eT(-1e-4)) )
)
{
use_layout_C = true;
break;
}
if(
(val >= eT(+10)) || ( (is_signed<eT>::value == true) && (val <= eT(-1
0)) )
)
{
use_layout_B = true;
}
}
if(use_layout_C == true)
{
o.setf(ios::scientific);
o.setf(ios::right);
o.unsetf(ios::fixed);
o.precision(4);
cell_width = 13;
}
else
if(use_layout_B == true)
{
o.unsetf(ios::scientific);
o.setf(ios::right);
o.setf(ios::fixed);
o.precision(4);
cell_width = 10;
}
else
{
o.unsetf(ios::scientific);
o.setf(ios::right);
o.setf(ios::fixed);
o.precision(4);
cell_width = 9;
}
return cell_width;
}
//! "better than nothing" settings for complex numbers
template<typename T>
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, typename SpMat<T>::const_itera
tor begin, const uword n_elem, const typename arma_cx_only<T>::result* junk
)
{
arma_ignore(begin);
arma_ignore(n_elem);
arma_ignore(junk);
o.unsetf(ios::showbase);
o.unsetf(ios::uppercase);
o.fill(' ');
o.setf(ios::scientific);
o.setf(ios::showpos);
o.setf(ios::right);
o.unsetf(ios::fixed);
std::streamsize cell_width;
o.precision(3);
cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1;
return cell_width;
}
template<typename eT>
inline
void void
arma_ostream::print_elem_zero(std::ostream& o) arma_ostream::print_elem_zero(std::ostream& o)
{ {
const std::streamsize orig_precision = o.precision(); const std::streamsize orig_precision = o.precision();
o.precision(0); o.precision(0);
o << eT(0); o << eT(0);
o.precision(orig_precision); o.precision(orig_precision);
skipping to change at line 362 skipping to change at line 461
o << x.at(row,col) << '\n'; o << x.at(row,col) << '\n';
} }
o << '\n'; o << '\n';
} }
o.flush(); o.flush();
stream_state.restore(o); stream_state.restore(o);
} }
template<typename eT>
inline
void
arma_ostream::print_dense(std::ostream& o, const SpMat<eT>& m, const bool m
odify)
{
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
const uword m_n_rows = m.n_rows;
const uword m_n_cols = m.n_cols;
if(m.n_nonzero > 0)
{
const std::streamsize cell_width = modify ? modify_stream<eT>(o, m.begi
n(), m.n_nonzero) : o.width();
typename SpMat<eT>::const_iterator begin = m.begin();
if(m_n_cols > 0)
{
if(cell_width > 0)
{
// An efficient row_iterator would make this simpler and faster
for(uword row=0; row < m_n_rows; ++row)
{
for(uword col=0; col < m_n_cols; ++col)
{
// the cell width appears to be reset after each element is pri
nted,
// hence we need to restore it
o.width(cell_width);
eT val = 0;
for(typename SpMat<eT>::const_iterator it = begin; it.pos() < m
.n_nonzero; ++it)
{
if(it.row() == row && it.col() == col)
{
val = *it;
break;
}
}
arma_ostream::print_elem(o,eT(val));
}
o << '\n';
}
}
else
{
// An efficient row_iterator would make this simpler and faster
for(uword row=0; row < m_n_rows; ++row)
{
for(uword col=0; col < m_n_cols; ++col)
{
eT val = 0;
for(typename SpMat<eT>::const_iterator it = begin; it.pos() < m
.n_nonzero; ++it)
{
if(it.row() == row && it.col() == col)
{
val = *it;
break;
}
}
arma_ostream::print_elem(o,eT(val));
o << ' ';
}
o << '\n';
}
}
}
}
else
{
o << "[matrix size: " << m_n_rows << 'x' << m_n_cols << "]\n";
}
o.flush();
stream_state.restore(o);
}
template<typename eT>
inline
void
arma_ostream::print(std::ostream& o, const SpMat<eT>& m, const bool modify)
{
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
o.unsetf(ios::showbase);
o.unsetf(ios::uppercase);
o.unsetf(ios::showpos);
o.unsetf(ios::scientific);
o.setf(ios::right);
o.setf(ios::fixed);
o.precision(2);
const uword m_n_nonzero = m.n_nonzero;
o << "[matrix size: " << m.n_rows << 'x' << m.n_cols << "; n_nonzero: " <
< m_n_nonzero
<< "; density: " << ((m.n_elem > 0) ? (double(m_n_nonzero) / double(m.n
_elem) * double(100)) : double(0))
<< "%]\n\n";
if(modify == false) { stream_state.restore(o); }
if(m_n_nonzero > 0)
{
const std::streamsize cell_width = modify ? modify_stream<eT>(o, m.begi
n(), m_n_nonzero) : o.width();
typename SpMat<eT>::const_iterator begin = m.begin();
while(begin.pos() < m_n_nonzero)
{
const uword row = begin.row();
// TODO: change the maximum number of spaces before and after each lo
cation to be dependent on n_rows and n_cols
if(row < 10) { o << " "; }
else if(row < 100) { o << " "; }
else if(row < 1000) { o << " "; }
else if(row < 10000) { o << " "; }
else if(row < 100000) { o << ' '; }
const uword col = begin.col();
o << '(' << row << ", " << col << ") ";
if(col < 10) { o << " "; }
else if(col < 100) { o << " "; }
else if(col < 1000) { o << " "; }
else if(col < 10000) { o << " "; }
else if(col < 100000) { o << ' '; }
if(cell_width > 0) { o.width(cell_width); }
arma_ostream::print_elem(o, eT(*begin));
o << '\n';
++begin;
}
o << '\n';
}
o.flush();
stream_state.restore(o);
}
//! @} //! @}
 End of changes. 3 change blocks. 
0 lines changed or deleted 263 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 3 #define ARMA_VERSION_MAJOR 3
#define ARMA_VERSION_MINOR 2 #define ARMA_VERSION_MINOR 3
#define ARMA_VERSION_PATCH 5 #define ARMA_VERSION_PATCH 91
#define ARMA_VERSION_NAME "Creamfields" #define ARMA_VERSION_NAME "v3.4 beta 1; for testing use only"
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 112 skipping to change at line 112
#include "armadillo_bits/memory.hpp" #include "armadillo_bits/memory.hpp"
#include "armadillo_bits/span.hpp" #include "armadillo_bits/span.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
#include "armadillo_bits/constants_compat.hpp" #include "armadillo_bits/constants_compat.hpp"
// //
// class prototypes // class prototypes
#include "armadillo_bits/Base_bones.hpp" #include "armadillo_bits/Base_bones.hpp"
#include "armadillo_bits/BaseCube_bones.hpp" #include "armadillo_bits/BaseCube_bones.hpp"
#include "armadillo_bits/SpBase_bones.hpp"
#include "armadillo_bits/blas_bones.hpp" #include "armadillo_bits/blas_bones.hpp"
#include "armadillo_bits/lapack_bones.hpp" #include "armadillo_bits/lapack_bones.hpp"
#include "armadillo_bits/atlas_bones.hpp" #include "armadillo_bits/atlas_bones.hpp"
#include "armadillo_bits/blas_wrapper.hpp" #include "armadillo_bits/blas_wrapper.hpp"
#include "armadillo_bits/lapack_wrapper.hpp" #include "armadillo_bits/lapack_wrapper.hpp"
#include "armadillo_bits/atlas_wrapper.hpp" #include "armadillo_bits/atlas_wrapper.hpp"
#include "armadillo_bits/cond_rel_bones.hpp" #include "armadillo_bits/cond_rel_bones.hpp"
skipping to change at line 133 skipping to change at line 134
#include "armadillo_bits/podarray_bones.hpp" #include "armadillo_bits/podarray_bones.hpp"
#include "armadillo_bits/auxlib_bones.hpp" #include "armadillo_bits/auxlib_bones.hpp"
#include "armadillo_bits/injector_bones.hpp" #include "armadillo_bits/injector_bones.hpp"
#include "armadillo_bits/Mat_bones.hpp" #include "armadillo_bits/Mat_bones.hpp"
#include "armadillo_bits/Col_bones.hpp" #include "armadillo_bits/Col_bones.hpp"
#include "armadillo_bits/Row_bones.hpp" #include "armadillo_bits/Row_bones.hpp"
#include "armadillo_bits/Cube_bones.hpp" #include "armadillo_bits/Cube_bones.hpp"
#include "armadillo_bits/SpValProxy_bones.hpp"
#include "armadillo_bits/SpMat_bones.hpp"
#include "armadillo_bits/SpCol_bones.hpp"
#include "armadillo_bits/SpRow_bones.hpp"
#include "armadillo_bits/SpSubview_bones.hpp"
#include "armadillo_bits/typedef_fixed.hpp" #include "armadillo_bits/typedef_fixed.hpp"
#include "armadillo_bits/field_bones.hpp" #include "armadillo_bits/field_bones.hpp"
#include "armadillo_bits/subview_bones.hpp" #include "armadillo_bits/subview_bones.hpp"
#include "armadillo_bits/subview_elem1_bones.hpp" #include "armadillo_bits/subview_elem1_bones.hpp"
#include "armadillo_bits/subview_elem2_bones.hpp" #include "armadillo_bits/subview_elem2_bones.hpp"
#include "armadillo_bits/subview_field_bones.hpp" #include "armadillo_bits/subview_field_bones.hpp"
#include "armadillo_bits/subview_cube_bones.hpp" #include "armadillo_bits/subview_cube_bones.hpp"
#include "armadillo_bits/diagview_bones.hpp" #include "armadillo_bits/diagview_bones.hpp"
#include "armadillo_bits/subview_each_bones.hpp"
#include "armadillo_bits/diskio_bones.hpp" #include "armadillo_bits/diskio_bones.hpp"
#include "armadillo_bits/wall_clock_bones.hpp" #include "armadillo_bits/wall_clock_bones.hpp"
#include "armadillo_bits/running_stat_bones.hpp" #include "armadillo_bits/running_stat_bones.hpp"
#include "armadillo_bits/running_stat_vec_bones.hpp" #include "armadillo_bits/running_stat_vec_bones.hpp"
#include "armadillo_bits/Op_bones.hpp" #include "armadillo_bits/Op_bones.hpp"
#include "armadillo_bits/OpCube_bones.hpp" #include "armadillo_bits/OpCube_bones.hpp"
#include "armadillo_bits/SpOp_bones.hpp"
#include "armadillo_bits/eOp_bones.hpp" #include "armadillo_bits/eOp_bones.hpp"
#include "armadillo_bits/eOpCube_bones.hpp" #include "armadillo_bits/eOpCube_bones.hpp"
#include "armadillo_bits/mtOp_bones.hpp" #include "armadillo_bits/mtOp_bones.hpp"
#include "armadillo_bits/mtOpCube_bones.hpp" #include "armadillo_bits/mtOpCube_bones.hpp"
#include "armadillo_bits/Glue_bones.hpp" #include "armadillo_bits/Glue_bones.hpp"
#include "armadillo_bits/eGlue_bones.hpp" #include "armadillo_bits/eGlue_bones.hpp"
#include "armadillo_bits/mtGlue_bones.hpp" #include "armadillo_bits/mtGlue_bones.hpp"
#include "armadillo_bits/SpGlue_bones.hpp"
#include "armadillo_bits/GlueCube_bones.hpp" #include "armadillo_bits/GlueCube_bones.hpp"
#include "armadillo_bits/eGlueCube_bones.hpp" #include "armadillo_bits/eGlueCube_bones.hpp"
#include "armadillo_bits/mtGlueCube_bones.hpp" #include "armadillo_bits/mtGlueCube_bones.hpp"
#include "armadillo_bits/eop_core_bones.hpp" #include "armadillo_bits/eop_core_bones.hpp"
#include "armadillo_bits/eglue_core_bones.hpp" #include "armadillo_bits/eglue_core_bones.hpp"
#include "armadillo_bits/Gen_bones.hpp" #include "armadillo_bits/Gen_bones.hpp"
#include "armadillo_bits/GenCube_bones.hpp" #include "armadillo_bits/GenCube_bones.hpp"
skipping to change at line 221 skipping to change at line 231
#include "armadillo_bits/glue_kron_bones.hpp" #include "armadillo_bits/glue_kron_bones.hpp"
#include "armadillo_bits/glue_cross_bones.hpp" #include "armadillo_bits/glue_cross_bones.hpp"
#include "armadillo_bits/glue_join_bones.hpp" #include "armadillo_bits/glue_join_bones.hpp"
#include "armadillo_bits/glue_relational_bones.hpp" #include "armadillo_bits/glue_relational_bones.hpp"
#include "armadillo_bits/glue_solve_bones.hpp" #include "armadillo_bits/glue_solve_bones.hpp"
#include "armadillo_bits/glue_conv_bones.hpp" #include "armadillo_bits/glue_conv_bones.hpp"
#include "armadillo_bits/glue_toeplitz_bones.hpp" #include "armadillo_bits/glue_toeplitz_bones.hpp"
#include "armadillo_bits/glue_hist_bones.hpp" #include "armadillo_bits/glue_hist_bones.hpp"
#include "armadillo_bits/glue_histc_bones.hpp" #include "armadillo_bits/glue_histc_bones.hpp"
#include "armadillo_bits/spop_max_bones.hpp"
#include "armadillo_bits/spop_min_bones.hpp"
#include "armadillo_bits/spop_sum_bones.hpp"
#include "armadillo_bits/spop_strans_bones.hpp"
#include "armadillo_bits/spop_htrans_bones.hpp"
#include "armadillo_bits/spop_misc_bones.hpp"
#include "armadillo_bits/spglue_plus_bones.hpp"
#include "armadillo_bits/spglue_minus_bones.hpp"
#include "armadillo_bits/spglue_times_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"
// //
// classes that underlay metaprogramming // classes that underlay metaprogramming
#include "armadillo_bits/unwrap.hpp" #include "armadillo_bits/unwrap.hpp"
#include "armadillo_bits/unwrap_cube.hpp" #include "armadillo_bits/unwrap_cube.hpp"
#include "armadillo_bits/unwrap_spmat.hpp"
#include "armadillo_bits/Proxy.hpp" #include "armadillo_bits/Proxy.hpp"
#include "armadillo_bits/ProxyCube.hpp" #include "armadillo_bits/ProxyCube.hpp"
#include "armadillo_bits/SpProxy.hpp"
#include "armadillo_bits/diagmat_proxy.hpp" #include "armadillo_bits/diagmat_proxy.hpp"
#include "armadillo_bits/strip.hpp" #include "armadillo_bits/strip.hpp"
#include "armadillo_bits/Op_meat.hpp" #include "armadillo_bits/Op_meat.hpp"
#include "armadillo_bits/OpCube_meat.hpp" #include "armadillo_bits/OpCube_meat.hpp"
#include "armadillo_bits/SpOp_meat.hpp"
#include "armadillo_bits/mtOp_meat.hpp" #include "armadillo_bits/mtOp_meat.hpp"
#include "armadillo_bits/mtOpCube_meat.hpp" #include "armadillo_bits/mtOpCube_meat.hpp"
#include "armadillo_bits/Glue_meat.hpp" #include "armadillo_bits/Glue_meat.hpp"
#include "armadillo_bits/GlueCube_meat.hpp" #include "armadillo_bits/GlueCube_meat.hpp"
#include "armadillo_bits/SpGlue_meat.hpp"
#include "armadillo_bits/eop_aux.hpp" #include "armadillo_bits/eop_aux.hpp"
#include "armadillo_bits/eOp_meat.hpp" #include "armadillo_bits/eOp_meat.hpp"
#include "armadillo_bits/eOpCube_meat.hpp" #include "armadillo_bits/eOpCube_meat.hpp"
#include "armadillo_bits/eGlue_meat.hpp" #include "armadillo_bits/eGlue_meat.hpp"
#include "armadillo_bits/eGlueCube_meat.hpp" #include "armadillo_bits/eGlueCube_meat.hpp"
#include "armadillo_bits/mtGlue_meat.hpp" #include "armadillo_bits/mtGlue_meat.hpp"
#include "armadillo_bits/mtGlueCube_meat.hpp" #include "armadillo_bits/mtGlueCube_meat.hpp"
#include "armadillo_bits/Base_meat.hpp" #include "armadillo_bits/Base_meat.hpp"
#include "armadillo_bits/BaseCube_meat.hpp" #include "armadillo_bits/BaseCube_meat.hpp"
#include "armadillo_bits/SpBase_meat.hpp"
#include "armadillo_bits/Gen_meat.hpp" #include "armadillo_bits/Gen_meat.hpp"
#include "armadillo_bits/GenCube_meat.hpp" #include "armadillo_bits/GenCube_meat.hpp"
// //
// ostream // ostream
#include "armadillo_bits/arma_ostream_bones.hpp" #include "armadillo_bits/arma_ostream_bones.hpp"
#include "armadillo_bits/arma_ostream_meat.hpp" #include "armadillo_bits/arma_ostream_meat.hpp"
// //
// n_unique, which is used by some sparse operators
#include "armadillo_bits/fn_n_unique.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"
#include "armadillo_bits/operator_relational.hpp" #include "armadillo_bits/operator_relational.hpp"
#include "armadillo_bits/operator_cube_plus.hpp" #include "armadillo_bits/operator_cube_plus.hpp"
skipping to change at line 364 skipping to change at line 395
#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_symmat.hpp"
#include "armadillo_bits/fn_syl_lyap.hpp" #include "armadillo_bits/fn_syl_lyap.hpp"
#include "armadillo_bits/fn_hist.hpp" #include "armadillo_bits/fn_hist.hpp"
#include "armadillo_bits/fn_histc.hpp" #include "armadillo_bits/fn_histc.hpp"
#include "armadillo_bits/fn_unique.hpp" #include "armadillo_bits/fn_unique.hpp"
#include "armadillo_bits/fn_speye.hpp"
#include "armadillo_bits/fn_spones.hpp"
#include "armadillo_bits/fn_sprandn.hpp"
#include "armadillo_bits/fn_sprandu.hpp"
// misc stuff
#include "armadillo_bits/hdf5_misc.hpp"
// //
// class meat // class meat
#include "armadillo_bits/gemv.hpp" #include "armadillo_bits/gemv.hpp"
#include "armadillo_bits/gemm.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"
skipping to change at line 392 skipping to change at line 432
#include "armadillo_bits/Col_meat.hpp" #include "armadillo_bits/Col_meat.hpp"
#include "armadillo_bits/Row_meat.hpp" #include "armadillo_bits/Row_meat.hpp"
#include "armadillo_bits/Cube_meat.hpp" #include "armadillo_bits/Cube_meat.hpp"
#include "armadillo_bits/field_meat.hpp" #include "armadillo_bits/field_meat.hpp"
#include "armadillo_bits/subview_meat.hpp" #include "armadillo_bits/subview_meat.hpp"
#include "armadillo_bits/subview_elem1_meat.hpp" #include "armadillo_bits/subview_elem1_meat.hpp"
#include "armadillo_bits/subview_elem2_meat.hpp" #include "armadillo_bits/subview_elem2_meat.hpp"
#include "armadillo_bits/subview_field_meat.hpp" #include "armadillo_bits/subview_field_meat.hpp"
#include "armadillo_bits/subview_cube_meat.hpp" #include "armadillo_bits/subview_cube_meat.hpp"
#include "armadillo_bits/diagview_meat.hpp" #include "armadillo_bits/diagview_meat.hpp"
#include "armadillo_bits/subview_each_meat.hpp"
#include "armadillo_bits/SpValProxy_meat.hpp"
#include "armadillo_bits/SpMat_meat.hpp"
#include "armadillo_bits/SpMat_iterators_meat.hpp"
#include "armadillo_bits/SpCol_meat.hpp"
#include "armadillo_bits/SpRow_meat.hpp"
#include "armadillo_bits/SpSubview_meat.hpp"
#include "armadillo_bits/SpSubview_iterators_meat.hpp"
#include "armadillo_bits/diskio_meat.hpp" #include "armadillo_bits/diskio_meat.hpp"
#include "armadillo_bits/wall_clock_meat.hpp" #include "armadillo_bits/wall_clock_meat.hpp"
#include "armadillo_bits/running_stat_meat.hpp" #include "armadillo_bits/running_stat_meat.hpp"
#include "armadillo_bits/running_stat_vec_meat.hpp" #include "armadillo_bits/running_stat_vec_meat.hpp"
#include "armadillo_bits/op_diagmat_meat.hpp" #include "armadillo_bits/op_diagmat_meat.hpp"
#include "armadillo_bits/op_diagvec_meat.hpp" #include "armadillo_bits/op_diagvec_meat.hpp"
#include "armadillo_bits/op_dot_meat.hpp" #include "armadillo_bits/op_dot_meat.hpp"
#include "armadillo_bits/op_inv_meat.hpp" #include "armadillo_bits/op_inv_meat.hpp"
skipping to change at line 447 skipping to change at line 496
#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"
#include "armadillo_bits/glue_conv_meat.hpp" #include "armadillo_bits/glue_conv_meat.hpp"
#include "armadillo_bits/glue_toeplitz_meat.hpp" #include "armadillo_bits/glue_toeplitz_meat.hpp"
#include "armadillo_bits/glue_hist_meat.hpp" #include "armadillo_bits/glue_hist_meat.hpp"
#include "armadillo_bits/glue_histc_meat.hpp" #include "armadillo_bits/glue_histc_meat.hpp"
#include "armadillo_bits/spop_max_meat.hpp"
#include "armadillo_bits/spop_min_meat.hpp"
#include "armadillo_bits/spop_sum_meat.hpp"
#include "armadillo_bits/spop_strans_meat.hpp"
#include "armadillo_bits/spop_htrans_meat.hpp"
#include "armadillo_bits/spop_misc_meat.hpp"
#include "armadillo_bits/spglue_plus_meat.hpp"
#include "armadillo_bits/spglue_minus_meat.hpp"
#include "armadillo_bits/spglue_times_meat.hpp"
} }
#endif #endif
 End of changes. 15 change blocks. 
0 lines changed or deleted 60 lines changed or added


 arrayops_bones.hpp   arrayops_bones.hpp 
skipping to change at line 28 skipping to change at line 28
public: public:
template<typename eT> template<typename eT>
arma_hot arma_inline static void arma_hot arma_inline static void
copy(eT* dest, const eT* src, const uword n_elem); copy(eT* dest, const eT* src, const uword n_elem);
template<typename eT> template<typename eT>
static inline void static inline void
copy_big(eT* dest, const eT* src, const uword n_elem); copy_big(eT* dest, const eT* src, const uword n_elem);
template<typename eT>
arma_hot inline static void
copy_forwards(eT* dest, const eT* src, const uword n_elem);
template<typename eT>
arma_hot inline static void
copy_backwards(eT* dest, const eT* src, const uword n_elem);
// //
// array = convert(array) // array = convert(array)
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_inline static void arma_hot arma_inline static void
convert_cx_scalar(out_eT& out, const in_eT& in, const typename arma_not_ cx<out_eT>::result* junk1 = 0, const typename arma_not_cx< in_eT>::result* junk2 = 0); convert_cx_scalar(out_eT& out, const in_eT& in, const typename arma_not_ cx<out_eT>::result* junk1 = 0, const typename arma_not_cx< in_eT>::result* junk2 = 0);
template<typename out_eT, typename in_T> template<typename out_eT, typename in_T>
arma_hot arma_inline static void arma_hot arma_inline static void
convert_cx_scalar(out_eT& out, const std::complex<in_T>& in, const typena me arma_not_cx<out_eT>::result* junk = 0); convert_cx_scalar(out_eT& out, const std::complex<in_T>& in, const typena me arma_not_cx<out_eT>::result* junk = 0);
 End of changes. 1 change blocks. 
0 lines changed or deleted 8 lines changed or added


 arrayops_meat.hpp   arrayops_meat.hpp 
skipping to change at line 123 skipping to change at line 123
dest[3] = src[3]; dest[3] = src[3];
case 3: case 3:
dest[2] = src[2]; dest[2] = src[2];
case 2: case 2:
dest[1] = src[1]; dest[1] = src[1];
case 1: case 1:
dest[0] = src[0]; dest[0] = src[0];
} }
} }
template<typename eT>
arma_hot
inline
void
arrayops::copy_forwards(eT* dest, const eT* src, const uword n_elem)
{
// can't use std::memcpy(), as we don't know how it copies data
uword i,j;
for(i=0, j=1; j < n_elem; i+=2, j+=2)
{
dest[i] = src[i];
dest[j] = src[j];
}
if(i < n_elem)
{
dest[i] = src[i];
}
}
// template<typename eT>
// arma_hot
// inline
// void
// arrayops::copy_backwards(eT* dest, const eT* src, const uword n_elem)
// {
// // can't use std::memcpy(), as we don't know how it copies data
//
// switch(n_elem)
// {
// default:
// for(uword i = (n_elem-1); i >= 1; --i) { dest[i] = src[i]; }
// // NOTE: the 'break' statement has been deliberately omitted
// case 1:
// dest[0] = src[0];
// case 0:
// ;
// }
// }
template<typename eT>
arma_hot
inline
void
arrayops::copy_backwards(eT* dest, const eT* src, const uword n_elem)
{
// can't use std::memcpy(), as we don't know how it copies data
switch(n_elem)
{
default:
{
uword i, j;
for(i = (n_elem-1), j = (n_elem-2); j >= 2; i-=2, j-=2)
{
const eT tmp_i = src[i];
const eT tmp_j = src[j];
dest[i] = tmp_i;
dest[j] = tmp_j;
}
// j is less than 2: it can be 1 or 0
// i is j+1, ie. less than 3: it can be 2 or 1
if(i == 2)
{
dest[2] = src[2];
}
}
// NOTE: the 'break' statement has been deliberately omitted
case 2:
dest[1] = src[1];
case 1:
dest[0] = src[0];
case 0:
;
}
}
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,
const typename arma_not_cx<out_eT>::result* junk1, const typename arma_not_cx<out_eT>::result* junk1,
const typename arma_not_cx< in_eT>::result* junk2 const typename arma_not_cx< in_eT>::result* junk2
 End of changes. 1 change blocks. 
0 lines changed or deleted 81 lines changed or added


 auxlib_bones.hpp   auxlib_bones.hpp 
skipping to change at line 137 skipping to change at line 137
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool chol(Mat<eT>& out, const Base<eT,T1>& X); inline static bool chol(Mat<eT>& out, const Base<eT,T1>& X);
// //
// qr // qr
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X); inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X);
template<typename eT, typename T1>
inline static bool qr_econ(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X);
// //
// svd // svd
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd(Col<eT>& S, const Base<eT,T1>& X, uword& n_rows, u word& n_cols); inline static bool svd(Col<eT>& S, const Base<eT,T1>& X, uword& n_rows, u word& n_cols);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X, uwo rd& n_rows, uword& n_cols); inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X, uwo rd& n_rows, uword& n_cols);
template<typename eT, typename T1> template<typename eT, typename T1>
skipping to change at line 164 skipping to change at line 167
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::co mplex<T> >& V, const Base< std::complex<T>, T1>& X); inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::co mplex<T> >& V, const Base< std::complex<T>, T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Bas e<eT,T1>& X, const char mode); inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Bas e<eT,T1>& X, const char mode);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode); inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode);
template<typename eT, typename T1>
inline static bool svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<
eT,T1>& X);
template<typename T, typename T1>
inline static bool svd_dc(Mat< std::complex<T> >& U, Col<T>& S, Mat< std:
:complex<T> >& V, const Base< std::complex<T>, T1>& X);
// //
// solve // solve
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool slow = false); inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool slow = false);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X); inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
 End of changes. 2 change blocks. 
0 lines changed or deleted 11 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// Copyright (C) 2012 Eric Jon Sundstrom // Copyright (C) 2012 Eric Jon Sundstrom
// Copyright (C) 2012 Michael McNeil Forbes
// //
// 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 493 skipping to change at line 494
{ {
return true; 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';
blas_int n = blas_int(out.n_rows); blas_int n = blas_int(out.n_rows);
blas_int lwork = n*n; // TODO: use lwork = -1 to determine optimal size blas_int lwork = 3 * (n*n); // TODO: use lwork = -1 to determine optima l size
blas_int info = 0; blas_int info = 0;
podarray<blas_int> ipiv; podarray<blas_int> ipiv;
ipiv.set_size(out.n_rows); ipiv.set_size(out.n_rows);
podarray<eT> work; podarray<eT> work;
work.set_size( uword(lwork) ); work.set_size( uword(lwork) );
lapack::sytrf(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr() , &lwork, &info); lapack::sytrf(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr() , &lwork, &info);
skipping to change at line 1135 skipping to change at line 1136
eigval.reset(); eigval.reset();
return true; return true;
} }
eigval.set_size(A.n_rows); eigval.set_size(A.n_rows);
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(A.n_rows); blas_int N = blas_int(A.n_rows);
blas_int lwork = 2*((std::max)(blas_int(1), 3*N-1)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 3*N-1) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &N, A.memptr(), &N, eigval.memptr(), work.me mptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &N, A.memptr(), &N, eigval.memptr(), work.me mptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
skipping to change at line 1183 skipping to change at line 1184
eigval.reset(); eigval.reset();
return true; return true;
} }
eigval.set_size(A.n_rows); eigval.set_size(A.n_rows);
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(A.n_rows); blas_int N = blas_int(A.n_rows);
blas_int lwork = 2*((std::max)(blas_int(1), 2*N-1)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*N-1) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>( (std::max)(blas_int(1), 3*N-2) ) ); podarray<T> rwork( static_cast<uword>( (std::max)(blas_int(1), 3*N-2) ) );
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &N, A.memptr(), &N, eigval.memptr(), work.me mptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &N, A.memptr(), &N, eigval.memptr(), work.me mptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
skipping to change at line 1231 skipping to change at line 1232
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows); eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows); blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 2*((std::max)(blas_int(1), 3*N-1)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 3*N-1) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), wo rk.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), wo rk.memptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
skipping to change at line 1281 skipping to change at line 1282
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows); eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows); blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 2*((std::max)(blas_int(1), 2*N-1)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*N-1) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*N-2)) ); podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*N-2)) );
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), wo rk.memptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), wo rk.memptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
skipping to change at line 1330 skipping to change at line 1331
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows); eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows); blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 2*(1 + 6*N + 2*(N*N)); blas_int lwork = 3 * (1 + 6*N + 2*(N*N));
blas_int liwork = 2*(3 + 5*N + 2); blas_int liwork = 3 * (3 + 5*N + 2);
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>( lwork) ); podarray<eT> work( static_cast<uword>( lwork) );
podarray<blas_int> iwork( static_cast<uword>(liwork) ); podarray<blas_int> iwork( static_cast<uword>(liwork) );
arma_extra_debug_print("lapack::syevd()"); arma_extra_debug_print("lapack::syevd()");
lapack::syevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, iwork.memptr(), &liwork, &info); lapack::syevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, iwork.memptr(), &liwork, &info);
return (info == 0); return (info == 0);
} }
skipping to change at line 1382 skipping to change at line 1383
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows); eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows); blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 2*(2*N + N*N); blas_int lwork = 3 * (2*N + N*N);
blas_int lrwork = 2*(1 + 5*N + 2*(N*N)); blas_int lrwork = 3 * (1 + 5*N + 2*(N*N));
blas_int liwork = 2*(3 + 5*N); blas_int liwork = 3 * (3 + 5*N);
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>(lrwork) ); podarray<T> rwork( static_cast<uword>(lrwork) );
podarray<blas_int> iwork( static_cast<uword>(liwork) ); podarray<blas_int> iwork( static_cast<uword>(liwork) );
arma_extra_debug_print("lapack::heevd()"); arma_extra_debug_print("lapack::heevd()");
lapack::heevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, rwork.memptr(), &lrwork, iwork.memptr(), &liwork, &in fo); lapack::heevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, rwork.memptr(), &lrwork, iwork.memptr(), &liwork, &in fo);
return (info == 0); return (info == 0);
skipping to change at line 1475 skipping to change at line 1476
} }
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size(A_n_rows, A_n_rows);
blas_int N = blas_int(A_n_rows); blas_int N = blas_int(A_n_rows);
blas_int lwork = 2*((std::max)(blas_int(1), 4*N)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 4*N) );
blas_int info = 0; blas_int info = 0;
podarray<T> work( static_cast<uword>(lwork) ); podarray<T> work( static_cast<uword>(lwork) );
podarray<T> wr(A_n_rows); podarray<T> wr(A_n_rows);
podarray<T> wi(A_n_rows); podarray<T> wi(A_n_rows);
arma_extra_debug_print("lapack::geev()"); arma_extra_debug_print("lapack::geev()");
lapack::geev(&jobvl, &jobvr, &N, A.memptr(), &N, wr.memptr(), wi.memptr (), l_eigvec.memptr(), &N, r_eigvec.memptr(), &N, work.memptr(), &lwork, &i nfo); lapack::geev(&jobvl, &jobvr, &N, A.memptr(), &N, wr.memptr(), wi.memptr (), l_eigvec.memptr(), &N, r_eigvec.memptr(), &N, work.memptr(), &lwork, &i nfo);
skipping to change at line 1577 skipping to change at line 1578
} }
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size(A_n_rows, A_n_rows);
blas_int N = blas_int(A_n_rows); blas_int N = blas_int(A_n_rows);
blas_int lwork = 2*((std::max)(blas_int(1), 2*N)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*N) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>(2*N) ); podarray<T> rwork( static_cast<uword>(2*N) );
arma_extra_debug_print("lapack::cx_geev()"); arma_extra_debug_print("lapack::cx_geev()");
lapack::cx_geev(&jobvl, &jobvr, &N, A.memptr(), &N, eigval.memptr(), l_ eigvec.memptr(), &N, r_eigvec.memptr(), &N, work.memptr(), &lwork, rwork.me mptr(), &info); lapack::cx_geev(&jobvl, &jobvr, &N, A.memptr(), &N, eigval.memptr(), l_ eigvec.memptr(), &N, r_eigvec.memptr(), &N, work.memptr(), &lwork, rwork.me mptr(), &info);
return (info == 0); return (info == 0);
} }
skipping to change at line 1672 skipping to change at line 1673
const uword R_n_cols = R.n_cols; const uword R_n_cols = R.n_cols;
if(R.is_empty()) if(R.is_empty())
{ {
Q.eye(R_n_rows, R_n_rows); Q.eye(R_n_rows, R_n_rows);
return true; return true;
} }
blas_int m = static_cast<blas_int>(R_n_rows); blas_int m = static_cast<blas_int>(R_n_rows);
blas_int n = static_cast<blas_int>(R_n_cols); blas_int n = static_cast<blas_int>(R_n_cols);
blas_int work_len = (std::max)(blas_int(1),n); blas_int work_len = 3*((std::max)(blas_int(1),n));
blas_int work_len_tmp; blas_int work_len_tmp;
blas_int k = (std::min)(m,n); blas_int k = (std::min)(m,n);
blas_int info = 0; blas_int info = 0;
podarray<eT> tau( static_cast<uword>(k) ); podarray<eT> tau ( static_cast<uword>(k) );
podarray<eT> work( static_cast<uword>(work_len) ); podarray<eT> work( static_cast<uword>(work_len) );
// query for the optimum value of work_len // query for the optimum value of work_len
work_len_tmp = -1; work_len_tmp = -1;
lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len_tmp, &info); lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len_tmp, &info);
if(info == 0) if(info == 0)
{ {
work_len = static_cast<blas_int>(access::tmp_real(work[0])); work_len_tmp = static_cast<blas_int>(access::tmp_real(work[0]));
work.set_size( static_cast<uword>(work_len) );
if(work_len < work_len_tmp)
{
work_len = work_len_tmp;
work.set_size( static_cast<uword>(work_len) );
}
} }
lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len, &info); lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor k_len, &info);
Q.set_size(R_n_rows, R_n_rows); Q.set_size(R_n_rows, R_n_rows);
arrayops::copy( Q.memptr(), R.memptr(), (std::min)(Q.n_elem, R.n_elem) ); arrayops::copy( Q.memptr(), R.memptr(), (std::min)(Q.n_elem, R.n_elem) );
// //
// construct R // construct R
skipping to change at line 1709 skipping to change at line 1716
for(uword col=0; col < R_n_cols; ++col) for(uword col=0; col < R_n_cols; ++col)
{ {
for(uword row=(col+1); row < R_n_rows; ++row) for(uword row=(col+1); row < R_n_rows; ++row)
{ {
R.at(row,col) = eT(0); R.at(row,col) = eT(0);
} }
} }
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
// query for the optimum value of work_len lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr()
work_len_tmp = -1; , &work_len, &info);
lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() }
, &work_len_tmp, &info); else
if( (is_supported_complex_float<eT>::value == true) || (is_supported_co
mplex_double<eT>::value == true) )
{
lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr()
, &work_len, &info);
}
if(info == 0) return (info == 0);
}
#else
{
arma_ignore(Q);
arma_ignore(R);
arma_ignore(X);
arma_stop("qr(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
template<typename eT, typename T1>
inline
bool
auxlib::qr_econ(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
// This function implements a memory-efficient QR for a non-square X that
has dimensions m x n.
// This basically discards the basis for the null-space.
//
// if m <= n: (use standard routine)
// Q[m,m]*R[m,n] = X[m,n]
// geqrf Needs A[m,n]: Uses R
// orgqr Needs A[m,m]: Uses Q
// otherwise: (memory-efficient routine)
// Q[m,n]*R[n,n] = X[m,n]
// geqrf Needs A[m,n]: Uses Q
// geqrf Needs A[m,n]: Uses Q
#if defined(ARMA_USE_LAPACK)
{
if(is_Mat<T1>::value == true)
{
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& M = tmp.M;
if(M.n_rows < M.n_cols)
{ {
work_len = static_cast<blas_int>(access::tmp_real(work[0])); return auxlib::qr(Q, R, X);
work.set_size( static_cast<uword>(work_len) );
} }
}
lapack::orgqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() Q = X.get_ref();
, &work_len, &info);
const uword Q_n_rows = Q.n_rows;
const uword Q_n_cols = Q.n_cols;
if( Q_n_rows <= Q_n_cols )
{
return auxlib::qr(Q, R, Q);
} }
else
if( (is_supported_complex_float<eT>::value == true) || (is_supported_co if(Q.is_empty())
mplex_double<eT>::value == true) )
{ {
// query for the optimum value of work_len Q.set_size(Q_n_rows, 0 );
work_len_tmp = -1; R.set_size(0, Q_n_cols);
lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() return true;
, &work_len_tmp, &info); }
if(info == 0) blas_int m = static_cast<blas_int>(Q_n_rows);
blas_int n = static_cast<blas_int>(Q_n_cols);
blas_int work_len = 3*((std::max)(blas_int(1),n));
blas_int work_len_tmp;
blas_int k = (std::min)(m,n);
blas_int info = 0;
podarray<eT> tau ( static_cast<uword>(k) );
podarray<eT> work( static_cast<uword>(work_len) );
// query for the optimum value of work_len
work_len_tmp = -1;
lapack::geqrf(&m, &n, Q.memptr(), &m, tau.memptr(), work.memptr(), &wor
k_len_tmp, &info);
if(info == 0)
{
work_len_tmp = static_cast<blas_int>(access::tmp_real(work[0]));
if(work_len < work_len_tmp)
{ {
work_len = static_cast<blas_int>(access::tmp_real(work[0])); work_len = work_len_tmp;
work.set_size( static_cast<uword>(work_len) ); work.set_size( static_cast<uword>(work_len) );
} }
}
lapack::ungqr(&m, &m, &k, Q.memptr(), &m, tau.memptr(), work.memptr() lapack::geqrf(&m, &n, Q.memptr(), &m, tau.memptr(), work.memptr(), &wor
, &work_len, &info); k_len, &info);
// Q now has the elements on and above the diagonal of the array
// contain the min(M,N)-by-N upper trapezoidal matrix Q
// (Q is upper triangular if m >= n);
// the elements below the diagonal, with the array TAU,
// represent the orthogonal matrix Q as a product of min(m,n) elementar
y reflectors.
R.set_size(Q_n_cols, Q_n_cols);
//
// construct R
for(uword col=0; col < Q_n_cols; ++col)
{
for(uword row=0; row <= col; ++row)
{
R.at(row,col) = Q.at(row,col);
}
for(uword row=(col+1); row < Q_n_cols; ++row)
{
R.at(row,col) = eT(0);
}
}
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
lapack::orgqr(&m, &n, &k, Q.memptr(), &m, tau.memptr(), work.memptr()
, &work_len, &info);
}
else
if( (is_supported_complex_float<eT>::value == true) || (is_supported_co
mplex_double<eT>::value == true) )
{
lapack::ungqr(&m, &n, &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(): use of LAPACK needs to be enabled"); arma_stop("qr_econ(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, uword& X_n_rows, uword& X_n_c ols) auxlib::svd(Col<eT>& S, const Base<eT,T1>& X, uword& X_n_rows, uword& X_n_c ols)
{ {
skipping to change at line 1776 skipping to change at line 1887
S.reset(); S.reset();
return true; 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;
blas_int lda = A.n_rows; blas_int min_mn = (std::min)(m,n);
blas_int ldu = U.n_rows; blas_int lda = A.n_rows;
blas_int ldvt = V.n_rows; blas_int ldu = U.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) blas_int ldvt = V.n_rows;
(m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), (std::max)( (3*min_mn
blas_int info = 0; + (std::max)(m,n)), 5*min_mn ) ) );
blas_int info = 0;
S.set_size( static_cast<uword>((std::min)(m, n)) ); S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m,&n, &m,&n,
skipping to change at line 1868 skipping to change at line 1980
S.reset(); S.reset();
return true; 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;
blas_int lda = A.n_rows; blas_int min_mn = (std::min)(m,n);
blas_int ldu = U.n_rows; blas_int lda = A.n_rows;
blas_int ldvt = V.n_rows; blas_int ldu = U.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m blas_int ldvt = V.n_rows;
ax)(m,n) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*min_mn+(std::max)(m,
blas_int info = 0; n) ) );
blas_int info = 0;
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork ) );
podarray< T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); podarray< T> rwork( static_cast<uword>(5*min_mn) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 1982 skipping to change at line 2095
V.eye(A.n_cols, A.n_cols); V.eye(A.n_cols, A.n_cols);
return true; 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 = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int lda = blas_int(A.n_rows); blas_int min_mn = (std::min)(m,n);
blas_int ldu = blas_int(U.n_rows); blas_int lda = blas_int(A.n_rows);
blas_int ldvt = blas_int(V.n_rows); blas_int ldu = blas_int(U.n_rows);
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) blas_int ldvt = blas_int(V.n_rows);
(m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), (std::max)( (3*min_mn
blas_int info = 0; + (std::max)(m,n)), 5*min_mn ) ) );
blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) );
S.set_size( static_cast<uword>((std::min)(m,n)) );
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork_tmp, work.memptr(), &lwork_tmp,
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(work[0]); blas_int proposed_lwork = static_cast<blas_int>(work[0]);
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<uword>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
skipping to change at line 2073 skipping to change at line 2189
V.eye(A.n_cols, A.n_cols); V.eye(A.n_cols, A.n_cols);
return true; 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 = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int lda = blas_int(A.n_rows); blas_int min_mn = (std::min)(m,n);
blas_int ldu = blas_int(U.n_rows); blas_int lda = blas_int(A.n_rows);
blas_int ldvt = blas_int(V.n_rows); blas_int ldu = blas_int(U.n_rows);
blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m blas_int ldvt = blas_int(V.n_rows);
ax)(m,n) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*min_mn + (std::max)(
blas_int info = 0; m,n) ) );
blas_int info = 0;
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork ) );
podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); podarray<T> rwork( static_cast<uword>(5*min_mn) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork_tmp, work.memptr(), &lwork_tmp,
rwork.memptr(), rwork.memptr(),
&info &info
); );
if(info == 0) if(info == 0)
{ {
blas_int proposed_lwork = static_cast<blas_int>(real(work[0])); blas_int proposed_lwork = static_cast<blas_int>(real(work[0]));
if(proposed_lwork > lwork) if(proposed_lwork > lwork)
{ {
lwork = proposed_lwork; lwork = proposed_lwork;
work.set_size( static_cast<uword>(lwork) ); work.set_size( static_cast<uword>(lwork) );
} }
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
skipping to change at line 2138 skipping to change at line 2256
#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(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X, const char mode) auxlib::svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X, const char mode)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
blas_int m = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int lda = blas_int(A.n_rows); blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>(min_mn) );
blas_int ldu = 0; blas_int ldu = 0;
blas_int ldvt = 0; blas_int ldvt = 0;
char jobu; char jobu;
char jobvt; char jobvt;
switch(mode) switch(mode)
{ {
case 'l': case 'l':
jobu = 'S'; jobu = 'S';
jobvt = 'N'; jobvt = 'N';
ldu = m; ldu = m;
ldvt = 1; ldvt = 1;
U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min)( m,n)) ); U.set_size( static_cast<uword>(ldu), static_cast<uword>(min_mn) );
V.reset(); V.reset();
break; break;
case 'r': case 'r':
jobu = 'N'; jobu = 'N';
jobvt = 'S'; jobvt = 'S';
ldu = 1; ldu = 1;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
skipping to change at line 2197 skipping to change at line 2315
break; break;
case 'b': case 'b':
jobu = 'S'; jobu = 'S';
jobvt = 'S'; jobvt = 'S';
ldu = m; ldu = m;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min) U.set_size( static_cast<uword>(ldu), static_cast<uword>(min_mn) );
(m,n)) ); V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n ) );
V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n)
);
break; break;
default: default:
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
return false; return false;
} }
if(A.is_empty()) if(A.is_empty())
{ {
U.eye(); U.eye();
S.reset(); S.reset();
V.eye(); V.eye();
return true; return true;
} }
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)( m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), (std::max)( (3*min_mn + (std::max)(m,n)), 5*min_mn ) ) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &jobu, &jobvt,
skipping to change at line 2289 skipping to change at line 2407
auxlib::svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode) auxlib::svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<T> eT; typedef std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
blas_int m = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int lda = blas_int(A.n_rows); blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>(min_mn) );
blas_int ldu = 0; blas_int ldu = 0;
blas_int ldvt = 0; blas_int ldvt = 0;
char jobu; char jobu;
char jobvt; char jobvt;
switch(mode) switch(mode)
{ {
case 'l': case 'l':
jobu = 'S'; jobu = 'S';
jobvt = 'N'; jobvt = 'N';
ldu = m; ldu = m;
ldvt = 1; ldvt = 1;
U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min)( m,n)) ); U.set_size( static_cast<uword>(ldu), static_cast<uword>(min_mn) );
V.reset(); V.reset();
break; break;
case 'r': case 'r':
jobu = 'N'; jobu = 'N';
jobvt = 'S'; jobvt = 'S';
ldu = 1; ldu = 1;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
skipping to change at line 2334 skipping to change at line 2453
break; break;
case 'b': case 'b':
jobu = 'S'; jobu = 'S';
jobvt = 'S'; jobvt = 'S';
ldu = m; ldu = m;
ldvt = (std::min)(m,n); ldvt = (std::min)(m,n);
U.set_size( static_cast<uword>(ldu), static_cast<uword>((std::min) U.set_size( static_cast<uword>(ldu), static_cast<uword>(min_mn) );
(m,n)) ); V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n) );
V.set_size( static_cast<uword>(ldvt), static_cast<uword>(n)
);
break; break;
default: default:
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
return false; return false;
} }
if(A.is_empty()) if(A.is_empty())
{ {
U.eye(); U.eye();
S.reset(); S.reset();
V.eye(); V.eye();
return true; return true;
} }
blas_int lwork = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min)( m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), (std::max)( (3*min_mn + (std::max)(m,n)), 5*min_mn ) ) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork ) );
podarray<T> rwork( static_cast<uword>(5*(std::min)(m,n)) ); podarray<T> rwork( static_cast<uword>(5*min_mn) );
// let gesvd_() calculate the optimum size of the workspace // let gesvd_() calculate the optimum size of the workspace
blas_int lwork_tmp = -1; blas_int lwork_tmp = -1;
lapack::cx_gesvd<T> lapack::cx_gesvd<T>
( (
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
skipping to change at line 2416 skipping to change at line 2535
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
arma_ignore(mode); arma_ignore(mode);
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
template<typename eT, typename T1>
inline
bool
auxlib::svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
Mat<eT> A(X.get_ref());
if(A.is_empty())
{
U.eye(A.n_rows, A.n_rows);
S.reset();
V.eye(A.n_cols, A.n_cols);
return true;
}
U.set_size(A.n_rows, A.n_rows);
V.set_size(A.n_cols, A.n_cols);
char jobz = 'A';
blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = blas_int(V.n_rows);
blas_int lwork = 3 * ( 3*min_mn*min_mn + (std::max)( (std::max)(m,n),
4*min_mn*min_mn + 4*min_mn ) );
blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::gesdd<eT>
(
&jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, iwork.memptr(), &info
);
op_strans::apply(V,V); // op_strans will work out that an in-place tra
nspose can be done
return (info == 0);
}
#else
{
arma_ignore(U);
arma_ignore(S);
arma_ignore(V);
arma_ignore(X);
arma_stop("svd(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
template<typename T, typename T1>
inline
bool
auxlib::svd_dc(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >
& V, const Base< std::complex<T>, T1>& X)
{
arma_extra_debug_sigprint();
typedef std::complex<T> eT;
#if defined(ARMA_USE_LAPACK)
{
Mat<eT> A(X.get_ref());
if(A.is_empty())
{
U.eye(A.n_rows, A.n_rows);
S.reset();
V.eye(A.n_cols, A.n_cols);
return true;
}
U.set_size(A.n_rows, A.n_rows);
V.set_size(A.n_cols, A.n_cols);
char jobz = 'A';
blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = blas_int(V.n_rows);
blas_int lwork = 3 * (min_mn*min_mn + 2*min_mn + (std::max)(m,n));
blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork
) );
podarray<T> rwork( static_cast<uword>(5*min_mn*min_mn + 7*min_mn
) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn
) );
lapack::cx_gesdd<T>
(
&jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info
);
op_htrans::apply(V,V); // op_htrans will work out that an in-place tra
nspose can be done
return (info == 0);
}
#else
{
arma_ignore(U);
arma_ignore(S);
arma_ignore(V);
arma_ignore(X);
arma_stop("svd(): use of LAPACK needs to be enabled");
return false;
}
#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, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool sl ow) auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool sl ow)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool status = false; bool status = false;
skipping to change at line 2546 skipping to change at line 2790
return true; return true;
} }
char trans = 'N'; char trans = 'N';
blas_int m = blas_int(A_n_rows); blas_int m = blas_int(A_n_rows);
blas_int n = blas_int(A_n_cols); blas_int n = blas_int(A_n_cols);
blas_int lda = blas_int(A_n_rows); blas_int lda = blas_int(A_n_rows);
blas_int ldb = blas_int(A_n_rows); blas_int ldb = blas_int(A_n_rows);
blas_int nrhs = blas_int(B_n_cols); blas_int nrhs = blas_int(B_n_cols);
blas_int lwork = 2*((std::max)(blas_int(1), n + (std::max)(n, nrhs))); blas_int lwork = 3 * ( (std::max)(blas_int(1), n + (std::max)(n, nrhs) ) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
// NOTE: the dgels() function in the lapack library supplied by ATLAS 3 .6 seems to have problems // NOTE: the dgels() function in the lapack library supplied by ATLAS 3 .6 seems to have problems
arma_extra_debug_print("lapack::gels()"); arma_extra_debug_print("lapack::gels()");
lapack::gels<eT>( &trans, &m, &n, &nrhs, A.memptr(), &lda, tmp.memptr() , &ldb, work.memptr(), &lwork, &info ); lapack::gels<eT>( &trans, &m, &n, &nrhs, A.memptr(), &lda, tmp.memptr() , &ldb, work.memptr(), &lwork, &info );
arma_extra_debug_print("lapack::gels() -- finished"); arma_extra_debug_print("lapack::gels() -- finished");
skipping to change at line 2615 skipping to change at line 2859
return true; return true;
} }
char trans = 'N'; char trans = 'N';
blas_int m = blas_int(A_n_rows); blas_int m = blas_int(A_n_rows);
blas_int n = blas_int(A_n_cols); blas_int n = blas_int(A_n_cols);
blas_int lda = blas_int(A_n_rows); blas_int lda = blas_int(A_n_rows);
blas_int ldb = blas_int(A_n_cols); blas_int ldb = blas_int(A_n_cols);
blas_int nrhs = blas_int(B_n_cols); blas_int nrhs = blas_int(B_n_cols);
blas_int lwork = 2*((std::max)(blas_int(1), m + (std::max)(m,nrhs))); blas_int lwork = 3 * ( (std::max)(blas_int(1), m + (std::max)(m,nrhs)) );
blas_int info = 0; blas_int info = 0;
Mat<eT> tmp(A_n_cols, B_n_cols); Mat<eT> tmp(A_n_cols, B_n_cols);
tmp.zeros(); tmp.zeros();
for(uword col=0; col<B_n_cols; ++col) for(uword col=0; col<B_n_cols; ++col)
{ {
eT* tmp_colmem = tmp.colptr(col); eT* tmp_colmem = tmp.colptr(col);
arrayops::copy( tmp_colmem, B.colptr(col), B_n_rows ); arrayops::copy( tmp_colmem, B.colptr(col), B_n_rows );
skipping to change at line 2735 skipping to change at line 2979
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
Z.set_size(A_n_rows, A_n_rows); Z.set_size(A_n_rows, A_n_rows);
T = A; T = A;
char jobvs = 'V'; // get Schur vectors (Z) char jobvs = 'V'; // get Schur vectors (Z)
char sort = 'N'; // do not sort eigenvalues/vecto rs char sort = 'N'; // do not sort eigenvalues/vecto rs
blas_int* select = 0; // pointer to sorting function blas_int* select = 0; // pointer to sorting function
blas_int n = blas_int(A_n_rows); blas_int n = blas_int(A_n_rows);
blas_int sdim = 0; // output for sorting blas_int sdim = 0; // output for sorting
blas_int lwork = 2*((std::max)(blas_int(1), 3*n)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 3*n) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<blas_int> bwork(A_n_rows); podarray<blas_int> bwork(A_n_rows);
podarray<eT> wr(A_n_rows); // output for eigenvalues podarray<eT> wr(A_n_rows); // output for eigenvalues
podarray<eT> wi(A_n_rows); // output for eigenvalues podarray<eT> wi(A_n_rows); // output for eigenvalues
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); 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);
skipping to change at line 2790 skipping to change at line 3034
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
Z.set_size(A_n_rows, A_n_rows); Z.set_size(A_n_rows, A_n_rows);
T = A; T = A;
char jobvs = 'V'; // get Schur vectors (Z) char jobvs = 'V'; // get Schur vectors (Z)
char sort = 'N'; // do not sort eigenvalues/vect ors char sort = 'N'; // do not sort eigenvalues/vect ors
blas_int* select = 0; // pointer to sorting function blas_int* select = 0; // pointer to sorting function
blas_int n = blas_int(A_n_rows); blas_int n = blas_int(A_n_rows);
blas_int sdim = 0; // output for sorting blas_int sdim = 0; // output for sorting
blas_int lwork = 2*((std::max)(blas_int(1), 2*n)); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*n) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<blas_int> bwork(A_n_rows); podarray<blas_int> bwork(A_n_rows);
podarray<eT> w(A_n_rows); // output for eigenvalues podarray<eT> w(A_n_rows); // output for eigenvalues
podarray<cT> rwork(A_n_rows); podarray<cT> rwork(A_n_rows);
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); 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);
 End of changes. 54 change blocks. 
104 lines changed or deleted 356 lines changed or added


 config.hpp   config.hpp 
skipping to change at line 83 skipping to change at line 83
//// as this greatly aids in finding mistakes in your code, and hence speed s up development. //// as this greatly aids in finding mistakes in your code, and hence speed s up development.
//// We recommend that run-time checks be disabled _only_ for the shipped v ersion of your program. //// We recommend that run-time checks be disabled _only_ for the shipped v ersion of your program.
// #define ARMA_EXTRA_DEBUG // #define ARMA_EXTRA_DEBUG
//// Uncomment the above line if you want to see the function traces of how Armadillo evaluates expressions. //// Uncomment the above line if you want to see the function traces of how Armadillo evaluates expressions.
//// This is mainly useful for debugging of the library. //// This is mainly useful for debugging of the library.
#define ARMA_USE_BOOST #define ARMA_USE_BOOST
#define ARMA_USE_BOOST_DATE #define ARMA_USE_BOOST_DATE
#define ARMA_USE_WRAPPER #define ARMA_USE_WRAPPER
/* #undef ARMA_USE_HDF5 */ #define ARMA_USE_HDF5
#if !defined(ARMA_DEFAULT_OSTREAM) #if !defined(ARMA_DEFAULT_OSTREAM)
#define ARMA_DEFAULT_OSTREAM std::cout #define ARMA_DEFAULT_OSTREAM std::cout
#endif #endif
#define ARMA_PRINT_LOGIC_ERRORS #define ARMA_PRINT_LOGIC_ERRORS
#define ARMA_PRINT_RUNTIME_ERRORS #define ARMA_PRINT_RUNTIME_ERRORS
//#define ARMA_PRINT_HDF5_ERRORS
#define ARMA_HAVE_STD_ISFINITE #define ARMA_HAVE_STD_ISFINITE
#define ARMA_HAVE_STD_ISINF #define ARMA_HAVE_STD_ISINF
#define ARMA_HAVE_STD_ISNAN #define ARMA_HAVE_STD_ISNAN
#define ARMA_HAVE_STD_SNPRINTF #define ARMA_HAVE_STD_SNPRINTF
#define ARMA_HAVE_LOG1P #define ARMA_HAVE_LOG1P
#define ARMA_HAVE_GETTIMEOFDAY #define ARMA_HAVE_GETTIMEOFDAY
#if defined(ARMA_DONT_USE_LAPACK) #if defined(ARMA_DONT_USE_LAPACK)
 End of changes. 2 change blocks. 
1 lines changed or deleted 2 lines changed or added


 diskio_bones.hpp   diskio_bones.hpp 
skipping to change at line 26 skipping to change at line 26
//! @{ //! @{
//! class for saving and loading matrices and fields //! class for saving and loading matrices and fields
class diskio class diskio
{ {
public: public:
template<typename eT> inline static std::string gen_txt_header(const Mat< eT>& x); template<typename eT> inline static std::string gen_txt_header(const Mat< eT>& x);
template<typename eT> inline static std::string gen_bin_header(const Mat< eT>& x); template<typename eT> inline static std::string gen_bin_header(const Mat< eT>& x);
template<typename eT> inline static std::string gen_txt_header(const SpMa
t<eT>& x);
template<typename eT> inline static std::string gen_bin_header(const SpMa
t<eT>& x);
template<typename eT> inline static std::string gen_txt_header(const Cube <eT>& x); template<typename eT> inline static std::string gen_txt_header(const Cube <eT>& x);
template<typename eT> inline static std::string gen_bin_header(const Cube <eT>& x); template<typename eT> inline static std::string gen_bin_header(const Cube <eT>& x);
inline static file_type guess_file_type(std::istream& f); inline static file_type guess_file_type(std::istream& f);
inline static char conv_to_hex_char(const u8 x); inline static char conv_to_hex_char(const u8 x);
inline static void conv_to_hex(char* out, const u8 x); inline static void conv_to_hex(char* out, const u8 x);
inline static std::string gen_tmp_name(const std::string& x); inline static std::string gen_tmp_name(const std::string& x);
skipping to change at line 83 skipping to change at line 86
template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg); template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg); template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg); template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, std::istream& is, std::string& err_msg); template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, std::istream& is, std::string& err_msg);
template<typename T> inline static bool load_pgm_binary (Mat< std::compl ex<T> >& x, std::istream& is, std::string& err_msg); template<typename T> inline static bool load_pgm_binary (Mat< std::compl ex<T> >& x, std::istream& is, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, std::istream& f, std::string& err_msg); template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, std::istream& f, std::string& err_msg);
inline static void pnm_skip_comments(std::istream& f); inline static void pnm_skip_comments(std::istream& f);
// //
// sparse saving
template<typename eT> inline static bool save_raw_ascii (const SpMat<eT>
& x, const std::string& final_name);
template<typename eT> inline static bool save_raw_binary (const SpMat<eT>
& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_ascii (const SpMat<eT>
& x, const std::string& final_name);
template<typename eT> inline static bool save_csv_ascii (const SpMat<eT>
& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_binary(const SpMat<eT>
& x, const std::string& final_name);
template<typename eT> inline static bool save_pgm_binary (const SpMat<eT>
& x, const std::string& final_name);
template<typename T> inline static bool save_pgm_binary (const SpMat<std
::complex<T> >& x, const std::string& final_name);
template<typename eT> inline static bool save_coord_ascii(const SpMat<eT>
& x, const std::string& final_name);
template<typename eT> inline static bool save_raw_ascii (const SpMat<eT>
& x, std::ostream& f);
template<typename eT> inline static bool save_raw_binary (const SpMat<eT>
& x, std::ostream& f);
template<typename eT> inline static bool save_arma_ascii (const SpMat<eT>
& x, std::ostream& f);
template<typename eT> inline static bool save_csv_ascii (const SpMat<eT>
& x, std::ostream& f);
template<typename eT> inline static bool save_arma_binary(const SpMat<eT>
& x, std::ostream& f);
template<typename eT> inline static bool save_pgm_binary (const SpMat<eT>
& x, std::ostream& f);
template<typename T> inline static bool save_pgm_binary (const SpMat<std
::complex<T> >& x, std::ostream& f);
template<typename eT> inline static bool save_coord_ascii(const SpMat<eT>
& x, std::ostream& f);
//
// sparse loading
template<typename eT> inline static bool load_raw_ascii (SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_pgm_binary (SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename T> inline static bool load_pgm_binary (SpMat<std::comp
lex<T> >& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_coord_ascii(SpMat<eT>& x, c
onst std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_ascii (SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_pgm_binary (SpMat<eT>& x, s
td::istream& is, std::string& err_msg);
template<typename T> inline static bool load_pgm_binary (SpMat<std::comp
lex<T> >& x, std::istream& is, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_coord_ascii(SpMat<eT>& x, s
td::istream& f, std::string& err_msg);
//
// cube saving // cube saving
template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, const std::string& name); template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, const std::string& name); template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, const std::string& name); template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_arma_binary(const Cube<eT>& x, const std::string& name); template<typename eT> inline static bool save_arma_binary(const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, std::ostream& f); template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, std::ostream& f); template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, std::ostream& f); template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, std::ostream& f);
 End of changes. 2 change blocks. 
0 lines changed or deleted 83 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2009-2010 Ian Cullinan // Copyright (C) 2009-2010 Ian Cullinan
// Copyright (C) 2012 Matthew Amidon // Copyright (C) 2012 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)
skipping to change at line 182 skipping to change at line 182
{ {
return std::string("ARMA_MAT_BIN_FC016"); return std::string("ARMA_MAT_BIN_FC016");
} }
else else
{ {
return std::string(); return std::string();
} }
} }
//! Generate the first line of the header used for saving matrices in text
format.
//! Format: "ARMA_SPM_TXT_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a
ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i
ndicates eight bytes.
template<typename eT>
inline
std::string
diskio::gen_txt_header(const SpMat<eT>& x)
{
arma_type_check(( is_supported_elem_type<eT>::value == false ));
arma_ignore(x);
if(is_u8<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IU001");
}
else
if(is_s8<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IS001");
}
else
if(is_u16<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IU002");
}
else
if(is_s16<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IS002");
}
else
if(is_u32<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IU004");
}
else
if(is_s32<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IS004");
}
#if defined(ARMA_64BIT_WORD)
else
if(is_u64<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IU008");
}
else
if(is_s64<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_IS008");
}
#endif
else
if(is_float<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_FN004");
}
else
if(is_double<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_FN008");
}
else
if(is_complex_float<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_FC008");
}
else
if(is_complex_double<eT>::value == true)
{
return std::string("ARMA_SPM_TXT_FC016");
}
else
{
return std::string();
}
}
//! Generate the first line of the header used for saving matrices in binar
y format.
//! Format: "ARMA_SPM_BIN_ABXYZ".
//! A is one of: I (for integral types) or F (for floating point types).
//! B is one of: U (for unsigned types), S (for signed types), N (for not a
ppliable) or C (for complex types).
//! XYZ specifies the width of each element in terms of bytes, e.g. "008" i
ndicates eight bytes.
template<typename eT>
inline
std::string
diskio::gen_bin_header(const SpMat<eT>& x)
{
arma_type_check(( is_supported_elem_type<eT>::value == false ));
arma_ignore(x);
if(is_u8<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IU001");
}
else
if(is_s8<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IS001");
}
else
if(is_u16<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IU002");
}
else
if(is_s16<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IS002");
}
else
if(is_u32<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IU004");
}
else
if(is_s32<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IS004");
}
#if defined(ARMA_64BIT_WORD)
else
if(is_u64<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IU008");
}
else
if(is_s64<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_IS008");
}
#endif
else
if(is_float<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_FN004");
}
else
if(is_double<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_FN008");
}
else
if(is_complex_float<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_FC008");
}
else
if(is_complex_double<eT>::value == true)
{
return std::string("ARMA_SPM_BIN_FC016");
}
else
{
return std::string();
}
}
//! 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)
{ {
skipping to change at line 967 skipping to change at line 1130
} }
//! Save a matrix as part of a HDF5 file //! Save a matrix as part of a HDF5 file
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::save_hdf5_binary(const Mat<eT>& x, const std::string& final_name) diskio::save_hdf5_binary(const Mat<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// TODO: we should save in the same format as used by Octave with the -hd
f5 option, ie: save -hdf5 "/tmp/X.h5" X
#if defined(ARMA_USE_HDF5) #if defined(ARMA_USE_HDF5)
{ {
#if !defined(ARMA_PRINT_HDF5_ERRORS)
{
// Disable annoying HDF5 error messages.
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
}
#endif
bool save_okay = false; bool save_okay = false;
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
// Set up the file according to HDF5's preferences // Set up the file according to HDF5's preferences
hid_t file = H5Fcreate(tmp_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5 P_DEFAULT); hid_t file = H5Fcreate(tmp_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5 P_DEFAULT);
// We need to create a dataset, datatype, and dataspace // We need to create a dataset, datatype, and dataspace
hsize_t dims[2]; hsize_t dims[2];
dims[0] = x.n_rows; dims[1] = x.n_rows;
dims[1] = x.n_cols; dims[0] = x.n_cols;
hid_t dataspace = H5Screate_simple(2, dims, NULL); // treat the matri
x as a 2d array dataspace; TODO: how to specify column-major ordering ?
hid_t datatype = H5Tcreate(H5T_OPAQUE, sizeof(eT)); // currently speci
fying only the size of each element; TODO: specify type explicitly
//// how to explicitly specify types ? uword (which could be 32 or 64 b hid_t dataspace = H5Screate_simple(2, dims, NULL); // treat the matri
it), float, double, std::complex<float>, std::complex<double> x as a 2d array dataspace
// hid_t datatype = H5Tcopy(...) hid_t datatype = hdf5_misc::get_hdf5_type<eT>();
// TODO: test by loading in Octave // If this returned something invalid, well, it's time to crash.
// TODO: test by loading in Matlab with h5read() arma_check(datatype == -1, "Mat::save(): unknown datatype for HDF5");
// TODO: what are the default dataset names used by Matlab and Octave ? // MATLAB forces the users to specify a name at save time for HDF5; Oct
ave
// will use the default of 'dataset' unless otherwise specified, so we
will
// use that.
hid_t dataset = H5Dcreate(file, "dataset", datatype, dataspace, H5P_DEF AULT, H5P_DEFAULT, H5P_DEFAULT); hid_t dataset = H5Dcreate(file, "dataset", datatype, dataspace, H5P_DEF AULT, H5P_DEFAULT, H5P_DEFAULT);
// H5Dwrite does not make a distinction between row-major and column-ma
jor;
// it just writes the memory. MATLAB and Octave store HDF5 matrices as
// column-major, though, so we can save ours like that too and not need
to
// transpose.
herr_t status = H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAU LT, x.mem); herr_t status = H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAU LT, x.mem);
save_okay = (status >= 0); save_okay = (status >= 0);
H5Dclose(dataset); H5Dclose(dataset);
H5Tclose(datatype); H5Tclose(datatype);
H5Sclose(dataspace); H5Sclose(dataspace);
H5Fclose(file); H5Fclose(file);
if(save_okay == true) { save_okay = diskio::safe_rename(tmp_name, final _name); } if(save_okay == true) { save_okay = diskio::safe_rename(tmp_name, final _name); }
skipping to change at line 1611 skipping to change at line 1782
return load_okay; return load_okay;
} }
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_hdf5_binary(Mat<eT>& x, const std::string& name, std::string& err_msg) diskio::load_hdf5_binary(Mat<eT>& x, const std::string& name, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// TODO: we should save in a format that can be correctly read by Octave
and Matlab
#if defined(ARMA_USE_HDF5) #if defined(ARMA_USE_HDF5)
{ {
// These may be necessary to store the error handler (if we need to).
herr_t (*old_func)(hid_t, void*);
void *old_client_data;
#if !defined(ARMA_PRINT_HDF5_ERRORS)
{
// Save old error handler.
H5Eget_auto(H5E_DEFAULT, &old_func, &old_client_data);
// Disable annoying HDF5 error messages.
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
}
#endif
bool load_okay = false; bool load_okay = false;
hid_t fid = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); hid_t fid = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if(fid >= 0) if(fid >= 0)
{ {
// TODO: do Matlab and Octave have default dataset names ? // MATLAB HDF5 dataset names are user-specified;
hid_t dataset = H5Dopen(fid, "dataset", H5P_DEFAULT); // Octave tends to store the datasets in a group, with the actual dat
aset being referred to as "value".
// So we will search for "dataset" and "value", and if those are not
found we will take the first dataset we do find.
std::vector<std::string> searchNames;
searchNames.push_back("dataset");
searchNames.push_back("value");
hid_t dataset = hdf5_misc::search_hdf5_file(searchNames, fid, 2, fals
e);
if(dataset >= 0) if(dataset >= 0)
{ {
hid_t filespace = H5Dget_space(dataset); hid_t filespace = H5Dget_space(dataset);
// This must be <= 2 due to our search rules.
const int ndims = H5Sget_simple_extent_ndims(filespace); const int ndims = H5Sget_simple_extent_ndims(filespace);
if(ndims == 2) hsize_t dims[2];
const herr_t query_status = H5Sget_simple_extent_dims(filespace, di
ms, NULL);
// arma_check(query_status < 0, "Mat::load(): cannot get size of HD
F5 dataset");
if(query_status < 0)
{ {
hsize_t dims[2]; err_msg = "cannot get size of HDF5 dataset in ";
const herr_t query_status = H5Sget_simple_extent_dims(filespace, H5Sclose(filespace);
dims, NULL); H5Dclose(dataset);
H5Fclose(fid);
if(query_status >= 0) #if !defined(ARMA_PRINT_HDF5_ERRORS)
{ {
const uword n_rows = dims[0]; // Restore HDF5 error handler.
const uword n_cols = dims[1]; H5Eset_auto(H5E_DEFAULT, old_func, old_client_data);
}
hid_t datatype = H5Dget_type(dataset); #endif
const size_t element_size = H5Tget_size(datatype); return false;
}
// TODO: rather than checking the element_size, we should reall y figure out the exact type stored in the file (eg. float, double, ...) if(ndims == 1) { dims[1] = 1; } // Vector case; fake second dimens ion (one column).
if( element_size == sizeof(eT) ) x.set_size(dims[1], dims[0]);
{
x.set_size(n_rows, n_cols);
// TODO: should H5S_ALL be used ? // Now we have to see what type is stored to figure out how to load
hid_t read_status = H5Dread( dataset, datatype, H5S_ALL, H5S_ it.
ALL, H5P_DEFAULT, void_ptr(x.memptr()) ); hid_t datatype = H5Dget_type(dataset);
hid_t mat_type = hdf5_misc::get_hdf5_type<eT>();
load_okay = (read_status >= 0); // If these are the same type, it is simple.
} if(H5Tequal(datatype, mat_type) > 0)
{
// Load directly; H5S_ALL used so that we load the entire dataset
.
hid_t read_status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL,
H5P_DEFAULT, void_ptr(x.memptr()));
H5Tclose(datatype); if(read_status >= 0) { load_okay = true; }
} }
else
{
// Load as another matrix and convert accordingly.
hid_t read_status = hdf5_misc::load_and_convert_hdf5(x, dataset,
datatype, dims);
if(read_status >= 0) { load_okay = true; }
} }
// Now clean up.
H5Tclose(datatype);
H5Tclose(mat_type);
H5Sclose(filespace); H5Sclose(filespace);
} }
H5Dclose(dataset); H5Dclose(dataset);
}
H5Fclose(fid); H5Fclose(fid);
if(load_okay == false)
{
err_msg = "unsupported or incorrect HDF5 data in ";
}
}
else
{
err_msg = "cannot open file ";
}
if(load_okay == false) { err_msg = "unsupported or incorrect HDF5 data #if !defined(ARMA_PRINT_HDF5_ERRORS)
in "; } {
// Restore HDF5 error handler.
H5Eset_auto(H5E_DEFAULT, old_func, old_client_data);
}
#endif
return load_okay; return load_okay;
} }
#else #else
{ {
arma_ignore(x); arma_ignore(x);
arma_ignore(name); arma_ignore(name);
arma_ignore(err_msg); arma_ignore(err_msg);
arma_stop("Mat::load(): use of HDF5 needs to be enabled"); arma_stop("Mat::load(): use of HDF5 needs to be enabled");
skipping to change at line 1779 skipping to change at line 2001
default: default:
err_msg = "unknown data in "; err_msg = "unknown data in ";
return false; return false;
} }
} }
return false; return false;
} }
// sparse matrices
//! Save a matrix as raw text (no header, human readable).
//! Matrices can be loaded in Matlab and Octave, as long as they don't have
complex elements.
template<typename eT>
inline
bool
diskio::save_raw_ascii(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::fstream f(tmp_name.c_str(), std::fstream::out);
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_raw_ascii(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
//! Save a matrix as raw text (no header, human readable).
//! Matrices can be loaded in Matlab and Octave, as long as they don't have
complex elements.
template<typename eT>
inline
bool
diskio::save_raw_ascii(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
uword cell_width;
// TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
f.setf(ios::scientific);
f.precision(10);
cell_width = 18;
}
for(uword row=0; row < x.n_rows; ++row)
{
for(uword col=0; col < x.n_cols; ++col)
{
f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
f.width(cell_width);
}
f << x.at(row,col);
}
f.put('\n');
}
return f.good();
}
//! Save a matrix as raw binary (no header)
template<typename eT>
inline
bool
diskio::save_raw_binary(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str(), std::fstream::binary);
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_raw_binary(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
template<typename eT>
inline
bool
diskio::save_raw_binary(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
//Write the dims of the matrix first
f.write( reinterpret_cast<const char*>(&x.n_rows), std::streamsize(sizeof
(uword)) );
f.write( reinterpret_cast<const char*>(&x.n_cols), std::streamsize(sizeof
(uword)) );
f.write( reinterpret_cast<const char*>(&x.n_nonzero), std::streamsize(siz
eof(uword)) );
//Now write the data for the three vectors
f.write( reinterpret_cast<const char*>(x.values), std::streamsize(x.n_non
zero*sizeof(eT)) );
f.write( reinterpret_cast<const char*>(x.row_indices), std::streamsize(x.
n_nonzero*sizeof(uword)) );
f.write( reinterpret_cast<const char*>(x.col_ptrs), std::streamsize((x.n_
cols+1)*sizeof(uword)) );
return f.good();
}
//! Save a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::save_arma_ascii(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str());
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_arma_ascii(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
//! Save a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::save_arma_ascii(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
const ios::fmtflags orig_flags = f.flags();
f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << '\n';
uword cell_width;
// TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
f.setf(ios::scientific);
f.precision(10);
cell_width = 18;
}
for(uword row=0; row < x.n_rows; ++row)
{
for(uword col=0; col < x.n_cols; ++col)
{
f.put(' ');
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
f.width(cell_width);
}
f << x.at(row,col);
}
f.put('\n');
}
const bool save_okay = f.good();
f.flags(orig_flags);
return save_okay;
}
//! Save a matrix in CSV text format (human readable)
template<typename eT>
inline
bool
diskio::save_csv_ascii(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str());
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_csv_ascii(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
//! Save a matrix in CSV text format (human readable)
template<typename eT>
inline
bool
diskio::save_csv_ascii(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
const ios::fmtflags orig_flags = f.flags();
// TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{
f.setf(ios::scientific);
f.precision(10);
}
uword x_n_rows = x.n_rows;
uword x_n_cols = x.n_cols;
for(uword row=0; row < x_n_rows; ++row)
{
for(uword col=0; col < x_n_cols; ++col)
{
f << x.at(row,col);
if( col < (x_n_cols-1) )
{
f.put(',');
}
}
f.put('\n');
}
const bool save_okay = f.good();
f.flags(orig_flags);
return save_okay;
}
//! Save a matrix in binary format,
//! with a header that stores the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::save_arma_binary(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str(), std::fstream::binary);
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_arma_binary(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
//! Save a matrix in binary format,
//! with a header that stores the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::save_arma_binary(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
//Write the dims of the matrix first
f << diskio::gen_bin_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_nonzero << '\n';
//Now write the data for the three vectors
f.write( reinterpret_cast<const char*>(x.values), std::streamsize(x.n_non
zero*sizeof(eT)) );
f.write( reinterpret_cast<const char*>(x.row_indices), std::streamsize(x.
n_nonzero*sizeof(uword)) );
f.write( reinterpret_cast<const char*>(x.col_ptrs), std::streamsize((x.n_
cols+1)*sizeof(uword)) );
return f.good();
}
//! Save a matrix as a PGM greyscale image
template<typename eT>
inline
bool
diskio::save_pgm_binary(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::fstream f(tmp_name.c_str(), std::fstream::out | std::fstream::binary
);
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_pgm_binary(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
//
// TODO:
// add functionality to save the image in a normalised format,
// i.e. scaled so that every value falls in the [0,255] range.
//! Save a matrix as a PGM greyscale image
template<typename eT>
inline
bool
diskio::save_pgm_binary(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
f << "P5" << '\n';
f << x.n_cols << ' ' << x.n_rows << ' ' << x.n_cols*x.n_rows << '\n';
f << 255 << '\n';
const uword n_elem = x.n_nonzero;
podarray<u8> tmp(n_elem);
uword i = 0;
for(uword row=0; row < x.n_rows; ++row)
{
for(uword col=0; col < x.n_cols; ++col)
{
tmp[i] = u8( x.at(row,col) ); // TODO: add round() ?
++i;
}
}
f.write(reinterpret_cast<const char*>(tmp.mem), std::streamsize(x.n_rows*
x.n_cols) );
return f.good();
}
//! Save a matrix as a PGM greyscale image
template<typename T>
inline
bool
diskio::save_pgm_binary(const SpMat< std::complex<T> >& x, const std::strin
g& final_name)
{
arma_extra_debug_sigprint();
const uchar_mat tmp = conv_to<uchar_mat>::from(x);
return diskio::save_pgm_binary(tmp, final_name);
}
//! Save a matrix as a PGM greyscale image
template<typename T>
inline
bool
diskio::save_pgm_binary(const SpMat< std::complex<T> >& x, std::ostream& f)
{
arma_extra_debug_sigprint();
const uchar_mat tmp = conv_to<uchar_mat>::from(x);
return diskio::save_pgm_binary(tmp, f);
}
//! Save a matrix in ASCII coord format
template<typename eT>
inline
bool
diskio::save_coord_ascii(const SpMat<eT>& x, const std::string& final_name)
{
arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str());
bool save_okay = f.is_open();
if(save_okay == true)
{
save_okay = diskio::save_coord_ascii(x, f);
f.flush();
f.close();
if(save_okay == true)
{
save_okay = diskio::safe_rename(tmp_name, final_name);
}
}
return save_okay;
}
//! Save a matrix in CSV text format (human readable)
template<typename eT>
inline
bool
diskio::save_coord_ascii(const SpMat<eT>& x, std::ostream& f)
{
arma_extra_debug_sigprint();
uword x_n_rows = x.n_rows;
uword x_n_cols = x.n_cols;
uword x_n_nonzero = x.n_nonzero;
//Put down the header
f << x_n_rows << " " << x_n_cols << " " << x_n_nonzero << endl;
typename SpMat<eT>::const_iterator iter = x.begin();
for(; iter.pos() < x.n_nonzero; iter++)
f << iter.row() << " " << iter.col() << " " << *iter << endl;
const bool save_okay = f.good();
return save_okay;
}
//! Load a matrix as raw text (no header, human readable).
//! Can read matrices saved as text in Matlab and Octave.
//! NOTE: this is much slower than reading a file with a header.
template<typename eT>
inline
bool
diskio::load_raw_ascii(SpMat<eT>& x, const std::string& name, std::string&
err_msg)
{
arma_extra_debug_sigprint();
std::fstream f;
f.open(name.c_str(), std::fstream::in);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_raw_ascii(x, f, err_msg);
f.close();
}
return load_okay;
}
//! Load a matrix as raw text (no header, human readable).
//! Can read matrices saved as text in Matlab and Octave.
//! NOTE: this is much slower than reading a file with a header.
template<typename eT>
inline
bool
diskio::load_raw_ascii(SpMat<eT>& x, std::istream& f, std::string& err_msg)
{
arma_extra_debug_sigprint();
bool load_okay = f.good();
f.clear();
const std::fstream::pos_type pos1 = f.tellg();
//
// work out the size
uword f_n_rows = 0;
uword f_n_cols = 0;
bool f_n_cols_found = false;
std::string line_string;
std::string token;
while( (f.good() == true) && (load_okay == true) )
{
std::getline(f, line_string);
if(line_string.size() == 0)
{
break;
}
std::stringstream line_stream(line_string);
uword line_n_cols = 0;
while (line_stream >> token)
{
++line_n_cols;
}
if(f_n_cols_found == false)
{
f_n_cols = line_n_cols;
f_n_cols_found = true;
}
else
{
if(line_n_cols != f_n_cols)
{
err_msg = "inconsistent number of columns in ";
load_okay = false;
}
}
++f_n_rows;
}
if(load_okay == true)
{
f.clear();
f.seekg(pos1);
x.set_size(f_n_rows, f_n_cols);
eT val;
for(uword row=0; (row < x.n_rows) && (load_okay == true); ++row)
{
for(uword col=0; (col < x.n_cols) && (load_okay == true); ++col)
{
f >> val;
if(f.fail() == false)
{
x.at(row,col) = val;
}
else
{
load_okay = false;
err_msg = "couldn't interpret data in ";
//break;
}
}
}
}
// an empty file indicates an empty matrix
if( (f_n_cols_found == false) && (load_okay == true) )
{
x.reset();
}
return load_okay;
}
//! Load a matrix in binary format (no header);
//! the matrix is assumed to have one column
template<typename eT>
inline
bool
diskio::load_raw_binary(SpMat<eT>& x, const std::string& name, std::string&
err_msg)
{
arma_extra_debug_sigprint();
std::ifstream f;
f.open(name.c_str(), std::fstream::binary);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_raw_binary(x, f, err_msg);
f.close();
}
return load_okay;
}
template<typename eT>
inline
bool
diskio::load_raw_binary(SpMat<eT>& x, std::istream& f, std::string& err_msg
)
{
arma_extra_debug_sigprint();
arma_ignore(err_msg);
//Make sure we are at top of file.
f.clear();
//Read the dimensions of the matrix
f.read( (char*) &access::rw(x.n_rows), std::streamsize(sizeof(uword)) );
f.read( (char*) &access::rw(x.n_cols), std::streamsize(sizeof(uword)) );
f.read( (char*) &access::rw(x.n_nonzero), std::streamsize(sizeof(uword))
);
access::rw(x.n_elem) = x.n_rows * x.n_cols;
//Allocate appropriate memory, then fill it.
eT* in_values = memory::acquire<eT>(x.n_nonzero);
uword* in_row_indices = memory::acquire<uword>(x.n_nonzero);
uword* in_col_ptrs = memory::acquire<uword>(x.n_cols + 1);
f.read( reinterpret_cast<char*>(in_values), std::streamsize(x.n_nonzero *
sizeof(eT)) );
f.read( reinterpret_cast<char*>(in_row_indices), std::streamsize(x.n_nonz
ero * sizeof(uword)) );
f.read( reinterpret_cast<char*>(in_col_ptrs), std::streamsize((x.n_cols +
1) * sizeof(uword)) );
//Replace the current data in the sparse matrix
if(x.n_nonzero > 0)
{
memory::release(x.values);
memory::release(x.row_indices);
}
memory::release(x.col_ptrs);
access::rwp(x.values) = in_values;
access::rwp(x.row_indices) = in_row_indices;
access::rwp(x.col_ptrs) = in_col_ptrs;
return f.good();
}
//! Load a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::load_arma_ascii(SpMat<eT>& x, const std::string& name, std::string&
err_msg)
{
arma_extra_debug_sigprint();
std::ifstream f(name.c_str());
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_arma_ascii(x, f, err_msg);
f.close();
}
return load_okay;
}
//! Load a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::load_arma_ascii(SpMat<eT>& x, std::istream& f, std::string& err_msg
)
{
arma_extra_debug_sigprint();
bool load_okay = true;
eT tmp;
std::string f_header;
uword f_n_rows;
uword f_n_cols;
f >> f_header;
f >> f_n_rows;
f >> f_n_cols;
if(f_header == diskio::gen_txt_header(x))
{
x.set_size(f_n_rows, f_n_cols);
for(uword row=0; row < x.n_rows; ++row)
{
for(uword col=0; col < x.n_cols; ++col)
{
f >> tmp;
x.at(row,col) = tmp;
}
}
load_okay = f.good();
}
else
{
load_okay = false;
err_msg = "incorrect header in ";
}
return load_okay;
}
//! Load a matrix in CSV text format (human readable)
template<typename eT>
inline
bool
diskio::load_csv_ascii(SpMat<eT>& x, const std::string& name, std::string&
err_msg)
{
arma_extra_debug_sigprint();
std::fstream f;
f.open(name.c_str(), std::fstream::in);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_csv_ascii(x, f, err_msg);
f.close();
}
return load_okay;
}
//! Load a matrix in CSV text format (human readable)
template<typename eT>
inline
bool
diskio::load_csv_ascii(SpMat<eT>& x, std::istream& f, std::string& err_msg)
{
arma_extra_debug_sigprint();
bool load_okay = f.good();
f.clear();
const std::fstream::pos_type pos1 = f.tellg();
//
// work out the size
uword f_n_rows = 0;
uword f_n_cols = 0;
std::string line_string;
std::string token;
while( (f.good() == true) && (load_okay == true) )
{
std::getline(f, line_string);
if(line_string.size() == 0)
{
break;
}
std::stringstream line_stream(line_string);
uword line_n_cols = 0;
while(line_stream.good() == true)
{
getline(line_stream, token, ',');
++line_n_cols;
}
if(f_n_cols < line_n_cols)
{
f_n_cols = line_n_cols;
}
++f_n_rows;
}
f.clear();
f.seekg(pos1);
x.zeros(f_n_rows, f_n_cols);
uword row = 0;
while(f.good() == true)
{
std::getline(f, line_string);
if(line_string.size() == 0)
{
break;
}
std::stringstream line_stream(line_string);
uword col = 0;
while(line_stream.good() == true)
{
getline(line_stream, token, ',');
eT val;
std::stringstream ss(token);
ss >> val;
if(ss.fail() == false)
{
x.at(row,col) = val;
}
++col;
}
++row;
}
return load_okay;
}
//! Load a matrix in binary format,
//! with a header that indicates the matrix type as well as its dimensions
template<typename eT>
inline
bool
diskio::load_arma_binary(SpMat<eT>& x, const std::string& name, std::string
& err_msg)
{
arma_extra_debug_sigprint();
std::ifstream f;
f.open(name.c_str(), std::fstream::binary);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_arma_binary(x, f, err_msg);
f.close();
}
return load_okay;
}
template<typename eT>
inline
bool
diskio::load_arma_binary(SpMat<eT>& x, std::istream& f, std::string& err_ms
g)
{
arma_extra_debug_sigprint();
bool load_okay = true;
std::string f_header;
f >> f_header;
f >> access::rw(x.n_rows);
f >> access::rw(x.n_cols);
f >> access::rw(x.n_nonzero);
access::rw(x.n_elem) = x.n_rows*x.n_cols;
if(f_header == diskio::gen_bin_header(x))
{
//f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win
dows machine a newline could be two characters
f.get();
//Allocate memory for the incoming data
eT* in_values = memory::acquire<eT>(x.n_nonzero);
uword* in_row_indices = memory::acquire<uword>(x.n_nonzero);
uword* in_col_ptrs = memory::acquire<uword>(x.n_cols + 1);
f.read((char*) in_values, std::streamsize(x.n_nonzero * sizeof(eT)) );
f.read((char*) in_row_indices, std::streamsize(x.n_nonzero * sizeof(uwo
rd)) );
f.read((char*) in_col_ptrs, std::streamsize((x.n_cols + 1) * sizeof(uwo
rd)) );
//Stick new data into sparse matrix
if (x.n_nonzero > 0)
{
memory::release(x.values);
memory::release(x.row_indices);
}
memory::release(x.col_ptrs);
access::rw(x.values) = in_values;
access::rw(x.row_indices) = in_row_indices;
access::rw(x.col_ptrs) = in_col_ptrs;
load_okay = f.good();
}
else
{
load_okay = false;
err_msg = "incorrect header in ";
}
return load_okay;
}
//! Load a PGM greyscale image as a matrix
template<typename eT>
inline
bool
diskio::load_pgm_binary(SpMat<eT>& x, const std::string& name, std::string&
err_msg)
{
arma_extra_debug_sigprint();
std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_pgm_binary(x, f, err_msg);
f.close();
}
return load_okay;
}
//! Load a PGM greyscale image as a matrix
template<typename eT>
inline
bool
diskio::load_pgm_binary(SpMat<eT>& x, std::istream& f, std::string& err_msg
)
{
bool load_okay = true;
std::string f_header;
f >> f_header;
if(f_header == "P5")
{
uword f_n_rows = 0;
uword f_n_cols = 0;
int f_maxval = 0;
diskio::pnm_skip_comments(f);
f >> f_n_cols;
diskio::pnm_skip_comments(f);
f >> f_n_rows;
diskio::pnm_skip_comments(f);
f >> f_maxval; //grabing a redundant size value
f >> f_maxval;
f.get();
if( (f_maxval > 0) || (f_maxval <= 65535) )
{
x.set_size(f_n_rows,f_n_cols);
if(f_maxval <= 255)
{
const uword n_elem = f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem);
f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_el
em) );
uword i = 0;
//cout << "f_n_cols = " << f_n_cols << endl;
//cout << "f_n_rows = " << f_n_rows << endl;
for(uword row=0; row < f_n_rows; ++row)
{
for(uword col=0; col < f_n_cols; ++col)
{
x.at(row,col) = eT(tmp[i]);
++i;
}
}
}
else
{
const uword n_elem = f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(n_e
lem*2) );
uword i = 0;
for(uword row=0; row < f_n_rows; ++row)
{
for(uword col=0; col < f_n_cols; ++col)
{
x.at(row,col) = eT(tmp[i]);
++i;
}
}
}
}
else
{
load_okay = false;
err_msg = "currently no code available to handle loading ";
}
if(f.good() == false)
{
load_okay = false;
}
}
else
{
load_okay = false;
err_msg = "unsupported header in ";
}
return load_okay;
}
//! Load a PGM greyscale image as a matrix
template<typename T>
inline
bool
diskio::load_pgm_binary(SpMat< std::complex<T> >& x, const std::string& nam
e, std::string& err_msg)
{
arma_extra_debug_sigprint();
uchar_mat tmp;
const bool load_okay = diskio::load_pgm_binary(tmp, name, err_msg);
x = conv_to< Mat< std::complex<T> > >::from(tmp);
return load_okay;
}
//! Load a PGM greyscale image as a matrix
template<typename T>
inline
bool
diskio::load_pgm_binary(SpMat< std::complex<T> >& x, std::istream& is, std:
:string& err_msg)
{
arma_extra_debug_sigprint();
uchar_mat tmp;
const bool load_okay = diskio::load_pgm_binary(tmp, is, err_msg);
x = conv_to< Mat< std::complex<T> > >::from(tmp);
return load_okay;
}
//! Try to load a matrix by automatically determining its type
template<typename eT>
inline
bool
diskio::load_auto_detect(SpMat<eT>& x, const std::string& name, std::string
& err_msg)
{
arma_extra_debug_sigprint();
std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_auto_detect(x, f, err_msg);
f.close();
}
return load_okay;
}
//! Try to load a matrix by automatically determining its type
template<typename eT>
inline
bool
diskio::load_auto_detect(SpMat<eT>& x, std::istream& f, std::string& err_ms
g)
{
arma_extra_debug_sigprint();
static const std::string ARMA_SPM_TXT = "ARMA_SPM_TXT";
static const std::string ARMA_SPM_BIN = "ARMA_SPM_BIN";
static const std::string P5 = "P5";
podarray<char> raw_header(ARMA_SPM_TXT.length() + 1);
std::streampos pos = f.tellg();
f.read( raw_header.memptr(), std::streamsize(ARMA_SPM_TXT.length()) );
raw_header[ARMA_SPM_TXT.length()] = '\0';
f.clear();
f.seekg(pos);
const std::string header = raw_header.mem;
if(ARMA_SPM_TXT == header.substr(0,ARMA_SPM_TXT.length()))
{
return load_arma_ascii(x, f, err_msg);
}
else
if(ARMA_SPM_BIN == header.substr(0,ARMA_SPM_BIN.length()))
{
return load_arma_binary(x, f, err_msg);
}
else
if(P5 == header.substr(0,P5.length()))
{
return load_pgm_binary(x, f, err_msg);
}
else
{
const file_type ft = guess_file_type(f);
switch(ft)
{
case csv_ascii:
return load_csv_ascii(x, f, err_msg);
break;
case raw_binary:
return load_raw_binary(x, f, err_msg);
break;
case raw_ascii:
return load_raw_ascii(x, f, err_msg);
break;
default:
err_msg = "unknown data in ";
return false;
}
}
return false;
}
template<typename eT>
inline
bool
diskio::load_coord_ascii(SpMat<eT>& x, const std::string& name, std::string
& err_msg)
{
arma_extra_debug_sigprint();
std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary);
bool load_okay = f.is_open();
if(load_okay == true)
{
load_okay = diskio::load_coord_ascii(x, f, err_msg);
f.close();
}
return load_okay;
}
template<typename eT>
inline
bool
diskio::load_coord_ascii(SpMat<eT>& x, std::istream& f, std::string& err_ms
g)
{
uword r,c,nz;
f >> r; f >> c; f >> nz; //Grab the header
x.set_size(r,c);
for(size_t i = 0; i < nz; i++)
{
eT data;
uword row, col;
f >> row; f >> col; f >> data;
x.at(row,col) = data;
}
return f.good();
}
// cubes // cubes
//! Save a cube as raw text (no header, human readable). //! Save a cube as raw text (no header, human readable).
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::save_raw_ascii(const Cube<eT>& x, const std::string& final_name) diskio::save_raw_ascii(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 30 change blocks. 
47 lines changed or deleted 1516 lines changed or added


 eGlue_meat.hpp   eGlue_meat.hpp 
skipping to change at line 45 skipping to change at line 45
P2.get_n_rows(), P2.get_n_cols(), P2.get_n_rows(), P2.get_n_cols(),
eglue_type::text() eglue_type::text()
); );
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
uword uword
eGlue<T1,T2,eglue_type>::get_n_rows() const eGlue<T1,T2,eglue_type>::get_n_rows() const
{ {
return is_row ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_rows() : P2.get_n_ro ws() ); return is_row ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_rows() : ( Proxy<T2> ::is_fixed ? P2.get_n_rows() : P1.get_n_rows() ) );
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
uword uword
eGlue<T1,T2,eglue_type>::get_n_cols() const eGlue<T1,T2,eglue_type>::get_n_cols() const
{ {
return is_col ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_cols() : P2.get_n_co ls() ); return is_col ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_cols() : ( Proxy<T2> ::is_fixed ? P2.get_n_cols() : P1.get_n_cols() ) );
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
uword uword
eGlue<T1,T2,eglue_type>::get_n_elem() const eGlue<T1,T2,eglue_type>::get_n_elem() const
{ {
return Proxy<T1>::is_fixed ? P1.get_n_elem() : P2.get_n_elem(); return Proxy<T1>::is_fixed ? P1.get_n_elem() : ( Proxy<T2>::is_fixed ? P2 .get_n_elem() : P1.get_n_elem() ) ;
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlue<T1,T2,eglue_type>::operator[] (const uword ii) const eGlue<T1,T2,eglue_type>::operator[] (const uword ii) 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
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 eop_aux.hpp   eop_aux.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup eop_aux //! \addtogroup eop_aux
//! @{ //! @{
template<typename eT> template<typename eT>
struct eop_aux_randu struct eop_aux_randu
{ {
arma_inline arma_inline
operator eT () operator eT ()
{ {
//return eT(std::rand()) / eT(RAND_MAX);
return eT(std::rand()) * ( eT(1) / eT(RAND_MAX) ); return eT(std::rand()) * ( eT(1) / eT(RAND_MAX) );
} }
inline
static
void
fill(eT* mem, const uword N)
{
uword i,j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
const eT tmp_i = eT(eop_aux_randu<eT>());
const eT tmp_j = eT(eop_aux_randu<eT>());
mem[i] = tmp_i;
mem[j] = tmp_j;
}
if(i < N)
{
mem[i] = eT(eop_aux_randu<eT>());
}
}
}; };
template<typename T> template<typename T>
struct eop_aux_randu< std::complex<T> > struct eop_aux_randu< std::complex<T> >
{ {
arma_inline arma_inline
operator std::complex<T> () operator std::complex<T> ()
{ {
return std::complex<T>( T(eop_aux_randu<T>()), T(eop_aux_randu<T>()) ); return std::complex<T>( T(eop_aux_randu<T>()), T(eop_aux_randu<T>()) );
} }
inline
static
void
fill(std::complex<T>* mem, const uword N)
{
for(uword i=0; i < N; ++i)
{
mem[i] = std::complex<T>( eop_aux_randu< std::complex<T> >() );
}
}
}; };
template<typename eT> template<typename eT>
struct eop_aux_randn struct eop_aux_randn
{ {
// // rudimentary method, based on the central limit theorem // rudimentary method, based on the central limit theorem:
// // http://en.wikipedia.org/wiki/Central_limit_theorem // http://en.wikipedia.org/wiki/Central_limit_theorem
// inline
// operator eT () const
// {
// const uword N = 12; // N must be >= 12 and an even number
// const uword N2 = N/2;
//
// eT acc = eT(0);
//
// for(uword i=0; i<N2; ++i)
// {
// const eT tmp1 = eT(std::rand()) / eT(RAND_MAX);
// const eT tmp2 = eT(std::rand()) / eT(RAND_MAX);
// acc += tmp1+tmp2;
// }
//
// return acc - eT(N2);
// }
// polar form of the Box-Muller transformation // polar form of the Box-Muller transformation:
// http://en.wikipedia.org/wiki/Box-Muller_transformation // http://en.wikipedia.org/wiki/Box-Muller_transformation
// http://en.wikipedia.org/wiki/Marsaglia_polar_method // http://en.wikipedia.org/wiki/Marsaglia_polar_method
// other methods:
// http://en.wikipedia.org/wiki/Ziggurat_algorithm
//
// Marsaglia and Tsang Ziggurat technique to transform from a uniform to
a normal distribution.
// G. Marsaglia, W.W. Tsang.
// "Ziggurat method for generating random variables",
// J. Statistical Software, vol 5, 2000.
// http://www.jstatsoft.org/v05/i08/
// currently using polar form of the Box-Muller transformation
inline inline
operator eT () const operator eT () const
{ {
// make sure we are internally using at least floats // make sure we are internally using at least floats
typedef typename promote_type<eT,float>::result eTp; typedef typename promote_type<eT,float>::result eTp;
eTp tmp1; eTp tmp1;
eTp tmp2; eTp tmp2;
eTp w; eTp w;
do do
{ {
// tmp1 = eTp(2) * eTp(std::rand()) / eTp(RAND_MAX) - eTp(1);
// tmp2 = eTp(2) * eTp(std::rand()) / eTp(RAND_MAX) - eTp(1);
tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1); tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1); tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
w = tmp1*tmp1 + tmp2*tmp2; w = tmp1*tmp1 + tmp2*tmp2;
} }
while ( w >= eTp(1) ); while ( w >= eTp(1) );
return eT( tmp1 * std::sqrt( (eTp(-2) * std::log(w)) / w) ); return eT( tmp1 * std::sqrt( (eTp(-2) * std::log(w)) / w) );
} }
// other methods: inline
// http://en.wikipedia.org/wiki/Ziggurat_algorithm static
// void
// Marsaglia and Tsang Ziggurat technique to transform from a uniform to generate(eT& out1, eT& out2)
a normal distribution. {
// G. Marsaglia, W.W. Tsang. // make sure we are internally using at least floats
// "Ziggurat method for generating random variables", typedef typename promote_type<eT,float>::result eTp;
// J. Statistical Software, vol 5, 2000.
// http://www.jstatsoft.org/v05/i08/ eTp tmp1;
eTp tmp2;
eTp w;
do
{
tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
w = tmp1*tmp1 + tmp2*tmp2;
}
while ( w >= eTp(1) );
const eTp k = std::sqrt( (eTp(-2) * std::log(w)) / w);
out1 = tmp1*k;
out2 = tmp2*k;
}
inline
static
void
fill(eT* mem, const uword N)
{
uword i, j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
eop_aux_randn<eT>::generate( mem[i], mem[j] );
}
if(i < N)
{
mem[i] = eT(eop_aux_randn<eT>());
}
}
}; };
template<typename T> template<typename T>
struct eop_aux_randn< std::complex<T> > struct eop_aux_randn< std::complex<T> >
{ {
arma_inline inline
operator std::complex<T> () const operator std::complex<T> () const
{ {
return std::complex<T>( T(eop_aux_randn<T>()), T(eop_aux_randn<T>()) ); T a, b;
eop_aux_randn<T>::generate(a, b);
return std::complex<T>(a, b);
}
inline
static
void
fill(std::complex<T>* mem, const uword N)
{
for(uword i=0; i < N; ++i)
{
mem[i] = std::complex<T>( eop_aux_randn< std::complex<T> >() );
}
} }
}; };
//! use of the SFINAE approach to work around compiler limitations //! use of the SFINAE approach to work around compiler limitations
//! http://en.wikipedia.org/wiki/SFINAE //! http://en.wikipedia.org/wiki/SFINAE
class eop_aux class eop_aux
{ {
public: public:
 End of changes. 10 change blocks. 
35 lines changed or deleted 110 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2012 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)
skipping to change at line 278 skipping to change at line 279
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
accu(const T& x) accu(const T& x)
{ {
return x; return x;
} }
//! accumulate values in a sparse object
template<typename T1>
arma_hot
inline
arma_warn_unused
typename enable_if2<is_arma_sparse_type<T1>::value, typename T1::elem_type>
::result
accu(const T1& x)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const SpProxy<T1> p(x);
if(SpProxy<T1>::must_use_iterator == false)
{
// direct counting
return arrayops::accumulate(p.get_values(), p.get_n_nonzero());
}
else
{
typename SpProxy<T1>::const_iterator_type it = p.begin();
eT result = eT(0);
while(it.pos() < p.get_n_nonzero())
{
result += (*it);
++it;
}
return result;
}
}
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 37 lines changed or added


 fn_as_scalar.hpp   fn_as_scalar.hpp 
skipping to change at line 326 skipping to change at line 326
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
as_scalar(const T& x) as_scalar(const T& x)
{ {
return x; return x;
} }
template<typename T1>
arma_inline
arma_warn_unused
typename T1::elem_type
as_scalar(const SpBase<typename T1::elem_type, T1>& X)
{
typedef typename T1::elem_type eT;
const unwrap_spmat<T1> tmp(X.get_ref());
const SpMat<eT>& A = tmp.M;
arma_debug_check( (A.n_elem != 1), "as_scalar(): expression doesn't evalu
ate to exactly one element" );
return A.at(0,0);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 17 lines changed or added


 fn_dot.hpp   fn_dot.hpp 
skipping to change at line 104 skipping to change at line 104
const Base<typename T1::elem_type,T2>& B, const Base<typename T1::elem_type,T2>& B,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0 const typename 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 cdot(A.m, B); return cdot(A.m, B);
} }
//! dot product of two sparse objects
template<typename T1, typename T2>
inline
arma_warn_unused
typename
enable_if2
<(is_arma_sparse_type<T1>::value) && (is_arma_sparse_type<T2>::value) &&
(is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
typename T1::elem_type
>::result
dot
(
const SpBase<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const SpProxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_ro
ws(), pb.get_n_cols(), "dot()");
typedef typename T1::elem_type eT;
if((&(x.get_ref()) == &(y.get_ref())) && (SpProxy<T1>::must_use_iterator
== false))
{
// We can do it directly!
return op_dot::direct_dot_arma(pa.get_n_nonzero(), pa.get_values(), pa.
get_values());
}
else
{
// Iterate over both objects and see when they are the same
eT result = eT(0);
typename SpProxy<T1>::const_iterator_type a_it = pa.begin();
typename SpProxy<T2>::const_iterator_type b_it = pb.begin();
while((a_it.pos() < pa.get_n_nonzero()) && (b_it.pos() < pb.get_n_nonze
ro()))
{
if(a_it == b_it)
{
result += (*a_it) * (*b_it);
++a_it;
++b_it;
}
else if((a_it.col() < b_it.col()) || ((a_it.col() == b_it.col()) && (
a_it.row() < b_it.row())))
{
// a_it is "behind"
++a_it;
}
else
{
// b_it is "behind"
++b_it;
}
}
return result;
}
}
//! dot product of one sparse and one dense object
template<typename T1, typename T2>
arma_inline
arma_warn_unused
typename
enable_if2
<(is_arma_sparse_type<T1>::value) && (is_arma_type<T2>::value) && (is_sam
e_type<typename T1::elem_type, typename T2::elem_type>::value),
typename T1::elem_type
>::result
dot
(
const SpBase<typename T1::elem_type, T1>& x,
const Base<typename T2::elem_type, T2>& y
)
{
// this is commutative
return dot(y, x);
}
//! dot product of one dense and one sparse object
template<typename T1, typename T2>
inline
arma_warn_unused
typename
enable_if2
<(is_arma_type<T1>::value) && (is_arma_sparse_type<T2>::value) && (is_sam
e_type<typename T1::elem_type, typename T2::elem_type>::value),
typename T1::elem_type
>::result
dot
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_ro
ws(), pb.get_n_cols(), "dot()");
typedef typename T1::elem_type eT;
eT result = eT(0);
typename SpProxy<T2>::const_iterator_type it = pb.begin();
// prefer_at_accessor won't save us operations
while(it.pos() < pb.get_n_nonzero())
{
result += (*it) * pa.at(it.row(), it.col());
++it;
}
return result;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 128 lines changed or added


 fn_max.hpp   fn_max.hpp 
skipping to change at line 109 skipping to change at line 109
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
max(const T& x) max(const T& x)
{ {
return x; return x;
} }
template<typename T1>
inline
arma_warn_unused
typename
enable_if2
<
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1
>::value == true),
typename T1::elem_type
>::result
max(const T1& x)
{
arma_extra_debug_sigprint();
return spop_max::vector_max(x);
}
template<typename T1>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1
>::value == false),
const SpOp<T1, spop_max>
>::result
max(const T1& X, const uword dim = 0)
{
arma_extra_debug_sigprint();
return SpOp<T1, spop_max>(X, dim, 0);
}
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
max(const SpOp<T1, spop_max>& X)
{
arma_extra_debug_sigprint();
arma_extra_debug_print("max(): two consecutive max() calls detected");
return spop_max::vector_max(X.m);
}
template<typename T1>
inline
const SpOp< SpOp<T1, spop_max>, spop_max>
max(const SpOp<T1, spop_max>& in, const uword dim)
{
arma_extra_debug_sigprint();
return SpOp< SpOp<T1, spop_max>, spop_max>(in, dim, 0);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 55 lines changed or added


 fn_min.hpp   fn_min.hpp 
skipping to change at line 109 skipping to change at line 109
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
min(const T& x) min(const T& x)
{ {
return x; return x;
} }
template<typename T1>
inline
arma_warn_unused
typename
enable_if2
<
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1
>::value == true),
typename T1::elem_type
>::result
min(const T1& x)
{
arma_extra_debug_sigprint();
return spop_min::vector_min(x);
}
template<typename T1>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1
>::value == false),
const SpOp<T1, spop_min>
>::result
min(const T1& X, const uword dim = 0)
{
arma_extra_debug_sigprint();
return SpOp<T1, spop_min>(X, dim, 0);
}
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
min(const SpOp<T1, spop_min>& X)
{
arma_extra_debug_sigprint();
arma_extra_debug_print("min(): two consecutive min() calls detected");
return spop_min::vector_min(X.m);
}
template<typename T1>
inline
const SpOp< SpOp<T1, spop_min>, spop_min>
min(const SpOp<T1, spop_min>& in, const uword dim)
{
arma_extra_debug_sigprint();
return SpOp< SpOp<T1, spop_min>, spop_min>(in, dim, 0);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 55 lines changed or added


 fn_qr.hpp   fn_qr.hpp 
skipping to change at line 45 skipping to change at line 45
if(status == false) if(status == false)
{ {
Q.reset(); Q.reset();
R.reset(); R.reset();
arma_bad("qr(): failed to converge", false); arma_bad("qr(): failed to converge", false);
} }
return status; return status;
} }
//! economical QR decomposition
template<typename T1>
inline
bool
qr_econ
(
Mat<typename T1::elem_type>& Q,
Mat<typename T1::elem_type>& R,
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
arma_debug_check( (&Q == &R), "qr_econ(): Q and R are the same object");
const bool status = auxlib::qr_econ(Q, R, X);
if(status == false)
{
Q.reset();
R.reset();
arma_bad("qr_econ(): failed to converge", false);
}
return status;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 30 lines changed or added


 fn_strans.hpp   fn_strans.hpp 
skipping to change at line 64 skipping to change at line 64
arma_inline arma_inline
const T1& const T1&
strans(const Op<T1, op_strans>& X) strans(const Op<T1, op_strans>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("strans(): removing op_strans"); arma_extra_debug_print("strans(): removing op_strans");
return X.m; return X.m;
} }
//
// handling of sparse matrices
template<typename T1>
inline
const SpOp<T1,spop_strans>
strans(const SpBase<typename T1::elem_type, T1>& x)
{
arma_extra_debug_sigprint();
return SpOp<T1,spop_strans>( x.get_ref() );
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 13 lines changed or added


 fn_sum.hpp   fn_sum.hpp 
skipping to change at line 113 skipping to change at line 113
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
sum(const T& x) sum(const T& x)
{ {
return x; return x;
} }
//! sum of sparse object
template<typename T1>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1
>::value == true),
typename T1::elem_type
>::result
sum(const T1& x)
{
arma_extra_debug_sigprint();
// sum elements
return accu(x);
}
template<typename T1>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1
>::value == false),
const SpOp<T1,spop_sum>
>::result
sum(const T1& x, const uword dim = 0)
{
arma_extra_debug_sigprint();
return SpOp<T1,spop_sum>(x, dim, 0);
}
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
sum(const SpOp<T1, spop_sum>& in)
{
arma_extra_debug_sigprint();
arma_extra_debug_print("sum(): two consecutive sum() calls detected");
return accu(in.m);
}
template<typename T1>
arma_inline
const SpOp<SpOp<T1, spop_sum>, spop_sum>
sum(const SpOp<T1, spop_sum>& in, const uword dim)
{
arma_extra_debug_sigprint();
return SpOp<SpOp<T1, spop_sum>, spop_sum>(in, dim, 0);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 56 lines changed or added


 fn_svd.hpp   fn_svd.hpp 
skipping to change at line 76 skipping to change at line 76
template<typename T1> template<typename T1>
inline inline
bool bool
svd svd
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char* method = "",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check arma_debug_check
( (
( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ), ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ),
"svd(): two or more output objects are the same object" "svd(): two or more output objects are the same object"
); );
bool use_divide_and_conquer = false;
const char sig = method[0];
switch(sig)
{
case '\0':
case 's':
break;
case 'd':
use_divide_and_conquer = true;
break;
default:
{
arma_stop("svd(): unknown method specified");
return false;
}
}
// auxlib::svd() makes an internal copy of X // auxlib::svd() makes an internal copy of X
const bool status = auxlib::svd(U, S, V, X); const bool status = (use_divide_and_conquer == false) ? auxlib::svd(U, S, V, X) : auxlib::svd_dc(U, S, V, X);
if(status == false) if(status == false)
{ {
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
arma_bad("svd(): failed to converge", false); arma_bad("svd(): failed to converge", false);
} }
return status; return status;
 End of changes. 3 change blocks. 
1 lines changed or deleted 23 lines changed or added


 fn_trace.hpp   fn_trace.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2010 Conrad Sanderson
// Copyright (C) 2012 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)
skipping to change at line 107 skipping to change at line 108
{ {
acc += A.at(i,j) * B_colmem[j]; acc += A.at(i,j) * B_colmem[j];
} }
val += acc; val += acc;
} }
return val; return val;
} }
//! trace of sparse object
template<typename T1>
inline
arma_warn_unused
typename enable_if2<is_arma_sparse_type<T1>::value, typename T1::elem_type>
::result
trace(const SpBase<typename T1::elem_type, T1>& x)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(x.get_ref());
arma_debug_check( (p.get_n_rows() != p.get_n_cols()), "trace(): matrix mu
st be square sized" );
typedef typename T1::elem_type eT;
eT result = eT(0);
typename SpProxy<T1>::const_iterator_type it = p.begin();
while(it.pos() < p.get_n_nonzero())
{
if(it.row() == it.col())
{
result += (*it);
}
++it;
}
return result;
}
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 35 lines changed or added


 fn_trans.hpp   fn_trans.hpp 
skipping to change at line 69 skipping to change at line 69
arma_inline arma_inline
const T1& const T1&
htrans(const Op<T1, op_htrans>& X) htrans(const Op<T1, op_htrans>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("htrans(): removing op_htrans"); arma_extra_debug_print("htrans(): removing op_htrans");
return X.m; return X.m;
} }
//
// handling of sparse matrices
template<typename T1>
inline
const SpOp<T1,spop_strans>
trans
(
const SpBase<typename T1::elem_type, T1>& x,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return SpOp<T1,spop_strans>( x.get_ref() );
}
template<typename T1>
inline
const SpOp<T1,spop_htrans>
trans
(
const SpBase<typename T1::elem_type, T1>& x,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return SpOp<T1,spop_htrans>( x.get_ref() );
}
template<typename T1>
inline
const SpOp<T1,spop_strans>
htrans
(
const SpBase<typename T1::elem_type, T1>& x,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return SpOp<T1,spop_strans>( x.get_ref() );
}
template<typename T1>
inline
const SpOp<T1,spop_htrans>
htrans
(
const SpBase<typename T1::elem_type, T1>& x,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return SpOp<T1,spop_htrans>( x.get_ref() );
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 63 lines changed or added


 forward_bones.hpp   forward_bones.hpp 
skipping to change at line 33 skipping to change at line 33
template<typename eT> class Row; template<typename eT> class Row;
template<typename eT> class Cube; template<typename eT> class Cube;
template<typename oT> class field; template<typename oT> class field;
template<typename eT> class subview; template<typename eT> class subview;
template<typename eT> class subview_col; template<typename eT> class subview_col;
template<typename eT> class subview_row; template<typename eT> class subview_row;
template<typename eT> class subview_cube; template<typename eT> class subview_cube;
template<typename oT> class subview_field; template<typename oT> class subview_field;
template<typename eT> class SpValProxy;
template<typename eT> class SpMat;
template<typename eT> class SpCol;
template<typename eT> class SpRow;
template<typename eT> class SpSubview;
template<typename eT> class diagview; template<typename eT> class diagview;
template<typename eT, typename T1> class subview_elem1; template<typename eT, typename T1> class subview_elem1;
template<typename eT, typename T1, typename T2> class subview_elem2; template<typename eT, typename T1, typename T2> class subview_elem2;
template<typename parent, unsigned int mode> class subview_eac
h1;
template<typename parent, unsigned int mode, typename TB> class subview_eac
h2;
class arma_empty_class {}; class arma_empty_class {};
class diskio; class diskio;
class op_min; class op_min;
class op_max; class op_max;
class op_strans; class op_strans;
class op_htrans; class op_htrans;
class op_htrans2; class op_htrans2;
skipping to change at line 128 skipping to change at line 137
template< typename T1, typename eop_type> class eOpCube; template< typename T1, typename eop_type> class eOpCube;
template<typename out_eT, typename T1, typename op_type> class mtOpCube; template<typename out_eT, typename T1, typename op_type> class mtOpCube;
template< typename T1, typename T2, typename glue_type> cl ass GlueCube; template< typename T1, typename T2, typename glue_type> cl ass GlueCube;
template< typename T1, typename T2, typename eglue_type> cl ass eGlueCube; template< typename T1, typename T2, typename eglue_type> cl ass eGlueCube;
template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlueCube; template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlueCube;
template<typename T1> class Proxy; template<typename T1> class Proxy;
template<typename T1> class ProxyCube; template<typename T1> class ProxyCube;
class spop_strans;
class spop_htrans;
class spop_scalar_times;
class spglue_plus;
class spglue_plus2;
class spglue_minus;
class spglue_minus2;
class spglue_times;
class spglue_times2;
template<typename T1, typename spop_type > class SpOp;
template<typename T1, typename T2, typename spglue_type> class SpGlue;
template<typename T1> class SpProxy;
struct arma_vec_indicator {}; struct arma_vec_indicator {};
struct arma_fixed_indicator {}; struct arma_fixed_indicator {};
//! \addtogroup injector //! \addtogroup injector
//! @{ //! @{
template<typename Dummy = int> struct injector_end_of_row {}; template<typename Dummy = int> struct injector_end_of_row {};
static const injector_end_of_row<> endr = injector_end_of_row<>(); static const injector_end_of_row<> endr = injector_end_of_row<>();
//!< endr indicates "end of row" when using the << operator; //!< endr indicates "end of row" when using the << operator;
 End of changes. 3 change blocks. 
0 lines changed or deleted 29 lines changed or added


 gemm.hpp   gemm.hpp 
skipping to change at line 89 skipping to change at line 89
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const uword B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
if( (do_trans_A == false) && (do_trans_B == false) ) if( (do_trans_A == false) && (do_trans_B == false) )
{ {
arma_aligned podarray<eT> tmp(A_n_cols); arma_aligned podarray<eT> tmp(A_n_cols);
eT* A_rowdata = tmp.memptr(); eT* A_rowdata = tmp.memptr();
for(uword row_A=0; row_A < A_n_rows; ++row_A) for(uword row_A=0; row_A < A_n_rows; ++row_A)
{ {
tmp.copy_row(A, row_A); //tmp.copy_row(A, row_A);
const eT acc0 = op_dot::dot_and_copy_row(A_rowdata, A, row_A, B.col
ptr(0), A_n_cols);
if( (use_alpha == false) && (use_beta == false) )
{
C.at(row_A,0) = acc0;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
C.at(row_A,0) = alpha * acc0;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
C.at(row_A,0) = acc0 + beta*C.at(row_A,0);
}
else
if( (use_alpha == true) && (use_beta == true) )
{
C.at(row_A,0) = alpha*acc0 + beta*C.at(row_A,0);
}
for(uword col_B=0; col_B < B_n_cols; ++col_B) //for(uword col_B=0; col_B < B_n_cols; ++col_B)
for(uword col_B=1; col_B < B_n_cols; ++col_B)
{ {
const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col ptr(col_B)); const eT acc = op_dot::direct_dot_arma(B_n_rows, A_rowdata, B.col ptr(col_B));
if( (use_alpha == false) && (use_beta == false) ) if( (use_alpha == false) && (use_beta == false) )
{ {
C.at(row_A,col_B) = acc; C.at(row_A,col_B) = acc;
} }
else else
if( (use_alpha == true) && (use_beta == false) ) if( (use_alpha == true) && (use_beta == false) )
{ {
 End of changes. 3 change blocks. 
2 lines changed or deleted 26 lines changed or added


 lapack_bones.hpp   lapack_bones.hpp 
skipping to change at line 80 skipping to change at line 80
#define arma_cungqr cungqr #define arma_cungqr cungqr
#define arma_zungqr zungqr #define arma_zungqr zungqr
#define arma_sgesvd sgesvd #define arma_sgesvd sgesvd
#define arma_dgesvd dgesvd #define arma_dgesvd dgesvd
#define arma_cgesvd cgesvd #define arma_cgesvd cgesvd
#define arma_zgesvd zgesvd #define arma_zgesvd zgesvd
#define arma_sgesdd sgesdd
#define arma_dgesdd dgesdd
#define arma_cgesdd cgesdd
#define arma_zgesdd zgesdd
#define arma_sgesv sgesv #define arma_sgesv sgesv
#define arma_dgesv dgesv #define arma_dgesv dgesv
#define arma_cgesv cgesv #define arma_cgesv cgesv
#define arma_zgesv zgesv #define arma_zgesv zgesv
#define arma_sgels sgels #define arma_sgels sgels
#define arma_dgels dgels #define arma_dgels dgels
#define arma_cgels cgels #define arma_cgels cgels
#define arma_zgels zgels #define arma_zgels zgels
skipping to change at line 177 skipping to change at line 182
#define arma_cungqr CUNGQR #define arma_cungqr CUNGQR
#define arma_zungqr ZUNGQR #define arma_zungqr ZUNGQR
#define arma_sgesvd SGESVD #define arma_sgesvd SGESVD
#define arma_dgesvd DGESVD #define arma_dgesvd DGESVD
#define arma_cgesvd CGESVD #define arma_cgesvd CGESVD
#define arma_zgesvd ZGESVD #define arma_zgesvd ZGESVD
#define arma_sgesdd SGESDD
#define arma_dgesdd DGESDD
#define arma_cgesdd CGESDD
#define arma_zgesdd ZGESDD
#define arma_sgesv SGESV #define arma_sgesv SGESV
#define arma_dgesv DGESV #define arma_dgesv DGESV
#define arma_cgesv CGESV #define arma_cgesv CGESV
#define arma_zgesv ZGESV #define arma_zgesv ZGESV
#define arma_sgels SGELS #define arma_sgels SGELS
#define arma_dgels DGELS #define arma_dgels DGELS
#define arma_cgels CGELS #define arma_cgels CGELS
#define arma_zgels ZGELS #define arma_zgels ZGELS
skipping to change at line 292 skipping to change at line 302
void arma_fortran(arma_zungqr)(blas_int* m, blas_int* n, blas_int* k, v oid* a, blas_int* lda, void* tau, void* work, blas_int* lwork, blas_int * info); void arma_fortran(arma_zungqr)(blas_int* m, blas_int* n, blas_int* k, v oid* a, blas_int* lda, void* tau, void* work, blas_int* lwork, blas_int * info);
// SVD (real matrices) // SVD (real matrices)
void arma_fortran(arma_sgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, float* a, blas_int* lda, float* s, float* u, blas_int* ldu, flo at* vt, blas_int* ldvt, float* work, blas_int* lwork, blas_int* info); void arma_fortran(arma_sgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, float* a, blas_int* lda, float* s, float* u, blas_int* ldu, flo at* vt, blas_int* ldvt, float* work, blas_int* lwork, blas_int* info);
void arma_fortran(arma_dgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, double* a, blas_int* lda, double* s, double* u, blas_int* ldu, dou ble* vt, blas_int* ldvt, double* work, blas_int* lwork, blas_int* info); void arma_fortran(arma_dgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, double* a, blas_int* lda, double* s, double* u, blas_int* ldu, dou ble* vt, blas_int* ldvt, double* work, blas_int* lwork, blas_int* info);
// SVD (complex matrices) // SVD (complex matrices)
void arma_fortran(arma_cgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, void* a, blas_int* lda, float* s, void* u, blas_int* ldu, voi d* vt, blas_int* ldvt, void* work, blas_int* lwork, float* rwork, blas _int* info); void arma_fortran(arma_cgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, void* a, blas_int* lda, float* s, void* u, blas_int* ldu, voi d* vt, blas_int* ldvt, void* work, blas_int* lwork, float* rwork, blas _int* info);
void arma_fortran(arma_zgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, void* a, blas_int* lda, double* s, void* u, blas_int* ldu, voi d* vt, blas_int* ldvt, void* work, blas_int* lwork, double* rwork, blas _int* info); void arma_fortran(arma_zgesvd)(char* jobu, char* jobvt, blas_int* m, blas _int* n, void* a, blas_int* lda, double* s, void* u, blas_int* ldu, voi d* vt, blas_int* ldvt, void* work, blas_int* lwork, double* rwork, blas _int* info);
// SVD (real matrices) by divide and conquer
void arma_fortran(arma_sgesdd)(char* jobz, blas_int* m, blas_int* n, floa
t* a, blas_int* lda, float* s, float* u, blas_int* ldu, float* vt, blas
_int* ldvt, float* work, blas_int* lwork, blas_int* iwork, blas_int* info)
;
void arma_fortran(arma_dgesdd)(char* jobz, blas_int* m, blas_int* n, doub
le* a, blas_int* lda, double* s, double* u, blas_int* ldu, double* vt, blas
_int* ldvt, double* work, blas_int* lwork, blas_int* iwork, blas_int* info)
;
// SVD (complex matrices) by divide and conquer
void arma_fortran(arma_cgesdd)(char* jobz, blas_int* m, blas_int* n, void
* a, blas_int* lda, float* s, void* u, blas_int* ldu, void* vt, blas_int*
ldvt, void* work, blas_int* lwork, float* rwork, blas_int* iwork, blas_int
* info);
void arma_fortran(arma_zgesdd)(char* jobz, blas_int* m, blas_int* n, void
* a, blas_int* lda, double* s, void* u, blas_int* ldu, void* vt, blas_int*
ldvt, void* work, blas_int* lwork, double* rwork, blas_int* iwork, blas_int
* info);
// solve system of linear equations, using LU decomposition // solve system of linear equations, using LU decomposition
void arma_fortran(arma_sgesv)(blas_int* n, blas_int* nrhs, float* a, bla s_int* lda, blas_int* ipiv, float* b, blas_int* ldb, blas_int* info); void arma_fortran(arma_sgesv)(blas_int* n, blas_int* nrhs, float* a, bla s_int* lda, blas_int* ipiv, float* b, blas_int* ldb, blas_int* info);
void arma_fortran(arma_dgesv)(blas_int* n, blas_int* nrhs, double* a, bla s_int* lda, blas_int* ipiv, double* b, blas_int* ldb, blas_int* info); void arma_fortran(arma_dgesv)(blas_int* n, blas_int* nrhs, double* a, bla s_int* lda, blas_int* ipiv, double* b, blas_int* ldb, blas_int* info);
void arma_fortran(arma_cgesv)(blas_int* n, blas_int* nrhs, void* a, bla s_int* lda, blas_int* ipiv, void* b, blas_int* ldb, blas_int* info); void arma_fortran(arma_cgesv)(blas_int* n, blas_int* nrhs, void* a, bla s_int* lda, blas_int* ipiv, void* b, blas_int* ldb, blas_int* info);
void arma_fortran(arma_zgesv)(blas_int* n, blas_int* nrhs, void* a, bla s_int* lda, blas_int* ipiv, void* b, blas_int* ldb, blas_int* info); void arma_fortran(arma_zgesv)(blas_int* n, blas_int* nrhs, void* a, bla s_int* lda, blas_int* ipiv, void* b, blas_int* ldb, blas_int* info);
// solve over/underdetermined system of linear equations // solve over/underdetermined system of linear equations
void arma_fortran(arma_sgels)(char* trans, blas_int* m, blas_int* n, blas _int* nrhs, float* a, blas_int* lda, float* b, blas_int* ldb, float* wor k, blas_int* lwork, blas_int* info); void arma_fortran(arma_sgels)(char* trans, blas_int* m, blas_int* n, blas _int* nrhs, float* a, blas_int* lda, float* b, blas_int* ldb, float* wor k, blas_int* lwork, blas_int* info);
void arma_fortran(arma_dgels)(char* trans, blas_int* m, blas_int* n, blas _int* nrhs, double* a, blas_int* lda, double* b, blas_int* ldb, double* wor k, blas_int* lwork, blas_int* info); void arma_fortran(arma_dgels)(char* trans, blas_int* m, blas_int* n, blas _int* nrhs, double* a, blas_int* lda, double* b, blas_int* ldb, double* wor k, blas_int* lwork, blas_int* info);
void arma_fortran(arma_cgels)(char* trans, blas_int* m, blas_int* n, blas _int* nrhs, void* a, blas_int* lda, void* b, blas_int* ldb, void* wor k, blas_int* lwork, blas_int* info); void arma_fortran(arma_cgels)(char* trans, blas_int* m, blas_int* n, blas _int* nrhs, void* a, blas_int* lda, void* b, blas_int* ldb, void* wor k, blas_int* lwork, blas_int* info);
 End of changes. 3 change blocks. 
0 lines changed or deleted 30 lines changed or added


 lapack_wrapper.hpp   lapack_wrapper.hpp 
skipping to change at line 475 skipping to change at line 475
jobu, jobvt, m, n, (std::complex<bT>*)a, lda, jobu, jobvt, m, n, (std::complex<bT>*)a, lda,
(bT*)s, (std::complex<bT>*)u, ldu, (std::complex<bT>*)vt, ldvt, (bT*)s, (std::complex<bT>*)u, ldu, (std::complex<bT>*)vt, ldvt,
(std::complex<bT>*)work, lwork, (bT*)rwork, info (std::complex<bT>*)work, lwork, (bT*)rwork, info
); );
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
gesdd
(
char* jobz, blas_int* m, blas_int* n,
eT* a, blas_int* lda, eT* s, eT* u, blas_int* ldu, eT* vt, blas_int* ld
vt,
eT* work, blas_int* lwork, blas_int* iwork, blas_int* info
)
{
arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true)
{
typedef float T;
arma_fortran(arma_sgesdd)(jobz, m, n, (T*)a, lda, (T*)s, (T*)u, ldu,
(T*)vt, ldvt, (T*)work, lwork, iwork, info);
}
else
if(is_double<eT>::value == true)
{
typedef double T;
arma_fortran(arma_dgesdd)(jobz, m, n, (T*)a, lda, (T*)s, (T*)u, ldu,
(T*)vt, ldvt, (T*)work, lwork, iwork, info);
}
}
template<typename T>
inline
void
cx_gesdd
(
char* jobz, blas_int* m, blas_int* n,
std::complex<T>* a, blas_int* lda, T* s, std::complex<T>* u, blas_int*
ldu, std::complex<T>* vt, blas_int* ldvt,
std::complex<T>* work, blas_int* lwork, T* rwork, blas_int* iwork, blas
_int* info
)
{
arma_type_check(( is_supported_blas_type<T>::value == false ));
arma_type_check(( is_supported_blas_type< std::complex<T> >::value == f
alse ));
if(is_float<T>::value == true)
{
typedef float bT;
arma_fortran(arma_cgesdd)
(
jobz, m, n,
(std::complex<bT>*)a, lda, (bT*)s, (std::complex<bT>*)u, ldu, (std:
:complex<bT>*)vt, ldvt,
(std::complex<bT>*)work, lwork, (bT*)rwork, iwork, info
);
}
else
if(is_double<T>::value == true)
{
typedef double bT;
arma_fortran(arma_zgesdd)
(
jobz, m, n,
(std::complex<bT>*)a, lda, (bT*)s, (std::complex<bT>*)u, ldu, (std:
:complex<bT>*)vt, ldvt,
(std::complex<bT>*)work, lwork, (bT*)rwork, iwork, info
);
}
}
template<typename eT>
inline
void
gesv(blas_int* n, blas_int* nrhs, eT* a, blas_int* lda, blas_int* ipiv, e T* b, blas_int* ldb, blas_int* info) gesv(blas_int* n, blas_int* nrhs, eT* a, blas_int* lda, blas_int* ipiv, e T* b, blas_int* ldb, blas_int* info)
{ {
arma_type_check(( is_supported_blas_type<eT>::value == false )); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_sgesv)(n, nrhs, (T*)a, lda, ipiv, (T*)b, ldb, info) ; arma_fortran(arma_sgesv)(n, nrhs, (T*)a, lda, ipiv, (T*)b, ldb, info) ;
} }
else else
 End of changes. 1 change blocks. 
0 lines changed or deleted 69 lines changed or added


 memory.hpp   memory.hpp 
skipping to change at line 20 skipping to change at line 20
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup memory //! \addtogroup memory
//! @{ //! @{
class memory class memory
{ {
public: public:
template<typename eT> arma_inline static eT* acquire(const uword n_elem) ; arma_inline static uword enlarge_to_mult_of_chunksi ze(const uword n_elem);
template<typename eT> arma_inline static void release(eT* mem); template<typename eT> arma_inline static eT* acquire(const uword n_elem
);
template<typename eT> arma_inline static eT* acquire_chunked(const uwor
d n_elem);
template<typename eT> arma_inline static void release(eT* mem);
}; };
arma_inline
uword
memory::enlarge_to_mult_of_chunksize(const uword n_elem)
{
const uword chunksize = arma_config::spmat_chunksize;
// this relies on integer division
const uword n_elem_mod = ((n_elem % chunksize) != 0) ? ((n_elem / chunksi
ze) + 1) * chunksize : n_elem;
return n_elem_mod;
}
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
memory::acquire(const uword n_elem) memory::acquire(const uword n_elem)
{ {
#if defined(ARMA_USE_TBB_ALLOC) #if defined(ARMA_USE_TBB_ALLOC)
{ {
return ( (eT *) scalable_malloc( sizeof(eT)*n_elem) ); return ( (eT *) scalable_malloc( sizeof(eT)*n_elem) );
} }
#elif defined(ARMA_USE_MKL_ALLOC) #elif defined(ARMA_USE_MKL_ALLOC)
{ {
return ( (eT *) mkl_malloc( sizeof(eT)*n_elem, 128 ) ); return ( (eT *) mkl_malloc( sizeof(eT)*n_elem, 128 ) );
} }
#else #else
{ {
return ( new(std::nothrow) eT[n_elem] ); return ( new(std::nothrow) eT[n_elem] );
} }
#endif #endif
} }
//! get memory in multiples of chunks, holding at least n_elem
template<typename eT>
arma_inline
eT*
memory::acquire_chunked(const uword n_elem)
{
const uword n_elem_mod = memory::enlarge_to_mult_of_chunksize(n_elem);
return memory::acquire<eT>(n_elem_mod);
}
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
memory::release(eT* mem) memory::release(eT* mem)
{ {
#if defined(ARMA_USE_TBB_ALLOC) #if defined(ARMA_USE_TBB_ALLOC)
{ {
scalable_free( (void *)(mem) ); scalable_free( (void *)(mem) );
} }
#elif defined(ARMA_USE_MKL_ALLOC) #elif defined(ARMA_USE_MKL_ALLOC)
 End of changes. 4 change blocks. 
2 lines changed or deleted 32 lines changed or added


 op_dot_bones.hpp   op_dot_bones.hpp 
skipping to change at line 49 skipping to change at line 49
arma_hot arma_pure inline static eT direct_dot(const uword n_elem, const eT* const A, const eT* const B, const eT* C); arma_hot arma_pure inline static eT direct_dot(const uword n_elem, const eT* const A, const eT* const B, const eT* C);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_inline static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot arma_inline static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename eT>
arma_hot inline static eT dot_and_copy_row(eT* out, const Mat<eT>& A, con
st uword row, const eT* B_mem, const uword N);
}; };
//! \brief //! \brief
//! normalised dot product operation //! normalised dot product operation
class op_norm_dot class op_norm_dot
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
 End of changes. 1 change blocks. 
0 lines changed or deleted 4 lines changed or added


 op_dot_meat.hpp   op_dot_meat.hpp 
skipping to change at line 226 skipping to change at line 226
} }
return val1 + val2; return val1 + val2;
} }
else else
{ {
return op_dot::apply_unwrap(A.Q, B.Q); return op_dot::apply_unwrap(A.Q, B.Q);
} }
} }
template<typename eT>
arma_hot
inline
eT
op_dot::dot_and_copy_row(eT* out, const Mat<eT>& A, const uword row, const
eT* B_mem, const uword N)
{
eT acc1 = eT(0);
eT acc2 = eT(0);
uword i,j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
const eT val_i = A.at(row, i);
const eT val_j = A.at(row, j);
out[i] = val_i;
out[j] = val_j;
acc1 += val_i * B_mem[i];
acc2 += val_j * B_mem[j];
}
if(i < N)
{
const eT val_i = A.at(row, i);
out[i] = val_i;
acc1 += val_i * B_mem[i];
}
return acc1 + acc2;
}
// //
// op_norm_dot // op_norm_dot
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
typename T1::elem_type typename T1::elem_type
op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typ ename T1::elem_type,T2>& Y) op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typ ename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 1 change blocks. 
0 lines changed or deleted 35 lines changed or added


 op_htrans_meat.hpp   op_htrans_meat.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2012 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)
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 op_sort_bones.hpp   op_sort_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 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
template<typename eT> template<typename eT>
inline static void copy_row(eT* X, const Mat<eT>& A, const uword row); inline static void copy_row(eT* X, const Mat<eT>& A, const uword row);
template<typename eT> template<typename eT>
inline static void copy_row(Mat<eT>& A, const eT* X, const uword row); inline static void copy_row(Mat<eT>& A, const eT* X, const uword row);
template<typename eT> template<typename eT>
inline static void direct_sort(eT* X, const uword N, const uword sort_typ e = 0); inline static void direct_sort(eT* X, const uword N, const uword sort_typ e = 0);
template<typename eT>
inline static void direct_sort_ascending(eT* X, const uword N);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _sort>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _sort>& in);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 5 lines changed or added


 op_sort_meat.hpp   op_sort_meat.hpp 
skipping to change at line 96 skipping to change at line 96
{ {
arma_descend_sort_helper<eT> comparator; arma_descend_sort_helper<eT> comparator;
std::sort(&X[0], &X[n_elem], comparator); std::sort(&X[0], &X[n_elem], comparator);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
op_sort::direct_sort_ascending(eT* X, const uword n_elem)
{
arma_extra_debug_sigprint();
arma_ascend_sort_helper<eT> comparator;
std::sort(&X[0], &X[n_elem], comparator);
}
template<typename eT>
inline
void
op_sort::copy_row(eT* X, const Mat<eT>& A, const uword row) op_sort::copy_row(eT* X, const Mat<eT>& A, const uword row)
{ {
const uword N = A.n_cols; const uword N = A.n_cols;
uword i,j; uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2) for(i=0, j=1; j<N; i+=2, j+=2)
{ {
X[i] = A.at(row,i); X[i] = A.at(row,i);
X[j] = A.at(row,j); X[j] = A.at(row,j);
 End of changes. 1 change blocks. 
0 lines changed or deleted 12 lines changed or added


 op_strans_meat.hpp   op_strans_meat.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2012 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)
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 operator_div.hpp   operator_div.hpp 
skipping to change at line 135 skipping to change at line 135
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_div>( X, Y ); return mtGlue<out_eT, T1, T2, glue_mixed_div>( X, Y );
} }
//! element-wise division of sparse matrix by scalar
template<typename T1>
inline
typename
enable_if2<is_arma_sparse_type<T1>::value, SpMat<typename T1::elem_type> >:
:result
operator/
(
const SpBase<typename T1::elem_type, T1>& X,
const typename T1::elem_type y
)
{
arma_extra_debug_sigprint();
arma_debug_check(y == typename T1::elem_type(0), "element-wise division:
division by zero");
SpMat<typename T1::elem_type> result(X.get_ref());
for(uword i = 0; i < result.n_nonzero; ++i)
{
access::rw(result.values[i]) /= y;
}
return result;
}
// //! element-wise division of two sparse objects. what a bad idea
// template<typename T1, typename T2>
// inline
// typename
// enable_if2
// <
// (is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value &&
// is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
// SpMat<typename T1::elem_type>
// >::result
// operator/
// (
// const SpBase<typename T1::elem_type, T1>& x,
// const SpBase<typename T2::elem_type, T2>& y
// )
// {
// arma_extra_debug_sigprint();
//
// const SpProxy<T1> pa(x.get_ref());
// const SpProxy<T2> pb(y.get_ref());
//
// arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n
_rows(), pb.get_n_cols(), "element-wise division");
//
// SpMat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols())
;
//
// // terrible
// for(uword i = 0; i < result.n_elem; ++i)
// {
// result[i] = (pa[i] / pb[i]);
// }
//
// return result;
// }
//! element-wise division of one sparse and one dense object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_type<T2>::value &&
is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
SpMat<typename T1::elem_type>
>::result
operator/
(
const SpBase<typename T1::elem_type, T1>& x,
const Base<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const SpProxy<T1> pa(x.get_ref());
const Proxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_ro
ws(), pb.get_n_cols(), "element-wise division");
SpMat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols());
// The compiler should be smart enough to optimize out the inner if/else
statement entirely
typename SpProxy<T1>::const_iterator_type it = pa.begin();
uword new_n_nonzero;
while(it.pos() < pa.get_n_nonzero())
{
if(Proxy<T2>::prefer_at_accessor == false)
{
const typename T1::elem_type val = (*it) / pb[(it.col() * pb.get_n_ro
ws()) + it.row()];
if(val != 0)
{
++new_n_nonzero;
}
}
else
{
const typename T1::elem_type val = (*it) / pb.at(it.row(), it.col());
if(val != 0)
{
++new_n_nonzero;
}
}
++it;
}
result.mem_resize(new_n_nonzero);
typename SpProxy<T1>::const_iterator_type it2 = pa.begin();
uword cur_pos = 0;
while(it2.pos() < pa.get_n_nonzero())
{
if(Proxy<T2>::prefer_at_accessor == false)
{
const typename T1::elem_type val = (*it2) / pb[(it2.col() * pb.get_n_
rows()) + it2.row()];
if(val != 0)
{
access::rw(result.values[cur_pos]) = val;
access::rw(result.row_indices[cur_pos]) = it2.row();
++access::rw(result.col_ptrs[it2.col() + 1]);
++cur_pos;
}
}
else
{
const typename T1::elem_type val = (*it2) / pb.at(it2.row(), it2.col(
));
if(val != 0)
{
access::rw(result.values[cur_pos]) = val;
access::rw(result.row_indices[cur_pos]) = it2.row();
++access::rw(result.col_ptrs[it2.col() + 1]);
++cur_pos;
}
}
++it2;
}
// Fix column pointers
for(uword col = 1; col <= result.n_cols; ++col)
{
access::rw(result.col_ptrs[col]) += result.col_ptrs[col - 1];
}
return result;
}
//! element-wise division of one dense and one sparse object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_type<T1>::value && is_arma_sparse_type<T2>::value &&
is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator/
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_ro
ws(), pb.get_n_cols(), "element-wise division");
Mat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols());
result.fill(Datum<typename T1::elem_type>::inf);
// Now divide each element
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
if(Proxy<T1>::prefer_at_accessor == false)
{
const uword index = (it.col() * result.n_rows) + it.row();
result[index] = pa[index] / (*it);
}
else
{
result.at(it.row(), it.col()) = pa.at(it.row(), it.col()) / (*it);
}
++it;
}
return result;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 208 lines changed or added


 operator_minus.hpp   operator_minus.hpp 
skipping to change at line 160 skipping to change at line 160
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_minus>( X, Y ); return mtGlue<out_eT, T1, T2, glue_mixed_minus>( X, Y );
} }
//! subtraction of two sparse objects
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value && is_s
ame_type<typename T1::elem_type, typename T2::elem_type>::value),
const SpGlue<T1,T2,spglue_minus>
>::result
operator-
(
const T1& X,
const T2& Y
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_minus>(X,Y);
}
//! subtraction of one sparse and one dense object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator-
(
const SpBase<typename T1::elem_type, T1>& x,
const Base<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
Mat<typename T1::elem_type> result(-y.get_ref());
const SpProxy<T1> pa(x.get_ref());
typename SpProxy<T1>::const_iterator_type it = pa.begin();
while(it.pos() != pa.get_n_nonzero())
{
const uword pos = it.col() * pa.get_n_cols() + it.row();
result[pos] += (*it);
++it;
}
return result;
}
//! subtraction of one dense and one sparse object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_type<T1>::value && is_arma_sparse_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator-
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
Mat<typename T1::elem_type> result(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
const uword pos = it.col() * pb.get_n_cols() + it.row();
result[pos] -= (*it);
++it;
}
return result;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 87 lines changed or added


 operator_ostream.hpp   operator_ostream.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 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 30 skipping to change at line 30
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
arma_ostream::print(o, tmp.M, true); arma_ostream::print(o, tmp.M, true);
return o; return o;
} }
template<typename eT, typename T1>
inline
std::ostream&
operator<< (std::ostream& o, const SpBase<eT,T1>& X)
{
arma_extra_debug_sigprint();
const unwrap_spmat<T1> tmp(X.get_ref());
arma_ostream::print(o, tmp.M, true);
return o;
}
template<typename T1> template<typename T1>
inline inline
std::ostream& std::ostream&
operator<< (std::ostream& o, const BaseCube<typename T1::elem_type,T1>& X) operator<< (std::ostream& o, const BaseCube<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
arma_ostream::print(o, tmp.M, true); arma_ostream::print(o, tmp.M, true);
 End of changes. 2 change blocks. 
2 lines changed or deleted 16 lines changed or added


 operator_plus.hpp   operator_plus.hpp 
skipping to change at line 139 skipping to change at line 139
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_plus>( X, Y ); return mtGlue<out_eT, T1, T2, glue_mixed_plus>( X, Y );
} }
//! addition of two sparse objects
template<typename T1, typename T2>
inline
arma_hot
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value && is_s
ame_type<typename T1::elem_type, typename T2::elem_type>::value),
SpGlue<T1,T2,spglue_plus>
>::result
operator+
(
const T1& x,
const T2& y
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_plus>(x, y);
}
//! addition of sparse and non-sparse object
template<typename T1, typename T2>
arma_inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator+
(
const SpBase<typename T1::elem_type, T1>& x,
const Base<typename T2::elem_type, T2>& y
)
{
// Just call the other order (these operations are commutative)
return (y + x);
}
//! addition of sparse and non-sparse object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_type<T1>::value && is_arma_sparse_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator+
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
Mat<typename T1::elem_type> result(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
const uword pos = it.col() * pb.get_n_cols() + it.row();
result[pos] += (*it);
++it;
}
return result;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 75 lines changed or added


 operator_schur.hpp   operator_schur.hpp 
skipping to change at line 65 skipping to change at line 65
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_schur>( X, Y ); return mtGlue<out_eT, T1, T2, glue_mixed_schur>( X, Y );
} }
//! element-wise multiplication of two sparse matrices
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value && is_s
ame_type<typename T1::elem_type, typename T2::elem_type>::value),
SpMat<typename T1::elem_type>
>::result
operator%
(
const SpBase<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const SpProxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_ro
ws(), pb.get_n_cols(), "element-wise multiplication");
SpMat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols());
// Resize memory to correct size.
result.mem_resize(n_unique(x, y, op_n_unique_mul()));
// Now iterate across both matrices.
typename SpProxy<T1>::const_iterator_type x_it = pa.begin();
typename SpProxy<T2>::const_iterator_type y_it = pb.begin();
uword cur_val = 0;
while((x_it.pos() < pa.get_n_nonzero()) || (y_it.pos() < pb.get_n_nonzero
()))
{
if(x_it == y_it)
{
const typename T1::elem_type val = (*x_it) * (*y_it);
if (val != 0)
{
access::rw(result.values[cur_val]) = val;
access::rw(result.row_indices[cur_val]) = x_it.row();
++access::rw(result.col_ptrs[x_it.col() + 1]);
++cur_val;
}
++x_it;
++y_it;
}
else
{
if((x_it.col() < y_it.col()) || ((x_it.col() == y_it.col()) && (x_it.
row() < y_it.row()))) // if y is closer to the end
{
++x_it;
}
else
{
++y_it;
}
}
}
// Fix column pointers to be cumulative.
for(uword c = 1; c <= result.n_cols; ++c)
{
access::rw(result.col_ptrs[c]) += result.col_ptrs[c - 1];
}
return result;
}
//! element-wise multiplication of one sparse and one dense object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
SpMat<typename T1::elem_type>
>::result
operator%
(
const SpBase<typename T1::elem_type, T1>& x,
const Base<typename T2::elem_type, T2>& y
)
{
// This operation is commutative.
return (y % x);
}
//! element-wise multiplication of one dense and one sparse object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_type<T1>::value && is_arma_sparse_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
SpMat<typename T1::elem_type>
>::result
operator%
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_ro
ws(), pb.get_n_cols(), "element-wise multiplication");
SpMat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols());
if(Proxy<T1>::prefer_at_accessor == false)
{
// use direct operator[] access
// count new size
uword new_n_nonzero = 0;
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
if(((*it) * pa[(it.col() * pa.get_n_rows()) + it.row()]) != 0)
{
++new_n_nonzero;
}
++it;
}
// Resize memory accordingly.
result.mem_resize(new_n_nonzero);
uword cur_val = 0;
typename SpProxy<T2>::const_iterator_type it2 = pb.begin();
while(it2.pos() < pb.get_n_nonzero())
{
const typename T1::elem_type val = (*it2) * pa[(it2.col() * pa.get_n_
rows()) + it2.row()];
if(val != 0)
{
access::rw(result.values[cur_val]) = val;
access::rw(result.row_indices[cur_val]) = it2.row();
++access::rw(result.col_ptrs[it2.col() + 1]);
++cur_val;
}
++it2;
}
}
else
{
// use at() access
// count new size
uword new_n_nonzero = 0;
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
if(((*it) * pa.at(it.row(), it.col())) != 0)
{
++new_n_nonzero;
}
++it;
}
// Resize memory accordingly.
result.mem_resize(new_n_nonzero);
uword cur_val = 0;
typename SpProxy<T2>::const_iterator_type it2 = pb.begin();
while(it2.pos() < pb.get_n_nonzero())
{
const typename T1::elem_type val = (*it2) * pa.at(it2.row(), it2.col(
));
if(val != 0)
{
access::rw(result.values[cur_val]) = val;
access::rw(result.row_indices[cur_val]) = it2.row();
++access::rw(result.col_ptrs[it2.col() + 1]);
++cur_val;
}
++it2;
}
}
// Fix column pointers.
for(uword c = 1; c <= result.n_cols; ++c)
{
access::rw(result.col_ptrs[c]) += result.col_ptrs[c - 1];
}
return result;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 202 lines changed or added


 operator_times.hpp   operator_times.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2012 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)
skipping to change at line 217 skipping to change at line 218
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_times>( X, Y ); return mtGlue<out_eT, T1, T2, glue_mixed_times>( X, Y );
} }
//! sparse multiplied by scalar
template<typename T1>
inline
typename
enable_if2
<
is_arma_sparse_type<T1>::value,
SpOp<T1,spop_scalar_times>
>::result
operator*
(
const T1& X,
const typename T1::elem_type k
)
{
arma_extra_debug_sigprint();
return SpOp<T1,spop_scalar_times>(X, k);
}
template<typename T1>
inline
typename
enable_if2
<
is_arma_sparse_type<T1>::value,
SpOp<T1,spop_scalar_times>
>::result
operator*
(
const typename T1::elem_type k,
const T1& X
)
{
arma_extra_debug_sigprint();
return SpOp<T1,spop_scalar_times>(X, k);
}
//! multiplication of two sparse objects
template<typename T1, typename T2>
inline
arma_hot
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value && is_s
ame_type<typename T1::elem_type, typename T2::elem_type>::value),
const SpGlue<T1,T2,spglue_times>
>::result
operator*
(
const T1& x,
const T2& y
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_times>(x, y);
}
//! convert "(sparse + sparse) * scalar" to specialised operation "scalar *
(sparse + sparse)"
template<typename T1, typename T2>
inline
const SpGlue<T1,T2,spglue_plus2>
operator*
(
const SpGlue<T1,T2,spglue_plus>& X,
const typename T1::elem_type k
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_plus2>(X.A, X.B, k);
}
//! convert "scalar * (sparse + sparse)" to specialised operation
template<typename T1, typename T2>
inline
const SpGlue<T1,T2,spglue_plus2>
operator*
(
const typename T1::elem_type k,
const SpGlue<T1,T2,spglue_plus>& X
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_plus2>(X.A, X.B, k);
}
//! convert "(sparse - sparse) * scalar" to specialised operation "scalar *
(sparse - sparse)"
template<typename T1, typename T2>
inline
const SpGlue<T1,T2,spglue_minus2>
operator*
(
const SpGlue<T1,T2,spglue_minus>& X,
const typename T1::elem_type k
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_minus2>(X.A, X.B, k);
}
//! convert "scalar * (sparse - sparse)" to specialised operation
template<typename T1, typename T2>
inline
const SpGlue<T1,T2,spglue_minus2>
operator*
(
const typename T1::elem_type k,
const SpGlue<T1,T2,spglue_minus>& X
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_minus2>(X.A, X.B, k);
}
//! convert "(sparse*sparse) * scalar" to specialised operation "scalar * (
sparse*sparse)"
template<typename T1, typename T2>
inline
const SpGlue<T1,T2,spglue_times2>
operator*
(
const SpGlue<T1,T2,spglue_times>& X,
const typename T1::elem_type k
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_times2>(X.A, X.B, k);
}
//! convert "scalar * (sparse*sparse)" to specialised operation
template<typename T1, typename T2>
inline
const SpGlue<T1,T2,spglue_times2>
operator*
(
const typename T1::elem_type k,
const SpGlue<T1,T2,spglue_times>& X
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_times2>(X.A, X.B, k);
}
//! convert "(scalar*sparse) * sparse" to specialised operation "scalar * (
sparse*sparse)"
template<typename T1, typename T2>
inline
typename
enable_if2
<
is_arma_sparse_type<T2>::value,
const SpGlue<T1,T2,spglue_times2>
>::result
operator*
(
const SpOp<T1,spop_scalar_times>& X,
const T2& Y
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_times2>(X.m, Y, X.aux);
}
//! convert "sparse * (scalar*sparse)" to specialised operation "scalar * (
sparse*sparse)"
template<typename T1, typename T2>
inline
typename
enable_if2
<
is_arma_sparse_type<T1>::value,
const SpGlue<T1,T2,spglue_times2>
>::result
operator*
(
const T1& X,
const SpOp<T2,spop_scalar_times>& Y
)
{
arma_extra_debug_sigprint();
return SpGlue<T1,T2,spglue_times2>(X, Y.m, Y.aux);
}
//! multiplication of one sparse and one dense object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_sparse_type<T1>::value && is_arma_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator*
(
const T1& x,
const T2& y
)
{
arma_extra_debug_sigprint();
const SpProxy<T1> pa(x.get_ref());
const Proxy<T2> pb(y.get_ref());
arma_debug_assert_mul_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_row
s(), pb.get_n_cols(), "matrix multiplication");
Mat<typename T1::elem_type> result(pa.get_n_rows(), pb.get_n_cols());
result.zeros();
if(Proxy<T2>::prefer_at_accessor == false)
{
// use direct operator[] access
for(typename SpProxy<T1>::const_iterator_type x_it = pa.begin(); x_it.p
os() < pa.get_n_nonzero(); x_it++)
{
// We just want to use values where y.row = x_it.col.
for(uword col = 0; col < result.n_cols; col++)
{
const uword index = x_it.col() + (pb.get_n_rows() * col);
result(x_it.row(), col) += (*x_it) * pb[index];
}
}
}
else
{
// use at() access
for(typename SpProxy<T1>::const_iterator_type x_it = pa.begin(); x_it.p
os() < pa.get_n_nonzero(); x_it++)
{
for(uword col = 0; col < result.n_cols; col++)
{
result(x_it.row(), col) += (*x_it) * pb.at(x_it.col(), col);
}
}
}
return result;
}
//! multiplication of one dense and one sparse object
template<typename T1, typename T2>
inline
typename
enable_if2
<
(is_arma_type<T1>::value && is_arma_sparse_type<T2>::value && is_same_typ
e<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator*
(
const T1& x,
const T2& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_mul_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_row
s(), pb.get_n_cols(), "matrix multiplication");
Mat<typename T1::elem_type> result(pa.get_n_rows(), pb.get_n_cols());
result.zeros();
if(Proxy<T1>::prefer_at_accessor == false)
{
// use direct operator[] access
for(typename SpProxy<T2>::const_iterator_type y_col_it = pb.begin(); y_
col_it.pos() < pb.get_n_nonzero(); ++y_col_it)
{
for(uword row = 0; row < result.n_rows; ++row)
{
const uword index = row + (y_col_it.row() * result.n_rows);
result(row, y_col_it.col()) += pa[index] * (*y_col_it);
}
}
}
else
{
// use at() access
for(typename SpProxy<T2>::const_iterator_type y_col_it = pb.begin(); y_
col_it.pos() < pb.get_n_nonzero(); ++y_col_it)
{
for(uword row = 0; row < result.n_rows; ++row)
{
result(row, y_col_it.col()) += pa.at(row, y_col_it.row()) * (*y_col
_it);
}
}
}
return result;
}
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 311 lines changed or added


 podarray_bones.hpp   podarray_bones.hpp 
skipping to change at line 55 skipping to change at line 55
template<typename T1> template<typename T1>
inline explicit podarray(const Proxy<T1>& P); inline explicit podarray(const Proxy<T1>& P);
arma_inline eT& operator[] (const uword i); arma_inline eT& operator[] (const uword i);
arma_inline eT operator[] (const uword i) const; arma_inline eT operator[] (const uword i) const;
arma_inline eT& operator() (const uword i); arma_inline eT& operator() (const uword i);
arma_inline eT operator() (const uword i) const; arma_inline eT operator() (const uword i) const;
inline void set_min_size(const uword min_n_elem);
inline void set_size(const uword new_n_elem); inline void set_size(const uword new_n_elem);
inline void reset(); inline void reset();
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const uword new_n_elem); inline void zeros(const uword new_n_elem);
arma_inline eT* memptr(); arma_inline eT* memptr();
arma_inline const eT* memptr() const; arma_inline const eT* memptr() const;
arma_hot inline void copy_row(const Mat<eT>& A, const uword row); arma_hot inline void copy_row(const Mat<eT>& A, const uword row);
protected: protected:
inline void init_cold(const uword new_n_elem); inline void init_cold(const uword new_n_elem);
inline void init_warm(const uword new_n_elem); inline void init_warm(const uword new_n_elem);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
1 lines changed or deleted 2 lines changed or added


 podarray_meat.hpp   podarray_meat.hpp 
skipping to change at line 191 skipping to change at line 191
podarray<eT>::operator() (const uword i) podarray<eT>::operator() (const uword i)
{ {
arma_debug_check( (i >= n_elem), "podarray::operator(): index out of boun ds"); arma_debug_check( (i >= n_elem), "podarray::operator(): index out of boun ds");
return access::rw(mem[i]); return access::rw(mem[i]);
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::set_min_size(const uword min_n_elem)
{
arma_extra_debug_sigprint();
if(min_n_elem > n_elem)
{
init_warm(min_n_elem);
}
}
template<typename eT>
inline
void
podarray<eT>::set_size(const uword new_n_elem) podarray<eT>::set_size(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init_warm(new_n_elem); init_warm(new_n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
skipping to change at line 288 skipping to change at line 301
out[j] = tmp_j; out[j] = tmp_j;
} }
if(i < cols) if(i < cols)
{ {
out[i] = A.at(row, i); out[i] = A.at(row, i);
} }
} }
break; break;
case 8: case 8: out[7] = A.at(row, 7);
out[7] = A.at(row, 7); case 7: out[6] = A.at(row, 6);
case 6: out[5] = A.at(row, 5);
case 7: case 5: out[4] = A.at(row, 4);
out[6] = A.at(row, 6); case 4: out[3] = A.at(row, 3);
case 3: out[2] = A.at(row, 2);
case 6: case 2: out[1] = A.at(row, 1);
out[5] = A.at(row, 5); case 1: out[0] = A.at(row, 0);
case 0: ;
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> template<typename eT>
arma_hot arma_hot
inline inline
void void
podarray<eT>::init_cold(const uword new_n_elem) podarray<eT>::init_cold(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 2 change blocks. 
23 lines changed or deleted 22 lines changed or added


 restrictors.hpp   restrictors.hpp 
skipping to change at line 160 skipping to change at line 160
template<typename T> struct arma_Mat_Col_Row_only { }; template<typename T> struct arma_Mat_Col_Row_only { };
template<typename eT> struct arma_Mat_Col_Row_only< Mat<eT> > { typedef Mat <eT> result; }; template<typename eT> struct arma_Mat_Col_Row_only< Mat<eT> > { typedef Mat <eT> result; };
template<typename eT> struct arma_Mat_Col_Row_only< Col<eT> > { typedef Col <eT> result; }; template<typename eT> struct arma_Mat_Col_Row_only< Col<eT> > { typedef Col <eT> result; };
template<typename eT> struct arma_Mat_Col_Row_only< Row<eT> > { typedef Row <eT> result; }; template<typename eT> struct arma_Mat_Col_Row_only< Row<eT> > { typedef Row <eT> result; };
template<typename T> struct arma_Cube_only { }; template<typename T> struct arma_Cube_only { };
template<typename eT> struct arma_Cube_only< Cube<eT> > { typedef Cube<eT> result; }; template<typename eT> struct arma_Cube_only< Cube<eT> > { typedef Cube<eT> result; };
template<typename T> struct arma_SpMat_SpCol_SpRow_only { };
template<typename eT> struct arma_SpMat_SpCol_SpRow_only< SpMat<eT> > { typ
edef SpMat<eT> result; };
template<typename eT> struct arma_SpMat_SpCol_SpRow_only< SpCol<eT> > { typ
edef SpCol<eT> result; };
template<typename eT> struct arma_SpMat_SpCol_SpRow_only< SpRow<eT> > { typ
edef SpRow<eT> result; };
template<bool> struct enable_if { }; template<bool> struct enable_if { };
template<> struct enable_if<true> { typedef int result; }; template<> struct enable_if<true> { typedef int result; };
template<bool, typename result_type > struct enable_if2 { }; template<bool, typename result_type > struct enable_if2 { };
template< typename result_type > struct enable_if2<true, result_type> { typedef result_type result; }; template< typename result_type > struct enable_if2<true, result_type> { typedef result_type result; };
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 9 lines changed or added


 subview_bones.hpp   subview_bones.hpp 
skipping to change at line 126 skipping to change at line 126
inline subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2); inline subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
inline const subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const; inline const subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
inline subview<eT> submat (const span& row_span, const span & col_span); inline subview<eT> submat (const span& row_span, const span & col_span);
inline const subview<eT> submat (const span& row_span, const span & col_span) const; inline const subview<eT> submat (const span& row_span, const span & col_span) const;
inline subview<eT> operator()(const span& row_span, const span & col_span); inline subview<eT> operator()(const span& row_span, const span & col_span);
inline const subview<eT> operator()(const span& row_span, const span & col_span) const; inline const subview<eT> operator()(const span& row_span, const span & col_span) const;
inline subview_each1< subview<eT>, 0 > each_col();
inline subview_each1< subview<eT>, 1 > each_row();
template<typename T1> inline subview_each2< subview<eT>, 0, T1 > each_col
(const Base<uword, T1>& indices);
template<typename T1> inline subview_each2< subview<eT>, 1, T1 > each_row
(const Base<uword, T1>& indices);
inline diagview<eT> diag(const sword in_id = 0); inline diagview<eT> diag(const sword in_id = 0);
inline const diagview<eT> diag(const sword in_id = 0) const; inline const diagview<eT> diag(const sword in_id = 0) const;
inline void swap_rows(const uword in_row1, const uword in_row2); inline void swap_rows(const uword in_row1, const uword in_row2);
inline void swap_cols(const uword in_col1, const uword in_col2); inline void swap_cols(const uword in_col1, const uword in_col2);
// // primitive forward iterator // // primitive forward iterator
// class iter // class iter
// { // {
// public: // public:
 End of changes. 1 change blocks. 
0 lines changed or deleted 8 lines changed or added


 subview_elem2_bones.hpp   subview_elem2_bones.hpp 
skipping to change at line 37 skipping to change at line 37
arma_aligned const Mat<eT>& m; arma_aligned const Mat<eT>& m;
arma_aligned const Base<uword,T1>& base_ri; arma_aligned const Base<uword,T1>& base_ri;
arma_aligned const Base<uword,T2>& base_ci; arma_aligned const Base<uword,T2>& base_ci;
const bool all_rows; const bool all_rows;
const bool all_cols; const bool all_cols;
protected: protected:
arma_inline subview_elem2(const Mat<eT>& in_m, const Base<uword,T1>& in_r i, const Base<uword,T2>& in_ci, const bool in_all_rows, const bool in_all_c ols); arma_inline subview_elem2(const Mat<eT>& in_m, const Base<uword,T1>& in_r i, const Base<uword,T1>& in_ci, const bool in_all_rows, const bool in_all_c ols);
public: public:
inline ~subview_elem2(); inline ~subview_elem2();
template<typename op_type> template<typename op_type>
inline void inplace_op(const eT val); inline void inplace_op(const eT val);
template<typename op_type, typename expr> template<typename op_type, typename expr>
inline void inplace_op(const Base<eT,expr>& x); inline void inplace_op(const Base<eT,expr>& x);
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 subview_elem2_meat.hpp   subview_elem2_meat.hpp 
skipping to change at line 29 skipping to change at line 29
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1, typename T2> template<typename eT, typename T1, typename T2>
arma_inline arma_inline
subview_elem2<eT,T1,T2>::subview_elem2 subview_elem2<eT,T1,T2>::subview_elem2
( (
const Mat<eT>& in_m, const Mat<eT>& in_m,
const Base<uword,T1>& in_ri, const Base<uword,T1>& in_ri,
const Base<uword,T2>& in_ci, const Base<uword,T1>& in_ci,
const bool in_all_rows, const bool in_all_rows,
const bool in_all_cols const bool in_all_cols
) )
: m (in_m ) : m (in_m )
, base_ri (in_ri ) , base_ri (in_ri )
, base_ci (in_ci ) , base_ci (in_ci )
, all_rows (in_all_rows) , all_rows (in_all_rows)
, all_cols (in_all_cols) , all_cols (in_all_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 1944 skipping to change at line 1944
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::operator()(const span& row_span, const span& col_span) const subview<eT>::operator()(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).submat(row_span, col_span); return (*this).submat(row_span, col_span);
} }
template<typename eT>
inline
subview_each1< subview<eT>, 0 >
subview<eT>::each_col()
{
arma_extra_debug_sigprint();
return subview_each1< subview<eT>, 0 >(*this);
}
template<typename eT>
inline
subview_each1< subview<eT>, 1 >
subview<eT>::each_row()
{
arma_extra_debug_sigprint();
return subview_each1< subview<eT>, 1 >(*this);
}
template<typename eT>
template<typename T1>
inline
subview_each2< subview<eT>, 0, T1 >
subview<eT>::each_col(const Base<uword,T1>& indices)
{
arma_extra_debug_sigprint();
return subview_each2< subview<eT>, 0, T1 >(*this, indices);
}
template<typename eT>
template<typename T1>
inline
subview_each2< subview<eT>, 1, T1 >
subview<eT>::each_row(const Base<uword,T1>& indices)
{
arma_extra_debug_sigprint();
return subview_each2< subview<eT>, 1, T1 >(*this, indices);
}
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
inline inline
diagview<eT> diagview<eT>
subview<eT>::diag(const sword in_id) subview<eT>::diag(const sword in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword row_offset = (in_id < 0) ? uword(-in_id) : 0; const uword row_offset = (in_id < 0) ? uword(-in_id) : 0;
const uword col_offset = (in_id > 0) ? uword( in_id) : 0; const uword col_offset = (in_id > 0) ? uword( in_id) : 0;
 End of changes. 1 change blocks. 
0 lines changed or deleted 42 lines changed or added


 traits.hpp   traits.hpp 
skipping to change at line 555 skipping to change at line 555
|| is_eGlueCube<T1>::value || is_eGlueCube<T1>::value
|| is_mtGlueCube<T1>::value || is_mtGlueCube<T1>::value
|| is_subview_cube<T1>::value || is_subview_cube<T1>::value
; ;
}; };
// //
// //
// //
template<typename T>
struct is_SpMat
{ static const bool value = false; };
template<typename eT>
struct is_SpMat< SpMat<eT> >
{ static const bool value = true; };
template<typename eT>
struct is_SpMat< SpCol<eT> >
{ static const bool value = true; };
template<typename eT>
struct is_SpMat< SpRow<eT> >
{ static const bool value = true; };
template<typename T>
struct is_SpRow
{ static const bool value = false; };
template<typename eT>
struct is_SpRow< SpRow<eT> >
{ static const bool value = true; };
template<typename T>
struct is_SpCol
{ static const bool value = false; };
template<typename eT>
struct is_SpCol< SpCol<eT> >
{ static const bool value = true; };
template<typename T>
struct is_SpSubview
{ static const bool value = false; };
template<typename eT>
struct is_SpSubview< SpSubview<eT> >
{ static const bool value = true; };
template<typename T>
struct is_SpOp
{ static const bool value = false; };
template<typename T1, typename op_type>
struct is_SpOp< SpOp<T1,op_type> >
{ static const bool value = true; };
template<typename T>
struct is_SpGlue
{ static const bool value = false; };
template<typename T1, typename T2, typename glue_type>
struct is_SpOp< SpGlue<T1,T2,glue_type> >
{ static const bool value = true; };
template<typename T1>
struct is_arma_sparse_type
{
static const bool value
= is_SpMat<T1>::value
|| is_SpSubview<T1>::value
|| is_SpOp<T1>::value
|| is_SpGlue<T1>::value
;
};
//
//
//
template<typename T1, typename T2> template<typename T1, typename T2>
struct is_same_type struct is_same_type
{ static const bool value = false; }; { static const bool value = false; };
template<typename T1> template<typename T1>
struct is_same_type<T1,T1> struct is_same_type<T1,T1>
{ static const bool value = true; }; { static const bool value = true; };
// //
// //
skipping to change at line 808 skipping to change at line 879
template<typename T1> template<typename T1>
struct resolves_to_vector_redirect<T1, false> { typedef resolves_to_vector_ default<T1> result; }; struct resolves_to_vector_redirect<T1, false> { typedef resolves_to_vector_ default<T1> result; };
template<typename T1> template<typename T1>
struct resolves_to_vector_redirect<T1, true> { typedef resolves_to_vector_ test<T1> result; }; struct resolves_to_vector_redirect<T1, true> { typedef resolves_to_vector_ test<T1> result; };
template<typename T1> template<typename T1>
struct resolves_to_vector : public resolves_to_vector_redirect<T1, is_arma_ type<T1>::value>::result {}; struct resolves_to_vector : public resolves_to_vector_redirect<T1, is_arma_ type<T1>::value>::result {};
template<typename T1>
struct resolves_to_sparse_vector : public resolves_to_vector_redirect<T1, i
s_arma_sparse_type<T1>::value>::result {};
template<typename glue_type> struct is_glue_mixed_times { static const bool value = false; }; template<typename glue_type> struct is_glue_mixed_times { static const bool value = false; };
template<> struct is_glue_mixed_times<glue_mixed_times> { static const bool value = true; }; template<> struct is_glue_mixed_times<glue_mixed_times> { static const bool value = true; };
template<typename glue_type> struct is_glue_mixed_elem { static const bool value = false; }; template<typename glue_type> struct is_glue_mixed_elem { static const bool value = false; };
template<> struct is_glue_mixed_elem<glue_mixed_plus> { static const bool value = true; }; template<> struct is_glue_mixed_elem<glue_mixed_plus> { static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_mixed_minus> { static const bool value = true; }; template<> struct is_glue_mixed_elem<glue_mixed_minus> { static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_mixed_div> { static const bool value = true; }; template<> struct is_glue_mixed_elem<glue_mixed_div> { static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_mixed_schur> { static const bool value = true; }; template<> struct is_glue_mixed_elem<glue_mixed_schur> { static const bool value = true; };
 End of changes. 2 change blocks. 
0 lines changed or deleted 75 lines changed or added


 typedef.hpp   typedef.hpp 
skipping to change at line 152 skipping to change at line 152
typedef Col <cx_float> cx_fcolvec; typedef Col <cx_float> cx_fcolvec;
typedef Row <cx_float> cx_frowvec; typedef Row <cx_float> cx_frowvec;
typedef Cube<cx_float> cx_fcube; typedef Cube<cx_float> cx_fcube;
typedef Mat <cx_double> cx_mat; typedef Mat <cx_double> cx_mat;
typedef Col <cx_double> cx_vec; typedef Col <cx_double> cx_vec;
typedef Col <cx_double> cx_colvec; typedef Col <cx_double> cx_colvec;
typedef Row <cx_double> cx_rowvec; typedef Row <cx_double> cx_rowvec;
typedef Cube<cx_double> cx_cube; typedef Cube<cx_double> cx_cube;
typedef SpMat <uword> sp_umat;
typedef SpCol <uword> sp_uvec;
typedef SpCol <uword> sp_ucolvec;
typedef SpRow <uword> sp_urowvec;
typedef SpMat <sword> sp_imat;
typedef SpCol <sword> sp_ivec;
typedef SpCol <sword> sp_icolvec;
typedef SpRow <sword> sp_irowvec;
typedef SpMat <float> sp_fmat;
typedef SpCol <float> sp_fvec;
typedef SpCol <float> sp_fcolvec;
typedef SpRow <float> sp_frowvec;
typedef SpMat <double> sp_mat;
typedef SpCol <double> sp_vec;
typedef SpCol <double> sp_colvec;
typedef SpRow <double> sp_rowvec;
typedef SpMat <cx_float> sp_cx_fmat;
typedef SpCol <cx_float> sp_cx_fvec;
typedef SpCol <cx_float> sp_cx_fcolvec;
typedef SpRow <cx_float> sp_cx_frowvec;
typedef SpMat <cx_double> sp_cx_mat;
typedef SpCol <cx_double> sp_cx_vec;
typedef SpCol <cx_double> sp_cx_colvec;
typedef SpRow <cx_double> sp_cx_rowvec;
typedef void* void_ptr; typedef void* void_ptr;
namespace junk namespace junk
{ {
struct arma_elem_size_test struct arma_elem_size_test
{ {
arma_static_check( (sizeof(u8) != 1), ERROR___TYPE_U8_HAS_UNSUPPORTED_S IZE ); arma_static_check( (sizeof(u8) != 1), ERROR___TYPE_U8_HAS_UNSUPPORTED_S IZE );
arma_static_check( (sizeof(s8) != 1), ERROR___TYPE_S8_HAS_UNSUPPORTED_S IZE ); arma_static_check( (sizeof(s8) != 1), ERROR___TYPE_S8_HAS_UNSUPPORTED_S IZE );
 End of changes. 1 change blocks. 
0 lines changed or deleted 30 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/