Col_bones.hpp   Col_bones.hpp 
skipping to change at line 80 skipping to change at line 80
arma_inline subview_col<eT> rows(const uword in_row1, const uword i n_row2); arma_inline subview_col<eT> rows(const uword in_row1, const uword i n_row2);
arma_inline const subview_col<eT> rows(const uword in_row1, const uword i n_row2) const; arma_inline const subview_col<eT> rows(const uword in_row1, const uword i n_row2) const;
arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2); arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2);
arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const; arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const;
arma_inline subview_col<eT> subvec(const span& row_span); arma_inline subview_col<eT> subvec(const span& row_span);
arma_inline const subview_col<eT> subvec(const span& row_span) const; arma_inline const subview_col<eT> subvec(const span& row_span) const;
//arma_inline subview_col<eT> operator()(const span& row_span); using Mat<eT>::operator();
//arma_inline const subview_col<eT> operator()(const span& row_span) cons
t; arma_inline subview_col<eT> operator()(const span& row_span);
arma_inline const subview_col<eT> operator()(const span& row_span) const;
inline void shed_row (const uword row_num); inline void shed_row (const uword row_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);
inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true); inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true);
template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X); template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X);
arma_inline arma_warn_unused eT& at(const uword i); arma_inline arma_warn_unused eT& at(const uword i);
arma_inline arma_warn_unused eT at(const uword i) const; arma_inline arma_warn_unused eT at(const uword i) const;
skipping to change at line 149 skipping to change at line 151
inline fixed(const char* text); inline fixed(const char* text);
inline fixed(const std::string& text); inline fixed(const std::string& text);
template<typename T1> inline const Col& operator=(const Base<eT,T1>& A) ; template<typename T1> inline const Col& operator=(const Base<eT,T1>& A) ;
inline const Col& operator=(const eT val); inline const Col& operator=(const eT val);
inline const Col& operator=(const char* text); inline const Col& operator=(const char* text);
inline const Col& operator=(const std::string& text); inline const Col& operator=(const std::string& text);
inline const Col& operator=(const subview_cube<eT>& X); inline const Col& operator=(const subview_cube<eT>& X);
inline subview_row<eT> operator()(const uword row_num, const s using Col<eT>::operator();
pan& col_span);
inline const subview_row<eT> operator()(const uword row_num, const s
pan& col_span) const;
inline subview_col<eT> operator()(const span& row_span, const uwo
rd col_num );
inline const subview_col<eT> operator()(const span& row_span, const uwo
rd col_num ) const;
inline subview<eT> operator()(const span& row_span, const spa #if defined(ARMA_USE_CXX11)
n& col_span); inline fixed(const std::initializer_list<eT>& list);
inline const subview<eT> operator()(const span& row_span, const spa inline const Col& operator=(const std::initializer_list<eT>& list);
n& col_span) const; #endif
arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const uword i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const uword i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const uword i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const uword i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const uword i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col);
arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const; arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const;
 End of changes. 3 change blocks. 
16 lines changed or deleted 9 lines changed or added


 Col_meat.hpp   Col_meat.hpp 
skipping to change at line 431 skipping to change at line 431
const uword in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
const uword in_row2 = row_span.b; const uword in_row2 = row_span.b;
const uword subvec_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1; const uword subvec_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
arma_debug_check( ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ), "Col::subvec(): indices out of bounds or incorrectly use d"); arma_debug_check( ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ), "Col::subvec(): indices out of bounds or incorrectly use d");
return subview_col<eT>(*this, 0, in_row1, subvec_n_rows); return subview_col<eT>(*this, 0, in_row1, subvec_n_rows);
} }
// template<typename eT> template<typename eT>
// arma_inline arma_inline
// subview_col<eT> subview_col<eT>
// Col<eT>::operator()(const span& row_span) Col<eT>::operator()(const span& row_span)
// { {
// arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//
// return subvec(row_span); return subvec(row_span);
// } }
//
// template<typename eT>
// arma_inline
// template<typename eT> const subview_col<eT>
// arma_inline Col<eT>::operator()(const span& row_span) const
// const subview_col<eT> {
// Col<eT>::operator()(const span& row_span) const arma_extra_debug_sigprint();
// {
// arma_extra_debug_sigprint(); return subvec(row_span);
// }
// return subvec(row_span);
// }
//! remove specified row //! remove specified row
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::shed_row(const uword row_num) Col<eT>::shed_row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= Mat<eT>::n_rows, "Col::shed_row(): out of bo unds"); arma_debug_check( row_num >= Mat<eT>::n_rows, "Col::shed_row(): out of bo unds");
skipping to change at line 842 skipping to change at line 840
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X) Col<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<eT>::operator=(X); Col<eT>::operator=(X);
return *this; return *this;
} }
template<typename eT> #if defined(ARMA_USE_CXX11)
template<uword fixed_n_elem>
inline
subview_row<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c
ol_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_row<eT> Col<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list)
Col<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c
ol_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); mem_setup();
}
template<typename eT>
template<uword fixed_n_elem>
inline
subview_col<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword
col_num)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); (*this).operator=(list);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_col<eT> const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword Col<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>& li
col_num) const st)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); const uword N = list.size();
}
template<typename eT> arma_debug_check( (N > fixed_n_elem), "Col::fixed: initialiser list is to
template<uword fixed_n_elem> o long" );
inline
subview<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); eT* this_mem = (*this).memptr();
}
template<typename eT> arrayops::copy( this_mem, list.begin(), N );
template<uword fixed_n_elem>
inline
const subview<eT>
Col<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
return *this;
} }
#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 i) Col<eT>::fixed<fixed_n_elem>::operator[] (const uword ii)
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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 i) const Col<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) const
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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>::at(const uword i) Col<eT>::fixed<fixed_n_elem>::at(const uword ii)
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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>::at(const uword i) const Col<eT>::fixed<fixed_n_elem>::at(const uword ii) const
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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 i) Col<eT>::fixed<fixed_n_elem>::operator() (const uword ii)
{ {
arma_debug_check( (i >= fixed_n_elem), "Col::operator(): out of bounds"); arma_debug_check( (ii >= fixed_n_elem), "Col::operator(): out of bounds") ;
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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 i) const Col<eT>::fixed<fixed_n_elem>::operator() (const uword ii) const
{ {
arma_debug_check( (i >= fixed_n_elem), "Col::operator(): out of bounds"); arma_debug_check( (ii >= fixed_n_elem), "Col::operator(): out of bounds") ;
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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>::at(const uword in_row, const uword) Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword)
{ {
return (use_extra) ? mem_local_extra[in_row] : Mat<eT>::mem_local[in_row] ; return (use_extra) ? mem_local_extra[in_row] : Mat<eT>::mem_local[in_row] ;
 End of changes. 26 change blocks. 
85 lines changed or deleted 50 lines changed or added


 Cube_bones.hpp   Cube_bones.hpp 
skipping to change at line 294 skipping to change at line 294
inline const Cube& operator=(const eT val) { mem_setup(); Cube<eT>::ope rator=(val); return *this; } inline const Cube& operator=(const eT val) { mem_setup(); Cube<eT>::ope rator=(val); return *this; }
template<typename T1> template<typename T1>
inline fixed(const BaseCube<eT,T1>& A) { mem_setup(); Cube<eT>::operato r=(A.get_ref()); } inline fixed(const BaseCube<eT,T1>& A) { mem_setup(); Cube<eT>::operato r=(A.get_ref()); }
template<typename T1> template<typename T1>
inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::oper ator=(A.get_ref()); return *this; } inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::oper ator=(A.get_ref()); return *this; }
template<typename T1, typename T2> template<typename T1, typename T2>
inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<po d_type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); } inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<po d_type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); }
// using Cube<eT>::operator();
// TODO: overload operator(), operator[] and .at() to allow faster elem
ent access
}; };
protected: protected:
inline void init_cold(); inline void init_cold();
inline void init_warm(const uword in_rows, const uword in_cols, const uwo rd in_slices); inline void init_warm(const uword in_rows, const uword in_cols, const uwo rd in_slices);
template<typename T1, typename T2> template<typename T1, typename T2>
inline void init(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type, T2>& B); inline void init(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type, T2>& B);
 End of changes. 1 change blocks. 
0 lines changed or deleted 4 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 267 skipping to change at line 267
arma_assert_same_size(X, Y, "Cube()"); arma_assert_same_size(X, Y, "Cube()");
init_warm(X.get_n_rows(), X.get_n_cols(), X.get_n_slices()); init_warm(X.get_n_rows(), X.get_n_cols(), X.get_n_slices());
const uword N = n_elem; const uword N = n_elem;
eT* out_mem = memptr(); eT* out_mem = memptr();
ea_type1 PX = X.get_ea(); ea_type1 PX = X.get_ea();
ea_type2 PY = Y.get_ea(); ea_type2 PY = Y.get_ea();
// TODO: add handling for prefer_at_accessor = true
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out_mem[i] = std::complex<T>(PX[i], PY[i]); out_mem[i] = std::complex<T>(PX[i], PY[i]);
} }
} }
//! try to steal the memory from a given cube; //! try to steal the memory from a given cube;
//! if memory can't be stolen, copy the given cube //! if memory can't be stolen, copy the given cube
template<typename eT> template<typename eT>
inline inline
skipping to change at line 334 skipping to change at line 336
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::delete_mat() Cube<eT>::delete_mat()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(uword slice = 0; slice < n_slices; ++slice) for(uword uslice = 0; uslice < n_slices; ++uslice)
{ {
delete access::rw(mat_ptrs[slice]); delete access::rw(mat_ptrs[uslice]);
} }
if(mem_state <= 2) if(mem_state <= 2)
{ {
if(n_slices > Cube_prealloc::mat_ptrs_size) if(n_slices > Cube_prealloc::mat_ptrs_size)
{ {
delete [] mat_ptrs; delete [] mat_ptrs;
} }
} }
} }
skipping to change at line 369 skipping to change at line 371
access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local); access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local);
} }
else else
{ {
access::rw(mat_ptrs) = new(std::nothrow) const Mat<eT>*[n_slices]; access::rw(mat_ptrs) = new(std::nothrow) const Mat<eT>*[n_slices];
arma_check_bad_alloc( (mat_ptrs == 0), "Cube::create_mat(): out of me mory" ); arma_check_bad_alloc( (mat_ptrs == 0), "Cube::create_mat(): out of me mory" );
} }
} }
for(uword slice = 0; slice < n_slices; ++slice) for(uword uslice = 0; uslice < n_slices; ++uslice)
{ {
mat_ptrs[slice] = new Mat<eT>('j', slice_memptr(slice), n_rows, n_cols) ; mat_ptrs[uslice] = new Mat<eT>('j', slice_memptr(uslice), n_rows, n_col s);
} }
} }
//! Set the cube to be equal to the specified scalar. //! Set the cube to be equal to the specified scalar.
//! NOTE: the size of the cube will be 1x1x1 //! NOTE: the size of the cube will be 1x1x1
template<typename eT> template<typename eT>
arma_inline arma_inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::operator=(const eT val) Cube<eT>::operator=(const eT val)
{ {
skipping to change at line 2050 skipping to change at line 2052
Cube<eT>::memptr() const Cube<eT>::memptr() const
{ {
return mem; return mem;
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Cube<eT>::slice_memptr(const uword slice) Cube<eT>::slice_memptr(const uword uslice)
{ {
return const_cast<eT*>( &mem[ slice*n_elem_slice ] ); return const_cast<eT*>( &mem[ uslice*n_elem_slice ] );
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const eT* const eT*
Cube<eT>::slice_memptr(const uword slice) const Cube<eT>::slice_memptr(const uword uslice) const
{ {
return &mem[ slice*n_elem_slice ]; return &mem[ uslice*n_elem_slice ];
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Cube<eT>::slice_colptr(const uword slice, const uword col) Cube<eT>::slice_colptr(const uword uslice, const uword col)
{ {
return const_cast<eT*>( &mem[ slice*n_elem_slice + col*n_rows] ); return const_cast<eT*>( &mem[ uslice*n_elem_slice + col*n_rows] );
} }
//! returns a pointer to array of eTs used by the specified slice in the cu be //! returns a pointer to array of eTs used by the specified slice in the cu be
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const eT* const eT*
Cube<eT>::slice_colptr(const uword slice, const uword col) const Cube<eT>::slice_colptr(const uword uslice, const uword col) const
{ {
return &mem[ slice*n_elem_slice + col*n_rows ]; return &mem[ uslice*n_elem_slice + col*n_rows ];
} }
//! print contents of the cube (to the cout stream), //! print contents of the cube (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the precision and cell width are modified. //! the precision and cell width are modified.
//! on return, the stream's state are restored to their original values. //! on return, the stream's state are restored to their original values.
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::impl_print(const std::string& extra_text) const Cube<eT>::impl_print(const std::string& extra_text) const
skipping to change at line 3010 skipping to change at line 3012
( (
out.n_rows, out.n_cols, out.n_slices, out.n_rows, out.n_cols, out.n_slices,
A.get_n_rows(), A.get_n_cols(), A.get_n_slices(), A.get_n_rows(), A.get_n_cols(), A.get_n_slices(),
"Cube::set_real()" "Cube::set_real()"
); );
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
// TODO: add handling for prefer_at_accessor = true
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
//out_mem[i].real() = PA[i]; //out_mem[i].real() = PA[i];
out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() ); out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() );
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
skipping to change at line 3040 skipping to change at line 3044
( (
out.n_rows, out.n_cols, out.n_slices, out.n_rows, out.n_cols, out.n_slices,
A.get_n_rows(), A.get_n_cols(), A.get_n_slices(), A.get_n_rows(), A.get_n_cols(), A.get_n_slices(),
"Cube::set_imag()" "Cube::set_imag()"
); );
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
ea_type PA = A.get_ea(); ea_type PA = A.get_ea();
// TODO: add handling for prefer_at_accessor = true
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
//out_mem[i].imag() = PA[i]; //out_mem[i].imag() = PA[i];
out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] ); out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] );
} }
} }
#ifdef ARMA_EXTRA_CUBE_MEAT #ifdef ARMA_EXTRA_CUBE_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_MEAT)
#endif #endif
 End of changes. 15 change blocks. 
12 lines changed or deleted 18 lines changed or added


 Gen_bones.hpp   Gen_bones.hpp 
skipping to change at line 22 skipping to change at line 22
//! \addtogroup Gen //! \addtogroup Gen
//! @{ //! @{
//! support class for generator functions (eg. zeros, randu, randn, ...) //! support class for generator functions (eg. zeros, randu, randn, ...)
template<typename T1, typename gen_type> template<typename T1, typename gen_type>
class Gen : public Base<typename T1::elem_type, Gen<T1, gen_type> > class Gen : public Base<typename T1::elem_type, Gen<T1, gen_type> >
{ {
public: public:
typedef typename T1::elem_type eT;
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool prefer_at_accessor = (is_same_type<gen_type, gen_ones_d iag>::value) ? true : false; static const bool prefer_at_accessor = (is_same_type<gen_type, gen_ones_d iag>::value) ? true : false;
static const bool is_row = T1::is_row; static const bool is_row = T1::is_row;
static const bool is_col = T1::is_col; static const bool is_col = T1::is_col;
arma_aligned const uword n_rows; arma_aligned const uword n_rows;
arma_aligned const uword n_cols; arma_aligned const uword n_cols;
arma_inline Gen(const uword in_n_rows, const uword in_n_cols); arma_inline Gen(const uword in_n_rows, const uword in_n_cols);
arma_inline ~Gen(); arma_inline ~Gen();
arma_inline static eT generate(); arma_inline static elem_type generate();
arma_inline eT operator[] (const uword i) const; arma_inline elem_type operator[] (const uword ii) const
arma_inline eT at (const uword row, const uword col) const; ;
arma_inline elem_type at (const uword row, const uword col) const
;
inline void apply (Mat<eT>& out) const; inline void apply (Mat<elem_type>& out) const;
inline void apply_inplace_plus (Mat<eT>& out) const; inline void apply_inplace_plus (Mat<elem_type>& out) const;
inline void apply_inplace_minus(Mat<eT>& out) const; inline void apply_inplace_minus(Mat<elem_type>& out) const;
inline void apply_inplace_schur(Mat<eT>& out) const; inline void apply_inplace_schur(Mat<elem_type>& out) const;
inline void apply_inplace_div (Mat<eT>& out) const; inline void apply_inplace_div (Mat<elem_type>& out) const;
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
9 lines changed or deleted 10 lines changed or added


 Gen_meat.hpp   Gen_meat.hpp 
skipping to change at line 49 skipping to change at line 49
if(is_same_type<gen_type, gen_ones_full>::value == true) { return eT (1); } if(is_same_type<gen_type, gen_ones_full>::value == true) { return eT (1); }
else if(is_same_type<gen_type, gen_zeros >::value == true) { return eT (0); } else if(is_same_type<gen_type, gen_zeros >::value == true) { return eT (0); }
else if(is_same_type<gen_type, gen_randu >::value == true) { return eT (eop_aux_randu<eT>()); } else if(is_same_type<gen_type, gen_randu >::value == true) { return eT (eop_aux_randu<eT>()); }
else if(is_same_type<gen_type, gen_randn >::value == true) { return eT (eop_aux_randn<eT>()); } else if(is_same_type<gen_type, gen_randn >::value == true) { return eT (eop_aux_randn<eT>()); }
else { return eT (); } else { return eT (); }
} }
template<typename T1, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
Gen<T1, gen_type>::operator[](const uword i) const Gen<T1, gen_type>::operator[](const uword ii) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
return ((i % n_rows) == (i / n_rows)) ? eT(1) : eT(0); return ((ii % n_rows) == (ii / n_rows)) ? eT(1) : eT(0);
} }
else else
{ {
return Gen<T1, gen_type>::generate(); return Gen<T1, gen_type>::generate();
} }
} }
template<typename T1, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
skipping to change at line 112 skipping to change at line 112
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword iq=0; iq < N; ++iq)
{ {
out.at(i,i) += eT(1); out.at(iq,iq) += eT(1);
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword iq,jq;
for(iq=0, jq=1; jq < n_elem; iq+=2, jq+=2)
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<T1, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<T1, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] += tmp_i; out_mem[iq] += tmp_i;
out_mem[j] += tmp_j; out_mem[jq] += tmp_j;
} }
if(i < n_elem) if(iq < n_elem)
{ {
out_mem[i] += Gen<T1, gen_type>::generate(); out_mem[iq] += Gen<T1, gen_type>::generate();
} }
} }
} }
template<typename T1, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<T1, gen_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out) co nst Gen<T1, gen_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out) co nst
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword iq=0; iq < N; ++iq)
{ {
out.at(i,i) -= eT(1); out.at(iq,iq) -= eT(1);
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword iq,jq;
for(iq=0, jq=1; jq < n_elem; iq+=2, jq+=2)
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<T1, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<T1, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] -= tmp_i; out_mem[iq] -= tmp_i;
out_mem[j] -= tmp_j; out_mem[jq] -= tmp_j;
} }
if(i < n_elem) if(iq < n_elem)
{ {
out_mem[i] -= Gen<T1, gen_type>::generate(); out_mem[iq] -= Gen<T1, gen_type>::generate();
} }
} }
} }
template<typename T1, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<T1, gen_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out) co nst Gen<T1, gen_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out) co nst
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword iq=0; iq < N; ++iq)
{ {
for(uword row=0; row<i; ++row) { out.at(row,i) = eT(0); } for(uword row=0; row < iq; ++row) { out.at(row,iq) = eT(0); }
for(uword row=i+1; row<n_rows; ++row) { out.at(row,i) = eT(0); } for(uword row=iq+1; row < n_rows; ++row) { out.at(row,iq) = eT(0); }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword iq,jq;
for(iq=0, jq=1; jq < n_elem; iq+=2, jq+=2)
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<T1, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<T1, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] *= tmp_i; out_mem[iq] *= tmp_i;
out_mem[j] *= tmp_j; out_mem[jq] *= tmp_j;
} }
if(i < n_elem) if(iq < n_elem)
{ {
out_mem[i] *= Gen<T1, gen_type>::generate(); out_mem[iq] *= Gen<T1, gen_type>::generate();
} }
} }
} }
template<typename T1, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<T1, gen_type>::apply_inplace_div(Mat<typename T1::elem_type>& out) cons t Gen<T1, gen_type>::apply_inplace_div(Mat<typename T1::elem_type>& out) cons t
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword iq=0; iq < N; ++iq)
{ {
const eT zero = eT(0); const eT zero = eT(0);
for(uword row=0; row<i; ++row) { out.at(row,i) /= zero; } for(uword row=0; row < iq; ++row) { out.at(row,iq) /= zero; }
for(uword row=i+1; row<n_rows; ++row) { out.at(row,i) /= zero; } for(uword row=iq+1; row < n_rows; ++row) { out.at(row,iq) /= zero; }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword iq,jq;
for(iq=0, jq=1; jq < n_elem; iq+=2, jq+=2)
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<T1, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<T1, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] /= tmp_i; out_mem[iq] /= tmp_i;
out_mem[j] /= tmp_j; out_mem[jq] /= tmp_j;
} }
if(i < n_elem) if(iq < n_elem)
{ {
out_mem[i] /= Gen<T1, gen_type>::generate(); out_mem[iq] /= Gen<T1, gen_type>::generate();
} }
} }
} }
//! @} //! @}
 End of changes. 26 change blocks. 
40 lines changed or deleted 36 lines changed or added


 Mat_bones.hpp   Mat_bones.hpp 
skipping to change at line 261 skipping to change at line 261
template<typename T1, typename T2, typename eglue_type> inline const Mat& operator/=(const eGlue<T1, T2, eglue_type>& X); template<typename T1, typename T2, typename eglue_type> inline const Mat& operator/=(const eGlue<T1, T2, eglue_type>& X);
template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X);
template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X); template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X);
arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT& operator[] (const uword ii);
arma_inline arma_warn_unused eT operator[] (const uword i) const; arma_inline arma_warn_unused eT operator[] (const uword ii) const;
arma_inline arma_warn_unused eT& at (const uword i); arma_inline arma_warn_unused eT& at (const uword ii);
arma_inline arma_warn_unused eT at (const uword i) const; arma_inline arma_warn_unused eT at (const uword ii) const;
arma_inline arma_warn_unused eT& operator() (const uword i); arma_inline arma_warn_unused eT& operator() (const uword ii);
arma_inline arma_warn_unused eT operator() (const uword i) const; arma_inline arma_warn_unused eT operator() (const uword ii) const;
arma_inline arma_warn_unused eT& at (const uword in_row, const uw ord in_col); arma_inline arma_warn_unused eT& at (const uword in_row, const uw ord in_col);
arma_inline arma_warn_unused eT at (const uword in_row, const uw ord in_col) const; arma_inline arma_warn_unused eT at (const uword in_row, const uw ord in_col) const;
arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw ord in_col); arma_inline arma_warn_unused eT& operator() (const uword in_row, const uw ord in_col);
arma_inline arma_warn_unused eT operator() (const uword in_row, const uw ord in_col) const; arma_inline arma_warn_unused eT operator() (const uword in_row, const uw ord in_col) const;
arma_inline const Mat& operator++(); arma_inline const Mat& operator++();
arma_inline void operator++(int); arma_inline void operator++(int);
arma_inline const Mat& operator--(); arma_inline const Mat& operator--();
arma_inline void operator--(int); arma_inline void operator--(int);
arma_inline arma_warn_unused bool is_empty() const; arma_inline arma_warn_unused bool is_empty() const;
arma_inline arma_warn_unused bool is_vec() const; arma_inline arma_warn_unused bool is_vec() const;
arma_inline arma_warn_unused bool is_rowvec() const; arma_inline arma_warn_unused bool is_rowvec() const;
arma_inline arma_warn_unused bool is_colvec() const; arma_inline arma_warn_unused bool is_colvec() const;
arma_inline arma_warn_unused bool is_square() const; arma_inline arma_warn_unused bool is_square() const;
inline arma_warn_unused bool is_finite() const; inline arma_warn_unused bool is_finite() const;
arma_inline arma_warn_unused bool in_range(const uword i) const; arma_inline arma_warn_unused bool in_range(const uword ii) const;
arma_inline arma_warn_unused bool in_range(const span& x) const; arma_inline arma_warn_unused bool in_range(const span& x ) const;
arma_inline arma_warn_unused bool in_range(const uword in_row, const uw ord in_col) const; arma_inline arma_warn_unused bool in_range(const uword in_row, const uw ord in_col) const;
arma_inline arma_warn_unused bool in_range(const span& row_span, const uw ord in_col) const; arma_inline arma_warn_unused bool in_range(const span& row_span, const uw ord in_col) const;
arma_inline arma_warn_unused bool in_range(const uword in_row, const sp an& col_span) const; arma_inline arma_warn_unused bool in_range(const uword in_row, const sp an& col_span) const;
arma_inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span) const; arma_inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span) const;
arma_inline arma_warn_unused eT* colptr(const uword in_col); arma_inline arma_warn_unused eT* colptr(const uword in_col);
arma_inline arma_warn_unused const eT* colptr(const uword in_col) const; arma_inline arma_warn_unused const eT* colptr(const uword in_col) const;
arma_inline arma_warn_unused eT* memptr(); arma_inline arma_warn_unused eT* memptr();
arma_inline arma_warn_unused const eT* memptr() const; arma_inline arma_warn_unused const eT* memptr() const;
inline void impl_print(const std::string& extra_text) const; inline void impl_print(const std::string& extra_text) const;
inline void impl_print(std::ostream& user_stream, const std::string& extr a_text) const; inline void impl_print(std::ostream& user_stream, const std::string& extr a_text) const;
inline void impl_print_trans(const std::string& extra_text) const;
inline void impl_print_trans(std::ostream& user_stream, const std::string
& extra_text) const;
inline void impl_raw_print(const std::string& extra_text) const; inline void impl_raw_print(const std::string& extra_text) const;
inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const; inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const;
inline void impl_raw_print_trans(const std::string& extra_text) const;
inline void impl_raw_print_trans(std::ostream& user_stream, const std::st
ring& extra_text) const;
template<typename eT2, typename expr> template<typename eT2, typename expr>
inline void copy_size(const Base<eT2,expr>& X); inline void copy_size(const Base<eT2,expr>& X);
inline void set_size(const uword in_elem); inline void set_size(const uword in_elem);
inline void set_size(const uword in_rows, const uword in_cols); inline void set_size(const uword in_rows, const uword in_cols);
inline void resize(const uword in_elem); inline void resize(const uword in_elem);
inline void resize(const uword in_rows, const uword in_cols); inline void resize(const uword in_rows, const uword in_cols);
inline void reshape(const uword in_rows, const uword in_cols, const uwor d dim = 0); inline void reshape(const uword in_rows, const uword in_cols, const uwor d dim = 0);
skipping to change at line 484 skipping to change at line 478
arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X); arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X);
template<typename T1> inline fixed(const Base<eT,T1>& A); template<typename T1> inline fixed(const Base<eT,T1>& A);
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B); template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B);
inline fixed(const eT* aux_mem); inline fixed(const eT* aux_mem);
inline fixed(const char* text); inline fixed(const char* text);
inline fixed(const std::string& text); inline fixed(const std::string& text);
// TODO: handling of initializer_list ? using Mat<eT>::operator=;
using Mat<eT>::operator();
template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A)
;
inline const Mat& operator=(const eT val);
inline const Mat& operator=(const char* text);
inline const Mat& operator=(const std::string& text);
inline subview_row<eT> operator()(const uword row_num, const spa
n& col_span);
inline const subview_row<eT> operator()(const uword row_num, const spa
n& col_span) const;
inline subview_col<eT> operator()(const span& row_span, const uwo
rd col_num);
inline const subview_col<eT> operator()(const span& row_span, const uwo
rd col_num) const;
inline subview<eT> operator()(const span& row_span, const spa #if defined(ARMA_USE_CXX11)
n& col_span); inline fixed(const std::initializer_list<eT>& list);
inline const subview<eT> operator()(const span& row_span, const spa inline const Mat& operator=(const std::initializer_list<eT>& list);
n& col_span) const; #endif
arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const uword i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const uword i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const uword i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const uword i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const uword i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col);
arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const; arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const;
 End of changes. 6 change blocks. 
38 lines changed or deleted 14 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 367 skipping to change at line 367
line_start = line_end+1; line_start = line_end+1;
} }
Mat<eT>& x = *this; Mat<eT>& x = *this;
x.set_size(t_n_rows, t_n_cols); x.set_size(t_n_rows, t_n_cols);
line_start = 0; line_start = 0;
line_end = 0; line_end = 0;
uword row = 0; uword urow = 0;
while( line_start < text.length() ) while( line_start < text.length() )
{ {
line_end = text.find(';', line_start); line_end = text.find(';', line_start);
if(line_end == std::string::npos) if(line_end == std::string::npos)
line_end = text.length()-1; line_end = text.length()-1;
std::string::size_type line_len = line_end - line_start + 1; std::string::size_type line_len = line_end - line_start + 1;
std::stringstream line_stream( text.substr(line_start,line_len) ); std::stringstream line_stream( text.substr(line_start,line_len) );
// uword col = 0; // uword ucol = 0;
// while(line_stream >> token) // while(line_stream >> token)
// { // {
// x.at(row,col) = strtod(token.c_str(), 0); // x.at(urow,ucol) = strtod(token.c_str(), 0);
// ++col; // ++ucol;
// } // }
uword col = 0; uword ucol = 0;
eT val; eT val;
while(line_stream >> val) while(line_stream >> val)
{ {
x.at(row,col) = val; x.at(urow,ucol) = val;
++col; ++ucol;
} }
++row; ++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)
skipping to change at line 596 skipping to change at line 596
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
typedef typename Proxy<T1>::ea_type ea_type1; typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; typedef typename Proxy<T2>::ea_type ea_type2;
const uword N = n_elem; const uword N = n_elem;
ea_type1 A = PX.get_ea(); ea_type1 A = PX.get_ea();
ea_type2 B = PY.get_ea(); ea_type2 B = PY.get_ea();
for(uword i=0; i<N; ++i) for(uword ii=0; ii < N; ++ii)
{ {
out_mem[i] = std::complex<T>(A[i], B[i]); out_mem[ii] = std::complex<T>(A[ii], B[ii]);
} }
} }
else else
{ {
uword i = 0; uword ii = 0;
for(uword col=0; col < local_n_cols; ++col) for(uword ucol=0; ucol < local_n_cols; ++ucol)
for(uword row=0; row < local_n_rows; ++row, ++i) for(uword urow=0; urow < local_n_rows; ++urow, ++ii)
{ {
out_mem[i] = std::complex<T>(PX.at(row,col), PY.at(row,col)); out_mem[ii] = std::complex<T>(PX.at(urow,ucol), PY.at(urow,ucol));
} }
} }
} }
//! try to steal the memory from a given matrix; //! try to steal the memory from a given matrix;
//! if memory can't be stolen, copy the given matrix //! if memory can't be stolen, copy the given matrix
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::steal_mem(Mat<eT>& x) Mat<eT>::steal_mem(Mat<eT>& x)
skipping to change at line 849 skipping to change at line 849
const uword in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const uword in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const uword in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const uword out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
for(uword col=0; col < in_n_cols; ++col) for(uword ucol=0; ucol < in_n_cols; ++ucol)
{ {
arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ) ; arrayops::copy( out.colptr(ucol), in.slice_colptr(0, ucol), in_n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if(in_n_cols == 1) if(in_n_cols == 1)
{ {
out.set_size(in_n_rows, in_n_slices); out.set_size(in_n_rows, in_n_slices);
skipping to change at line 934 skipping to change at line 934
const uword in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const uword in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const uword in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const uword out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const uword out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const uword out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(uword col=0; col < in_n_cols; ++col) for(uword ucol=0; ucol < in_n_cols; ++ucol)
{ {
arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_ n_rows ); arrayops::inplace_plus( out.colptr(ucol), in.slice_colptr(0, ucol), i n_n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(uword i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
skipping to change at line 1013 skipping to change at line 1013
const uword in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const uword in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const uword in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const uword out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const uword out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const uword out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(uword col=0; col < in_n_cols; ++col) for(uword ucol=0; ucol < in_n_cols; ++ucol)
{ {
arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in _n_rows ); arrayops::inplace_minus( out.colptr(ucol), in.slice_colptr(0, ucol), in_n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(uword i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
skipping to change at line 1107 skipping to change at line 1107
const uword in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const uword in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const uword in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const uword out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const uword out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const uword out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(uword col=0; col < in_n_cols; ++col) for(uword ucol=0; ucol < in_n_cols; ++ucol)
{ {
arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n _rows ); arrayops::inplace_mul( out.colptr(ucol), in.slice_colptr(0, ucol), in _n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(uword i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
skipping to change at line 1186 skipping to change at line 1186
const uword in_n_rows = in.n_rows; const uword in_n_rows = in.n_rows;
const uword in_n_cols = in.n_cols; const uword in_n_cols = in.n_cols;
const uword in_n_slices = in.n_slices; const uword in_n_slices = in.n_slices;
const uword out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const uword out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
const uword out_vec_state = out.vec_state; const uword out_vec_state = out.vec_state;
if(in_n_slices == 1) if(in_n_slices == 1)
{ {
for(uword col=0; col < in_n_cols; ++col) for(uword ucol=0; ucol < in_n_cols; ++ucol)
{ {
arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n _rows ); arrayops::inplace_div( out.colptr(ucol), in.slice_colptr(0, ucol), in _n_rows );
} }
} }
else else
{ {
if(out_vec_state == 0) if(out_vec_state == 0)
{ {
if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
{ {
for(uword i=0; i < in_n_slices; ++i) for(uword i=0; i < in_n_slices; ++i)
{ {
skipping to change at line 2361 skipping to change at line 2361
return diagview<eT>(*this, row_offset, col_offset, len); return diagview<eT>(*this, row_offset, col_offset, len);
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::swap_rows(const uword in_row1, const uword in_row2) Mat<eT>::swap_rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
arma_debug_check arma_debug_check
( (
(in_row1 >= n_rows) || (in_row2 >= n_rows), (in_row1 >= local_n_rows) || (in_row2 >= local_n_rows),
"Mat::swap_rows(): out of bounds" "Mat::swap_rows(): out of bounds"
); );
for(uword col=0; col<n_cols; ++col) if(n_elem > 0)
{ {
const uword offset = col*n_rows; for(uword ucol=0; ucol < local_n_cols; ++ucol)
const uword pos1 = in_row1 + offset; {
const uword pos2 = in_row2 + offset; const uword offset = ucol * local_n_rows;
const uword pos1 = in_row1 + offset;
const eT tmp = mem[pos1]; const uword pos2 = in_row2 + offset;
access::rw(mem[pos1]) = mem[pos2];
access::rw(mem[pos2]) = tmp;
}
std::swap( access::rw(mem[pos1]), access::rw(mem[pos2]) );
}
}
} }
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::swap_cols(const uword in_col1, const uword in_col2) Mat<eT>::swap_cols(const uword in_colA, const uword in_colB)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
arma_debug_check arma_debug_check
( (
(in_col1 >= n_cols) || (in_col2 >= n_cols), (in_colA >= local_n_cols) || (in_colB >= local_n_cols),
"Mat::swap_cols(): out of bounds" "Mat::swap_cols(): out of bounds"
); );
if(n_elem > 0) if(n_elem > 0)
{ {
eT* ptr1 = colptr(in_col1); eT* ptrA = colptr(in_colA);
eT* ptr2 = colptr(in_col2); eT* ptrB = colptr(in_colB);
eT tmp_i;
eT tmp_j;
uword iq,jq;
for(iq=0, jq=1; jq < local_n_rows; iq+=2, jq+=2)
{
tmp_i = ptrA[iq];
tmp_j = ptrA[jq];
ptrA[iq] = ptrB[iq];
ptrA[jq] = ptrB[jq];
ptrB[iq] = tmp_i;
ptrB[jq] = tmp_j;
}
for(uword row=0; row<n_rows; ++row) if(iq < local_n_rows)
{ {
const eT tmp = ptr1[row]; std::swap( ptrA[iq], ptrB[iq] );
ptr1[row] = ptr2[row];
ptr2[row] = tmp;
} }
} }
} }
//! remove specified row //! remove specified row
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::shed_row(const uword row_num) Mat<eT>::shed_row(const uword row_num)
{ {
skipping to change at line 2990 skipping to change at line 3010
const bool bad_alias = (eOp<T1, eop_type>::proxy_type::has_subview && X .P.is_alias(*this)); const bool bad_alias = (eOp<T1, eop_type>::proxy_type::has_subview && X .P.is_alias(*this));
if(bad_alias == false) if(bad_alias == false)
{ {
init_warm(X.get_n_rows(), X.get_n_cols()); init_warm(X.get_n_rows(), X.get_n_cols());
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
else else
{ {
arma_extra_debug_print("bad_alias = true");
Mat<eT> tmp(X); Mat<eT> tmp(X);
steal_mem(tmp); steal_mem(tmp);
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
skipping to change at line 3371 skipping to change at line 3393
); );
if(bad_alias == false) if(bad_alias == false)
{ {
init_warm(X.get_n_rows(), X.get_n_cols()); init_warm(X.get_n_rows(), X.get_n_cols());
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
} }
else else
{ {
arma_extra_debug_print("bad_alias = true");
Mat<eT> tmp(X); Mat<eT> tmp(X);
steal_mem(tmp); steal_mem(tmp);
} }
return *this; return *this;
} }
//! in-place matrix addition, with the right-hand-side operands having dela yed operations //! in-place matrix addition, with the right-hand-side operands having dela yed operations
template<typename eT> template<typename eT>
skipping to change at line 3566 skipping to change at line 3590
const Mat<eT> m(X); const Mat<eT> m(X);
return (*this).operator/=(m); return (*this).operator/=(m);
} }
//! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::operator() (const uword i) Mat<eT>::operator() (const uword ii)
{ {
arma_debug_check( (i >= n_elem), "Mat::operator(): out of bounds"); arma_debug_check( (ii >= n_elem), "Mat::operator(): out of bounds");
return access::rw(mem[i]); return access::rw(mem[ii]);
} }
//! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined //! linear element accessor (treats the matrix as a vector); bounds checkin g not done when ARMA_NO_DEBUG is defined
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::operator() (const uword i) const Mat<eT>::operator() (const uword ii) const
{ {
arma_debug_check( (i >= n_elem), "Mat::operator(): out of bounds"); arma_debug_check( (ii >= n_elem), "Mat::operator(): out of bounds");
return mem[i]; return mem[ii];
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k. //! linear element accessor (treats the matrix as a vector); no bounds chec k.
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::operator[] (const uword i) Mat<eT>::operator[] (const uword ii)
{ {
return access::rw(mem[i]); return access::rw(mem[ii]);
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k //! linear element accessor (treats the matrix as a vector); no bounds chec k
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::operator[] (const uword i) const Mat<eT>::operator[] (const uword ii) const
{ {
return mem[i]; return mem[ii];
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k. //! linear element accessor (treats the matrix as a vector); no bounds chec k.
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::at(const uword i) Mat<eT>::at(const uword ii)
{ {
return access::rw(mem[i]); return access::rw(mem[ii]);
} }
//! linear element accessor (treats the matrix as a vector); no bounds chec k //! linear element accessor (treats the matrix as a vector); no bounds chec k
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::at(const uword i) const Mat<eT>::at(const uword ii) const
{ {
return mem[i]; return mem[ii];
} }
//! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d //! element accessor; bounds checking not done when ARMA_NO_DEBUG is define d
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::operator() (const uword in_row, const uword in_col) Mat<eT>::operator() (const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "Mat::opera tor(): out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "Mat::opera tor(): out of bounds");
skipping to change at line 3768 skipping to change at line 3792
Mat<eT>::is_finite() const Mat<eT>::is_finite() const
{ {
return arrayops::is_finite( memptr(), n_elem ); return arrayops::is_finite( memptr(), n_elem );
} }
//! returns true if the given index is currently in range //! returns true if the given index is currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const uword i) const Mat<eT>::in_range(const uword ii) const
{ {
return (i < n_elem); return (ii < n_elem);
} }
//! returns true if the given start and end indices are currently in range //! returns true if the given start and end indices are currently in range
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
bool bool
Mat<eT>::in_range(const span& x) const Mat<eT>::in_range(const span& x) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 3953 skipping to change at line 3977
const std::streamsize orig_width = user_stream.width(); const std::streamsize orig_width = user_stream.width();
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
user_stream.width(orig_width); user_stream.width(orig_width);
} }
arma_ostream::print(user_stream, *this, true); arma_ostream::print(user_stream, *this, true);
} }
//! DEPRECATED FUNCTION
template<typename eT>
inline
void
Mat<eT>::impl_print_trans(const std::string& extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this);
tmp.impl_print(extra_text);
}
//! DEPRECATED FUNCTION
template<typename eT>
inline
void
Mat<eT>::impl_print_trans(std::ostream& user_stream, const std::string& ext
ra_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this);
tmp.impl_print(user_stream, extra_text);
}
//! print contents of the matrix (to the cout stream), //! print contents of the matrix (to the cout stream),
//! optionally preceding with a user specified line of text. //! optionally preceding with a user specified line of text.
//! the stream's state are used as is and are not modified //! the stream's state are used as is and are not modified
//! (i.e. the precision and cell width are not modified). //! (i.e. the precision and cell width are not modified).
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::impl_raw_print(const std::string& extra_text) const Mat<eT>::impl_raw_print(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 4027 skipping to change at line 4023
const std::streamsize orig_width = user_stream.width(); const std::streamsize orig_width = user_stream.width();
user_stream << extra_text << '\n'; user_stream << extra_text << '\n';
user_stream.width(orig_width); user_stream.width(orig_width);
} }
arma_ostream::print(user_stream, *this, false); arma_ostream::print(user_stream, *this, false);
} }
//! DEPRECATED FUNCTION
template<typename eT>
inline
void
Mat<eT>::impl_raw_print_trans(const std::string& extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this);
tmp.impl_raw_print(extra_text);
}
//! DEPRECATED FUNCTION
template<typename eT>
inline
void
Mat<eT>::impl_raw_print_trans(std::ostream& user_stream, const std::string&
extra_text) const
{
arma_extra_debug_sigprint();
Mat<eT> tmp;
op_strans::apply_noalias(tmp, *this);
tmp.impl_raw_print(user_stream, extra_text);
}
//! change the matrix to have user specified dimensions (data is not preser ved) //! change the matrix to have user specified dimensions (data is not preser ved)
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::set_size(const uword in_elem) Mat<eT>::set_size(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(vec_state) switch(vec_state)
{ {
skipping to change at line 4245 skipping to change at line 4213
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; const uword N = n_elem;
eT* ptr = memptr(); eT* ptr = memptr();
uword i,j; uword ii,jj;
for(i=0, j=1; j<N; i+=2, j+=2) for(ii=0, jj=1; jj < N; ii+=2, jj+=2)
{ {
const eT tmp_i = eT(eop_aux_randu<eT>()); const eT tmp_ii = eT(eop_aux_randu<eT>());
const eT tmp_j = eT(eop_aux_randu<eT>()); const eT tmp_jj = eT(eop_aux_randu<eT>());
ptr[i] = tmp_i; ptr[ii] = tmp_ii;
ptr[j] = tmp_j; ptr[jj] = tmp_jj;
} }
if(i < N) if(ii < N)
{ {
ptr[i] = eT(eop_aux_randu<eT>()); 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)
{ {
skipping to change at line 4298 skipping to change at line 4266
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; const uword N = n_elem;
eT* ptr = memptr(); eT* ptr = memptr();
for(uword i=0; i<N; ++i) for(uword ii=0; ii<N; ++ii)
{ {
ptr[i] = eT(eop_aux_randn<eT>()); 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)
{ {
skipping to change at line 4341 skipping to change at line 4309
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::eye() Mat<eT>::eye()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); fill(eT(0));
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword ii=0; ii<N; ++ii)
{ {
at(i,i) = eT(1); at(ii,ii) = eT(1);
} }
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::eye(const uword in_rows, const uword in_cols) Mat<eT>::eye(const uword in_rows, const uword in_cols)
{ {
skipping to change at line 4465 skipping to change at line 4433
template<typename eT> template<typename eT>
inline inline
eT eT
Mat<eT>::min(uword& row_of_min_val, uword& col_of_min_val) const Mat<eT>::min(uword& row_of_min_val, uword& col_of_min_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "min(): object has no elements" ); arma_debug_check( (n_elem == 0), "min(): object has no elements" );
uword i; uword iq;
eT val = op_min::direct_min(memptr(), n_elem, i); eT val = op_min::direct_min(memptr(), n_elem, iq);
row_of_min_val = i % n_rows; row_of_min_val = iq % n_rows;
col_of_min_val = i / n_rows; col_of_min_val = iq / n_rows;
return val; return val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
Mat<eT>::max(uword& row_of_max_val, uword& col_of_max_val) const Mat<eT>::max(uword& row_of_max_val, uword& col_of_max_val) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (n_elem == 0), "max(): object has no elements" ); arma_debug_check( (n_elem == 0), "max(): object has no elements" );
uword i; uword iq;
eT val = op_max::direct_max(memptr(), n_elem, i); eT val = op_max::direct_max(memptr(), n_elem, iq);
row_of_max_val = i % n_rows; row_of_max_val = iq % n_rows;
col_of_max_val = i / n_rows; col_of_max_val = iq / n_rows;
return val; return val;
} }
//! save the matrix to a file //! save the matrix to a file
template<typename eT> template<typename eT>
inline inline
bool bool
Mat<eT>::save(const std::string name, const file_type type, const bool prin t_status) const Mat<eT>::save(const std::string name, const file_type type, const bool prin t_status) const
{ {
skipping to change at line 4530 skipping to change at line 4498
break; break;
case arma_binary: case arma_binary:
save_okay = diskio::save_arma_binary(*this, name); save_okay = diskio::save_arma_binary(*this, name);
break; break;
case pgm_binary: case pgm_binary:
save_okay = diskio::save_pgm_binary(*this, name); save_okay = diskio::save_pgm_binary(*this, name);
break; break;
case hdf5_binary:
save_okay = diskio::save_hdf5_binary(*this, name);
break;
default: default:
arma_warn(print_status, "Mat::save(): unsupported file type"); arma_warn(print_status, "Mat::save(): unsupported file type");
save_okay = false; save_okay = false;
} }
arma_warn( (print_status && (save_okay == false)), "Mat::save(): couldn't write to ", name); arma_warn( (print_status && (save_okay == false)), "Mat::save(): couldn't write to ", name);
return save_okay; return save_okay;
} }
skipping to change at line 4627 skipping to change at line 4599
break; break;
case arma_binary: case arma_binary:
load_okay = diskio::load_arma_binary(*this, name, err_msg); load_okay = diskio::load_arma_binary(*this, name, err_msg);
break; break;
case pgm_binary: case pgm_binary:
load_okay = diskio::load_pgm_binary(*this, name, err_msg); load_okay = diskio::load_pgm_binary(*this, name, err_msg);
break; break;
case hdf5_binary:
load_okay = diskio::load_hdf5_binary(*this, name, err_msg);
break;
default: default:
arma_warn(print_status, "Mat::load(): unsupported file type"); arma_warn(print_status, "Mat::load(): unsupported file type");
load_okay = false; load_okay = false;
} }
if( (print_status == true) && (load_okay == false) ) if( (print_status == true) && (load_okay == false) )
{ {
if(err_msg.length() > 0) if(err_msg.length() > 0)
{ {
arma_warn(true, "Mat::load(): ", err_msg, name); arma_warn(true, "Mat::load(): ", err_msg, name);
skipping to change at line 5211 skipping to change at line 5187
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::string& text) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::string& text)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Mat<eT>::operator=(text); Mat<eT>::operator=(text);
} }
template<typename eT> #if defined(ARMA_USE_CXX11)
template<uword fixed_n_rows, uword fixed_n_cols>
template<typename T1>
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const Base<eT,T1>& A)
{
Mat<eT>::operator=(A.get_ref());
return *this;
}
template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols>
inline
const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const eT val)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(val);
return *this;
}
template<typename eT> template<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>& Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const std::initializer_li
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const char* text) st<eT>& list)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint_this(this);
Mat<eT>::operator=(text); mem_setup();
return *this; (*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::string& te Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const std::initialize
xt) r_list<eT>& list)
{
arma_extra_debug_sigprint();
Mat<eT>::operator=(text);
return *this;
}
template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols>
inline
subview_row<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const uword row_num,
const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span); const uword N = list.size();
}
template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols>
inline
const subview_row<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const uword row_num,
const span& col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT> arma_debug_check( (N > fixed_n_elem), "Mat::fixed: initialiser list is to
template<uword fixed_n_rows, uword fixed_n_cols> o long" );
inline
subview_col<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const uword col_num)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); eT* this_mem = (*this).memptr();
}
template<typename eT> arrayops::copy( this_mem, list.begin(), N );
template<uword fixed_n_rows, uword fixed_n_cols>
inline
const subview_col<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const uword col_num) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
}
template<typename eT> return *this;
template<uword fixed_n_rows, uword fixed_n_cols>
inline
subview<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const span& col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> #endif
template<uword fixed_n_rows, uword fixed_n_cols>
inline
const subview<eT>
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator()(const span& row_span
, const span& col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span);
}
template<typename eT> template<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 i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword ii)
{ {
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[ii] : mem_local[ii];
} }
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 i) cons t Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword ii) con st
{ {
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[ii] : mem_local[ii];
} }
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>::at(const uword i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword ii)
{ {
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[ii] : mem_local[ii];
} }
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>::at(const uword i) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword ii) const
{ {
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[ii] : mem_local[ii];
} }
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 i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword ii)
{ {
arma_debug_check( (i >= fixed_n_elem), "Mat::operator(): out of bounds"); arma_debug_check( (ii >= fixed_n_elem), "Mat::operator(): out of bounds") ;
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[ii] : mem_local[ii];
} }
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 i) cons t Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword ii) con st
{ {
arma_debug_check( (i >= fixed_n_elem), "Mat::operator(): out of bounds"); arma_debug_check( (ii >= fixed_n_elem), "Mat::operator(): out of bounds") ;
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[ii] : mem_local[ii];
} }
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>::at(const uword in_row, const uw ord in_col) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col)
{ {
const uword i = in_row + in_col*fixed_n_rows; const uword iq = in_row + in_col*fixed_n_rows;
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[iq] : mem_local[iq];
} }
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>::at(const uword in_row, const uw ord in_col) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col) const
{ {
const uword i = in_row + in_col*fixed_n_rows; const uword iq = in_row + in_col*fixed_n_rows;
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[iq] : mem_local[iq];
} }
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 in_row, const uword in_col) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::operator(): out of bounds"); arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::operator(): out of bounds");
const uword i = in_row + in_col*fixed_n_rows; const uword iq = in_row + in_col*fixed_n_rows;
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[iq] : mem_local[iq];
} }
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 in_row, const uword in_col) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::operator(): out of bounds"); arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::operator(): out of bounds");
const uword i = in_row + in_col*fixed_n_rows; const uword iq = in_row + in_col*fixed_n_rows;
return (use_extra) ? mem_local_extra[i] : mem_local[i]; return (use_extra) ? mem_local_extra[iq] : mem_local[iq];
} }
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>::memptr() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::memptr()
{ {
return (use_extra) ? mem_local_extra : mem_local; return (use_extra) ? mem_local_extra : mem_local;
 End of changes. 103 change blocks. 
258 lines changed or deleted 148 lines changed or added


 Proxy.hpp   Proxy.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 Proxy //! \addtogroup Proxy
//! @{ //! @{
// ea_type is the "element accessor" type, // ea_type is the "element accessor" type,
// which can provide access to elements via operator[] // which can provide access to elements via operator[]
template<typename T1> template<typename T1>
struct Proxy_Mat_fixed struct Proxy_default
{
inline Proxy_default(const T1&)
{
arma_type_check(( is_arma_type<T1>::value == false ));
}
};
template<typename T1>
struct Proxy_fixed
{ {
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef T1 stored_type; typedef T1 stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = true;
static const bool is_row = T1::is_row; static const bool is_row = T1::is_row;
static const bool is_col = T1::is_col; static const bool is_col = T1::is_col;
arma_aligned const T1& Q; arma_aligned const T1& Q;
inline explicit Proxy_Mat_fixed(const T1& A) inline explicit Proxy_fixed(const T1& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline static uword get_n_rows() { return T1::n_rows; } arma_inline static uword get_n_rows() { return T1::n_rows; }
arma_inline static uword get_n_cols() { return T1::n_cols; } arma_inline static uword get_n_cols() { return T1::n_cols; }
arma_inline static uword get_n_elem() { return T1::n_elem; } arma_inline static uword get_n_elem() { return T1::n_elem; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); }
}; };
template<typename T1>
struct Proxy_extra_empty
{
inline Proxy_extra_empty(const T1&)
{
arma_type_check(( is_arma_type<T1>::value == false ));
}
};
template<typename T1, bool condition> template<typename T1, bool condition>
struct Proxy_extra {}; struct Proxy_redirect {};
template<typename T1> template<typename T1>
struct Proxy_extra<T1, true> { typedef Proxy_Mat_fixed<T1> result; }; struct Proxy_redirect<T1, false> { typedef Proxy_default<T1> result; };
template<typename T1> template<typename T1>
struct Proxy_extra<T1, false> { typedef Proxy_extra_empty<T1> result; }; struct Proxy_redirect<T1, true> { typedef Proxy_fixed<T1> result; };
template<typename T1> template<typename T1>
class Proxy : public Proxy_extra<T1, is_Mat_fixed<T1>::value >::result class Proxy : public Proxy_redirect<T1, is_Mat_fixed<T1>::value >::result
{ {
public: public:
inline Proxy(const T1& A) inline Proxy(const T1& A)
: Proxy_extra<T1, is_Mat_fixed<T1>::value >::result(A) : Proxy_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
{ {
} }
}; };
template<typename eT> template<typename eT>
class Proxy< Mat<eT> > class Proxy< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = false; static const bool is_col = false;
arma_aligned const Mat<eT>& Q; arma_aligned const Mat<eT>& Q;
inline explicit Proxy(const Mat<eT>& A) inline explicit Proxy(const Mat<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 131 skipping to change at line 133
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Col<eT> stored_type; typedef Col<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = true; static const bool is_col = true;
arma_aligned const Col<eT>& Q; arma_aligned const Col<eT>& Q;
inline explicit Proxy(const Col<eT>& A) inline explicit Proxy(const Col<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 168 skipping to change at line 171
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Row<eT> stored_type; typedef Row<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = true; static const bool is_row = true;
static const bool is_col = false; static const bool is_col = false;
arma_aligned const Row<eT>& Q; arma_aligned const Row<eT>& Q;
inline explicit Proxy(const Row<eT>& A) inline explicit Proxy(const Row<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 205 skipping to change at line 209
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Gen<T1, gen_type> stored_type; typedef Gen<T1, gen_type> stored_type;
typedef const Gen<T1, gen_type>& ea_type; typedef const Gen<T1, gen_type>& ea_type;
static const bool prefer_at_accessor = Gen<T1, gen_type>::prefer_at_acces sor; static const bool prefer_at_accessor = Gen<T1, gen_type>::prefer_at_acces sor;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = Gen<T1, gen_type>::is_row; static const bool is_row = Gen<T1, gen_type>::is_row;
static const bool is_col = Gen<T1, gen_type>::is_col; static const bool is_col = Gen<T1, gen_type>::is_col;
arma_aligned const Gen<T1, gen_type>& Q; arma_aligned const Gen<T1, gen_type>& Q;
inline explicit Proxy(const Gen<T1, gen_type>& A) inline explicit Proxy(const Gen<T1, gen_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } arma_inline uword get_n_rows() const { return (is_row ? 1 : Q.n_rows);
arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } }
arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols; } arma_inline uword get_n_cols() const { return (is_col ? 1 : Q.n_cols);
}
arma_inline uword get_n_elem() const { return (is_row ? 1 : Q.n_rows) * (
is_col ? 1 : Q.n_cols); }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
skipping to change at line 242 skipping to change at line 247
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = Op<T1, op_type>::is_row; static const bool is_row = Op<T1, op_type>::is_row;
static const bool is_col = Op<T1, op_type>::is_col; static const bool is_col = Op<T1, op_type>::is_col;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Op<T1, op_type>& A) inline explicit Proxy(const Op<T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 267 skipping to change at line 273
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
template<typename T1>
struct Proxy_xtrans_default
{
typedef typename T1::elem_type eT;
static const bool prefer_at_accessor = false;
static const bool has_subview = false;
static const bool is_fixed = false;
arma_aligned const Mat<eT> Q;
arma_hot
inline Proxy_xtrans_default(const T1& A)
: Q(A)
{
arma_extra_debug_sigprint();
}
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
};
template<typename T1>
struct Proxy_xtrans_vector
{
inline Proxy_xtrans_vector(const T1&) {}
};
template<typename T1>
struct Proxy_xtrans_vector< Op<T1, op_htrans> >
{
typedef typename T1::elem_type eT;
static const bool prefer_at_accessor = false;
static const bool has_subview = quasi_unwrap<T1>::has_subview;
static const bool is_fixed = false;
arma_aligned const quasi_unwrap<T1> U; // avoid copy if T1 is a Row, Col
or subview_col
arma_aligned const Mat<eT> Q;
inline Proxy_xtrans_vector(const Op<T1, op_htrans>& A)
: U(A.m)
, Q(const_cast<eT*>(U.M.memptr()), U.M.n_cols, U.M.n_rows, false, false
)
{
arma_extra_debug_sigprint();
}
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X)
; }
};
template<typename T1>
struct Proxy_xtrans_vector< Op<T1, op_strans> >
{
typedef typename T1::elem_type eT;
static const bool prefer_at_accessor = false;
static const bool has_subview = quasi_unwrap<T1>::has_subview;
static const bool is_fixed = false;
arma_aligned const quasi_unwrap<T1> U; // avoid copy if T1 is a Row, Col
or subview_col
arma_aligned const Mat<eT> Q;
inline Proxy_xtrans_vector(const Op<T1, op_strans>& A)
: U(A.m)
, Q(const_cast<eT*>(U.M.memptr()), U.M.n_cols, U.M.n_rows, false, false
)
{
arma_extra_debug_sigprint();
}
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X)
; }
};
template<typename T1, bool condition>
struct Proxy_xtrans_redirect {};
template<typename T1>
struct Proxy_xtrans_redirect<T1, false> { typedef Proxy_xtrans_default<T1>
result; };
template<typename T1>
struct Proxy_xtrans_redirect<T1, true> { typedef Proxy_xtrans_vector<T1>
result; };
template<typename T1>
class Proxy< Op<T1, op_htrans> >
: public
Proxy_xtrans_redirect
<
Op<T1, op_htrans>,
((is_complex<typename T1::elem_type>::value == false) && ((Op<T1, op_
htrans>::is_row) || (Op<T1, op_htrans>::is_col)) )
>::result
{
public:
typedef
typename
Proxy_xtrans_redirect
<
Op<T1, op_htrans>,
((is_complex<typename T1::elem_type>::value == false) && ((Op<T1, op_ht
rans>::is_row) || (Op<T1, op_htrans>::is_col)) )
>::result
Proxy_xtrans;
typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type;
static const bool prefer_at_accessor = Proxy_xtrans::prefer_at_accessor;
static const bool has_subview = Proxy_xtrans::has_subview;
static const bool is_fixed = Proxy_xtrans::is_fixed;
// NOTE: the Op class takes care of swapping row and col for op_htrans
static const bool is_row = Op<T1, op_htrans>::is_row;
static const bool is_col = Op<T1, op_htrans>::is_col;
using Proxy_xtrans::Q;
inline explicit Proxy(const Op<T1, op_htrans>& A)
: Proxy_xtrans(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const
{ return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return Proxy_xtrans:
:is_alias(X); }
};
template<typename T1>
class Proxy< Op<T1, op_strans> >
: public
Proxy_xtrans_redirect
<
Op<T1, op_strans>,
( (Op<T1, op_strans>::is_row) || (Op<T1, op_strans>::is_col) )
>::result
{
public:
typedef
typename
Proxy_xtrans_redirect
<
Op<T1, op_strans>,
( (Op<T1, op_strans>::is_row) || (Op<T1, op_strans>::is_col) )
>::result
Proxy_xtrans;
typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type;
static const bool prefer_at_accessor = Proxy_xtrans::prefer_at_accessor;
static const bool has_subview = Proxy_xtrans::has_subview;
static const bool is_fixed = Proxy_xtrans::is_fixed;
// NOTE: the Op class takes care of swapping row and col for op_strans
static const bool is_row = Op<T1, op_strans>::is_row;
static const bool is_col = Op<T1, op_strans>::is_col;
using Proxy_xtrans::Q;
inline explicit Proxy(const Op<T1, op_strans>& A)
: Proxy_xtrans(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const
{ return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return Proxy_xtrans:
:is_alias(X); }
};
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class Proxy< Glue<T1, T2, glue_type> > class Proxy< Glue<T1, T2, glue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = Glue<T1, T2, glue_type>::is_row; static const bool is_row = Glue<T1, T2, glue_type>::is_row;
static const bool is_col = Glue<T1, T2, glue_type>::is_col; static const bool is_col = Glue<T1, T2, glue_type>::is_col;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Glue<T1, T2, glue_type>& A) inline explicit Proxy(const Glue<T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 316 skipping to change at line 514
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview<eT> stored_type; typedef subview<eT> stored_type;
typedef const subview<eT>& ea_type; typedef const subview<eT>& ea_type;
static const bool prefer_at_accessor = true; static const bool prefer_at_accessor = true;
static const bool has_subview = true; static const bool has_subview = true;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = false; static const bool is_col = false;
arma_aligned const subview<eT>& Q; arma_aligned const subview<eT>& Q;
inline explicit Proxy(const subview<eT>& A) inline explicit Proxy(const subview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 353 skipping to change at line 552
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview_col<eT> stored_type; typedef subview_col<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = true; static const bool has_subview = true;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = true; static const bool is_col = true;
arma_aligned const subview_col<eT>& Q; arma_aligned const subview_col<eT>& Q;
inline explicit Proxy(const subview_col<eT>& A) inline explicit Proxy(const subview_col<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 390 skipping to change at line 590
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview_row<eT> stored_type; typedef subview_row<eT> stored_type;
typedef const subview_row<eT>& ea_type; typedef const subview_row<eT>& ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = true; static const bool has_subview = true;
static const bool is_fixed = false;
static const bool is_row = true; static const bool is_row = true;
static const bool is_col = false; static const bool is_col = false;
arma_aligned const subview_row<eT>& Q; arma_aligned const subview_row<eT>& Q;
inline explicit Proxy(const subview_row<eT>& A) inline explicit Proxy(const subview_row<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 427 skipping to change at line 628
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = true; static const bool is_col = true;
arma_aligned const Mat<eT> Q; arma_aligned const Mat<eT> Q;
inline explicit Proxy(const subview_elem1<eT,T1>& A) inline explicit Proxy(const subview_elem1<eT,T1>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 464 skipping to change at line 666
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = false; static const bool is_col = false;
arma_aligned const Mat<eT> Q; arma_aligned const Mat<eT> Q;
inline explicit Proxy(const subview_elem2<eT,T1,T2>& A) inline explicit Proxy(const subview_elem2<eT,T1,T2>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 501 skipping to change at line 704
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef diagview<eT> stored_type; typedef diagview<eT> stored_type;
typedef const diagview<eT>& ea_type; typedef const diagview<eT>& ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = true; static const bool has_subview = true;
static const bool is_fixed = false;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = true; static const bool is_col = true;
arma_aligned const diagview<eT>& Q; arma_aligned const diagview<eT>& Q;
inline explicit Proxy(const diagview<eT>& A) inline explicit Proxy(const diagview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 538 skipping to change at line 742
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eOp<T1, eop_type> stored_type; typedef eOp<T1, eop_type> stored_type;
typedef const eOp<T1, eop_type>& ea_type; typedef const eOp<T1, eop_type>& ea_type;
static const bool prefer_at_accessor = eOp<T1, eop_type>::prefer_at_acces sor; static const bool prefer_at_accessor = eOp<T1, eop_type>::prefer_at_acces sor;
static const bool has_subview = eOp<T1, eop_type>::has_subview; static const bool has_subview = eOp<T1, eop_type>::has_subview;
static const bool is_fixed = eOp<T1, eop_type>::is_fixed;
static const bool is_row = eOp<T1, eop_type>::is_row; static const bool is_row = eOp<T1, eop_type>::is_row;
static const bool is_col = eOp<T1, eop_type>::is_col; static const bool is_col = eOp<T1, eop_type>::is_col;
arma_aligned const eOp<T1, eop_type>& Q; arma_aligned const eOp<T1, eop_type>& Q;
inline explicit Proxy(const eOp<T1, eop_type>& A) inline explicit Proxy(const eOp<T1, eop_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 575 skipping to change at line 780
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eGlue<T1, T2, eglue_type> stored_type; typedef eGlue<T1, T2, eglue_type> stored_type;
typedef const eGlue<T1, T2, eglue_type>& ea_type; typedef const eGlue<T1, T2, eglue_type>& ea_type;
static const bool prefer_at_accessor = eGlue<T1, T2, eglue_type>::prefer_ at_accessor; static const bool prefer_at_accessor = eGlue<T1, T2, eglue_type>::prefer_ at_accessor;
static const bool has_subview = eGlue<T1, T2, eglue_type>::has_sub view; static const bool has_subview = eGlue<T1, T2, eglue_type>::has_sub view;
static const bool is_fixed = eGlue<T1, T2, eglue_type>::is_fixe d;
static const bool is_row = eGlue<T1, T2, eglue_type>::is_row; static const bool is_row = eGlue<T1, T2, eglue_type>::is_row;
static const bool is_col = eGlue<T1, T2, eglue_type>::is_col; static const bool is_col = eGlue<T1, T2, eglue_type>::is_col;
arma_aligned const eGlue<T1, T2, eglue_type>& Q; arma_aligned const eGlue<T1, T2, eglue_type>& Q;
inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A) inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 612 skipping to change at line 818
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Mat<out_eT> stored_type; typedef Mat<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = mtOp<out_eT, T1, op_type>::is_row; static const bool is_row = mtOp<out_eT, T1, op_type>::is_row;
static const bool is_col = mtOp<out_eT, T1, op_type>::is_col; static const bool is_col = mtOp<out_eT, T1, op_type>::is_col;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A) inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 649 skipping to change at line 856
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Mat<out_eT> stored_type; typedef Mat<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_fixed = false;
static const bool is_row = mtGlue<out_eT, T1, T2, glue_type>::is_row; static const bool is_row = mtGlue<out_eT, T1, T2, glue_type>::is_row;
static const bool is_col = mtGlue<out_eT, T1, T2, glue_type>::is_col; static const bool is_col = mtGlue<out_eT, T1, T2, glue_type>::is_col;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A) inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 27 change blocks. 
19 lines changed or deleted 246 lines changed or added


 Row_bones.hpp   Row_bones.hpp 
skipping to change at line 80 skipping to change at line 80
arma_inline subview_row<eT> cols(const uword in_col1, const uword i n_col2); arma_inline subview_row<eT> cols(const uword in_col1, const uword i n_col2);
arma_inline const subview_row<eT> cols(const uword in_col1, const uword i n_col2) const; arma_inline const subview_row<eT> cols(const uword in_col1, const uword i n_col2) const;
arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2); arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2);
arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const; arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
arma_inline subview_row<eT> subvec(const span& col_span); arma_inline subview_row<eT> subvec(const span& col_span);
arma_inline const subview_row<eT> subvec(const span& col_span) const; arma_inline const subview_row<eT> subvec(const span& col_span) const;
// arma_inline subview_row<eT> operator()(const span& col_span); using Mat<eT>::operator();
// arma_inline const subview_row<eT> operator()(const span& col_span) con
st; arma_inline subview_row<eT> operator()(const span& col_span);
arma_inline const subview_row<eT> operator()(const span& col_span) const;
inline void shed_col (const uword col_num); inline void shed_col (const uword col_num);
inline void shed_cols(const uword in_col1, const uword in_col2); inline void shed_cols(const uword in_col1, const uword in_col2);
inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero = true); inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero = true);
template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X); template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X);
arma_inline arma_warn_unused eT& at(const uword i); arma_inline arma_warn_unused eT& at(const uword i);
arma_inline arma_warn_unused eT at(const uword i) const; arma_inline arma_warn_unused eT at(const uword i) const;
skipping to change at line 148 skipping to change at line 150
inline fixed(const char* text); inline fixed(const char* text);
inline fixed(const std::string& text); inline fixed(const std::string& text);
template<typename T1> inline const Row& operator=(const Base<eT,T1>& A) ; template<typename T1> inline const Row& operator=(const Base<eT,T1>& A) ;
inline const Row& operator=(const eT val); inline const Row& operator=(const eT val);
inline const Row& operator=(const char* text); inline const Row& operator=(const char* text);
inline const Row& operator=(const std::string& text); inline const Row& operator=(const std::string& text);
inline const Row& operator=(const subview_cube<eT>& X); inline const Row& operator=(const subview_cube<eT>& X);
inline subview_row<eT> operator()(const uword row_num, const s using Row<eT>::operator();
pan& col_span);
inline const subview_row<eT> operator()(const uword row_num, const s
pan& col_span) const;
inline subview_col<eT> operator()(const span& row_span, const uwo
rd col_num );
inline const subview_col<eT> operator()(const span& row_span, const uwo
rd col_num ) const;
inline subview<eT> operator()(const span& row_span, const spa #if defined(ARMA_USE_CXX11)
n& col_span); inline fixed(const std::initializer_list<eT>& list);
inline const subview<eT> operator()(const span& row_span, const spa inline const Row& operator=(const std::initializer_list<eT>& list);
n& col_span) const; #endif
arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT& operator[] (const uword i);
arma_inline arma_warn_unused eT operator[] (const uword i) const; arma_inline arma_warn_unused eT operator[] (const uword i) const;
arma_inline arma_warn_unused eT& at (const uword i); arma_inline arma_warn_unused eT& at (const uword i);
arma_inline arma_warn_unused eT at (const uword i) const; arma_inline arma_warn_unused eT at (const uword i) const;
arma_inline arma_warn_unused eT& operator() (const uword i); arma_inline arma_warn_unused eT& operator() (const uword i);
arma_inline arma_warn_unused eT operator() (const uword i) const; arma_inline arma_warn_unused eT operator() (const uword i) const;
arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col);
arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const; arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const;
 End of changes. 3 change blocks. 
16 lines changed or deleted 9 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 397 skipping to change at line 397
const uword in_col1 = col_all ? 0 : col_span.a; const uword in_col1 = col_all ? 0 : col_span.a;
const uword in_col2 = col_span.b; const uword in_col2 = col_span.b;
const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly use d"); arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly use d");
return subview_row<eT>(*this, 0, in_col1, subvec_n_cols); return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
} }
// template<typename eT> template<typename eT>
// arma_inline arma_inline
// subview_row<eT> subview_row<eT>
// Row<eT>::operator()(const span& col_span) Row<eT>::operator()(const span& col_span)
// { {
// arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//
// return subvec(col_span); return subvec(col_span);
// } }
//
// template<typename eT>
// arma_inline
// template<typename eT> const subview_row<eT>
// arma_inline Row<eT>::operator()(const span& col_span) const
// const subview_row<eT> {
// Row<eT>::operator()(const span& col_span) const arma_extra_debug_sigprint();
// {
// arma_extra_debug_sigprint(); return subvec(col_span);
// }
// return subvec(col_span);
// }
//! remove specified columns //! remove specified columns
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::shed_col(const uword col_num) Row<eT>::shed_col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): out of bo unds"); arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): out of bo unds");
skipping to change at line 723 skipping to change at line 721
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::operator=(text); Row<eT>::operator=(text);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline
subview_row<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c
ol_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT>
template<uword fixed_n_elem>
template<typename T1> template<typename T1>
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A) Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(A.get_ref()); Row<eT>::operator=(A.get_ref());
return *this; return *this;
} }
skipping to change at line 793 skipping to change at line 780
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X) Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<eT>::operator=(X); Row<eT>::operator=(X);
return *this; return *this;
} }
template<typename eT> #if defined(ARMA_USE_CXX11)
template<uword fixed_n_elem>
inline
const subview_row<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& c
ol_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_num, col_span);
}
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
subview_col<eT> Row<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list)
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword
col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); mem_setup();
(*this).operator=(list);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
const subview_col<eT> const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword Row<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>& li
col_num) const st)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_num); const uword N = list.size();
}
template<typename eT> arma_debug_check( (N > fixed_n_elem), "Row::fixed: initialiser list is to
template<uword fixed_n_elem> o long" );
inline
subview<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span)
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); eT* this_mem = (*this).memptr();
}
template<typename eT> arrayops::copy( this_mem, list.begin(), N );
template<uword fixed_n_elem>
inline
const subview<eT>
Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span&
col_span) const
{
arma_extra_debug_sigprint();
return Mat<eT>::operator()(row_span, col_span); for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
return *this;
} }
#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 i) Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii)
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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 i) const Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) const
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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>::at(const uword i) Row<eT>::fixed<fixed_n_elem>::at(const uword ii)
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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>::at(const uword i) const Row<eT>::fixed<fixed_n_elem>::at(const uword ii) const
{ {
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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 i) Row<eT>::fixed<fixed_n_elem>::operator() (const uword ii)
{ {
arma_debug_check( (i >= fixed_n_elem), "Row::operator(): out of bounds"); arma_debug_check( (ii >= fixed_n_elem), "Row::operator(): out of bounds") ;
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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 i) const Row<eT>::fixed<fixed_n_elem>::operator() (const uword ii) const
{ {
arma_debug_check( (i >= fixed_n_elem), "Row::operator(): out of bounds"); arma_debug_check( (ii >= fixed_n_elem), "Row::operator(): out of bounds") ;
return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i]; return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
} }
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>::at(const uword, const uword in_col) Row<eT>::fixed<fixed_n_elem>::at(const uword, const uword in_col)
{ {
return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col] ; return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col] ;
 End of changes. 26 change blocks. 
86 lines changed or deleted 51 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 0 #define ARMA_VERSION_MINOR 1
#define ARMA_VERSION_PATCH 4 #define ARMA_VERSION_PATCH 91
#define ARMA_VERSION_NAME "Antarctic Chilli Ranch" #define ARMA_VERSION_NAME "v3.2 beta 1"
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 80 skipping to change at line 80
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/current_function.hpp> #include <boost/current_function.hpp>
#define ARMA_USE_BOOST_FORMAT #define ARMA_USE_BOOST_FORMAT
#endif #endif
#endif #endif
#include "armadillo_bits/include_atlas.hpp" #include "armadillo_bits/include_atlas.hpp"
#if defined(ARMA_USE_HDF5)
#include <hdf5.h>
#endif
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
// preliminaries // preliminaries
#include "armadillo_bits/forward_bones.hpp" #include "armadillo_bits/forward_bones.hpp"
#include "armadillo_bits/arma_static_check.hpp" #include "armadillo_bits/arma_static_check.hpp"
#include "armadillo_bits/typedef.hpp" #include "armadillo_bits/typedef.hpp"
#include "armadillo_bits/typedef_blas_int.hpp" #include "armadillo_bits/typedef_blas_int.hpp"
skipping to change at line 201 skipping to change at line 205
#include "armadillo_bits/op_princomp_bones.hpp" #include "armadillo_bits/op_princomp_bones.hpp"
#include "armadillo_bits/op_misc_bones.hpp" #include "armadillo_bits/op_misc_bones.hpp"
#include "armadillo_bits/op_relational_bones.hpp" #include "armadillo_bits/op_relational_bones.hpp"
#include "armadillo_bits/op_find_bones.hpp" #include "armadillo_bits/op_find_bones.hpp"
#include "armadillo_bits/op_chol_bones.hpp" #include "armadillo_bits/op_chol_bones.hpp"
#include "armadillo_bits/op_cx_scalar_bones.hpp" #include "armadillo_bits/op_cx_scalar_bones.hpp"
#include "armadillo_bits/op_trimat_bones.hpp" #include "armadillo_bits/op_trimat_bones.hpp"
#include "armadillo_bits/op_cumsum_bones.hpp" #include "armadillo_bits/op_cumsum_bones.hpp"
#include "armadillo_bits/op_symmat_bones.hpp" #include "armadillo_bits/op_symmat_bones.hpp"
#include "armadillo_bits/op_hist_bones.hpp" #include "armadillo_bits/op_hist_bones.hpp"
#include "armadillo_bits/op_unique_bones.hpp"
#include "armadillo_bits/glue_times_bones.hpp" #include "armadillo_bits/glue_times_bones.hpp"
#include "armadillo_bits/glue_mixed_bones.hpp" #include "armadillo_bits/glue_mixed_bones.hpp"
#include "armadillo_bits/glue_cov_bones.hpp" #include "armadillo_bits/glue_cov_bones.hpp"
#include "armadillo_bits/glue_cor_bones.hpp" #include "armadillo_bits/glue_cor_bones.hpp"
#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"
skipping to change at line 229 skipping to change at line 234
#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_cube.hpp"
#include "armadillo_bits/Proxy.hpp" #include "armadillo_bits/Proxy.hpp"
#include "armadillo_bits/ProxyCube.hpp" #include "armadillo_bits/ProxyCube.hpp"
#include "armadillo_bits/diagmat_proxy.hpp" #include "armadillo_bits/diagmat_proxy.hpp"
#include "armadillo_bits/unwrap.hpp"
#include "armadillo_bits/unwrap_cube.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/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"
skipping to change at line 357 skipping to change at line 362
#include "armadillo_bits/fn_conv.hpp" #include "armadillo_bits/fn_conv.hpp"
#include "armadillo_bits/fn_trunc_exp.hpp" #include "armadillo_bits/fn_trunc_exp.hpp"
#include "armadillo_bits/fn_trunc_log.hpp" #include "armadillo_bits/fn_trunc_log.hpp"
#include "armadillo_bits/fn_toeplitz.hpp" #include "armadillo_bits/fn_toeplitz.hpp"
#include "armadillo_bits/fn_trimat.hpp" #include "armadillo_bits/fn_trimat.hpp"
#include "armadillo_bits/fn_cumsum.hpp" #include "armadillo_bits/fn_cumsum.hpp"
#include "armadillo_bits/fn_symmat.hpp" #include "armadillo_bits/fn_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"
// //
// 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 426 skipping to change at line 432
#include "armadillo_bits/op_princomp_meat.hpp" #include "armadillo_bits/op_princomp_meat.hpp"
#include "armadillo_bits/op_misc_meat.hpp" #include "armadillo_bits/op_misc_meat.hpp"
#include "armadillo_bits/op_relational_meat.hpp" #include "armadillo_bits/op_relational_meat.hpp"
#include "armadillo_bits/op_find_meat.hpp" #include "armadillo_bits/op_find_meat.hpp"
#include "armadillo_bits/op_chol_meat.hpp" #include "armadillo_bits/op_chol_meat.hpp"
#include "armadillo_bits/op_cx_scalar_meat.hpp" #include "armadillo_bits/op_cx_scalar_meat.hpp"
#include "armadillo_bits/op_trimat_meat.hpp" #include "armadillo_bits/op_trimat_meat.hpp"
#include "armadillo_bits/op_cumsum_meat.hpp" #include "armadillo_bits/op_cumsum_meat.hpp"
#include "armadillo_bits/op_symmat_meat.hpp" #include "armadillo_bits/op_symmat_meat.hpp"
#include "armadillo_bits/op_hist_meat.hpp" #include "armadillo_bits/op_hist_meat.hpp"
#include "armadillo_bits/op_unique_meat.hpp"
#include "armadillo_bits/glue_times_meat.hpp" #include "armadillo_bits/glue_times_meat.hpp"
#include "armadillo_bits/glue_mixed_meat.hpp" #include "armadillo_bits/glue_mixed_meat.hpp"
#include "armadillo_bits/glue_cov_meat.hpp" #include "armadillo_bits/glue_cov_meat.hpp"
#include "armadillo_bits/glue_cor_meat.hpp" #include "armadillo_bits/glue_cor_meat.hpp"
#include "armadillo_bits/glue_kron_meat.hpp" #include "armadillo_bits/glue_kron_meat.hpp"
#include "armadillo_bits/glue_cross_meat.hpp" #include "armadillo_bits/glue_cross_meat.hpp"
#include "armadillo_bits/glue_join_meat.hpp" #include "armadillo_bits/glue_join_meat.hpp"
#include "armadillo_bits/glue_relational_meat.hpp" #include "armadillo_bits/glue_relational_meat.hpp"
#include "armadillo_bits/glue_solve_meat.hpp" #include "armadillo_bits/glue_solve_meat.hpp"
 End of changes. 6 change blocks. 
3 lines changed or deleted 10 lines changed or added


 auxlib_bones.hpp   auxlib_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
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2012 Eric Jon Sundstrom
// //
// 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 112 skipping to change at line 113
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1> & X); inline static bool eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1> & X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<e T,T1>& X); inline static bool eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<e T,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec , const Base<std::complex<T>,T1>& X); inline static bool eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec , const Base<std::complex<T>,T1>& X);
template<typename eT, typename T1>
inline static bool eig_sym_dc(Col<eT>& eigval, Mat<eT>& eigvec, const Bas
e<eT,T1>& X);
template<typename T, typename T1>
inline static bool eig_sym_dc(Col<T>& eigval, Mat< std::complex<T> >& eig
vec, const Base<std::complex<T>,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat<T>& l_eigv ec, Mat<T>& r_eigvec, const Base<T,T1>& X, const char side); inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat<T>& l_eigv ec, Mat<T>& r_eigvec, const Base<T,T1>& X, const char side);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat< std::comp lex<T> >& l_eigvec, Mat< std::complex<T> >& r_eigvec, const Base< std::comp lex<T>, T1 >& X, const char side); inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat< std::comp lex<T> >& l_eigvec, Mat< std::complex<T> >& r_eigvec, const Base< std::comp lex<T>, T1 >& X, const char side);
// //
// chol // chol
template<typename eT, typename T1> template<typename eT, typename T1>
skipping to change at line 170 skipping to change at line 177
template<typename eT> template<typename eT>
inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, c onst bool slow = false); inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, c onst bool slow = false);
template<typename eT> template<typename eT>
inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B); inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B);
template<typename eT> template<typename eT>
inline static bool solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B); inline static bool solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B);
// //
// solve_new
template<typename eT, typename T1>
inline static bool solve_new (Mat<eT>& out, Mat<eT>& A, const Base<eT,T
1>& X, const bool slow = false);
template<typename eT, typename T1>
inline static bool solve_new_od(Mat<eT>& out, Mat<eT>& A, const Base<eT,T
1>& X);
template<typename eT, typename T1>
inline static bool solve_new_ud(Mat<eT>& out, Mat<eT>& A, const Base<eT,T
1>& X);
//
// solve_tr // solve_tr
template<typename eT> template<typename eT>
inline static bool solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT> & B, const uword layout); inline static bool solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT> & B, const uword layout);
// //
// Schur decomposition // Schur decomposition
template<typename eT> template<typename eT>
inline static bool schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A); inline static bool schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A);
 End of changes. 3 change blocks. 
4 lines changed or deleted 28 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
// //
// 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 1128 skipping to change at line 1129
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is not square"); arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is not square");
if(A.is_empty()) if(A.is_empty())
{ {
eigval.reset(); eigval.reset();
return true; return true;
} }
// rudimentary "better-than-nothing" test for symmetry eigval.set_size(A.n_rows);
//arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl
ib::eig(): given matrix is not symmetric" );
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = A.n_rows; blas_int N = blas_int(A.n_rows);
blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1) + 2; // +2 for p blas_int lwork = 2*((std::max)(blas_int(1), 3*N-1));
aranoia: some versions of Lapack might be trashing memory blas_int info = 0;
eigval.set_size( static_cast<uword>(n_rows) );
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
blas_int info = 0;
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &n_rows, A.memptr(), &n_rows, eigval.memptr( ), work.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &N, A.memptr(), &N, eigval.memptr(), work.me mptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): use of LAPACK needs to be enabled"); arma_stop("eig_sym(): use of LAPACK needs to be enabled");
return false; return false;
} }
skipping to change at line 1170 skipping to change at line 1168
bool bool
auxlib::eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X) auxlib::eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is
not hermitian"); arma_debug_check( (A.is_square() == false), "eig_sym(): given matrix is
not square");
if(A.is_empty()) if(A.is_empty())
{ {
eigval.reset(); eigval.reset();
return true; return true;
} }
eigval.set_size(A.n_rows);
char jobz = 'N'; char jobz = 'N';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = A.n_rows; blas_int N = blas_int(A.n_rows);
blas_int lda = A.n_rows; blas_int lwork = 2*((std::max)(blas_int(1), 2*N-1));
blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1) + 2; // +2 for blas_int info = 0;
paranoia: some versions of Lapack might be trashing memory
// TODO: automatically find best size of lwork
eigval.set_size( static_cast<uword>(n_rows) );
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_rows podarray<T> rwork( static_cast<uword>( (std::max)(blas_int(1), 3*N-2)
- 2)) ); ) );
blas_int info = 0;
arma_extra_debug_print("lapack::heev()"); arma_extra_debug_print("lapack::heev()");
lapack::heev(&jobz, &uplo, &n_rows, A.memptr(), &lda, eigval.memptr(), work.memptr(), &lwork, rwork.memptr(), &info); lapack::heev(&jobz, &uplo, &N, A.memptr(), &N, eigval.memptr(), work.me mptr(), &lwork, rwork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): use of LAPACK needs to be enabled"); arma_stop("eig_sym(): use of LAPACK needs to be enabled");
return false; return false;
} }
skipping to change at line 1229 skipping to change at line 1225
arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not square" ); arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not square" );
if(eigvec.is_empty()) if(eigvec.is_empty())
{ {
eigval.reset(); eigval.reset();
eigvec.reset(); eigvec.reset();
return true; return true;
} }
// rudimentary "better-than-nothing" test for symmetry eigval.set_size(eigvec.n_rows);
//arma_debug_check( (A.at(A.n_rows-1, 0) != A.at(0, A.n_cols-1)), "auxl
ib::eig(): given matrix is not symmetric" );
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = eigvec.n_rows; blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = (std::max)(blas_int(1), 3*n_rows-1) + 2; // +2 for p blas_int lwork = 2*((std::max)(blas_int(1), 3*N-1));
aranoia: some versions of Lapack might be trashing memory blas_int info = 0;
eigval.set_size( static_cast<uword>(n_rows) );
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
blas_int info = 0;
arma_extra_debug_print("lapack::syev()"); arma_extra_debug_print("lapack::syev()");
lapack::syev(&jobz, &uplo, &n_rows, eigvec.memptr(), &n_rows, eigval.me mptr(), work.memptr(), &lwork, &info); lapack::syev(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), wo rk.memptr(), &lwork, &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(eigvec); arma_ignore(eigvec);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): use of LAPACK needs to be enabled"); arma_stop("eig_sym(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
//! immediate eigenvalues and eigenvectors of a hermitian complex matrix us ing LAPACK //! immediate eigenvalues and eigenvectors of a hermitian complex matrix us ing LAPACK
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Base< std::complex<T>,T1>& X) auxlib::eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Base< std::complex<T>,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
eigvec = X.get_ref(); eigvec = X.get_ref();
arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not hermitian" ); arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr ix is not square" );
if(eigvec.is_empty()) if(eigvec.is_empty())
{ {
eigval.reset(); eigval.reset();
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int n_rows = eigvec.n_rows; blas_int N = blas_int(eigvec.n_rows);
blas_int lda = eigvec.n_rows; blas_int lwork = 2*((std::max)(blas_int(1), 2*N-1));
blas_int lwork = (std::max)(blas_int(1), 2*n_rows - 1) + 2; // +2 for blas_int info = 0;
paranoia: some versions of Lapack might be trashing memory
// TODO: automatically find best size of lwork
eigval.set_size( static_cast<uword>(n_rows) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*N-2))
);
podarray<eT> work( static_cast<uword>(lwork) ); arma_extra_debug_print("lapack::heev()");
podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows lapack::heev(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), wo
- 2)) ); rk.memptr(), &lwork, rwork.memptr(), &info);
blas_int info = 0; return (info == 0);
}
#else
{
arma_ignore(eigval);
arma_ignore(eigvec);
arma_ignore(X);
arma_stop("eig_sym(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
arma_extra_debug_print("lapack::heev()"); //! immediate eigenvalues and eigenvectors of a symmetric real matrix using
lapack::heev(&jobz, &uplo, &n_rows, eigvec.memptr(), &lda, eigval.mempt LAPACK (divide and conquer algorithm)
r(), work.memptr(), &lwork, rwork.memptr(), &info); template<typename eT, typename T1>
inline
bool
auxlib::eig_sym_dc(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
eigvec = X.get_ref();
arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr
ix is not square" );
if(eigvec.is_empty())
{
eigval.reset();
eigvec.reset();
return true;
}
eigval.set_size(eigvec.n_rows);
char jobz = 'V';
char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 2*(1 + 6*N + 2*(N*N));
blas_int liwork = 2*(3 + 5*N + 2);
blas_int info = 0;
podarray<eT> work( static_cast<uword>( lwork) );
podarray<blas_int> iwork( static_cast<uword>(liwork) );
arma_extra_debug_print("lapack::syevd()");
lapack::syevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w
ork.memptr(), &lwork, iwork.memptr(), &liwork, &info);
return (info == 0);
}
#else
{
arma_ignore(eigval);
arma_ignore(eigvec);
arma_ignore(X);
arma_stop("eig_sym(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
//! immediate eigenvalues and eigenvectors of a hermitian complex matrix us
ing LAPACK (divide and conquer algorithm)
template<typename T, typename T1>
inline
bool
auxlib::eig_sym_dc(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Ba
se<std::complex<T>,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK)
{
eigvec = X.get_ref();
arma_debug_check( (eigvec.is_square() == false), "eig_sym(): given matr
ix is not square" );
if(eigvec.is_empty())
{
eigval.reset();
eigvec.reset();
return true;
}
eigval.set_size(eigvec.n_rows);
char jobz = 'V';
char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 2*(2*N + N*N);
blas_int lrwork = 2*(1 + 5*N + 2*(N*N));
blas_int liwork = 2*(3 + 5*N);
blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>(lrwork) );
podarray<blas_int> iwork( static_cast<uword>(liwork) );
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);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(eigvec); arma_ignore(eigvec);
arma_ignore(X); arma_ignore(X);
arma_stop("eig_sym(): use of LAPACK needs to be enabled"); arma_stop("eig_sym(): use of LAPACK needs to be enabled");
return false; return false;
skipping to change at line 1323 skipping to change at line 1415
} }
//! Eigenvalues and eigenvectors of a general square real matrix using LAPA CK. //! Eigenvalues and eigenvectors of a general square real matrix using LAPA CK.
//! The argument 'side' specifies which eigenvectors should be calculated //! The argument 'side' specifies which eigenvectors should be calculated
//! (see code for mode details). //! (see code for mode details).
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::eig_gen auxlib::eig_gen
( (
Col< std::complex<T> >& eigval, Col< std::complex<T> >& eigval,
Mat<T>& l_eigvec, Mat<T>& l_eigvec,
Mat<T>& r_eigvec, Mat<T>& r_eigvec,
const Base<T,T1>& X, const Base<T,T1>& X,
const char side const char side
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
char jobvl; char jobvl;
char jobvr; char jobvr;
switch(side) switch(side)
skipping to change at line 1375 skipping to change at line 1467
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" );
if(A.is_empty()) if(A.is_empty())
{ {
eigval.reset(); eigval.reset();
l_eigvec.reset(); l_eigvec.reset();
r_eigvec.reset(); r_eigvec.reset();
return true; return true;
} }
uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
blas_int n_rows = A_n_rows;
blas_int lda = A_n_rows;
blas_int lwork = (std::max)(blas_int(1), 4*n_rows) + 2; // +2 for par
anoia: some versions of Lapack might be trashing memory
// TODO: automatically find best size of lwork
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size(A_n_rows, A_n_rows);
podarray<T> work( static_cast<uword>(lwork) ); blas_int N = blas_int(A_n_rows);
podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows) blas_int lwork = 2*((std::max)(blas_int(1), 4*N));
) ); blas_int info = 0;
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);
blas_int info = 0;
arma_extra_debug_print("lapack::geev()"); arma_extra_debug_print("lapack::geev()");
lapack::geev(&jobvl, &jobvr, &n_rows, A.memptr(), &lda, wr.memptr(), wi .memptr(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, work.mem ptr(), &lwork, &info); 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);
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
for(uword i=0; i<A_n_rows; ++i) for(uword i=0; i<A_n_rows; ++i)
{ {
eigval[i] = std::complex<T>(wr[i], wi[i]); eigval[i] = std::complex<T>(wr[i], wi[i]);
} }
return (info == 0); return (info == 0);
} }
#else #else
skipping to change at line 1426 skipping to change at line 1515
} }
//! Eigenvalues and eigenvectors of a general square complex matrix using L APACK //! Eigenvalues and eigenvectors of a general square complex matrix using L APACK
//! The argument 'side' specifies which eigenvectors should be calculated //! The argument 'side' specifies which eigenvectors should be calculated
//! (see code for mode details). //! (see code for mode details).
template<typename T, typename T1> template<typename T, typename T1>
inline inline
bool bool
auxlib::eig_gen auxlib::eig_gen
( (
Col< std::complex<T> >& eigval, Col< std::complex<T> >& eigval,
Mat< std::complex<T> >& l_eigvec, Mat< std::complex<T> >& l_eigvec,
Mat< std::complex<T> >& r_eigvec, Mat< std::complex<T> >& r_eigvec,
const Base< std::complex<T>, T1 >& X, const Base< std::complex<T>, T1 >& X,
const char side const char side
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
char jobvl; char jobvl;
char jobvr; char jobvr;
skipping to change at line 1480 skipping to change at line 1569
arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "eig_gen(): given matrix is not square" );
if(A.is_empty()) if(A.is_empty())
{ {
eigval.reset(); eigval.reset();
l_eigvec.reset(); l_eigvec.reset();
r_eigvec.reset(); r_eigvec.reset();
return true; return true;
} }
uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
blas_int n_rows = A_n_rows;
blas_int lda = A_n_rows;
blas_int lwork = (std::max)(blas_int(1), 4*n_rows) + 2; // +2 for par
anoia: some versions of Lapack might be trashing memory
// TODO: automatically find best size of lwork
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size(A_n_rows, A_n_rows);
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size(A_n_rows, A_n_rows);
podarray<eT> work( static_cast<uword>(lwork) ); blas_int N = blas_int(A_n_rows);
podarray<T> rwork( static_cast<uword>((std::max)(blas_int(1), 3*n_rows blas_int lwork = 2*((std::max)(blas_int(1), 2*N));
)) ); // was 2,3 blas_int info = 0;
blas_int info = 0; podarray<eT> work( static_cast<uword>(lwork) );
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_rows, A.memptr(), &lda, eigval.mempt r(), l_eigvec.memptr(), &n_rows, r_eigvec.memptr(), &n_rows, work.memptr(), &lwork, rwork.memptr(), &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);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(l_eigvec); arma_ignore(l_eigvec);
arma_ignore(r_eigvec); arma_ignore(r_eigvec);
arma_ignore(X); arma_ignore(X);
arma_ignore(side); arma_ignore(side);
skipping to change at line 1536 skipping to change at line 1623
if(out.is_empty()) if(out.is_empty())
{ {
return true; return true;
} }
const uword out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
char uplo = 'U'; char uplo = 'U';
blas_int n = out_n_rows; blas_int n = out_n_rows;
blas_int info; blas_int info = 0;
lapack::potrf(&uplo, &n, out.memptr(), &n, &info); lapack::potrf(&uplo, &n, out.memptr(), &n, &info);
for(uword col=0; col<out_n_rows; ++col) for(uword col=0; col<out_n_rows; ++col)
{ {
eT* colptr = out.colptr(col); eT* colptr = out.colptr(col);
for(uword row=(col+1); row < out_n_rows; ++row) for(uword row=(col+1); row < out_n_rows; ++row)
{ {
colptr[row] = eT(0); colptr[row] = eT(0);
skipping to change at line 1791 skipping to change at line 1878
blas_int m = A.n_rows; blas_int m = A.n_rows;
blas_int n = A.n_cols; blas_int n = A.n_cols;
blas_int lda = A.n_rows; blas_int lda = A.n_rows;
blas_int ldu = U.n_rows; blas_int ldu = U.n_rows;
blas_int ldvt = V.n_rows; blas_int ldvt = V.n_rows;
blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) ); blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) );
blas_int info = 0; blas_int info = 0;
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
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*(std::min)(m,n)) );
// 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 1895 skipping to change at line 1982
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 = A.n_rows; blas_int m = blas_int(A.n_rows);
blas_int n = A.n_cols; blas_int n = blas_int(A.n_cols);
blas_int lda = A.n_rows; blas_int lda = blas_int(A.n_rows);
blas_int ldu = U.n_rows; blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = V.n_rows; blas_int ldvt = blas_int(V.n_rows);
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 = 2 * (std::max)(blas_int(1), (std::max)( (3*(std::min) (m,n) + (std::max)(m,n)), 5*(std::min)(m,n) ) );
blas_int info = 0; blas_int info = 0;
S.set_size( static_cast<uword>((std::min)(m,n)) ); 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>
skipping to change at line 1986 skipping to change at line 2073
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 = A.n_rows; blas_int m = blas_int(A.n_rows);
blas_int n = A.n_cols; blas_int n = blas_int(A.n_cols);
blas_int lda = A.n_rows; blas_int lda = blas_int(A.n_rows);
blas_int ldu = U.n_rows; blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = V.n_rows; blas_int ldvt = blas_int(V.n_rows);
blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) ); blas_int lwork = 2 * (std::max)(blas_int(1), 2*(std::min)(m,n)+(std::m ax)(m,n) );
blas_int info = 0; blas_int info = 0;
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
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*(std::min)(m,n)) );
// 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;
skipping to change at line 2065 skipping to change at line 2152
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 = A.n_rows; blas_int m = blas_int(A.n_rows);
blas_int n = A.n_cols; blas_int n = blas_int(A.n_cols);
blas_int lda = A.n_rows; blas_int lda = blas_int(A.n_rows);
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
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)
skipping to change at line 2202 skipping to change at line 2289
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 = A.n_rows; blas_int m = blas_int(A.n_rows);
blas_int n = A.n_cols; blas_int n = blas_int(A.n_cols);
blas_int lda = A.n_rows; blas_int lda = blas_int(A.n_rows);
S.set_size( static_cast<uword>((std::min)(m,n)) ); S.set_size( static_cast<uword>((std::min)(m,n)) );
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)
skipping to change at line 2338 skipping to change at line 2425
//! Solve a system of linear equations. //! Solve a system of linear equations.
//! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows //! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, const bool slow) auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, const bool slow)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword A_n_rows = A.n_rows;
const uword B_n_cols = B.n_cols;
if(A.is_empty() || B.is_empty()) if(A.is_empty() || B.is_empty())
{ {
out.zeros(A.n_cols, B.n_cols); out.zeros(A.n_cols, B_n_cols);
return true; return true;
} }
else else
{ {
const uword A_n_rows = A.n_rows;
bool status = false; bool status = false;
if( (A_n_rows <= 4) && (slow == false) ) if( (A_n_rows <= 4) && (slow == false) )
{ {
Mat<eT> A_inv; Mat<eT> A_inv;
status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows); status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows);
if(status == true) if(status == true)
{ {
out.set_size(A_n_rows, B.n_cols); out.set_size(A_n_rows, B_n_cols);
gemm_emul<false,false,false,false>::apply(out, A_inv, B); gemm_emul<false,false,false,false>::apply(out, A_inv, B);
return true; return true;
} }
} }
if( (A_n_rows > 4) || (status == false) ) if( (A_n_rows > 4) || (status == false) )
{ {
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
{ {
out = B; out = B;
podarray<int> ipiv(A_n_rows + 2); // +2 for paranoia: old versions of Atlas might be trashing memory podarray<int> ipiv(A_n_rows + 2); // +2 for paranoia: old versions of Atlas might be trashing memory
int info = atlas::clapack_gesv<eT>(atlas::CblasColMajor, A_n_rows, B.n_cols, A.memptr(), A_n_rows, ipiv.memptr(), out.memptr(), A_n_rows); int info = atlas::clapack_gesv<eT>(atlas::CblasColMajor, A_n_rows, B_n_cols, A.memptr(), A_n_rows, ipiv.memptr(), out.memptr(), A_n_rows);
return (info == 0); return (info == 0);
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
{ {
blas_int n = A_n_rows; // assuming A is square
blas_int lda = A_n_rows;
blas_int ldb = A_n_rows;
blas_int nrhs = B.n_cols;
blas_int info = 0;
out = B; out = B;
blas_int n = blas_int(A_n_rows); // assuming A is square
blas_int lda = blas_int(A_n_rows);
blas_int ldb = blas_int(A_n_rows);
blas_int nrhs = blas_int(B_n_cols);
blas_int info = 0;
podarray<blas_int> ipiv(A_n_rows + 2); // +2 for paranoia: some ve rsions of Lapack might be trashing memory podarray<blas_int> ipiv(A_n_rows + 2); // +2 for paranoia: some ve rsions of Lapack might be trashing memory
arma_extra_debug_print("lapack::gesv()");
lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.me mptr(), &ldb, &info); lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.me mptr(), &ldb, &info);
arma_extra_debug_print("lapack::gesv() -- finished");
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_stop("solve(): use of ATLAS or LAPACK needs to be enabled"); arma_stop("solve(): use of ATLAS or LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
} }
skipping to change at line 2416 skipping to change at line 2507
//! Assumes that A.n_rows > A.n_cols and B.n_rows = A.n_rows //! Assumes that A.n_rows > A.n_cols and B.n_rows = A.n_rows
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) auxlib::solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols;
const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols;
out.set_size(A_n_cols, B_n_cols);
if(A.is_empty() || B.is_empty()) if(A.is_empty() || B.is_empty())
{ {
out.zeros(A.n_cols, B.n_cols); out.zeros();
return true; return true;
} }
char trans = 'N'; char trans = 'N';
blas_int m = A.n_rows; blas_int m = blas_int(A_n_rows);
blas_int n = A.n_cols; blas_int n = blas_int(A_n_cols);
blas_int lda = A.n_rows; blas_int lda = blas_int(A_n_rows);
blas_int ldb = A.n_rows; blas_int ldb = blas_int(A_n_rows);
blas_int nrhs = B.n_cols; blas_int nrhs = blas_int(B_n_cols);
blas_int lwork = n + (std::max)(n, nrhs) + 2; // +2 for paranoia: som blas_int lwork = 2*((std::max)(blas_int(1), n + (std::max)(n, nrhs)));
e versions of Lapack might be trashing memory
blas_int info = 0; blas_int info = 0;
Mat<eT> tmp = B; Mat<eT> tmp = B;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
arma_extra_debug_print("lapack::gels()");
// 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()");
lapack::gels<eT> lapack::gels<eT>( &trans, &m, &n, &nrhs, A.memptr(), &lda, tmp.memptr()
( , &ldb, work.memptr(), &lwork, &info );
&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");
out.set_size(A.n_cols, B.n_cols); for(uword col=0; col<B_n_cols; ++col)
for(uword col=0; col<B.n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); arrayops::copy( out.colptr(col), tmp.colptr(col), A_n_cols );
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
arma_ignore(B); arma_ignore(B);
arma_stop("solve(): use of LAPACK needs to be enabled"); arma_stop("solve(): use of LAPACK needs to be enabled");
skipping to change at line 2482 skipping to change at line 2570
//! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows //! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) auxlib::solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols;
const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols;
out.set_size(A_n_cols, B_n_cols);
if(A.is_empty() || B.is_empty()) if(A.is_empty() || B.is_empty())
{ {
out.zeros(A.n_cols, B.n_cols); out.zeros();
return true; return true;
} }
char trans = 'N'; char trans = 'N';
blas_int m = A.n_rows; blas_int m = blas_int(A_n_rows);
blas_int n = A.n_cols; blas_int n = blas_int(A_n_cols);
blas_int lda = A.n_rows; blas_int lda = blas_int(A_n_rows);
blas_int ldb = A.n_cols; blas_int ldb = blas_int(A_n_cols);
blas_int nrhs = B.n_cols; blas_int nrhs = blas_int(B_n_cols);
blas_int lwork = m + (std::max)(m,nrhs) + 2; // +2 for paranoia: some blas_int lwork = 2*((std::max)(blas_int(1), m + (std::max)(m,nrhs)));
versions of Lapack might be trashing memory
blas_int info = 0; blas_int info = 0;
Mat<eT> tmp; Mat<eT> tmp(A_n_cols, B_n_cols);
tmp.zeros(A.n_cols, B.n_cols); 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 );
for(uword row=B.n_rows; row<A.n_cols; ++row) for(uword row=B_n_rows; row<A_n_cols; ++row)
{ {
tmp_colmem[row] = eT(0); tmp_colmem[row] = eT(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
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 );
arma_extra_debug_print("lapack::gels() -- finished");
for(uword col=0; col<B_n_cols; ++col)
{
arrayops::copy( out.colptr(col), tmp.colptr(col), A_n_cols );
}
return (info == 0);
}
#else
{
arma_ignore(out);
arma_ignore(A);
arma_ignore(B);
arma_stop("solve(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
//! Solve a system of linear equations.
//! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows
template<typename eT, typename T1>
inline
bool
auxlib::solve_new(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const boo
l slow)
{
arma_extra_debug_sigprint();
bool status = false;
const uword A_n_rows = A.n_rows;
if( (A_n_rows <= 4) && (slow == false) )
{
Mat<eT> A_inv;
status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows);
if(status == true)
{
const unwrap_check<T1> Y( X.get_ref(), out );
const Mat<eT>& B = Y.M;
const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols;
arma_debug_check( (A_n_rows != B_n_rows), "solve(): number of rows in
the given objects must be the same" );
if(A.is_empty() || B.is_empty())
{
out.zeros(A.n_cols, B_n_cols);
return true;
}
out.set_size(A_n_rows, B_n_cols);
gemm_emul<false,false,false,false>::apply(out, A_inv, B);
return true;
}
}
if( (A_n_rows > 4) || (status == false) )
{
out = X.get_ref();
const uword B_n_rows = out.n_rows;
const uword B_n_cols = out.n_cols;
arma_debug_check( (A_n_rows != B_n_rows), "solve(): number of rows in t
he given objects must be the same" );
if(A.is_empty() || out.is_empty())
{
out.zeros(A.n_cols, B_n_cols);
return true;
}
#if defined(ARMA_USE_ATLAS)
{
podarray<int> ipiv(A_n_rows + 2); // +2 for paranoia: old versions o
f Atlas might be trashing memory
int info = atlas::clapack_gesv<eT>(atlas::CblasColMajor, A_n_rows, B_
n_cols, A.memptr(), A_n_rows, ipiv.memptr(), out.memptr(), A_n_rows);
return (info == 0);
}
#elif defined(ARMA_USE_LAPACK)
{
blas_int n = blas_int(A_n_rows); // assuming A is square
blas_int lda = blas_int(A_n_rows);
blas_int ldb = blas_int(A_n_rows);
blas_int nrhs = blas_int(B_n_cols);
blas_int info = 0;
podarray<blas_int> ipiv(A_n_rows + 2); // +2 for paranoia: some vers
ions of Lapack might be trashing memory
arma_extra_debug_print("lapack::gesv()");
lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.memp
tr(), &ldb, &info);
arma_extra_debug_print("lapack::gesv() -- finished");
return (info == 0);
}
#else
{
arma_stop("solve(): use of ATLAS or LAPACK needs to be enabled");
return false;
}
#endif
}
return true;
}
//! Solve an over-determined system.
//! Assumes that A.n_rows > A.n_cols and B.n_rows = A.n_rows
template<typename eT, typename T1>
inline
bool
auxlib::solve_new_od(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
Mat<eT> tmp = X.get_ref();
const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols;
const uword B_n_rows = tmp.n_rows;
const uword B_n_cols = tmp.n_cols;
arma_debug_check( (A_n_rows != B_n_rows), "solve(): number of rows in t
he given objects must be the same" );
out.set_size(A_n_cols, B_n_cols);
if(A.is_empty() || tmp.is_empty())
{
out.zeros();
return true;
}
char trans = 'N';
blas_int m = blas_int(A_n_rows);
blas_int n = blas_int(A_n_cols);
blas_int lda = blas_int(A_n_rows);
blas_int ldb = blas_int(A_n_rows);
blas_int nrhs = blas_int(B_n_cols);
blas_int lwork = 2*((std::max)(blas_int(1), n + (std::max)(n, nrhs)));
blas_int info = 0;
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()");
lapack::gels<eT>( &trans, &m, &n, &nrhs, A.memptr(), &lda, tmp.memptr()
, &ldb, work.memptr(), &lwork, &info );
lapack::gels<eT> arma_extra_debug_print("lapack::gels() -- finished");
(
&trans, &m, &n, &nrhs, for(uword col=0; col<B_n_cols; ++col)
A.memptr(), &lda, {
tmp.memptr(), &ldb, arrayops::copy( out.colptr(col), tmp.colptr(col), A_n_cols );
work.memptr(), &lwork, }
&info
); return (info == 0);
}
#else
{
arma_ignore(out);
arma_ignore(A);
arma_ignore(X);
arma_stop("solve(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
//! Solve an under-determined system.
//! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows
template<typename eT, typename T1>
inline
bool
auxlib::solve_new_ud(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
const unwrap<T1> Y( X.get_ref() );
const Mat<eT>& B = Y.M;
const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols;
const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols;
arma_debug_check( (A_n_rows != B_n_rows), "solve(): number of rows in t
he given objects must be the same" );
// B could be an alias of "out", hence we need to check whether B is em
pty before setting the size of "out"
if(A.is_empty() || B.is_empty())
{
out.zeros(A_n_cols, B_n_cols);
return true;
}
char trans = 'N';
blas_int m = blas_int(A_n_rows);
blas_int n = blas_int(A_n_cols);
blas_int lda = blas_int(A_n_rows);
blas_int ldb = blas_int(A_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 info = 0;
Mat<eT> tmp(A_n_cols, B_n_cols);
tmp.zeros();
for(uword col=0; col<B_n_cols; ++col)
{
eT* tmp_colmem = tmp.colptr(col);
arrayops::copy( tmp_colmem, B.colptr(col), B_n_rows );
for(uword row=B_n_rows; row<A_n_cols; ++row)
{
tmp_colmem[row] = eT(0);
}
}
podarray<eT> work( static_cast<uword>(lwork) );
// NOTE: the dgels() function in the lapack library supplied by ATLAS 3
.6 seems to have problems
arma_extra_debug_print("lapack::gels()");
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");
out.set_size(A.n_cols, B.n_cols); out.set_size(A_n_cols, B_n_cols);
for(uword col=0; col<B.n_cols; ++col) for(uword col=0; col<B_n_cols; ++col)
{ {
arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); arrayops::copy( out.colptr(col), tmp.colptr(col), A_n_cols );
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(out); arma_ignore(out);
arma_ignore(A); arma_ignore(A);
arma_ignore(B); arma_ignore(X);
arma_stop("solve(): use of LAPACK needs to be enabled"); arma_stop("solve(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
// //
// solve_tr // solve_tr
template<typename eT> template<typename eT>
skipping to change at line 2616 skipping to change at line 2942
if(A.is_empty()) if(A.is_empty())
{ {
Z.reset(); Z.reset();
T.reset(); T.reset();
return true; return true;
} }
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);
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 * n; // workspace must be at least 3 blas_int info = 0;
* n (if set to -1, optimal size is output in work(0) and nothing else is do
ne
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);
blas_int info = 0;
Z.set_size(A_n_rows, A_n_rows);
T = A;
podarray<eT> wr(A_n_rows); // output for eigenvalues podarray<eT> 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);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(Z); arma_ignore(Z);
skipping to change at line 2673 skipping to change at line 2997
{ {
Z.reset(); Z.reset();
T.reset(); T.reset();
return true; return true;
} }
typedef std::complex<cT> eT; typedef std::complex<cT> eT;
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);
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 * n; // workspace must be at least 3 blas_int info = 0;
* n (if set to -1, optimal size is output in work(0) and nothing else is d
one
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);
blas_int info = 0;
Z.set_size(A_n_rows, A_n_rows);
T = A;
podarray<eT> w(A_n_rows); // output for eigenvalues podarray<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);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(Z); arma_ignore(Z);
 End of changes. 81 change blocks. 
180 lines changed or deleted 509 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 971 skipping to change at line 971
#else #else
#undef ARMA_EXTRA_DEBUG #undef ARMA_EXTRA_DEBUG
#define arma_debug_print true ? (void)0 : arma_print #define arma_debug_print true ? (void)0 : arma_print
#define arma_debug_warn true ? (void)0 : arma_warn #define arma_debug_warn true ? (void)0 : arma_warn
#define arma_debug_check true ? (void)0 : arma_check #define arma_debug_check true ? (void)0 : arma_check
#define arma_debug_set_error true ? (void)0 : arma_set_error #define arma_debug_set_error true ? (void)0 : arma_set_error
#define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s ize #define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s ize
#define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si ze #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si ze
#define arma_debug_assert_cube_as_mat true ? (void)0 : arma_assert_cube_a s_mat #define arma_debug_assert_cube_as_mat true ? (void)0 : arma_debug_assert_ cube_as_mat
#endif #endif
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint #define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint
#define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint #define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint
#define arma_extra_debug_print arma_print #define arma_extra_debug_print arma_print
#define arma_extra_debug_warn arma_warn #define arma_extra_debug_warn arma_warn
#define arma_extra_debug_check arma_check #define arma_extra_debug_check arma_check
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 diagmat_proxy.hpp   diagmat_proxy.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 diagmat_proxy //! \addtogroup diagmat_proxy
//! @{ //! @{
template<typename T1> template<typename T1>
class diagmat_proxy class diagmat_proxy_default
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const T1& X) inline
diagmat_proxy_default(const T1& X)
: P ( X ) : P ( X )
, P_is_vec( (P.get_n_rows() == 1) || (P.get_n_cols() == 1) ) , P_is_vec( (resolves_to_vector<T1>::value) || (P.get_n_rows() == 1) ||
, P_is_col( P.get_n_cols() == 1 ) (P.get_n_cols() == 1) )
, P_is_col( T1::is_col || (P.get_n_cols() == 1) )
, n_elem ( P_is_vec ? P.get_n_elem() : (std::min)(P.get_n_elem(), P.ge t_n_rows()) ) , n_elem ( P_is_vec ? P.get_n_elem() : (std::min)(P.get_n_elem(), P.ge t_n_rows()) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.get_n_rows() != P.get_n_cols()), (P_is_vec == false) && (P.get_n_rows() != P.get_n_cols()),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
skipping to change at line 94 skipping to change at line 95
return elem_type(0); return elem_type(0);
} }
} }
const Proxy<T1> P; const Proxy<T1> P;
const bool P_is_vec; const bool P_is_vec;
const bool P_is_col; const bool P_is_col;
const uword n_elem; const uword n_elem;
}; };
template<typename T1>
class diagmat_proxy_fixed
{
public:
typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
inline
diagmat_proxy_fixed(const T1& X)
: P(X)
{
arma_extra_debug_sigprint();
arma_debug_check
(
(P_is_vec == false) && (T1::n_rows != T1::n_cols),
"diagmat(): only vectors and square matrices are accepted"
);
}
arma_inline
elem_type
operator[](const uword i) const
{
return (P_is_vec) ? P[i] : P.at(i,i);
}
arma_inline
elem_type
at(const uword row, const uword col) const
{
if(row == col)
{
return (P_is_vec) ? P[row] : P.at(row,row);
}
else
{
return elem_type(0);
}
}
const T1& P;
static const bool P_is_vec = (T1::n_rows == 1) || (T1::n_cols == 1);
static const uword n_elem = P_is_vec ? T1::n_elem : ( (T1::n_elem < T1:
:n_rows) ? T1::n_elem : T1::n_rows );
};
template<typename T1, bool condition>
struct diagmat_proxy_redirect {};
template<typename T1>
struct diagmat_proxy_redirect<T1, false> { typedef diagmat_proxy_default<T1
> result; };
template<typename T1>
struct diagmat_proxy_redirect<T1, true> { typedef diagmat_proxy_fixed<T1>
result; };
template<typename T1>
class diagmat_proxy : public diagmat_proxy_redirect<T1, is_Mat_fixed<T1>::v
alue >::result
{
public:
inline diagmat_proxy(const T1& X)
: diagmat_proxy_redirect< T1, is_Mat_fixed<T1>::value >::result(X)
{
}
};
template<typename eT> template<typename eT>
class diagmat_proxy< Mat<eT> > class diagmat_proxy< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Mat<eT>& X) inline
: P(X) diagmat_proxy(const Mat<eT>& X)
, P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) ) : P ( X )
, n_elem( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) ) , P_is_vec( (X.n_rows == 1) || (X.n_cols == 1) )
, n_elem ( P_is_vec ? X.n_elem : (std::min)(X.n_elem, X.n_rows) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.n_rows != P.n_cols), (P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
skipping to change at line 132 skipping to change at line 201
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Row<eT> > class diagmat_proxy< Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Row<eT>& X) inline
diagmat_proxy(const Row<eT>& X)
: P(X) : P(X)
, P_is_vec(true) , n_elem(X.n_elem)
, n_elem(P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline elem_type operator[] (const uword i) const { return P[i]; } arma_inline elem_type operator[] (const uword i) const { return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); } arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const Row<eT>& P; const Row<eT>& P;
const bool P_is_vec;
const uword n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy< Col<eT> > class diagmat_proxy< Col<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy(const Col<eT>& X) inline
diagmat_proxy(const Col<eT>& X)
: P(X) : P(X)
, P_is_vec(true) , n_elem(X.n_elem)
, n_elem(P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline elem_type operator[] (const uword i) const { return P[i]; } arma_inline elem_type operator[] (const uword i) const { return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); } arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const Col<eT>& P; const Col<eT>& P;
const bool P_is_vec;
const uword n_elem; const uword n_elem;
}; };
template<typename eT>
class diagmat_proxy< subview_row<eT> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
inline
diagmat_proxy(const subview_row<eT>& X)
: P(X)
, n_elem(X.n_elem)
{
arma_extra_debug_sigprint();
}
arma_inline elem_type operator[] (const uword i) const
{ return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const subview_row<eT>& P;
const uword n_elem;
};
template<typename eT>
class diagmat_proxy< subview_col<eT> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
inline
diagmat_proxy(const subview_col<eT>& X)
: P(X)
, n_elem(X.n_elem)
{
arma_extra_debug_sigprint();
}
arma_inline elem_type operator[] (const uword i) const
{ return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const subview_col<eT>& P;
const uword n_elem;
};
//
//
//
template<typename T1> template<typename T1>
class diagmat_proxy_check class diagmat_proxy_check_default
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy_check(const T1& X, const Mat<typename T1::elem_type> inline
& out) diagmat_proxy_check_default(const T1& X, const Mat<typename T1::elem_type
>&)
: P(X) : P(X)
, P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) ) , P_is_vec( (resolves_to_vector<T1>::value) || (P.n_rows == 1) || (P.n_ cols == 1) )
, n_elem( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) ) , n_elem( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(out);
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.n_rows != P.n_cols), (P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
arma_inline elem_type operator[] (const uword i) const { return P_is_vec ? P[i] : P.at(i,i); } arma_inline elem_type operator[] (const uword i) const { return P_is_vec ? P[i] : P.at(i,i); }
arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type( 0); } arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type( 0); }
const Mat<elem_type> P; const Mat<elem_type> P;
const bool P_is_vec; const bool P_is_vec;
const uword n_elem; const uword n_elem;
}; };
template<typename T1>
class diagmat_proxy_check_fixed
{
public:
typedef typename T1::elem_type eT;
typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
inline
diagmat_proxy_check_fixed(const T1& X, const Mat<eT>& out)
: P( const_cast<eT*>(X.memptr()), T1::n_rows, T1::n_cols, (&X == &out),
false )
{
arma_extra_debug_sigprint();
arma_debug_check
(
(P_is_vec == false) && (T1::n_rows != T1::n_cols),
"diagmat(): only vectors and square matrices are accepted"
);
}
arma_inline eT operator[] (const uword i) const { retu
rn P_is_vec ? P[i] : P.at(i,i); }
arma_inline eT at (const uword row, const uword col) const { retu
rn (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type(0); }
const Mat<eT> P; // TODO: why not just store X directly as T1& ? test w
ith fixed size vectors and matrices
static const bool P_is_vec = (T1::n_rows == 1) || (T1::n_cols == 1);
static const uword n_elem = P_is_vec ? T1::n_elem : ( (T1::n_elem < T1:
:n_rows) ? T1::n_elem : T1::n_rows );
};
template<typename T1, bool condition>
struct diagmat_proxy_check_redirect {};
template<typename T1>
struct diagmat_proxy_check_redirect<T1, false> { typedef diagmat_proxy_chec
k_default<T1> result; };
template<typename T1>
struct diagmat_proxy_check_redirect<T1, true> { typedef diagmat_proxy_chec
k_fixed<T1> result; };
template<typename T1>
class diagmat_proxy_check : public diagmat_proxy_check_redirect<T1, is_Mat_
fixed<T1>::value >::result
{
public:
inline diagmat_proxy_check(const T1& X, const Mat<typename T1::elem_type>
& out)
: diagmat_proxy_check_redirect< T1, is_Mat_fixed<T1>::value >::result(X
, out)
{
}
};
template<typename eT> template<typename eT>
class diagmat_proxy_check< Mat<eT> > class diagmat_proxy_check< Mat<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy_check(const Mat<eT>& X, const Mat<eT>& out) inline
diagmat_proxy_check(const Mat<eT>& X, const Mat<eT>& out)
: P_local ( (&X == &out) ? new Mat<eT>(X) : 0 ) : P_local ( (&X == &out) ? new Mat<eT>(X) : 0 )
, P ( (&X == &out) ? (*P_local) : X ) , P ( (&X == &out) ? (*P_local) : X )
, P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) ) , P_is_vec( (P.n_rows == 1) || (P.n_cols == 1) )
, n_elem ( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) ) , n_elem ( P_is_vec ? P.n_elem : (std::min)(P.n_elem, P.n_rows) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(P_is_vec == false) && (P.n_rows != P.n_cols), (P_is_vec == false) && (P.n_rows != P.n_cols),
"diagmat(): only vectors and square matrices are accepted" "diagmat(): only vectors and square matrices are accepted"
); );
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local) { delete P_local; }
{
delete P_local;
}
} }
arma_inline elem_type operator[] (const uword i) const { return P_is_vec ? P[i] : P.at(i,i); } arma_inline elem_type operator[] (const uword i) const { return P_is_vec ? P[i] : P.at(i,i); }
arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type( 0); } arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? ( P_is_vec ? P[row] : P.at(row,row) ) : elem_type( 0); }
const Mat<eT>* P_local; const Mat<eT>* P_local;
const Mat<eT>& P; const Mat<eT>& P;
const bool P_is_vec; const bool P_is_vec;
const uword n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy_check< Row<eT> > class diagmat_proxy_check< Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy_check(const Row<eT>& X, const Mat<eT>& out) inline
diagmat_proxy_check(const Row<eT>& X, const Mat<eT>& out)
: P_local ( (&X == reinterpret_cast<const Row<eT>*>(&out)) ? new Row<eT >(X) : 0 ) : P_local ( (&X == reinterpret_cast<const Row<eT>*>(&out)) ? new Row<eT >(X) : 0 )
, P ( (&X == reinterpret_cast<const Row<eT>*>(&out)) ? (*P_local) : X ) , P ( (&X == reinterpret_cast<const Row<eT>*>(&out)) ? (*P_local) : X )
, P_is_vec(true) , n_elem (X.n_elem)
, n_elem (P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local) { delete P_local; }
{
delete P_local;
}
} }
arma_inline elem_type operator[] (const uword i) const { return P[i]; } arma_inline elem_type operator[] (const uword i) const { return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); } arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const Row<eT>* P_local; const Row<eT>* P_local;
const Row<eT>& P; const Row<eT>& P;
const bool P_is_vec;
const uword n_elem; const uword n_elem;
}; };
template<typename eT> template<typename eT>
class diagmat_proxy_check< Col<eT> > class diagmat_proxy_check< Col<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
inline diagmat_proxy_check(const Col<eT>& X, const Mat<eT>& out) inline
diagmat_proxy_check(const Col<eT>& X, const Mat<eT>& out)
: P_local ( (&X == reinterpret_cast<const Col<eT>*>(&out)) ? new Col<eT >(X) : 0 ) : P_local ( (&X == reinterpret_cast<const Col<eT>*>(&out)) ? new Col<eT >(X) : 0 )
, P ( (&X == reinterpret_cast<const Col<eT>*>(&out)) ? (*P_local) : X ) , P ( (&X == reinterpret_cast<const Col<eT>*>(&out)) ? (*P_local) : X )
, P_is_vec(true) , n_elem (X.n_elem)
, n_elem (P.n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline ~diagmat_proxy_check() inline ~diagmat_proxy_check()
{ {
if(P_local) if(P_local) { delete P_local; }
{
delete P_local;
}
} }
arma_inline elem_type operator[] (const uword i) const { return P[i]; } arma_inline elem_type operator[] (const uword i) const { return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); } arma_inline elem_type at (const uword row, const uword col) const { return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const Col<eT>* P_local; const Col<eT>* P_local;
const Col<eT>& P; const Col<eT>& P;
const bool P_is_vec;
const uword n_elem; const uword n_elem;
}; };
template<typename eT>
class diagmat_proxy_check< subview_row<eT> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
inline
diagmat_proxy_check(const subview_row<eT>& X, const Mat<eT>&)
: P ( X )
, n_elem ( X.n_elem )
{
arma_extra_debug_sigprint();
}
arma_inline elem_type operator[] (const uword i) const
{ return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const Row<eT> P;
const uword n_elem;
};
template<typename eT>
class diagmat_proxy_check< subview_col<eT> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
inline
diagmat_proxy_check(const subview_col<eT>& X, const Mat<eT>& out)
: P ( const_cast<eT*>(X.colptr(0)), X.n_rows, (&(X.m) == &out), fal
se )
, n_elem( X.n_elem )
//, X_ref ( X )
{
arma_extra_debug_sigprint();
}
arma_inline elem_type operator[] (const uword i) const
{ return P[i]; }
arma_inline elem_type at (const uword row, const uword col) const
{ return (row == col) ? P[row] : elem_type(0); }
static const bool P_is_vec = true;
const Col<eT> P;
const uword n_elem;
//const subview_col<eT>& X_ref; // prevents the compiler from potential
ly deleting X before we're done with it
};
//! @} //! @}
 End of changes. 32 change blocks. 
42 lines changed or deleted 289 lines changed or added


 diagview_bones.hpp   diagview_bones.hpp 
skipping to change at line 59 skipping to change at line 59
inline void operator-=(const eT val); inline void operator-=(const eT val);
inline void operator*=(const eT val); inline void operator*=(const eT val);
inline void operator/=(const eT val); inline void operator/=(const eT val);
template<typename T1> inline void operator= (const Base<eT,T1>& x); template<typename T1> inline void operator= (const Base<eT,T1>& x);
template<typename T1> inline void operator+=(const Base<eT,T1>& x); template<typename T1> inline void operator+=(const Base<eT,T1>& x);
template<typename T1> inline void operator-=(const Base<eT,T1>& x); template<typename T1> inline void operator-=(const Base<eT,T1>& x);
template<typename T1> inline void operator%=(const Base<eT,T1>& x); template<typename T1> inline void operator%=(const Base<eT,T1>& x);
template<typename T1> inline void operator/=(const Base<eT,T1>& x); template<typename T1> inline void operator/=(const Base<eT,T1>& x);
arma_inline eT& operator[](const uword i); arma_inline eT& operator[](const uword ii);
arma_inline eT operator[](const uword i) const; arma_inline eT operator[](const uword ii) const;
arma_inline eT& at(const uword i); arma_inline eT& at(const uword ii);
arma_inline eT at(const uword i) const; arma_inline eT at(const uword ii) const;
arma_inline eT& operator()(const uword i); arma_inline eT& operator()(const uword ii);
arma_inline eT operator()(const uword i) const; arma_inline eT operator()(const uword ii) const;
arma_inline eT& at(const uword in_n_row, const uword); arma_inline eT& at(const uword in_n_row, const uword);
arma_inline eT at(const uword in_n_row, const uword) const; arma_inline eT at(const uword in_n_row, const uword) const;
arma_inline eT& operator()(const uword in_n_row, const uword in_n_col); arma_inline eT& operator()(const uword in_n_row, const uword in_n_col);
arma_inline eT operator()(const uword in_n_row, const uword in_n_col) co nst; arma_inline eT operator()(const uword in_n_row, const uword in_n_col) co nst;
arma_inline const Op<diagview<eT>,op_htrans> t() const; arma_inline const Op<diagview<eT>,op_htrans> t() const;
arma_inline const Op<diagview<eT>,op_htrans> ht() const; arma_inline const Op<diagview<eT>,op_htrans> ht() const;
arma_inline const Op<diagview<eT>,op_strans> st() const; arma_inline const Op<diagview<eT>,op_strans> st() const;
 End of changes. 3 change blocks. 
6 lines changed or deleted 6 lines changed or added


 diagview_meat.hpp   diagview_meat.hpp 
skipping to change at line 43 skipping to change at line 43
} }
//! set a diagonal of our matrix using a diagonal from a foreign matrix //! set a diagonal of our matrix using a diagonal from a foreign matrix
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator= (const diagview<eT>& x) diagview<eT>::operator= (const diagview<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>& t = *this; diagview<eT>& d = *this;
arma_debug_check( (t.n_elem != x.n_elem), "diagview: diagonals have incom patible lengths"); arma_debug_check( (d.n_elem != x.n_elem), "diagview: diagonals have incom patible lengths");
Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m); Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
const Mat<eT>& x_m = x.m; const Mat<eT>& x_m = x.m;
if(&t_m != &x_m) if(&d_m != &x_m)
{ {
const uword t_n_elem = t.n_elem; const uword d_n_elem = d.n_elem;
const uword t_row_offset = t.row_offset; const uword d_row_offset = d.row_offset;
const uword t_col_offset = t.col_offset; const uword d_col_offset = d.col_offset;
const uword x_row_offset = x.row_offset; const uword x_row_offset = x.row_offset;
const uword x_col_offset = x.col_offset; const uword x_col_offset = x.col_offset;
uword i,j; uword ii,jj;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{ {
const eT tmp_i = x_m.at(i + x_row_offset, i + x_col_offset); const eT tmp_i = x_m.at(ii + x_row_offset, ii + x_col_offset);
const eT tmp_j = x_m.at(j + x_row_offset, j + x_col_offset); const eT tmp_j = x_m.at(jj + x_row_offset, jj + x_col_offset);
t_m.at(i + t_row_offset, i + t_col_offset) = tmp_i; d_m.at(ii + d_row_offset, ii + d_col_offset) = tmp_i;
t_m.at(j + t_row_offset, j + t_col_offset) = tmp_j; d_m.at(jj + d_row_offset, jj + d_col_offset) = tmp_j;
} }
if(i < t_n_elem) if(ii < d_n_elem)
{ {
t_m.at(i + t_row_offset, i + t_col_offset) = x_m.at(i + x_row_offset, i + x_col_offset); d_m.at(ii + d_row_offset, ii + d_col_offset) = x_m.at(ii + x_row_offs et, ii + x_col_offset);
} }
} }
else else
{ {
const Mat<eT> tmp = x; const Mat<eT> tmp = x;
(*this).operator=(tmp); (*this).operator=(tmp);
} }
} }
skipping to change at line 95 skipping to change at line 95
diagview<eT>::operator+=(const eT val) diagview<eT>::operator+=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = const_cast< Mat<eT>& >(m); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword ii=0; ii < t_n_elem; ++ii)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) += val; t_m.at( ii + t_row_offset, ii + t_col_offset) += val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator-=(const eT val) diagview<eT>::operator-=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = const_cast< Mat<eT>& >(m); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword ii=0; ii < t_n_elem; ++ii)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) -= val; t_m.at( ii + t_row_offset, ii + t_col_offset) -= val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator*=(const eT val) diagview<eT>::operator*=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = const_cast< Mat<eT>& >(m); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword ii=0; ii < t_n_elem; ++ii)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) *= val; t_m.at( ii + t_row_offset, ii + t_col_offset) *= val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator/=(const eT val) diagview<eT>::operator/=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = const_cast< Mat<eT>& >(m); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword ii=0; ii < t_n_elem; ++ii)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) /= val; t_m.at( ii + t_row_offset, ii + t_col_offset) /= val;
} }
} }
//! set a diagonal of our matrix using data from a foreign object //! set a diagonal of our matrix using data from a foreign object
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator= (const Base<eT,T1>& o) diagview<eT>::operator= (const Base<eT,T1>& o)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(o.get_ref()); diagview<eT>& d = *this;
const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
const uword d_n_elem = d.n_elem;
const uword d_row_offset = d.row_offset;
const uword d_col_offset = d.col_offset;
const Proxy<T1> P( o.get_ref() );
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (d.n_elem != P.get_n_elem()) || ((P.get_n_rows() != 1) && (P.get_n_co ls() != 1)) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m); const bool is_alias = P.is_alias(d_m);
const uword t_n_elem = t.n_elem; arma_extra_debug_warn(is_alias, "aliasing detected");
const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (Proxy<T1
>::prefer_at_accessor == true) || (is_alias == true) )
uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
const eT tmp_i = x_mem[i]; const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const eT tmp_j = x_mem[j]; const Mat<eT>& x = tmp.M;
t_m.at( i + t_row_offset, i + t_col_offset) = tmp_i; const eT* x_mem = x.memptr();
t_m.at( j + t_row_offset, j + t_col_offset) = tmp_j;
} uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = x_mem[ii];
const eT tmp_j = x_mem[jj];
if(i < t_n_elem) d_m.at( ii + d_row_offset, ii + d_col_offset) = tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) = tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) = x_mem[ii];
}
}
else
{ {
t_m.at( i + t_row_offset, i + t_col_offset) = x_mem[i]; typename Proxy<T1>::ea_type Pea = P.get_ea();
uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = Pea[ii];
const eT tmp_j = Pea[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) = tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) = tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) = Pea[ii];
}
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator+=(const Base<eT,T1>& o) diagview<eT>::operator+=(const Base<eT,T1>& o)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(o.get_ref()); diagview<eT>& d = *this;
const Mat<eT>& x = tmp.M;
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
const uword d_n_elem = d.n_elem;
const uword d_row_offset = d.row_offset;
const uword d_col_offset = d.col_offset;
diagview<eT>& t = *this; const Proxy<T1> P( o.get_ref() );
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (d.n_elem != P.get_n_elem()) || ((P.get_n_rows() != 1) && (P.get_n_co ls() != 1)) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m); const bool is_alias = P.is_alias(d_m);
const uword t_n_elem = t.n_elem; arma_extra_debug_warn(is_alias, "aliasing detected");
const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (Proxy<T1
>::prefer_at_accessor == true) || (is_alias == true) )
uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
const eT tmp_i = x_mem[i]; const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const eT tmp_j = x_mem[j]; const Mat<eT>& x = tmp.M;
t_m.at( i + t_row_offset, i + t_col_offset) += tmp_i; const eT* x_mem = x.memptr();
t_m.at( j + t_row_offset, j + t_col_offset) += tmp_j;
}
if(i < t_n_elem) uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = x_mem[ii];
const eT tmp_j = x_mem[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) += tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) += tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) += x_mem[ii];
}
}
else
{ {
t_m.at( i + t_row_offset, i + t_col_offset) += x_mem[i]; typename Proxy<T1>::ea_type Pea = P.get_ea();
uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = Pea[ii];
const eT tmp_j = Pea[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) += tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) += tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) += Pea[ii];
}
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator-=(const Base<eT,T1>& o) diagview<eT>::operator-=(const Base<eT,T1>& o)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(o.get_ref()); diagview<eT>& d = *this;
const Mat<eT>& x = tmp.M;
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
diagview<eT>& t = *this; const uword d_n_elem = d.n_elem;
const uword d_row_offset = d.row_offset;
const uword d_col_offset = d.col_offset;
const Proxy<T1> P( o.get_ref() );
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (d.n_elem != P.get_n_elem()) || ((P.get_n_rows() != 1) && (P.get_n_co ls() != 1)) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m); const bool is_alias = P.is_alias(d_m);
const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); arma_extra_debug_warn(is_alias, "aliasing detected");
uword i,j; if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (Proxy<T1
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) >::prefer_at_accessor == true) || (is_alias == true) )
{ {
const eT tmp_i = x_mem[i]; const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const eT tmp_j = x_mem[j]; const Mat<eT>& x = tmp.M;
t_m.at( i + t_row_offset, i + t_col_offset) -= tmp_i; const eT* x_mem = x.memptr();
t_m.at( j + t_row_offset, j + t_col_offset) -= tmp_j;
} uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = x_mem[ii];
const eT tmp_j = x_mem[jj];
if(i < t_n_elem) d_m.at( ii + d_row_offset, ii + d_col_offset) -= tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) -= tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) -= x_mem[ii];
}
}
else
{ {
t_m.at( i + t_row_offset, i + t_col_offset) -= x_mem[i]; typename Proxy<T1>::ea_type Pea = P.get_ea();
uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = Pea[ii];
const eT tmp_j = Pea[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) -= tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) -= tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) -= Pea[ii];
}
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator%=(const Base<eT,T1>& o) diagview<eT>::operator%=(const Base<eT,T1>& o)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(o.get_ref()); diagview<eT>& d = *this;
const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
const uword d_n_elem = d.n_elem;
const uword d_row_offset = d.row_offset;
const uword d_col_offset = d.col_offset;
const Proxy<T1> P( o.get_ref() );
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (d.n_elem != P.get_n_elem()) || ((P.get_n_rows() != 1) && (P.get_n_co ls() != 1)) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m); const bool is_alias = P.is_alias(d_m);
const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); arma_extra_debug_warn(is_alias, "aliasing detected");
uword i,j; if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (Proxy<T1
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) >::prefer_at_accessor == true) || (is_alias == true) )
{ {
const eT tmp_i = x_mem[i]; const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const eT tmp_j = x_mem[j]; const Mat<eT>& x = tmp.M;
t_m.at( i + t_row_offset, i + t_col_offset) *= tmp_i; const eT* x_mem = x.memptr();
t_m.at( j + t_row_offset, j + t_col_offset) *= tmp_j;
} uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = x_mem[ii];
const eT tmp_j = x_mem[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) *= tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) *= tmp_j;
}
if(i < t_n_elem) if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) *= x_mem[ii];
}
}
else
{ {
t_m.at( i + t_row_offset, i + t_col_offset) *= x_mem[i]; typename Proxy<T1>::ea_type Pea = P.get_ea();
uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = Pea[ii];
const eT tmp_j = Pea[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) *= tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) *= tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) *= Pea[ii];
}
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
diagview<eT>::operator/=(const Base<eT,T1>& o) diagview<eT>::operator/=(const Base<eT,T1>& o)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(o.get_ref()); diagview<eT>& d = *this;
const Mat<eT>& x = tmp.M;
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
const uword d_n_elem = d.n_elem;
const uword d_row_offset = d.row_offset;
const uword d_col_offset = d.col_offset;
diagview<eT>& t = *this; const Proxy<T1> P( o.get_ref() );
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (d.n_elem != P.get_n_elem()) || ((P.get_n_rows() != 1) && (P.get_n_co ls() != 1)) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m); const bool is_alias = P.is_alias(d_m);
const uword t_n_elem = t.n_elem; arma_extra_debug_warn(is_alias, "aliasing detected");
const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (Proxy<T1
>::prefer_at_accessor == true) || (is_alias == true) )
uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
const eT tmp_i = x_mem[i]; const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const eT tmp_j = x_mem[j]; const Mat<eT>& x = tmp.M;
t_m.at( i + t_row_offset, i + t_col_offset) /= tmp_i; const eT* x_mem = x.memptr();
t_m.at( j + t_row_offset, j + t_col_offset) /= tmp_j;
}
if(i < t_n_elem) uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = x_mem[ii];
const eT tmp_j = x_mem[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) /= tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) /= tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) /= x_mem[ii];
}
}
else
{ {
t_m.at( i + t_row_offset, i + t_col_offset) /= x_mem[i]; typename Proxy<T1>::ea_type Pea = P.get_ea();
uword ii,jj;
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
{
const eT tmp_i = Pea[ii];
const eT tmp_j = Pea[jj];
d_m.at( ii + d_row_offset, ii + d_col_offset) /= tmp_i;
d_m.at( jj + d_row_offset, jj + d_col_offset) /= tmp_j;
}
if(ii < d_n_elem)
{
d_m.at( ii + d_row_offset, ii + d_col_offset) /= Pea[ii];
}
} }
} }
//! extract a diagonal and store it as a column vector //! extract a diagonal and store it as a column vector
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::extract(Mat<eT>& out, const diagview<eT>& in) diagview<eT>::extract(Mat<eT>& out, const diagview<eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 548 skipping to change at line 688
if(i < in_n_elem) if(i < in_n_elem)
{ {
out_mem[i] /= in_m.at( i + in_row_offset, i + in_col_offset ); out_mem[i] /= in_m.at( i + in_row_offset, i + in_col_offset );
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator[](const uword i) diagview<eT>::operator[](const uword ii)
{ {
return (const_cast< Mat<eT>& >(m)).at(i+row_offset, i+col_offset); return (const_cast< Mat<eT>& >(m)).at(ii+row_offset, ii+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator[](const uword i) const diagview<eT>::operator[](const uword ii) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(ii+row_offset, ii+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const uword i) diagview<eT>::at(const uword ii)
{ {
return (const_cast< Mat<eT>& >(m)).at(i+row_offset, i+col_offset); return (const_cast< Mat<eT>& >(m)).at(ii+row_offset, ii+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::at(const uword i) const diagview<eT>::at(const uword ii) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(ii+row_offset, ii+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator()(const uword i) diagview<eT>::operator()(const uword ii)
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (ii >= n_elem), "diagview::operator(): out of bounds" ) ;
return (const_cast< Mat<eT>& >(m)).at(i+row_offset, i+col_offset); return (const_cast< Mat<eT>& >(m)).at(ii+row_offset, ii+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator()(const uword i) const diagview<eT>::operator()(const uword ii) const
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (ii >= n_elem), "diagview::operator(): out of bounds" ) ;
return m.at(i+row_offset, i+col_offset); return m.at(ii+row_offset, ii+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const uword row, const uword) diagview<eT>::at(const uword row, const uword)
{ {
return (const_cast< Mat<eT>& >(m)).at(row+row_offset, row+col_offset); return (const_cast< Mat<eT>& >(m)).at(row+row_offset, row+col_offset);
} }
skipping to change at line 666 skipping to change at line 806
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::fill(const eT val) diagview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& x = const_cast< Mat<eT>& >(m); Mat<eT>& x = const_cast< Mat<eT>& >(m);
for(uword i=0; i<n_elem; ++i) for(uword ii=0; ii < n_elem; ++ii)
{ {
x.at(i+row_offset, i+col_offset) = val; x.at(ii+row_offset, ii+col_offset) = val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::zeros() diagview<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 84 change blocks. 
134 lines changed or deleted 279 lines changed or added


 diskio_bones.hpp   diskio_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
// Copyright (C) 2009-2010 Ian Cullinan // Copyright (C) 2009-2010 Ian Cullinan
// Copyright (C) 2012 Matthew Amidon
// //
// 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 47 skipping to change at line 48
// //
// matrix saving // matrix saving
template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, const std::string& final_name); template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, const std::string& final_name); template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, const std::string& final_name); template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, const std::string& final_name); template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, const std::string& final_name); template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, const std::string& final_name); template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, const std::string& final_name);
template<typename T> inline static bool save_pgm_binary (const Mat< std: :complex<T> >& x, const std::string& final_name); template<typename T> inline static bool save_pgm_binary (const Mat< std: :complex<T> >& x, const std::string& final_name);
template<typename eT> inline static bool save_hdf5_binary(const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, std::ostream& f); template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, std::ostream& f); template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, std::ostream& f); template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, std::ostream& f); template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, std::ostream& f); template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, std::ostream& f); template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, std::ostream& f);
template<typename T> inline static bool save_pgm_binary (const Mat< std: :complex<T> >& x, std::ostream& f); template<typename T> inline static bool save_pgm_binary (const Mat< std: :complex<T> >& x, std::ostream& f);
// //
// matrix loading // matrix loading
template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename T> inline static bool load_pgm_binary (Mat< std::compl ex<T> >& x, const std::string& name, std::string& err_msg); template<typename T> inline static bool load_pgm_binary (Mat< std::compl ex<T> >& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_hdf5_binary(Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, const std::string& name, std::string& err_msg); template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg); template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, std::istream& f, std::string& err_msg); template<typename eT> inline static bool load_raw_binary (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_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);
 End of changes. 4 change blocks. 
2 lines changed or deleted 5 lines changed or added


 diskio_meat.hpp   diskio_meat.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
// Copyright (C) 2009-2010 Ian Cullinan // Copyright (C) 2009-2010 Ian Cullinan
// Copyright (C) 2012 Matthew Amidon
// //
// 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 958 skipping to change at line 959
bool bool
diskio::save_pgm_binary(const Mat< std::complex<T> >& x, std::ostream& f) diskio::save_pgm_binary(const Mat< std::complex<T> >& x, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uchar_mat tmp = conv_to<uchar_mat>::from(x); const uchar_mat tmp = conv_to<uchar_mat>::from(x);
return diskio::save_pgm_binary(tmp, f); return diskio::save_pgm_binary(tmp, f);
} }
//! Save a matrix as part of a HDF5 file
template<typename eT>
inline
bool
diskio::save_hdf5_binary(const Mat<eT>& x, const std::string& final_name)
{
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)
{
bool save_okay = false;
const std::string tmp_name = diskio::gen_tmp_name(final_name);
// 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);
// We need to create a dataset, datatype, and dataspace
hsize_t dims[2];
dims[0] = x.n_rows;
dims[1] = 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
it), float, double, std::complex<float>, std::complex<double>
// hid_t datatype = H5Tcopy(...)
// TODO: test by loading in Octave
// TODO: test by loading in Matlab with h5read()
// TODO: what are the default dataset names used by Matlab and Octave ?
hid_t dataset = H5Dcreate(file, "dataset", datatype, dataspace, H5P_DEF
AULT, H5P_DEFAULT, H5P_DEFAULT);
herr_t status = H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAU
LT, x.mem);
save_okay = (status >= 0);
H5Dclose(dataset);
H5Tclose(datatype);
H5Sclose(dataspace);
H5Fclose(file);
if(save_okay == true) { save_okay = diskio::safe_rename(tmp_name, final
_name); }
return save_okay;
}
#else
{
arma_ignore(x);
arma_ignore(final_name);
arma_stop("Mat::save(): use of HDF5 needs to be enabled");
return false;
}
#endif
}
//! Load a matrix as raw text (no header, human readable). //! Load a matrix as raw text (no header, human readable).
//! Can read matrices saved as text in Matlab and Octave. //! Can read matrices saved as text in Matlab and Octave.
//! NOTE: this is much slower than reading a file with a header. //! NOTE: this is much slower than reading a file with a header.
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_raw_ascii(Mat<eT>& x, const std::string& name, std::string& er r_msg) diskio::load_raw_ascii(Mat<eT>& x, const std::string& name, std::string& er r_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1543 skipping to change at line 1604
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
uchar_mat tmp; uchar_mat tmp;
const bool load_okay = diskio::load_pgm_binary(tmp, is, err_msg); const bool load_okay = diskio::load_pgm_binary(tmp, is, err_msg);
x = conv_to< Mat< std::complex<T> > >::from(tmp); x = conv_to< Mat< std::complex<T> > >::from(tmp);
return load_okay; return load_okay;
} }
template<typename eT>
inline
bool
diskio::load_hdf5_binary(Mat<eT>& x, const std::string& name, std::string&
err_msg)
{
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)
{
bool load_okay = false;
hid_t fid = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if(fid >= 0)
{
// TODO: do Matlab and Octave have default dataset names ?
hid_t dataset = H5Dopen(fid, "dataset", H5P_DEFAULT);
if(dataset >= 0)
{
hid_t filespace = H5Dget_space(dataset);
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,
dims, NULL);
if(query_status >= 0)
{
const uword n_rows = dims[0];
const uword n_cols = dims[1];
hid_t datatype = H5Dget_type(dataset);
const size_t element_size = H5Tget_size(datatype);
// TODO: rather than checking the element_size, we should reall
y figure out the exact type stored in the file (eg. float, double, ...)
if( element_size == sizeof(eT) )
{
x.set_size(n_rows, n_cols);
// TODO: should H5S_ALL be used ?
hid_t read_status = H5Dread( dataset, datatype, H5S_ALL, H5S_
ALL, H5P_DEFAULT, void_ptr(x.memptr()) );
load_okay = (read_status >= 0);
}
H5Tclose(datatype);
}
}
H5Sclose(filespace);
}
H5Dclose(dataset);
}
H5Fclose(fid);
if(load_okay == false) { err_msg = "unsupported or incorrect HDF5 data
in "; }
return load_okay;
}
#else
{
arma_ignore(x);
arma_ignore(name);
arma_ignore(err_msg);
arma_stop("Mat::load(): use of HDF5 needs to be enabled");
return false;
}
#endif
}
//! Try to load a matrix by automatically determining its type //! Try to load a matrix by automatically determining its type
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_auto_detect(Mat<eT>& x, const std::string& name, std::string& err_msg) diskio::load_auto_detect(Mat<eT>& x, const std::string& name, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_HDF5)
// We're currently using the C bindings for the HDF5 library, which don
't support C++ streams
if( H5Fis_hdf5(name.c_str()) ) { return load_hdf5_binary(x, name, err_m
sg); }
#endif
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
bool load_okay = f.is_open(); bool load_okay = f.is_open();
if(load_okay == true) if(load_okay == true)
{ {
load_okay = diskio::load_auto_detect(x, f, err_msg); load_okay = diskio::load_auto_detect(x, f, err_msg);
f.close(); f.close();
} }
 End of changes. 5 change blocks. 
2 lines changed or deleted 167 lines changed or added


 eGlue_bones.hpp   eGlue_bones.hpp 
skipping to change at line 28 skipping to change at line 28
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Proxy<T1> proxy1_type; typedef Proxy<T1> proxy1_type;
typedef Proxy<T2> proxy2_type; typedef Proxy<T2> proxy2_type;
static const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor); static const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
static const bool has_subview = (Proxy<T1>::has_subview || Proxy<T2>::has_subview ); static const bool has_subview = (Proxy<T1>::has_subview || Proxy<T2>::has_subview );
static const bool is_fixed = (Proxy<T1>::is_fixed || Proxy<T2>::is_fixed );
static const bool is_col = (Proxy<T1>::is_col || Proxy<T2>::is_col); static const bool is_col = (Proxy<T1>::is_col || Proxy<T2>::is_col);
static const bool is_row = (Proxy<T1>::is_row || Proxy<T2>::is_row); static const bool is_row = (Proxy<T1>::is_row || Proxy<T2>::is_row);
arma_aligned const Proxy<T1> P1; arma_aligned const Proxy<T1> P1;
arma_aligned const Proxy<T2> P2; arma_aligned const Proxy<T2> P2;
arma_inline ~eGlue(); arma_inline ~eGlue();
arma_inline eGlue(const T1& in_A, const T2& in_B); arma_inline eGlue(const T1& in_A, const T2& in_B);
arma_inline uword get_n_rows() const; arma_inline uword get_n_rows() const;
arma_inline uword get_n_cols() const; arma_inline uword get_n_cols() const;
arma_inline uword get_n_elem() const; arma_inline uword get_n_elem() const;
arma_inline elem_type operator[] (const uword i) const ; arma_inline elem_type operator[] (const uword ii) const ;
arma_inline elem_type at (const uword row, const uword col) const ; arma_inline elem_type at (const uword row, const uword col) const ;
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
1 lines changed or deleted 2 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 : P1.get_n_rows(); return is_row ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_rows() : P2.get_n_ro ws() );
} }
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 : P1.get_n_cols(); return is_col ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_cols() : P2.get_n_co ls() );
} }
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 P1.get_n_elem(); return Proxy<T1>::is_fixed ? P1.get_n_elem() : P2.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 i) 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
if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1
[i] + P2[i]; } [ii] + P2[ii]; }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1
[i] - P2[i]; } [ii] - P2[ii]; }
else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1
[i] / P2[i]; } [ii] / P2[ii]; }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1
[i] * P2[i]; } [ii] * P2[ii]; }
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eGlue<T1,T2,eglue_type>::at(const uword row, const uword col) const eGlue<T1,T2,eglue_type>::at(const uword row, const uword col) const
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
 End of changes. 5 change blocks. 
12 lines changed or deleted 12 lines changed or added


 eOp_bones.hpp   eOp_bones.hpp 
skipping to change at line 27 skipping to change at line 27
class eOp : public Base<typename T1::elem_type, eOp<T1, eop_type> > class eOp : public Base<typename T1::elem_type, eOp<T1, eop_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Proxy<T1> proxy_type; typedef Proxy<T1> proxy_type;
static const bool prefer_at_accessor = Proxy<T1>::prefer_at_accessor; static const bool prefer_at_accessor = Proxy<T1>::prefer_at_accessor;
static const bool has_subview = Proxy<T1>::has_subview; static const bool has_subview = Proxy<T1>::has_subview;
static const bool is_fixed = Proxy<T1>::is_fixed;
static const bool is_row = Proxy<T1>::is_row; static const bool is_row = Proxy<T1>::is_row;
static const bool is_col = Proxy<T1>::is_col; static const bool is_col = Proxy<T1>::is_col;
arma_aligned const Proxy<T1> P; arma_aligned const Proxy<T1> P;
arma_aligned elem_type aux; //!< storage of auxiliary data , user defined format arma_aligned elem_type aux; //!< storage of auxiliary data , user defined format
arma_aligned uword aux_uword_a; //!< storage of auxiliary data , uword format arma_aligned uword aux_uword_a; //!< storage of auxiliary data , uword format
arma_aligned uword aux_uword_b; //!< storage of auxiliary data , uword format arma_aligned uword aux_uword_b; //!< storage of auxiliary data , uword format
inline ~eOp(); inline ~eOp();
inline explicit eOp(const T1& in_m); inline explicit eOp(const T1& in_m);
inline eOp(const T1& in_m, const elem_type in_aux); inline eOp(const T1& in_m, const elem_type in_aux);
inline eOp(const T1& in_m, const uword in_aux_uword_a, const uwo rd in_aux_uword_b); inline eOp(const T1& in_m, const uword in_aux_uword_a, const uwo rd in_aux_uword_b);
inline eOp(const T1& in_m, const elem_type in_aux, const uword i n_aux_uword_a, const uword in_aux_uword_b); inline eOp(const T1& in_m, const elem_type in_aux, const uword i n_aux_uword_a, const uword in_aux_uword_b);
arma_inline uword get_n_rows() const; arma_inline uword get_n_rows() const;
arma_inline uword get_n_cols() const; arma_inline uword get_n_cols() const;
arma_inline uword get_n_elem() const; arma_inline uword get_n_elem() const;
arma_inline elem_type operator[] (const uword i) const ; arma_inline elem_type operator[] (const uword ii) const ;
arma_inline elem_type at (const uword row, const uword col) const ; arma_inline elem_type at (const uword row, const uword col) const ;
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
1 lines changed or deleted 2 lines changed or added


 eOp_meat.hpp   eOp_meat.hpp 
skipping to change at line 83 skipping to change at line 83
arma_inline arma_inline
uword uword
eOp<T1, eop_type>::get_n_elem() const eOp<T1, eop_type>::get_n_elem() const
{ {
return P.get_n_elem(); return P.get_n_elem();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOp<T1, eop_type>::operator[] (const uword i) const eOp<T1, eop_type>::operator[] (const uword ii) const
{ {
return eop_core<eop_type>::process(P[i], aux); return eop_core<eop_type>::process(P[ii], aux);
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOp<T1, eop_type>::at(const uword row, const uword col) const eOp<T1, eop_type>::at(const uword row, const uword col) const
{ {
if(is_row) if(is_row)
{ {
return eop_core<eop_type>::process(P.at(0, col), aux); return eop_core<eop_type>::process(P.at(0, col), aux);
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 eglue_core_meat.hpp   eglue_core_meat.hpp 
skipping to change at line 178 skipping to change at line 178
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
// NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; // NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o r operator=() // size setting and alias checking is done by either the Mat contructor o r operator=()
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(=, *); }
} }
else else
skipping to change at line 225 skipping to change at line 226
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); }
} }
else else
skipping to change at line 269 skipping to change at line 271
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); }
} }
else else
skipping to change at line 313 skipping to change at line 316
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); }
} }
else else
skipping to change at line 357 skipping to change at line 361
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); }
} }
else else
skipping to change at line 450 skipping to change at line 455
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); }
} }
else else
skipping to change at line 495 skipping to change at line 500
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); }
} }
else else
skipping to change at line 540 skipping to change at line 545
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); }
} }
else else
skipping to change at line 585 skipping to change at line 590
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor); const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea(); typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea(); typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); }
} }
else else
 End of changes. 9 change blocks. 
4 lines changed or deleted 9 lines changed or added


 eop_core_meat.hpp   eop_core_meat.hpp 
skipping to change at line 135 skipping to change at line 135
// NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; // NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o r operator=() // size setting and alias checking is done by either the Mat contructor o r operator=()
const eT k = x.aux; const eT k = x.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P = x.P.get_ea(); typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(=); arma_applier_1(=);
} }
else else
{ {
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
skipping to change at line 167 skipping to change at line 168
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion");
eT* out_mem = out.memptr(); const eT k = x.aux;
const uword n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT k = x.aux;
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this
causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P = x.P.get_ea(); typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(+=); arma_applier_1(+=);
} }
else else
{ {
const Proxy<T1>& P = x.P; const Proxy<T1>& P = x.P;
arma_applier_2(+=); arma_applier_2(+=);
} }
skipping to change at line 202 skipping to change at line 204
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction");
eT* out_mem = out.memptr(); const eT k = x.aux;
const uword n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT k = x.aux;
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this
causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P = x.P.get_ea(); typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(-=); arma_applier_1(-=);
} }
else else
{ {
const Proxy<T1>& P = x.P; const Proxy<T1>& P = x.P;
arma_applier_2(-=); arma_applier_2(-=);
} }
skipping to change at line 237 skipping to change at line 240
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication");
eT* out_mem = out.memptr(); const eT k = x.aux;
const uword n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT k = x.aux;
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this
causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P = x.P.get_ea(); typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(*=); arma_applier_1(*=);
} }
else else
{ {
const Proxy<T1>& P = x.P; const Proxy<T1>& P = x.P;
arma_applier_2(*=); arma_applier_2(*=);
} }
skipping to change at line 272 skipping to change at line 276
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division");
const eT k = x.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem;
const eT k = x.aux;
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
//const uword n_elem = x.get_n_elem(); // for fixed-sized matrices this
causes a mis-optimisation (slowdown) of the loop under GCC 4.4
typename Proxy<T1>::ea_type P = x.P.get_ea(); typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(/=); arma_applier_1(/=);
} }
else else
{ {
const Proxy<T1>& P = x.P; const Proxy<T1>& P = x.P;
arma_applier_2(/=); arma_applier_2(/=);
} }
skipping to change at line 305 skipping to change at line 310
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply(Cube<typename T1::elem_type>& out, const eOpCube< T1, eop_type>& x) eop_core<eop_type>::apply(Cube<typename T1::elem_type>& out, const eOpCube< T1, eop_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const uword n_slices = out.n_slices;
const uword n_elem = out.n_elem;
// NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; // NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o r operator=() // size setting and alias checking is done by either the Mat contructor o r operator=()
const eT k = x.aux; const eT k = x.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(ProxyCube<T1>::prefer_at_accessor == false) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P = x.P.get_ea(); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(=); arma_applier_1(=);
} }
else else
{ {
const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
const uword n_slices = x.get_n_slices();
const ProxyCube<T1>& P = x.P; const ProxyCube<T1>& P = x.P;
arma_applier_3(=); arma_applier_3(=);
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
skipping to change at line 347 skipping to change at line 353
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const uword n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
eT* out_mem = out.memptr(); const eT k = x.aux;
const uword n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT k = x.aux;
if(ProxyCube<T1>::prefer_at_accessor == false) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P = x.P.get_ea(); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(+=); arma_applier_1(+=);
} }
else else
{ {
const ProxyCube<T1>& P = x.P; const ProxyCube<T1>& P = x.P;
arma_applier_3(+=); arma_applier_3(+=);
} }
skipping to change at line 383 skipping to change at line 389
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const uword n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
eT* out_mem = out.memptr(); const eT k = x.aux;
const uword n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT k = x.aux;
if(ProxyCube<T1>::prefer_at_accessor == false) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P = x.P.get_ea(); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(-=); arma_applier_1(-=);
} }
else else
{ {
const ProxyCube<T1>& P = x.P; const ProxyCube<T1>& P = x.P;
arma_applier_3(-=); arma_applier_3(-=);
} }
skipping to change at line 419 skipping to change at line 425
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const uword n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication");
eT* out_mem = out.memptr(); const eT k = x.aux;
const uword n_elem = out.n_elem; eT* out_mem = out.memptr();
const eT k = x.aux;
if(ProxyCube<T1>::prefer_at_accessor == false) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P = x.P.get_ea(); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(*=); arma_applier_1(*=);
} }
else else
{ {
const ProxyCube<T1>& P = x.P; const ProxyCube<T1>& P = x.P;
arma_applier_3(*=); arma_applier_3(*=);
} }
skipping to change at line 455 skipping to change at line 461
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = x.get_n_rows(); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols(); const uword n_cols = x.get_n_cols();
const uword n_slices = x.get_n_slices(); const uword n_slices = x.get_n_slices();
arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division");
const eT k = x.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem;
const eT k = x.aux;
if(ProxyCube<T1>::prefer_at_accessor == false) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
typename ProxyCube<T1>::ea_type P = x.P.get_ea(); typename ProxyCube<T1>::ea_type P = x.P.get_ea();
arma_applier_1(/=); arma_applier_1(/=);
} }
else else
{ {
const ProxyCube<T1>& P = x.P; const ProxyCube<T1>& P = x.P;
arma_applier_3(/=); arma_applier_3(/=);
} }
skipping to change at line 483 skipping to change at line 489
// //
// common // common
template<typename eop_type> template<typename eop_type>
template<typename eT> template<typename eT>
arma_hot arma_hot
arma_pure arma_pure
arma_inline arma_inline
eT eT
eop_core<eop_type>::process(const eT val, const eT k) eop_core<eop_type>::process(const eT, const eT)
{ {
arma_ignore(val);
arma_ignore(k);
arma_stop("eop_core::process(): unhandled eop_type"); arma_stop("eop_core::process(): unhandled eop_type");
return eT(0); return eT(0);
} }
template<> template<typename eT> arma_hot arma_const arma_inline eT template<> template<typename eT> arma_hot arma_const arma_inline eT
eop_core<eop_scalar_plus >::process(const eT val, const eT k) { return val + k; } eop_core<eop_scalar_plus >::process(const eT val, const eT k) { return val + k; }
template<> template<typename eT> arma_hot arma_const arma_inline eT template<> template<typename eT> arma_hot arma_const arma_inline eT
eop_core<eop_scalar_minus_pre >::process(const eT val, const eT k) { return k - val; } eop_core<eop_scalar_minus_pre >::process(const eT val, const eT k) { return k - val; }
 End of changes. 24 change blocks. 
39 lines changed or deleted 46 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 900 skipping to change at line 900
//! construct a field from a given field //! construct a field from a given field
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::init(const field<oT>& x) field<oT>::init(const field<oT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
init(x.n_rows, x.n_cols); const uword x_n_rows = x.n_rows;
const uword x_n_cols = x.n_cols;
init(x_n_rows, x_n_cols);
field& t = *this; field& t = *this;
for(uword col=0; col<x.n_cols; ++col) for(uword ucol=0; ucol < x_n_cols; ++ucol)
for(uword row=0; row<x.n_rows; ++row) for(uword urow=0; urow < x_n_rows; ++urow)
{ {
t.at(row,col) = x.at(row,col); t.at(urow,ucol) = x.at(urow,ucol);
} }
} }
} }
//! internal field construction; if the requested size is small enough, mem ory from the stack is used. otherwise memory is allocated via 'new' //! internal field construction; if the requested size is small enough, mem ory from the stack is used. otherwise memory is allocated via 'new'
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::init(const uword n_rows_in, const uword n_cols_in) field<oT>::init(const uword n_rows_in, const uword n_cols_in)
 End of changes. 3 change blocks. 
4 lines changed or deleted 7 lines changed or added


 fn_det.hpp   fn_det.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
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det det
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const bool slow = false, const bool slow = false,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return auxlib::det(X, slow); return auxlib::det(X, slow);
} }
//! determinant of diagmat //! determinant of diagmat
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
skipping to change at line 105 skipping to change at line 104
const Op<T1,op_htrans>& in, const Op<T1,op_htrans>& in,
const bool slow = false, const bool slow = false,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk1 = 0, const typename arma_blas_type_only<typename T1::elem_type>::result* junk1 = 0,
const typename arma_not_cx<typename T1::elem_type>::result* junk2 = 0 const typename arma_not_cx<typename T1::elem_type>::result* junk2 = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
typedef typename T1::elem_type eT; return auxlib::det(in.m, slow); // bypass op_htrans
const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M;
return det(X, slow);
} }
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 &
det(const T& x) det(const T& x)
{ {
return x; return x;
} }
 End of changes. 3 change blocks. 
9 lines changed or deleted 3 lines changed or added


 fn_eig.hpp   fn_eig.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
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// //
// 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.
skipping to change at line 84 skipping to change at line 84
//! Eigenvalues and eigenvectors of real/complex symmetric/hermitian matrix X //! Eigenvalues and eigenvectors of real/complex symmetric/hermitian matrix X
template<typename T1> template<typename T1>
inline inline
bool bool
eig_sym eig_sym
( (
Col<typename T1::pod_type>& eigval, Col<typename T1::pod_type>& eigval,
Mat<typename T1::elem_type>& eigvec, Mat<typename T1::elem_type>& eigvec,
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);
arma_debug_check( ( ((void*)(&eigval)) == ((void*)(&eigvec)) ), "eig_sym( ): eigval is an alias of eigvec" ); arma_debug_check( void_ptr(&eigval) == void_ptr(&eigvec), "eig_sym(): eig val is an alias of eigvec" );
const bool status = auxlib::eig_sym(eigval, eigvec, X); 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("eig_sym(): unknown method specified");
return false;
}
}
const bool status = (use_divide_and_conquer == false) ? auxlib::eig_sym(e
igval, eigvec, X) : auxlib::eig_sym_dc(eigval, eigvec, X);
if(status == false) if(status == false)
{ {
eigval.reset(); eigval.reset();
eigvec.reset(); eigvec.reset();
arma_bad("eig_sym(): failed to converge", false); arma_bad("eig_sym(): failed to converge", false);
} }
return status; return status;
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 27 lines changed or added


 fn_log_det.hpp   fn_log_det.hpp 
skipping to change at line 63 skipping to change at line 63
const uword N = A.n_elem; const uword N = A.n_elem;
if(N == 0) if(N == 0)
{ {
out_val = eT(0); out_val = eT(0);
out_sign = T(1); out_sign = T(1);
return; return;
} }
const eT x = A[0]; eT x = A[0];
T sign = (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1; T sign = (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1;
eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x); eT val = (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x);
for(uword i=1; i<N; ++i) for(uword i=1; i<N; ++i)
{ {
const eT x = A[i]; x = A[i];
sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1; sign *= (is_complex<eT>::value == false) ? ( (access::tmp_real(x) < T(0 )) ? -1 : +1 ) : +1;
val += (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x); val += (is_complex<eT>::value == false) ? std::log( (access::tmp_real( x) < T(0)) ? x*T(-1) : x ) : std::log(x);
} }
out_val = val; out_val = val;
out_sign = sign; out_sign = sign;
} }
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_princomp.hpp   fn_princomp.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// Copyright (C) 2010 Dimitrios Bouzas // Copyright (C) 2010 Dimitrios Bouzas
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 39 skipping to change at line 39
Mat<typename T1::elem_type>& score_out, Mat<typename T1::elem_type>& score_out,
Col<typename T1::pod_type>& latent_out, Col<typename T1::pod_type>& latent_out,
Col<typename T1::elem_type>& tsquared_out, Col<typename T1::elem_type>& tsquared_out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; const bool status = op_princomp::direct_princomp(coeff_out, score_out, la
tent_out, tsquared_out, X);
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
const bool status = op_princomp::direct_princomp(coeff_out, score_out, la
tent_out, tsquared_out, A);
if(status == false) if(status == false)
{ {
coeff_out.reset(); coeff_out.reset();
score_out.reset(); score_out.reset();
latent_out.reset(); latent_out.reset();
tsquared_out.reset(); tsquared_out.reset();
arma_bad("princomp(): failed to converge", false); arma_bad("princomp(): failed to converge", false);
} }
skipping to change at line 79 skipping to change at line 74
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<typename T1::elem_type>& score_out, Mat<typename T1::elem_type>& score_out,
Col<typename T1::pod_type>& latent_out, Col<typename T1::pod_type>& latent_out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; const bool status = op_princomp::direct_princomp(coeff_out, score_out, la
tent_out, X);
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
const bool status = op_princomp::direct_princomp(coeff_out, score_out, la
tent_out, A);
if(status == false) if(status == false)
{ {
coeff_out.reset(); coeff_out.reset();
score_out.reset(); score_out.reset();
latent_out.reset(); latent_out.reset();
arma_bad("princomp(): failed to converge", false); arma_bad("princomp(): failed to converge", false);
} }
skipping to change at line 116 skipping to change at line 106
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<typename T1::elem_type>& score_out, Mat<typename T1::elem_type>& score_out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; const bool status = op_princomp::direct_princomp(coeff_out, score_out, X)
;
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
const bool status = op_princomp::direct_princomp(coeff_out, score_out, A)
;
if(status == false) if(status == false)
{ {
coeff_out.reset(); coeff_out.reset();
score_out.reset(); score_out.reset();
arma_bad("princomp(): failed to converge", false); arma_bad("princomp(): failed to converge", false);
} }
return status; return status;
skipping to change at line 150 skipping to change at line 135
princomp princomp
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; const bool status = op_princomp::direct_princomp(coeff_out, X);
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
const bool status = op_princomp::direct_princomp(coeff_out, A);
if(status == false) if(status == false)
{ {
coeff_out.reset(); coeff_out.reset();
arma_bad("princomp(): failed to converge", false); arma_bad("princomp(): failed to converge", false);
} }
return status; return status;
} }
 End of changes. 5 change blocks. 
29 lines changed or deleted 9 lines changed or added


 fn_sort_index.hpp   fn_sort_index.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-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 72 skipping to change at line 72
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = packet_vec[i].index; out_mem[i] = packet_vec[i].index;
} }
} }
template<typename T1> template<typename T1>
inline inline
umat umat
sort_index(const Base<typename T1::elem_type,T1>& X, const uword sort_type sort_index
= 0) (
const Base<typename T1::elem_type,T1>& X,
const uword sort_type = 0,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_type_check(( is_complex<eT>::value == true )); const unwrap<T1> tmp(X.get_ref());
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
if(A.is_empty() == true) if(A.is_empty() == true)
{ {
return umat(); return umat();
} }
arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha ndles vectors"); arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha ndles vectors");
typedef typename umat::elem_type out_elem_type; typedef typename umat::elem_type out_elem_type;
 End of changes. 3 change blocks. 
7 lines changed or deleted 9 lines changed or added


 forward_bones.hpp   forward_bones.hpp 
skipping to change at line 154 skipping to change at line 154
enum file_type enum file_type
{ {
file_type_unknown, file_type_unknown,
auto_detect, //!< Automatically detect the file type (file must be one o f the following types) auto_detect, //!< Automatically detect the file type (file must be one o f the following types)
raw_ascii, //!< ASCII format (text), without any other information. raw_ascii, //!< ASCII format (text), without any other information.
arma_ascii, //!< Armadillo ASCII format (text), with information about matrix type and size arma_ascii, //!< Armadillo ASCII format (text), with information about matrix type and size
csv_ascii, //!< comma separated values (CSV), without any other inform ation csv_ascii, //!< comma separated values (CSV), without any other inform ation
raw_binary, //!< raw binary format, without any other information. raw_binary, //!< raw binary format, without any other information.
arma_binary, //!< Armadillo binary format, with information about matrix type and size arma_binary, //!< Armadillo binary format, with information about matrix type and size
pgm_binary, //!< Portable Grey Map (greyscale image) pgm_binary, //!< Portable Grey Map (greyscale image)
ppm_binary //!< Portable Pixel Map (colour image), used by the field a ppm_binary, //!< Portable Pixel Map (colour image), used by the field a
nd cube classes nd cube classes
hdf5_binary //!< Open binary format, not specific to Armadillo, which c
an store arbitrary data
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
2 lines changed or deleted 4 lines changed or added


 glue_mixed_meat.hpp   glue_mixed_meat.hpp 
skipping to change at line 27 skipping to change at line 27
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_times::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_times>& X) glue_mixed_times::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
// TODO: extend the unwrap_check framework to handle mixed matrix types const unwrap_check_mixed<T1> tmp1(X.A, out);
const unwrap_check_mixed<T2> tmp2(X.B, out);
const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
const Mat<eT1>& A = tmp1.M; const Mat<eT1>& A = tmp1.M;
const Mat<eT2>& B = tmp2.M; const Mat<eT2>& B = tmp2.M;
const bool A_is_alias = ( ((void *)&out) == ((void *)&A) ); arma_debug_assert_mul_size(A, B, "multiplication");
const bool B_is_alias = ( ((void *)&out) == ((void *)&B) );
const Mat<eT1>* AA_ptr = A_is_alias ? new Mat<eT1>(A) : 0;
const Mat<eT2>* BB_ptr = B_is_alias ? new Mat<eT2>(B) : 0;
const Mat<eT1>& AA = A_is_alias ? *AA_ptr : A;
const Mat<eT2>& BB = B_is_alias ? *BB_ptr : B;
arma_debug_assert_mul_size(AA, BB, "multiplication");
out.set_size(AA.n_rows, BB.n_cols);
gemm_mixed<>::apply(out, AA, BB); out.set_size(A.n_rows, B.n_cols);
if(A_is_alias == true) gemm_mixed<>::apply(out, A, B);
{
delete AA_ptr;
}
if(B_is_alias == true)
{
delete BB_ptr;
}
} }
//! matrix addition with different element types //! matrix addition with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_plus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtG lue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_plus>& X) glue_mixed_plus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtG lue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_plus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 297 skipping to change at line 276
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();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "addition"); arma_debug_assert_same_size(A, B, "addition");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
for(uword i=0; i<n_elem; ++i) if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: typename ProxyCube<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename ProxyCube<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) + upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword slice = 0; slice < n_slices; ++slice)
for(uword col = 0; col < n_cols; ++col )
for(uword row = 0; row < n_rows; ++row )
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col,slice)) + upgra
de_val<eT1,eT2>::apply(B.at(row,col,slice));
++i;
}
} }
} }
//! cube subtraction with different element types //! cube subtraction with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_minus::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X) glue_mixed_minus::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 330 skipping to change at line 331
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();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "subtraction"); arma_debug_assert_same_size(A, B, "subtraction");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
for(uword i=0; i<n_elem; ++i) if(prefer_at_accessor == false)
{
typename ProxyCube<T1>::ea_type AA = A.get_ea();
typename ProxyCube<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) - upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: uword i = 0;
apply(B[i]);
for(uword slice = 0; slice < n_slices; ++slice)
for(uword col = 0; col < n_cols; ++col )
for(uword row = 0; row < n_rows; ++row )
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col,slice)) - upgra
de_val<eT1,eT2>::apply(B.at(row,col,slice));
++i;
}
} }
} }
//! element-wise cube division with different element types //! element-wise cube division with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_div::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtG lueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X) glue_mixed_div::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtG lueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 363 skipping to change at line 386
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();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise division"); arma_debug_assert_same_size(A, B, "element-wise division");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
for(uword i=0; i<n_elem; ++i) if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: typename ProxyCube<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename ProxyCube<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) / upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword slice = 0; slice < n_slices; ++slice)
for(uword col = 0; col < n_cols; ++col )
for(uword row = 0; row < n_rows; ++row )
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col,slice)) / upgra
de_val<eT1,eT2>::apply(B.at(row,col,slice));
++i;
}
} }
} }
//! element-wise cube multiplication with different element types //! element-wise cube multiplication with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_schur::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X) glue_mixed_schur::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const m tGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 396 skipping to change at line 441
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();
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise multiplication"); arma_debug_assert_same_size(A, B, "element-wise multiplication");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || Pro xyCube<T2>::prefer_at_accessor);
for(uword i=0; i<n_elem; ++i) if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: typename ProxyCube<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename ProxyCube<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) * upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword slice = 0; slice < n_slices; ++slice)
for(uword col = 0; col < n_cols; ++col )
for(uword row = 0; row < n_rows; ++row )
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col,slice)) * upgra
de_val<eT1,eT2>::apply(B.at(row,col,slice));
++i;
}
} }
} }
//! @} //! @}
 End of changes. 24 change blocks. 
50 lines changed or deleted 121 lines changed or added


 glue_relational_meat.hpp   glue_relational_meat.hpp 
skipping to change at line 78 skipping to change at line 78
for(uword col=0; col<n_cols; ++col)\ for(uword col=0; col<n_cols; ++col)\
for(uword row=0; row<n_rows; ++row, ++count)\ for(uword row=0; row<n_rows; ++row, ++count)\
{\ {\
out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? u word(1) : uword(0);\ out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? u word(1) : uword(0);\
}\ }\
}\ }\
}\ }\
}\ }\
else\ else\
{\ {\
const unwrap<typename Proxy<T1>::stored_type> tmp1(P1.Q);\ const unwrap_check<typename Proxy<T1>::stored_type> tmp1(P1.Q, P1.is_al
const unwrap<typename Proxy<T2>::stored_type> tmp2(P2.Q);\ ias(out));\
const unwrap_check<typename Proxy<T2>::stored_type> tmp2(P2.Q, P2.is_al
ias(out));\
\ \
out = (tmp1.M) operator_rel (tmp2.M);\ out = (tmp1.M) operator_rel (tmp2.M);\
}\ }\
} }
#define arma_applier_cube(operator_rel, operator_str) \ #define arma_applier_cube(operator_rel, operator_str) \
{\ {\
const ProxyCube<T1> P1(X.A);\ const ProxyCube<T1> P1(X.A);\
const ProxyCube<T2> P2(X.B);\ const ProxyCube<T2> P2(X.B);\
\ \
 End of changes. 1 change blocks. 
2 lines changed or deleted 4 lines changed or added


 glue_solve_bones.hpp   glue_solve_bones.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 glue_solve //! \addtogroup glue_solve
//! @{ //! @{
class glue_solve class glue_solve
{ {
public: public:
template<typename eT> inline static void solve_direct(Mat<eT>& out, Mat<e T>& A, const Mat<eT>& B, const bool slow); template<typename eT, typename T2> inline static void solve_direct(Mat<eT >& out, Mat<eT>& A, const Base<eT,T2>& X, const bool slow);
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve>& X); template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve>& X);
}; };
class glue_solve_tr class glue_solve_tr
{ {
public: public:
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve_tr>& X); template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve_tr>& X);
}; };
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 glue_solve_meat.hpp   glue_solve_meat.hpp 
skipping to change at line 16 skipping to change at line 16
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_solve //! \addtogroup glue_solve
//! @{ //! @{
template<typename eT> template<typename eT, typename T2>
inline inline
void void
glue_solve::solve_direct(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, const bool slow) glue_solve::solve_direct(Mat<eT>& out, Mat<eT>& A, const Base<eT,T2>& X, co nst bool slow)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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;
arma_debug_check( (A_n_rows != B.n_rows), "solve(): number of rows in A a
nd B must be the same" );
bool status = false; bool status = false;
if(A_n_rows == A_n_cols) if(A_n_rows == A_n_cols)
{ {
status = auxlib::solve(out, A, B, slow); status = auxlib::solve_new(out, A, X, slow);
} }
else else
if(A_n_rows > A_n_cols) if(A_n_rows > A_n_cols)
{ {
arma_extra_debug_print("solve(): detected over-determined system"); arma_extra_debug_print("solve(): detected over-determined system");
status = auxlib::solve_od(out, A, B); status = auxlib::solve_new_od(out, A, X);
} }
else else
{ {
arma_extra_debug_print("solve(): detected under-determined system"); arma_extra_debug_print("solve(): detected under-determined system");
status = auxlib::solve_ud(out, A, B); status = auxlib::solve_new_ud(out, A, X);
} }
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("solve(): solution not found"); arma_bad("solve(): solution not found");
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_solve::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_s olve>& X) glue_solve::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_s olve>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
Mat<eT> A = X.A.get_ref(); Mat<eT> A = X.A.get_ref();
const unwrap_check<T2> B_tmp(X.B, out); glue_solve::solve_direct( out, A, X.B, (X.aux_uword == 1) );
const Mat<eT>& B = B_tmp.M;
glue_solve::solve_direct( out, A, B, (X.aux_uword == 1) );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_solve_tr::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glu e_solve_tr>& X) glue_solve_tr::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glu e_solve_tr>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
 End of changes. 7 change blocks. 
12 lines changed or deleted 6 lines changed or added


 glue_times_meat.hpp   glue_times_meat.hpp 
skipping to change at line 148 skipping to change at line 148
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
arma_hot arma_hot
inline inline
void void
glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// TODO: investigate detecting inv(A)*B*C and replacing with solve(A,B)*C
// TODO: investigate detecting A*inv(B)*C and replacing with A*solve(B,C)
// there is exactly 3 objects // there is exactly 3 objects
// hence we can safely expand X as X.A.A, X.A.B and X.B // hence we can safely expand X as X.A.A, X.A.B and X.B
const partial_unwrap_check<T1> tmp1(X.A.A, out); const partial_unwrap_check<T1> tmp1(X.A.A, out);
const partial_unwrap_check<T2> tmp2(X.A.B, out); const partial_unwrap_check<T2> tmp2(X.A.B, out);
const partial_unwrap_check<T3> tmp3(X.B, out); const partial_unwrap_check<T3> tmp3(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
skipping to change at line 238 skipping to change at line 241
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X) glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(X, out); const unwrap_check<T1> B_tmp(X, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = B_tmp.M;
arma_debug_assert_mul_size(out, B, "matrix multiplication"); arma_debug_assert_mul_size(out, B, "matrix multiplication");
const uword out_n_rows = out.n_rows; const uword out_n_rows = out.n_rows;
const uword out_n_cols = out.n_cols; const uword out_n_cols = out.n_cols;
if(out_n_cols == B.n_cols) if(out_n_cols == B.n_cols)
{ {
// size of resulting matrix is the same as 'out' // size of resulting matrix is the same as 'out'
 End of changes. 2 change blocks. 
2 lines changed or deleted 5 lines changed or added


 lapack_bones.hpp   lapack_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
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2012 Eric Jon Sundstrom
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 40 skipping to change at line 41
#define arma_dtrtri dtrtri #define arma_dtrtri dtrtri
#define arma_ctrtri ctrtri #define arma_ctrtri ctrtri
#define arma_ztrtri ztrtri #define arma_ztrtri ztrtri
#define arma_ssyev ssyev #define arma_ssyev ssyev
#define arma_dsyev dsyev #define arma_dsyev dsyev
#define arma_cheev cheev #define arma_cheev cheev
#define arma_zheev zheev #define arma_zheev zheev
#define arma_ssyevd ssyevd
#define arma_dsyevd dsyevd
#define arma_cheevd cheevd
#define arma_zheevd zheevd
#define arma_sgeev sgeev #define arma_sgeev sgeev
#define arma_dgeev dgeev #define arma_dgeev dgeev
#define arma_cgeev cgeev #define arma_cgeev cgeev
#define arma_zgeev zgeev #define arma_zgeev zgeev
#define arma_spotrf spotrf #define arma_spotrf spotrf
#define arma_dpotrf dpotrf #define arma_dpotrf dpotrf
#define arma_cpotrf cpotrf #define arma_cpotrf cpotrf
#define arma_zpotrf zpotrf #define arma_zpotrf zpotrf
skipping to change at line 131 skipping to change at line 138
#define arma_dtrtri DTRTRI #define arma_dtrtri DTRTRI
#define arma_ctrtri CTRTRI #define arma_ctrtri CTRTRI
#define arma_ztrtri ZTRTRI #define arma_ztrtri ZTRTRI
#define arma_ssyev SSYEV #define arma_ssyev SSYEV
#define arma_dsyev DSYEV #define arma_dsyev DSYEV
#define arma_cheev CHEEV #define arma_cheev CHEEV
#define arma_zheev ZHEEV #define arma_zheev ZHEEV
#define arma_ssyevd SSYEVD
#define arma_dsyevd DSYEVD
#define arma_cheevd CHEEVD
#define arma_zheevd ZHEEVD
#define arma_sgeev SGEEV #define arma_sgeev SGEEV
#define arma_dgeev DGEEV #define arma_dgeev DGEEV
#define arma_cgeev CGEEV #define arma_cgeev CGEEV
#define arma_zgeev ZGEEV #define arma_zgeev ZGEEV
#define arma_spotrf SPOTRF #define arma_spotrf SPOTRF
#define arma_dpotrf DPOTRF #define arma_dpotrf DPOTRF
#define arma_cpotrf CPOTRF #define arma_cpotrf CPOTRF
#define arma_zpotrf ZPOTRF #define arma_zpotrf ZPOTRF
skipping to change at line 229 skipping to change at line 242
void arma_fortran(arma_ztrtri)(char* uplo, char* diag, blas_int* n, voi d* a, blas_int* lda, blas_int* info); void arma_fortran(arma_ztrtri)(char* uplo, char* diag, blas_int* n, voi d* a, blas_int* lda, blas_int* info);
// eigenvector decomposition of symmetric real matrices // eigenvector decomposition of symmetric real matrices
void arma_fortran(arma_ssyev)(char* jobz, char* uplo, blas_int* n, float * a, blas_int* lda, float* w, float* work, blas_int* lwork, blas_int* inf o); void arma_fortran(arma_ssyev)(char* jobz, char* uplo, blas_int* n, float * a, blas_int* lda, float* w, float* work, blas_int* lwork, blas_int* inf o);
void arma_fortran(arma_dsyev)(char* jobz, char* uplo, blas_int* n, double * a, blas_int* lda, double* w, double* work, blas_int* lwork, blas_int* inf o); void arma_fortran(arma_dsyev)(char* jobz, char* uplo, blas_int* n, double * a, blas_int* lda, double* w, double* work, blas_int* lwork, blas_int* inf o);
// eigenvector decomposition of hermitian matrices (complex) // eigenvector decomposition of hermitian matrices (complex)
void arma_fortran(arma_cheev)(char* jobz, char* uplo, blas_int* n, void * a, blas_int* lda, float* w, void* work, blas_int* lwork, float* rwork , blas_int* info); void arma_fortran(arma_cheev)(char* jobz, char* uplo, blas_int* n, void * a, blas_int* lda, float* w, void* work, blas_int* lwork, float* rwork , blas_int* info);
void arma_fortran(arma_zheev)(char* jobz, char* uplo, blas_int* n, void * a, blas_int* lda, double* w, void* work, blas_int* lwork, double* rwork , blas_int* info); void arma_fortran(arma_zheev)(char* jobz, char* uplo, blas_int* n, void * a, blas_int* lda, double* w, void* work, blas_int* lwork, double* rwork , blas_int* info);
// eigenvector decomposition of symmetric real matrices by divide and con
quer
void arma_fortran(arma_ssyevd)(char* jobz, char* uplo, blas_int* n, floa
t* a, blas_int* lda, float* w, float* work, blas_int* lwork, blas_int* iw
ork, blas_int* liwork, blas_int* info);
void arma_fortran(arma_dsyevd)(char* jobz, char* uplo, blas_int* n, doubl
e* a, blas_int* lda, double* w, double* work, blas_int* lwork, blas_int* iw
ork, blas_int* liwork, blas_int* info);
// eigenvector decomposition of hermitian matrices (complex) by divide an
d conquer
void arma_fortran(arma_cheevd)(char* jobz, char* uplo, blas_int* n, voi
d* a, blas_int* lda, float* w, void* work, blas_int* lwork, float* rwor
k, blas_int* lrwork, blas_int* iwork, blas_int* liwork, blas_int* info);
void arma_fortran(arma_zheevd)(char* jobz, char* uplo, blas_int* n, voi
d* a, blas_int* lda, double* w, void* work, blas_int* lwork, double* rwor
k, blas_int* lrwork, blas_int* iwork, blas_int* liwork, blas_int* info);
// eigenvector decomposition of general real matrices // eigenvector decomposition of general real matrices
void arma_fortran(arma_sgeev)(char* jobvl, char* jobvr, blas_int* n, flo at* a, blas_int* lda, float* wr, float* wi, float* vl, blas_int* ldvl, float* vr, blas_int* ldvr, float* work, blas_int* lwork, blas_int* info); void arma_fortran(arma_sgeev)(char* jobvl, char* jobvr, blas_int* n, flo at* a, blas_int* lda, float* wr, float* wi, float* vl, blas_int* ldvl, float* vr, blas_int* ldvr, float* work, blas_int* lwork, blas_int* info);
void arma_fortran(arma_dgeev)(char* jobvl, char* jobvr, blas_int* n, doub le* a, blas_int* lda, double* wr, double* wi, double* vl, blas_int* ldvl, d ouble* vr, blas_int* ldvr, double* work, blas_int* lwork, blas_int* info); void arma_fortran(arma_dgeev)(char* jobvl, char* jobvr, blas_int* n, doub le* a, blas_int* lda, double* wr, double* wi, double* vl, blas_int* ldvl, d ouble* vr, blas_int* ldvr, double* work, blas_int* lwork, blas_int* info);
// eigenvector decomposition of general complex matrices // eigenvector decomposition of general complex matrices
void arma_fortran(arma_cgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, float* rwork, blas_int* info); void arma_fortran(arma_cgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, float* rwork, blas_int* info);
void arma_fortran(arma_zgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, double* rwork, blas_int* info); void arma_fortran(arma_zgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, double* rwork, blas_int* info);
// Cholesky decomposition // Cholesky decomposition
void arma_fortran(arma_spotrf)(char* uplo, blas_int* n, float* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_spotrf)(char* uplo, blas_int* n, float* a, blas_i nt* lda, blas_int* info);
 End of changes. 4 change blocks. 
4 lines changed or deleted 35 lines changed or added


 lapack_wrapper.hpp   lapack_wrapper.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
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2012 Eric Jon Sundstrom
// //
// 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 140 skipping to change at line 141
if(is_double<eT>::value == true) if(is_double<eT>::value == true)
{ {
typedef double T; typedef double T;
arma_fortran(arma_dsyev)(jobz, uplo, n, (T*)a, lda, (T*)w, (T*)work, lwork, info); arma_fortran(arma_dsyev)(jobz, uplo, n, (T*)a, lda, (T*)w, (T*)work, lwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
syevd(char* jobz, char* uplo, blas_int* n, eT* a, blas_int* lda, eT* w,
eT* work, blas_int* lwork, blas_int* iwork, blas_int* liwork, blas_int* inf
o)
{
arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true)
{
typedef float T;
arma_fortran(arma_ssyevd)(jobz, uplo, n, (T*)a, lda, (T*)w, (T*)work,
lwork, iwork, liwork, info);
}
else
if(is_double<eT>::value == true)
{
typedef double T;
arma_fortran(arma_dsyevd)(jobz, uplo, n, (T*)a, lda, (T*)w, (T*)work,
lwork, iwork, liwork, info);
}
}
template<typename eT>
inline
void
heev heev
( (
char* jobz, char* uplo, blas_int* n, char* jobz, char* uplo, blas_int* n,
eT* a, blas_int* lda, typename eT::value_type* w, eT* a, blas_int* lda, typename eT::value_type* w,
eT* work, blas_int* lwork, typename eT::value_type* rwork, eT* work, blas_int* lwork, typename eT::value_type* rwork,
blas_int* info blas_int* info
) )
{ {
arma_type_check(( is_supported_blas_type<eT>::value == false )); arma_type_check(( is_supported_blas_type<eT>::value == false ));
skipping to change at line 168 skipping to change at line 189
{ {
typedef double T; typedef double T;
typedef typename std::complex<T> cx_T; typedef typename std::complex<T> cx_T;
arma_fortran(arma_zheev)(jobz, uplo, n, (cx_T*)a, lda, (T*)w, (cx_T*) work, lwork, (T*)rwork, info); arma_fortran(arma_zheev)(jobz, uplo, n, (cx_T*)a, lda, (T*)w, (cx_T*) work, lwork, (T*)rwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
heevd
(
char* jobz, char* uplo, blas_int* n,
eT* a, blas_int* lda, typename eT::value_type* w,
eT* work, blas_int* lwork, typename eT::value_type* rwork,
blas_int* lrwork, blas_int* iwork, blas_int* liwork,
blas_int* info
)
{
arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_supported_complex_float<eT>::value == true)
{
typedef float T;
typedef typename std::complex<T> cx_T;
arma_fortran(arma_cheevd)(jobz, uplo, n, (cx_T*)a, lda, (T*)w, (cx_T*
)work, lwork, (T*)rwork, lrwork, iwork, liwork, info);
}
else
if(is_supported_complex_double<eT>::value == true)
{
typedef double T;
typedef typename std::complex<T> cx_T;
arma_fortran(arma_zheevd)(jobz, uplo, n, (cx_T*)a, lda, (T*)w, (cx_T*
)work, lwork, (T*)rwork, lrwork, iwork, liwork, info);
}
}
template<typename eT>
inline
void
geev geev
( (
char* jobvl, char* jobvr, blas_int* n, char* jobvl, char* jobvr, blas_int* n,
eT* a, blas_int* lda, eT* wr, eT* wi, eT* vl, eT* a, blas_int* lda, eT* wr, eT* wi, eT* vl,
blas_int* ldvl, eT* vr, blas_int* ldvr, blas_int* ldvl, eT* vr, blas_int* ldvr,
eT* work, blas_int* lwork, eT* work, blas_int* lwork,
blas_int* info blas_int* info
) )
{ {
arma_type_check(( is_supported_blas_type<eT>::value == false )); arma_type_check(( is_supported_blas_type<eT>::value == false ));
 End of changes. 3 change blocks. 
4 lines changed or deleted 60 lines changed or added


 op_cumsum_meat.hpp   op_cumsum_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-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 25 skipping to change at line 25
template<typename T1> template<typename T1>
inline inline
void void
op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_mat>& in) op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_mat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or 1"); arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or 1");
out.copy_size(X); out.copy_size(X);
const uword X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) if(dim == 0)
skipping to change at line 83 skipping to change at line 83
template<typename T1> template<typename T1>
inline inline
void void
op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_vec>& in) op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu m_vec>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const uword n_elem = X.n_elem; const uword n_elem = X.n_elem;
out.copy_size(X); out.copy_size(X);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const eT* X_mem = X.memptr(); const eT* X_mem = X.memptr();
eT acc = eT(0); eT acc = eT(0);
 End of changes. 3 change blocks. 
6 lines changed or deleted 6 lines changed or added


 op_diagmat_meat.hpp   op_diagmat_meat.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 25 skipping to change at line 25
template<typename T1> template<typename T1>
inline inline
void void
op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagmat >& X) op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagmat >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.m); const Proxy<T1> P(X.m);
const Mat<eT>& A = tmp.M;
if(A.is_vec() == true) const uword n_rows = P.get_n_rows();
{ const uword n_cols = P.get_n_cols();
// generate a diagonal matrix out of a vector
const uword N = A.n_elem; const bool P_is_vec = (n_rows == 1) || (n_cols == 1);
const eT* A_mem = A.memptr();
if(&out != &A) if(P.is_alias(out) == false)
{
if(P_is_vec) // generate a diagonal matrix out of a vector
{ {
// no aliasing const uword N = (n_rows == 1) ? n_cols : n_rows;
out.zeros(N,N);
out.zeros(N, N);
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type P_ea = P.get_ea();
for(uword i=0; i<N; ++i) for(uword i=0; i < N; ++i) { out.at(i,i) = P_ea[i]; }
}
else
{ {
out.at(i,i) = A_mem[i]; if(n_rows == 1)
{
for(uword i=0; i < N; ++i) { out.at(i,i) = P.at(0,i); }
}
else
{
for(uword i=0; i < N; ++i) { out.at(i,i) = P.at(i,0); }
}
} }
} }
else else // generate a diagonal matrix out of a matrix
{ {
// aliasing arma_debug_check( (n_rows != n_cols), "diagmat(): given matrix is not
square" );
const podarray<eT> tmp(A_mem, N);
const eT* tmp_mem = tmp.memptr();
out.zeros(N,N); out.zeros(n_rows, n_rows);
for(uword i=0; i<N; ++i) for(uword i=0; i < n_rows; ++i) { out.at(i,i) = P.at(i,i); }
{
out.at(i,i) = tmp_mem[i];
}
} }
} }
else else // we have aliasing
{ {
// generate a diagonal matrix out of a matrix if(P_is_vec) // generate a diagonal matrix out of a vector
arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is
not square" );
const uword N = A.n_rows;
if(&out != &A)
{ {
// no aliasing const uword N = (n_rows == 1) ? n_cols : n_rows;
out.zeros(N,N); podarray<eT> tmp(N);
eT* tmp_mem = tmp.memptr();
for(uword i=0; i<N; ++i) if(Proxy<T1>::prefer_at_accessor == false)
{ {
out.at(i,i) = A.at(i,i); typename Proxy<T1>::ea_type P_ea = P.get_ea();
for(uword i=0; i < N; ++i) { tmp_mem[i] = P_ea[i]; }
} }
else
{
if(n_rows == 1)
{
for(uword i=0; i < N; ++i) { tmp_mem[i] = P.at(0,i); }
}
else
{
for(uword i=0; i < N; ++i) { tmp_mem[i] = P.at(i,0); }
}
}
out.zeros(N, N);
for(uword i=0; i < N; ++i) { out.at(i,i) = tmp_mem[i]; }
} }
else else // generate a diagonal matrix out of a matrix
{ {
// aliasing // NOTE: we're assuming that the output matrix is the same as the mat
rix provided by the Proxy,
// NOTE: and the alias is not due to a matrix using auxiliary memory;
// NOTE: this assumption is currently valid for matrices, but not for
vectors;
// NOTE: as we've checked that at this point in code we're dealing wi
th a matrix,
// NOTE: the assumption is thus currently valid
arma_debug_check( (n_rows != n_cols), "diagmat(): given matrix is not
square" );
for(uword i=0; i<N; ++i) for(uword i=0; i < n_rows; ++i)
{ {
eT* colptr = out.colptr(i); eT* colptr = out.colptr(i);
// clear above the diagonal // clear above the diagonal
arrayops::inplace_set(colptr, eT(0), i); arrayops::inplace_set(colptr, eT(0), i);
// clear below the diagonal // clear below the diagonal
arrayops::inplace_set(colptr+(i+1), eT(0), N-1-i); arrayops::inplace_set(colptr+(i+1), eT(0), n_rows-1-i);
} }
} }
} }
} }
//! @} //! @}
 End of changes. 23 change blocks. 
42 lines changed or deleted 70 lines changed or added


 op_dot_meat.hpp   op_dot_meat.hpp 
skipping to change at line 334 skipping to change at line 334
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1; typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2; typedef typename Proxy<T2>::ea_type ea_type2;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
const Proxy<T2> B(Y.get_ref()); const Proxy<T2> B(Y.get_ref());
arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "cdot(): objects mu st have the same number of elements" ); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) || (Proxy <T2>::prefer_at_accessor);
const uword N = A.get_n_elem(); if(prefer_at_accessor == false)
ea_type1 PA = A.get_ea(); {
ea_type2 PB = B.get_ea(); arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "cdot(): objects
must have the same number of elements" );
eT val1 = eT(0); const uword N = A.get_n_elem();
eT val2 = eT(0); ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea();
eT val1 = eT(0);
eT val2 = eT(0);
uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
val1 += std::conj(PA[i]) * PB[i];
val2 += std::conj(PA[j]) * PB[j];
}
if(i < N)
{
val1 += std::conj(PA[i]) * PB[i];
}
uword i,j; return val1 + val2;
for(i=0, j=1; j<N; i+=2, j+=2)
{
val1 += std::conj(PA[i]) * PB[i];
val2 += std::conj(PA[j]) * PB[j];
} }
else
if(i < N)
{ {
val1 += std::conj(PA[i]) * PB[i]; const unwrap< typename Proxy<T1>::stored_type > tmp_A(A.Q);
} const unwrap< typename Proxy<T2>::stored_type > tmp_B(B.Q);
return val1 + val2; return op_cdot::apply( tmp_A.M, tmp_B.M );
}
} }
//! @} //! @}
 End of changes. 7 change blocks. 
16 lines changed or deleted 29 lines changed or added


 op_hist_meat.hpp   op_hist_meat.hpp 
skipping to change at line 65 skipping to change at line 65
} }
if(arma_isfinite(min_val) == false) { min_val = priv::most_neg<eT>(); } if(arma_isfinite(min_val) == false) { min_val = priv::most_neg<eT>(); }
if(arma_isfinite(max_val) == false) { max_val = priv::most_pos<eT>(); } if(arma_isfinite(max_val) == false) { max_val = priv::most_pos<eT>(); }
if(n_bins >= 1) if(n_bins >= 1)
{ {
Col<eT> c(n_bins); Col<eT> c(n_bins);
eT* c_mem = c.memptr(); eT* c_mem = c.memptr();
for(uword i=0; i < n_bins; ++i) for(uword ii=0; ii < n_bins; ++ii)
{ {
c_mem[i] = (0.5 + i) / double(n_bins); // TODO: may need to be modi fied for integer matrices c_mem[ii] = (0.5 + ii) / double(n_bins); // TODO: may need to be mo dified for integer matrices
} }
c = ((max_val - min_val) * c) + min_val; c = ((max_val - min_val) * c) + min_val;
out = hist(A, c); out = hist(A, c);
} }
else else
{ {
out.reset(); out.reset();
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 op_htrans_bones.hpp   op_htrans_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)
//! \addtogroup op_htrans //! \addtogroup op_htrans
//! @{ //! @{
//! 'hermitian transpose' operation //! 'hermitian transpose' operation
class op_htrans class op_htrans
{ {
public: public:
template<typename eT> template<typename eT>
arma_inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, con st typename arma_not_cx<eT>::result* junk = 0); arma_hot arma_inline static void apply_noalias(Mat<eT>& out, const Mat<eT >& A, const typename arma_not_cx<eT>::result* junk = 0);
template<typename eT> template<typename eT>
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const ty pename arma_cx_only<eT>::result* junk = 0); arma_hot inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_only<eT>::result* junk = 0);
// //
template<typename eT> template<typename eT>
arma_inline static void apply(Mat<eT>& out, const Mat<eT>& A, const typen ame arma_not_cx<eT>::result* junk = 0); arma_hot arma_inline static void apply(Mat<eT>& out, const Mat<eT>& A, co nst typename arma_not_cx<eT>::result* junk = 0);
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const typename a rma_cx_only<eT>::result* junk = 0); arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const t ypename arma_cx_only<eT>::result* junk = 0);
// //
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _htrans>& in); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Op<T 1, op_trimat>, op_htrans>& in); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trimat>, op_htrans>& in);
}; };
class op_htrans2 class op_htrans2
{ {
public: public:
template<typename eT>
arma_hot arma_inline static void apply(Mat<eT>& out, const Mat<eT>& A, co
nst eT val, const typename arma_not_cx<eT>::result* junk = 0);
template<typename eT>
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const e
T val, const typename arma_cx_only<eT>::result* junk = 0);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _htrans2>& in); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2>& in);
}; };
//! @} //! @}
 End of changes. 9 change blocks. 
9 lines changed or deleted 17 lines changed or added


 op_htrans_meat.hpp   op_htrans_meat.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)
//! \addtogroup op_htrans //! \addtogroup op_htrans
//! @{ //! @{
template<typename eT> template<typename eT>
arma_hot
arma_inline arma_inline
void void
op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_not_cx<eT>::result* junk) op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_not_cx<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
op_strans::apply_noalias(out, A); op_strans::apply_noalias(out, A);
} }
template<typename eT> template<typename eT>
arma_hot
inline inline
void void
op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_cx_only<eT>::result* junk) op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arm a_cx_only<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
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;
skipping to change at line 54 skipping to change at line 56
for(uword in_col = 0; in_col < A_n_cols; ++in_col) for(uword in_col = 0; in_col < A_n_cols; ++in_col)
{ {
const uword out_row = in_col; const uword out_row = in_col;
out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) ); out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) );
} }
} }
} }
template<typename eT> template<typename eT>
arma_hot
arma_inline arma_inline
void void
op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx <eT>::result* junk) op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx <eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
op_strans::apply(out, A); op_strans::apply(out, A);
} }
template<typename eT> template<typename eT>
arma_hot
inline inline
void void
op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_onl y<eT>::result* junk) op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_onl y<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
if(&out != &A) if(&out != &A)
{ {
op_htrans::apply_noalias(out, A); op_htrans::apply_noalias(out, A);
skipping to change at line 113 skipping to change at line 117
Mat<eT> tmp; Mat<eT> tmp;
op_htrans::apply_noalias(tmp, A); op_htrans::apply_noalias(tmp, A);
out.steal_mem(tmp); out.steal_mem(tmp);
} }
} }
} }
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in) op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_htrans::apply(out, A); op_htrans::apply(out, A);
} }
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trim at>, op_htrans>& in) op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trim at>, op_htrans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m.m); const unwrap<T1> tmp(in.m.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const bool upper = in.m.aux_uword_a; const bool upper = in.m.aux_uword_a;
op_trimat::apply_htrans(out, A, upper); op_trimat::apply_htrans(out, A, upper);
} }
//
// op_htrans2
template<typename eT>
arma_hot
arma_inline
void
op_htrans2::apply(Mat<eT>& out, const Mat<eT>& A, const eT val, const typen
ame arma_not_cx<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
op_strans2::apply(out, A, val);
}
template<typename eT>
arma_hot
inline
void
op_htrans2::apply(Mat<eT>& out, const Mat<eT>& A, const eT val, const typen
ame arma_cx_only<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
// TODO: replace with specialised implementation
op_htrans::apply(out, A);
arrayops::inplace_mul( out.memptr(), val, out.n_elem );
}
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2> & in) op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2> & in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
op_htrans::apply(out, tmp.M); op_htrans2::apply(out, tmp.M, in.aux);
arrayops::inplace_mul( out.memptr(), in.aux, out.n_elem );
} }
//! @} //! @}
 End of changes. 10 change blocks. 
5 lines changed or deleted 43 lines changed or added


 op_princomp_bones.hpp   op_princomp_bones.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// Copyright (C) 2010 Dimitrios Bouzas // Copyright (C) 2010 Dimitrios Bouzas
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_princomp //! \addtogroup op_princomp
//! @{ //! @{
class op_princomp class op_princomp
{ {
public: public:
//
// real element versions // real element versions
template<typename eT> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
); );
template<typename eT> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<eT>& score_out, Mat<typename T1::elem_type>& score_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
); );
template<typename eT> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<eT>& score_out, Mat<typename T1::elem_type>& score_out,
Col<eT>& latent_out, Col<typename T1::elem_type>& latent_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
); );
template<typename eT> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<eT>& score_out, Mat<typename T1::elem_type>& score_out,
Col<eT>& latent_out, Col<typename T1::elem_type>& latent_out,
Col<eT>& tsquared_out, Col<typename T1::elem_type>& tsquared_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
); );
//
// complex element versions // complex element versions
template<typename T> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
); );
template<typename T> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<typename T1::pod_type> >& score_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
); );
template<typename T> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<typename T1::pod_type> >& score_out,
Col<T>& latent_out, Col< typename T1::pod_type >& latent_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
); );
template<typename T> template<typename T1>
inline static bool inline static bool
direct_princomp direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<typename T1::pod_type> >& score_out,
Col<T>& latent_out, Col< typename T1::pod_type >& latent_out,
Col< std::complex<T> >& tsquared_out, Col< std::complex<typename T1::pod_type> >& tsquared_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
); );
template<typename T1> template<typename T1>
inline static void inline static void
apply(Mat<typename T1::elem_type>& out, const Op<T1,op_princomp>& in); apply(Mat<typename T1::elem_type>& out, const Op<T1,op_princomp>& in);
}; };
//! @} //! @}
 End of changes. 19 change blocks. 
38 lines changed or deleted 48 lines changed or added


 op_princomp_meat.hpp   op_princomp_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// Copyright (C) 2010 Dimitrios Bouzas // Copyright (C) 2010 Dimitrios Bouzas
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// //
// 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.
skipping to change at line 25 skipping to change at line 25
//! \addtogroup op_princomp //! \addtogroup op_princomp
//! @{ //! @{
//! \brief //! \brief
//! principal component analysis -- 4 arguments version //! principal component analysis -- 4 arguments version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
//! latent_out -> eigenvalues of principal vectors //! latent_out -> eigenvalues of principal vectors
//! tsquared_out -> Hotelling's T^2 statistic //! tsquared_out -> Hotelling's T^2 statistic
template<typename eT> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<eT>& score_out, Mat<typename T1::elem_type>& score_out,
Col<eT>& latent_out, Col<typename T1::elem_type>& latent_out,
Col<eT>& tsquared_out, Col<typename T1::elem_type>& tsquared_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M;
const uword n_rows = in.n_rows; const uword n_rows = in.n_rows;
const uword n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
skipping to change at line 116 skipping to change at line 123
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 3 arguments version //! principal component analysis -- 3 arguments version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
//! latent_out -> eigenvalues of principal vectors //! latent_out -> eigenvalues of principal vectors
template<typename eT> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<eT>& score_out, Mat<typename T1::elem_type>& score_out,
Col<eT>& latent_out, Col<typename T1::elem_type>& latent_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M;
const uword n_rows = in.n_rows; const uword n_rows = in.n_rows;
const uword n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
skipping to change at line 188 skipping to change at line 202
} }
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 2 arguments version //! principal component analysis -- 2 arguments version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
template<typename eT> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<eT>& score_out, Mat<typename T1::elem_type>& score_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M;
const uword n_rows = in.n_rows; const uword n_rows = in.n_rows;
const uword n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
skipping to change at line 250 skipping to change at line 271
score_out.zeros(); score_out.zeros();
} }
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 1 argument version //! principal component analysis -- 1 argument version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
template<typename eT> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat<eT>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
const Mat<eT>& in const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
const unwrap<T1> Y( X.get_ref() );
const Mat<eT>& in = Y.M;
if(in.n_elem != 0) if(in.n_elem != 0)
{ {
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
const Mat<eT> tmp = in - repmat(mean(in), in.n_rows, 1); const Mat<eT> tmp = in - repmat(mean(in), in.n_rows, 1);
const bool svd_ok = svd(U,s,coeff_out, tmp); const bool svd_ok = svd(U,s,coeff_out, tmp);
skipping to change at line 291 skipping to change at line 319
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 4 arguments complex version //! principal component analysis -- 4 arguments complex version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
//! latent_out -> eigenvalues of principal vectors //! latent_out -> eigenvalues of principal vectors
//! tsquared_out -> Hotelling's T^2 statistic //! tsquared_out -> Hotelling's T^2 statistic
template<typename T> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<typename T1::pod_type> >& score_out,
Col<T>& latent_out, Col< typename T1::pod_type >& latent_out,
Col< std::complex<T> >& tsquared_out, Col< std::complex<typename T1::pod_type> >& tsquared_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::pod_type T;
typedef std::complex<T> eT;
typedef std::complex<T> eT; const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M;
const uword n_rows = in.n_rows; const uword n_rows = in.n_rows;
const uword n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
skipping to change at line 381 skipping to change at line 415
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 3 arguments complex version //! principal component analysis -- 3 arguments complex version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
//! latent_out -> eigenvalues of principal vectors //! latent_out -> eigenvalues of principal vectors
template<typename T> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<typename T1::pod_type> >& score_out,
Col<T>& latent_out, Col< typename T1::pod_type >& latent_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef std::complex<T> eT; typedef typename T1::pod_type T;
typedef std::complex<T> eT;
const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M;
const uword n_rows = in.n_rows; const uword n_rows = in.n_rows;
const uword n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
skipping to change at line 455 skipping to change at line 495
} }
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 2 arguments complex version //! principal component analysis -- 2 arguments complex version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
template<typename T> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
Mat< std::complex<T> >& score_out, Mat< std::complex<typename T1::pod_type> >& score_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::pod_type T;
typedef std::complex<T> eT;
typedef std::complex<T> eT; const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M;
const uword n_rows = in.n_rows; const uword n_rows = in.n_rows;
const uword n_cols = in.n_cols; const uword n_cols = in.n_cols;
if(n_rows > 1) // more than one sample if(n_rows > 1) // more than one sample
{ {
// subtract the mean - use score_out as temporary matrix // subtract the mean - use score_out as temporary matrix
score_out = in - repmat(mean(in), n_rows, 1); score_out = in - repmat(mean(in), n_rows, 1);
// singular value decomposition // singular value decomposition
skipping to change at line 517 skipping to change at line 563
score_out.zeros(); score_out.zeros();
} }
return true; return true;
} }
//! \brief //! \brief
//! principal component analysis -- 1 argument complex version //! principal component analysis -- 1 argument complex version
//! computation is done via singular value decomposition //! computation is done via singular value decomposition
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
template<typename T> template<typename T1>
inline inline
bool bool
op_princomp::direct_princomp op_princomp::direct_princomp
( (
Mat< std::complex<T> >& coeff_out, Mat< std::complex<typename T1::pod_type> >& coeff_out,
const Mat< std::complex<T> >& in const Base< std::complex<typename T1::pod_type>, T1 >& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::pod_type T;
typedef std::complex<T> eT;
typedef typename std::complex<T> eT; const unwrap<T1> Y( X.get_ref() );
const Mat<eT>& in = Y.M;
if(in.n_elem != 0) if(in.n_elem != 0)
{ {
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
const Mat<eT> tmp = in - repmat(mean(in), in.n_rows, 1); const Mat<eT> tmp = in - repmat(mean(in), in.n_rows, 1);
const bool svd_ok = svd(U,s,coeff_out, tmp); const bool svd_ok = svd(U,s,coeff_out, tmp);
 End of changes. 29 change blocks. 
42 lines changed or deleted 94 lines changed or added


 op_relational_meat.hpp   op_relational_meat.hpp 
skipping to change at line 77 skipping to change at line 77
for(uword col=0; col < n_cols; ++col)\ for(uword col=0; col < n_cols; ++col)\
for(uword row=0; row < n_rows; ++row, ++count)\ for(uword row=0; row < n_rows; ++row, ++count)\
{\ {\
out_mem[count] = (val operator_rel P.at(row,col)) ? uword(1) : uw ord(0);\ out_mem[count] = (val operator_rel P.at(row,col)) ? uword(1) : uw ord(0);\
}\ }\
}\ }\
}\ }\
}\ }\
else\ else\
{\ {\
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);\ const Mat<eT> tmp(P.Q);\
\ \
out = (val) operator_rel (tmp.M);\ out = (val) operator_rel (tmp);\
}\ }\
} }
#define arma_applier_mat_post(operator_rel) \ #define arma_applier_mat_post(operator_rel) \
{\ {\
typedef typename T1::elem_type eT;\ typedef typename T1::elem_type eT;\
typedef typename Proxy<T1>::ea_type ea_type;\ typedef typename Proxy<T1>::ea_type ea_type;\
\ \
const eT val = X.aux;\ const eT val = X.aux;\
\ \
skipping to change at line 136 skipping to change at line 136
for(uword col=0; col < n_cols; ++col)\ for(uword col=0; col < n_cols; ++col)\
for(uword row=0; row < n_rows; ++row, ++count)\ for(uword row=0; row < n_rows; ++row, ++count)\
{\ {\
out_mem[count] = (P.at(row,col) operator_rel val) ? uword(1) : uw ord(0);\ out_mem[count] = (P.at(row,col) operator_rel val) ? uword(1) : uw ord(0);\
}\ }\
}\ }\
}\ }\
}\ }\
else\ else\
{\ {\
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);\ const Mat<eT> tmp(P.Q);\
\ \
out = (tmp.M) operator_rel (val);\ out = (tmp) operator_rel (val);\
}\ }\
} }
#define arma_applier_cube_pre(operator_rel) \ #define arma_applier_cube_pre(operator_rel) \
{\ {\
typedef typename T1::elem_type eT;\ typedef typename T1::elem_type eT;\
typedef typename ProxyCube<T1>::ea_type ea_type;\ typedef typename ProxyCube<T1>::ea_type ea_type;\
\ \
const eT val = X.aux;\ const eT val = X.aux;\
\ \
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_reshape_meat.hpp   op_reshape_meat.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 25 skipping to change at line 25
template<typename T1> template<typename T1>
inline inline
void void
op_reshape::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reshape> & in) op_reshape::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reshape> & in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> A_tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = A_tmp.M;
const bool is_alias = (&out == &A);
const uword in_n_rows = in.aux_uword_a; const uword in_n_rows = in.aux_uword_a;
const uword in_n_cols = in.aux_uword_b; const uword in_n_cols = in.aux_uword_b;
const uword in_dim = in.aux_uword_c; const uword in_dim = in.aux_uword_c;
const uword in_n_elem = in_n_rows * in_n_cols; const uword in_n_elem = in_n_rows * in_n_cols;
if(A.n_elem == in_n_elem) if(A.n_elem == in_n_elem)
{ {
if(in_dim == 0) if(in_dim == 0)
{ {
if(&out != &A) if(is_alias == false)
{ {
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
arrayops::copy( out.memptr(), A.memptr(), out.n_elem ); arrayops::copy( out.memptr(), A.memptr(), out.n_elem );
} }
else // &out == &A, i.e. inplace resize else // &out == &A, i.e. inplace resize
{ {
const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols = = in_n_cols) ); const bool same_size = ( (out.n_rows == in_n_rows) && (out.n_cols = = in_n_cols) );
if(same_size == false) if(same_size == false)
{ {
skipping to change at line 62 skipping to change at line 64
"reshape(): size can't be changed as template based size specif ication is in use" "reshape(): size can't be changed as template based size specif ication is in use"
); );
access::rw(out.n_rows) = in_n_rows; access::rw(out.n_rows) = in_n_rows;
access::rw(out.n_cols) = in_n_cols; access::rw(out.n_cols) = in_n_cols;
} }
} }
} }
else else
{ {
unwrap_check< Mat<eT> > tmp(A, out); unwrap_check< Mat<eT> > B_tmp(A, is_alias);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = B_tmp.M;
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
uword i = 0; uword i = 0;
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;
for(uword row=0; row<B_n_rows; ++row) for(uword row=0; row<B_n_rows; ++row)
for(uword col=0; col<B_n_cols; ++col)
{ {
for(uword col=0; col<B_n_cols; ++col) out_mem[i] = B.at(row,col);
{ ++i;
out_mem[i] = B.at(row,col);
++i;
}
} }
} }
} }
else else
{ {
const unwrap_check< Mat<eT> > tmp(A, out); const unwrap_check< Mat<eT> > B_tmp(A, is_alias);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = B_tmp.M;
const uword n_elem_to_copy = (std::min)(B.n_elem, in_n_elem); const uword n_elem_to_copy = (std::min)(B.n_elem, in_n_elem);
out.set_size(in_n_rows, in_n_cols); out.set_size(in_n_rows, in_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(in_dim == 0) if(in_dim == 0)
{ {
arrayops::copy( out_mem, B.memptr(), n_elem_to_copy ); arrayops::copy( out_mem, B.memptr(), n_elem_to_copy );
skipping to change at line 137 skipping to change at line 136
template<typename T1> template<typename T1>
inline inline
void void
op_reshape::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_res hape>& in) op_reshape::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_res hape>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(in.m); const unwrap_cube<T1> A_tmp(in.m);
const Cube<eT>& A = tmp.M; const Cube<eT>& A = A_tmp.M;
const uword in_n_rows = in.aux_uword_a; const uword in_n_rows = in.aux_uword_a;
const uword in_n_cols = in.aux_uword_b; const uword in_n_cols = in.aux_uword_b;
const uword in_n_slices = in.aux_uword_c; const uword in_n_slices = in.aux_uword_c;
const uword in_dim = in.aux_uword_d; const uword in_dim = in.aux_uword_d;
const uword in_n_elem = in_n_rows * in_n_cols * in_n_slices; const uword in_n_elem = in_n_rows * in_n_cols * in_n_slices;
if(A.n_elem == in_n_elem) if(A.n_elem == in_n_elem)
{ {
skipping to change at line 181 skipping to change at line 180
access::rw(out.n_cols) = in_n_cols; access::rw(out.n_cols) = in_n_cols;
access::rw(out.n_elem_slice) = in_n_rows * in_n_cols; access::rw(out.n_elem_slice) = in_n_rows * in_n_cols;
access::rw(out.n_slices) = in_n_slices; access::rw(out.n_slices) = in_n_slices;
out.create_mat(); out.create_mat();
} }
} }
} }
else else
{ {
unwrap_cube_check< Cube<eT> > tmp(A, out); unwrap_cube_check< Cube<eT> > B_tmp(A, out);
const Cube<eT>& B = tmp.M; const Cube<eT>& B = B_tmp.M;
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
uword i = 0; uword i = 0;
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;
const uword B_n_slices = B.n_slices; const uword B_n_slices = B.n_slices;
for(uword slice=0; slice<B_n_slices; ++slice) for(uword slice=0; slice<B_n_slices; ++slice)
for(uword row=0; row<B_n_rows; ++row)
for(uword col=0; col<B_n_cols; ++col)
{ {
for(uword row=0; row<B_n_rows; ++row) out_mem[i] = B.at(row,col,slice);
{ ++i;
for(uword col=0; col<B_n_cols; ++col)
{
out_mem[i] = B.at(row,col,slice);
++i;
}
}
} }
} }
} }
else else
{ {
const unwrap_cube_check< Cube<eT> > tmp(A, out); const unwrap_cube_check< Cube<eT> > B_tmp(A, out);
const Cube<eT>& B = tmp.M; const Cube<eT>& B = B_tmp.M;
const uword n_elem_to_copy = (std::min)(B.n_elem, in_n_elem); const uword n_elem_to_copy = (std::min)(B.n_elem, in_n_elem);
out.set_size(in_n_rows, in_n_cols, in_n_slices); out.set_size(in_n_rows, in_n_cols, in_n_slices);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(in_dim == 0) if(in_dim == 0)
{ {
arrayops::copy( out_mem, B.memptr(), n_elem_to_copy ); arrayops::copy( out_mem, B.memptr(), n_elem_to_copy );
 End of changes. 14 change blocks. 
30 lines changed or deleted 24 lines changed or added


 op_shuffle_meat.hpp   op_shuffle_meat.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 29 skipping to change at line 29
void void
op_shuffle::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_shuffle> & in) op_shuffle::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_shuffle> & in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
if(X.is_empty()) if(X.is_empty()) { out.copy_size(X); return; }
{
out.copy_size(X);
return;
}
const uword dim = in.aux_uword_a; const uword dim = in.aux_uword_a;
const uword N = (dim == 0) ? X.n_rows : X.n_cols; const uword N = (dim == 0) ? X.n_rows : X.n_cols;
// see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet_ ascend" // see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet_ ascend"
// and the associated "operator<" // and the associated "operator<"
std::vector< arma_sort_index_packet_ascend<int,uword> > packet_vec(N); std::vector< arma_sort_index_packet_ascend<int,uword> > packet_vec(N);
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
packet_vec[i].val = std::rand(); packet_vec[i].val = std::rand();
packet_vec[i].index = i; packet_vec[i].index = i;
} }
std::sort( packet_vec.begin(), packet_vec.end() ); std::sort( packet_vec.begin(), packet_vec.end() );
const bool is_alias = (&out == &X);
if(X.is_vec() == false) if(X.is_vec() == false)
{ {
if(&out != &X) if(is_alias == false)
{ {
arma_extra_debug_print("op_shuffle::apply(): matrix"); arma_extra_debug_print("op_shuffle::apply(): matrix");
out.copy_size(X); out.copy_size(X);
if(dim == 0) if(dim == 0)
{ {
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i) { out.row(i) = X.row(packet_vec[i].index);
{ }
out.row(i) = X.row(packet_vec[i].index);
}
} }
else else
{ {
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i) { out.col(i) = X.col(packet_vec[i].index);
{ }
out.col(i) = X.col(packet_vec[i].index);
}
} }
} }
else // in-place shuffle else // in-place shuffle
{ {
arma_extra_debug_print("op_shuffle::apply(): in-place matrix"); arma_extra_debug_print("op_shuffle::apply(): in-place matrix");
// reuse the val member variable of packet_vec // reuse the val member variable of packet_vec
// to indicate whether a particular row or column // to indicate whether a particular row or column
// has already been shuffled // has already been shuffled
skipping to change at line 118 skipping to change at line 110
out.swap_cols(i, j); out.swap_cols(i, j);
packet_vec[j].val = 1; packet_vec[j].val = 1;
} }
} }
} }
} }
} }
else // we're dealing with a vector else // we're dealing with a vector
{ {
if(&out != &X) if(is_alias == false)
{ {
arma_extra_debug_print("op_shuffle::apply(): vector"); arma_extra_debug_print("op_shuffle::apply(): vector");
out.copy_size(X); out.copy_size(X);
if(dim == 0) if(dim == 0)
{ {
if(X.n_rows > 1) // i.e. column vector if(X.n_rows > 1) // i.e. column vector
{ {
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i) { out[i] = X[ packet_vec[i].index ]; }
{
out[i] = X[ packet_vec[i].index ];
}
} }
else else
{ {
out = X; out = X;
} }
} }
else else
{ {
if(X.n_cols > 1) // i.e. row vector if(X.n_cols > 1) // i.e. row vector
{ {
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i) { out[i] = X[ packet_vec[i].index ]; }
{
out[i] = X[ packet_vec[i].index ];
}
} }
else else
{ {
out = X; out = X;
} }
} }
} }
else // in-place shuffle else // in-place shuffle
{ {
arma_extra_debug_print("op_shuffle::apply(): in-place vector"); arma_extra_debug_print("op_shuffle::apply(): in-place vector");
 End of changes. 9 change blocks. 
25 lines changed or deleted 13 lines changed or added


 op_sort_meat.hpp   op_sort_meat.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 144 skipping to change at line 144
template<typename T1> template<typename T1>
inline inline
void void
op_sort::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort>& in) op_sort::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const uword sort_type = in.aux_uword_a; const uword sort_type = in.aux_uword_a;
const uword dim = in.aux_uword_b; const uword dim = in.aux_uword_b;
arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor t_type must be 0 or 1"); arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor t_type must be 0 or 1");
arma_debug_check( (dim > 1), "sort(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sort(): incorrect usage. dim must be 0 or 1" );
arma_debug_check( (X.is_finite() == false), "sort(): given object has non -finite elements" ); arma_debug_check( (X.is_finite() == false), "sort(): given object has non -finite elements" );
if( (X.n_rows * X.n_cols) <= 1 ) if( (X.n_rows * X.n_cols) <= 1 )
{ {
 End of changes. 2 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_stddev_meat.hpp   op_stddev_meat.hpp 
skipping to change at line 66 skipping to change at line 66
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_stddev::apply(), dim = 1"); arma_extra_debug_print("op_stddev::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "stddev(): given object has zero col umns" ); arma_debug_check( (X_n_cols == 0), "stddev(): given object has zero col umns" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
podarray<in_eT> tmp(X_n_cols); podarray<in_eT> dat(X_n_cols);
in_eT* tmp_mem = tmp.memptr(); in_eT* dat_mem = dat.memptr();
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp.copy_row(X, row); dat.copy_row(X, row);
out_mem[row] = std::sqrt( op_var::direct_var( tmp_mem, X_n_cols, norm _type) ); out_mem[row] = std::sqrt( op_var::direct_var( dat_mem, X_n_cols, norm _type) );
} }
} }
} }
//! @} //! @}
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_strans_bones.hpp   op_strans_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 31 skipping to change at line 31
template<const bool do_flip, const uword row, const uword col> template<const bool do_flip, const uword row, const uword col>
struct pos struct pos
{ {
static const uword n2 = (do_flip == false) ? (row + col*2) : (col + row *2); static const uword n2 = (do_flip == false) ? (row + col*2) : (col + row *2);
static const uword n3 = (do_flip == false) ? (row + col*3) : (col + row *3); static const uword n3 = (do_flip == false) ? (row + col*3) : (col + row *3);
static const uword n4 = (do_flip == false) ? (row + col*4) : (col + row *4); static const uword n4 = (do_flip == false) ? (row + col*4) : (col + row *4);
}; };
template<typename eT> template<typename eT>
inline static void apply_noalias_tinysq(Mat<eT>& out, const Mat<eT>& A); arma_hot inline static void apply_noalias_tinysq(Mat<eT>& out, const Mat< eT>& A);
template<typename eT> template<typename eT>
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A); arma_hot inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A) ;
template<typename eT> template<typename eT>
inline static void apply(Mat<eT>& out, const Mat<eT>& A); arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const
_strans>& in); Op<T1,op_strans>& in);
};
class op_strans2
{
public:
template<const bool do_flip, const uword row, const uword col>
struct pos
{
static const uword n2 = (do_flip == false) ? (row + col*2) : (col + row
*2);
static const uword n3 = (do_flip == false) ? (row + col*3) : (col + row
*3);
static const uword n4 = (do_flip == false) ? (row + col*4) : (col + row
*4);
};
// inline static void apply_inplace(mat &out); template<typename eT>
arma_hot inline static void apply_noalias_tinysq(Mat<eT>& out, const Mat<
eT>& A, const eT val);
template<typename eT>
arma_hot inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A,
const eT val);
template<typename eT>
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const e
T val);
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
8 lines changed or deleted 33 lines changed or added


 op_strans_meat.hpp   op_strans_meat.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)
//! \addtogroup op_strans //! \addtogroup op_strans
//! @{ //! @{
//! for tiny square matrices (size <= 4x4) //! for tiny square matrices (size <= 4x4)
template<typename eT> template<typename eT>
arma_hot
inline inline
void void
op_strans::apply_noalias_tinysq(Mat<eT>& out, const Mat<eT>& A) op_strans::apply_noalias_tinysq(Mat<eT>& out, const Mat<eT>& A)
{ {
const eT* Am = A.memptr(); const eT* Am = A.memptr();
eT* outm = out.memptr(); eT* outm = out.memptr();
switch(A.n_rows) switch(A.n_rows)
{ {
case 1: case 1:
skipping to change at line 91 skipping to change at line 92
break; break;
default: default:
; ;
} }
} }
//! Immediate transpose of a dense matrix //! Immediate transpose of a dense matrix
template<typename eT> template<typename eT>
arma_hot
inline inline
void void
op_strans::apply_noalias(Mat<eT>& out, const Mat<eT>& A) op_strans::apply_noalias(Mat<eT>& out, const Mat<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
out.set_size(A_n_cols, A_n_rows); out.set_size(A_n_cols, A_n_rows);
skipping to change at line 139 skipping to change at line 141
if(i < A_n_rows) if(i < A_n_rows)
{ {
out.at(k, i) = colptr[i]; out.at(k, i) = colptr[i];
} }
} }
} }
} }
} }
template<typename eT> template<typename eT>
arma_hot
inline inline
void void
op_strans::apply(Mat<eT>& out, const Mat<eT>& A) op_strans::apply(Mat<eT>& out, const Mat<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(&out != &A) if(&out != &A)
{ {
op_strans::apply_noalias(out, A); op_strans::apply_noalias(out, A);
} }
skipping to change at line 189 skipping to change at line 192
{ {
Mat<eT> tmp; Mat<eT> tmp;
op_strans::apply_noalias(tmp, A); op_strans::apply_noalias(tmp, A);
out.steal_mem(tmp); out.steal_mem(tmp);
} }
} }
} }
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
op_strans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_strans>& in) op_strans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_strans>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_strans::apply(out, A); op_strans::apply(out, A);
} }
// inline void op_strans::apply_inplace(mat &X)
// {
// arma_extra_debug_sigprint();
// //
// if((X.n_rows == 1) || (X.n_cols == 1)) // op_strans2
// {
// const uword old_n_rows = X.n_rows; //! for tiny square matrices (size <= 4x4)
// access::rw(X.n_rows) = X.n_cols; template<typename eT>
// access::rw(X.n_cols) = old_n_rows; arma_hot
// } inline
// else void
// if(X.n_rows == X.n_cols) op_strans2::apply_noalias_tinysq(Mat<eT>& out, const Mat<eT>& A, const eT v
// { al)
// for(uword col=0; col < X.n_cols; ++col) {
// { const eT* Am = A.memptr();
// double* X_coldata = X.colptr(col); eT* outm = out.memptr();
//
// for(uword row=(col+1); row < X.n_rows; ++row) switch(A.n_rows)
// { {
// std::swap( A.at(col,row), A_coldata[row] ); case 1:
// } {
// } outm[0] = val * Am[0];
// } }
// else break;
// {
// mat tmp = trans(X); case 2:
// {
// if(X.mem != X.mem_local) outm[pos<false,0,0>::n2] = val * Am[pos<true,0,0>::n2];
// { outm[pos<false,1,0>::n2] = val * Am[pos<true,1,0>::n2];
// double* old_mem = X.memptr();
// access::rw(X.mem) = tmp.memptr(); outm[pos<false,0,1>::n2] = val * Am[pos<true,0,1>::n2];
// access::rw(tmp.mem) = old_mem; outm[pos<false,1,1>::n2] = val * Am[pos<true,1,1>::n2];
// } }
// else break;
// {
// X = tmp; case 3:
// } {
// } outm[pos<false,0,0>::n3] = val * Am[pos<true,0,0>::n3];
// outm[pos<false,1,0>::n3] = val * Am[pos<true,1,0>::n3];
// } outm[pos<false,2,0>::n3] = val * Am[pos<true,2,0>::n3];
outm[pos<false,0,1>::n3] = val * Am[pos<true,0,1>::n3];
outm[pos<false,1,1>::n3] = val * Am[pos<true,1,1>::n3];
outm[pos<false,2,1>::n3] = val * Am[pos<true,2,1>::n3];
outm[pos<false,0,2>::n3] = val * Am[pos<true,0,2>::n3];
outm[pos<false,1,2>::n3] = val * Am[pos<true,1,2>::n3];
outm[pos<false,2,2>::n3] = val * Am[pos<true,2,2>::n3];
}
break;
case 4:
{
outm[pos<false,0,0>::n4] = val * Am[pos<true,0,0>::n4];
outm[pos<false,1,0>::n4] = val * Am[pos<true,1,0>::n4];
outm[pos<false,2,0>::n4] = val * Am[pos<true,2,0>::n4];
outm[pos<false,3,0>::n4] = val * Am[pos<true,3,0>::n4];
outm[pos<false,0,1>::n4] = val * Am[pos<true,0,1>::n4];
outm[pos<false,1,1>::n4] = val * Am[pos<true,1,1>::n4];
outm[pos<false,2,1>::n4] = val * Am[pos<true,2,1>::n4];
outm[pos<false,3,1>::n4] = val * Am[pos<true,3,1>::n4];
outm[pos<false,0,2>::n4] = val * Am[pos<true,0,2>::n4];
outm[pos<false,1,2>::n4] = val * Am[pos<true,1,2>::n4];
outm[pos<false,2,2>::n4] = val * Am[pos<true,2,2>::n4];
outm[pos<false,3,2>::n4] = val * Am[pos<true,3,2>::n4];
outm[pos<false,0,3>::n4] = val * Am[pos<true,0,3>::n4];
outm[pos<false,1,3>::n4] = val * Am[pos<true,1,3>::n4];
outm[pos<false,2,3>::n4] = val * Am[pos<true,2,3>::n4];
outm[pos<false,3,3>::n4] = val * Am[pos<true,3,3>::n4];
}
break;
default:
;
}
}
//! Immediate transpose of a dense matrix
template<typename eT>
arma_hot
inline
void
op_strans2::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const eT val)
{
arma_extra_debug_sigprint();
const uword A_n_cols = A.n_cols;
const uword A_n_rows = A.n_rows;
out.set_size(A_n_cols, A_n_rows);
if( (A_n_cols == 1) || (A_n_rows == 1) )
{
const uword N = A.n_elem;
const eT* A_mem = A.memptr();
eT* out_mem = out.memptr();
uword i,j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
const eT tmp_i = A_mem[i];
const eT tmp_j = A_mem[j];
out_mem[i] = val * tmp_i;
out_mem[j] = val * tmp_j;
}
if(i < N)
{
out_mem[i] = val * A_mem[i];
}
}
else
{
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) )
{
op_strans2::apply_noalias_tinysq(out, A, val);
}
else
{
for(uword k=0; k < A_n_cols; ++k)
{
uword i, j;
const eT* colptr = A.colptr(k);
for(i=0, j=1; j < A_n_rows; i+=2, j+=2)
{
const eT tmp_i = colptr[i];
const eT tmp_j = colptr[j];
out.at(k, i) = val * tmp_i;
out.at(k, j) = val * tmp_j;
}
if(i < A_n_rows)
{
out.at(k, i) = val * colptr[i];
}
}
}
}
}
template<typename eT>
arma_hot
inline
void
op_strans2::apply(Mat<eT>& out, const Mat<eT>& A, const eT val)
{
arma_extra_debug_sigprint();
if(&out != &A)
{
op_strans2::apply_noalias(out, A, val);
}
else
{
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
if(n_rows == n_cols)
{
arma_extra_debug_print("op_strans2::apply(): doing in-place transpose
of a square matrix");
const uword N = n_rows;
// TODO: do multiplication while swapping
for(uword k=0; k < N; ++k)
{
eT* colptr = out.colptr(k);
uword i,j;
for(i=(k+1), j=(k+2); j < N; i+=2, j+=2)
{
std::swap(out.at(k,i), colptr[i]);
std::swap(out.at(k,j), colptr[j]);
}
if(i < N)
{
std::swap(out.at(k,i), colptr[i]);
}
}
arrayops::inplace_mul( out.memptr(), val, out.n_elem );
}
else
{
Mat<eT> tmp;
op_strans2::apply_noalias(tmp, A, val);
out.steal_mem(tmp);
}
}
}
//! @} //! @}
 End of changes. 7 change blocks. 
41 lines changed or deleted 206 lines changed or added


 op_sum_meat.hpp   op_sum_meat.hpp 
skipping to change at line 34 skipping to change at line 34
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword dim = in.aux_uword_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" );
const Proxy<T1> P(in.m); const Proxy<T1> P(in.m);
if( (is_Mat< typename Proxy<T1>::stored_type>::value == true) || (P.is_al const bool is_alias = P.is_alias(out);
ias(out) == true) )
if( (is_Mat< typename Proxy<T1>::stored_type>::value == true) || is_alias
)
{ {
const unwrap_check< typename Proxy<T1>::stored_type > tmp(P.Q, out); const unwrap_check< typename Proxy<T1>::stored_type > tmp(P.Q, is_alias );
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
const uword X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the sum in each column ) if(dim == 0) // traverse across rows (i.e. find the sum in each column )
{ {
out.set_size(1, X_n_cols); out.set_size(1, X_n_cols);
 End of changes. 2 change blocks. 
3 lines changed or deleted 5 lines changed or added


 op_symmat_meat.hpp   op_symmat_meat.hpp 
// Copyright (C) 2011 NICTA (www.nicta.com.au) // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Conrad Sanderson // Copyright (C) 2011-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 31 skipping to change at line 31
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Op<T1,op_symmat>& in, const Op<T1,op_symmat>& in,
const typename arma_not_cx<typename T1::elem_type>::result* junk const typename arma_not_cx<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" );
const uword N = A.n_rows; const uword N = A.n_rows;
const bool upper = (in.aux_uword_a == 0); const bool upper = (in.aux_uword_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(upper) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
skipping to change at line 114 skipping to change at line 114
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Op<T1,op_symmat>& in, const Op<T1,op_symmat>& in,
const typename arma_cx_only<typename T1::elem_type>::result* junk const typename arma_cx_only<typename T1::elem_type>::result* junk
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "symmatu()/symmatl(): given m atrix must be square" );
const uword N = A.n_rows; const uword N = A.n_rows;
const bool upper = (in.aux_uword_a == 0); const bool upper = (in.aux_uword_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(upper) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
 End of changes. 5 change blocks. 
8 lines changed or deleted 8 lines changed or added


 op_trimat_bones.hpp   op_trimat_bones.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// Copyright (C) 2011 Ryan Curtin // Copyright (C) 2011 Ryan Curtin
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
 End of changes. 1 change blocks. 
2 lines changed or deleted 2 lines changed or added


 op_trimat_meat.hpp   op_trimat_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// Copyright (C) 2011 Ryan Curtin // Copyright (C) 2011 Ryan Curtin
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 59 skipping to change at line 59
template<typename T1> template<typename T1>
inline inline
void void
op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimat>& in) op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimat>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" ); arma_debug_check( (A.is_square() == false), "trimatu()/trimatl(): given m atrix must be square" );
const uword N = A.n_rows; const uword N = A.n_rows;
const bool upper = (in.aux_uword_a == 0); const bool upper = (in.aux_uword_a == 0);
if(&out != &A) if(&out != &A)
{ {
out.copy_size(A); out.copy_size(A);
if(upper) if(upper)
{ {
// upper triangular: copy the diagonal and the elements above the dia gonal // upper triangular: copy the diagonal and the elements above the dia gonal
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
 End of changes. 3 change blocks. 
5 lines changed or deleted 5 lines changed or added


 op_var_meat.hpp   op_var_meat.hpp 
skipping to change at line 66 skipping to change at line 66
} }
else else
if(dim == 1) if(dim == 1)
{ {
arma_extra_debug_print("op_var::apply(), dim = 1"); arma_extra_debug_print("op_var::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "var(): given object has zero column s" ); arma_debug_check( (X_n_cols == 0), "var(): given object has zero column s" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
podarray<in_eT> tmp(X_n_cols); podarray<in_eT> dat(X_n_cols);
in_eT* tmp_mem = tmp.memptr(); in_eT* dat_mem = dat.memptr();
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp.copy_row(X, row); dat.copy_row(X, row);
out_mem[row] = op_var::direct_var( tmp_mem, X_n_cols, norm_type ); out_mem[row] = op_var::direct_var( dat_mem, X_n_cols, norm_type );
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
typename T1::pod_type typename T1::pod_type
op_var::var_vec(const Base<typename T1::elem_type, T1>& X, const uword norm _type) op_var::var_vec(const Base<typename T1::elem_type, T1>& X, const uword norm _type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 operator_times.hpp   operator_times.hpp 
skipping to change at line 140 skipping to change at line 140
operator* operator*
(const Op<T1, op_diagmat>& X, const T2& Y) (const Op<T1, op_diagmat>& X, const T2& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Glue<Op<T1, op_diagmat>, T2, glue_times_diag>(X, Y); return Glue<Op<T1, op_diagmat>, T2, glue_times_diag>(X, Y);
} }
//! diagmat * diagmat //! diagmat * diagmat
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline inline
Mat< typename promote_type<typename T1::elem_type, typename T2::elem_type>: :result > Mat< typename promote_type<typename T1::elem_type, typename T2::elem_type>: :result >
operator* operator*
(const Op<T1, op_diagmat>& X, const Op<T2, op_diagmat>& Y) (const Op<T1, op_diagmat>& X, const Op<T2, op_diagmat>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
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;
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 running_stat_meat.hpp   running_stat_meat.hpp 
skipping to change at line 169 skipping to change at line 169
} }
//! set all statistics to zero //! set all statistics to zero
template<typename eT> template<typename eT>
inline inline
void void
running_stat<eT>::reset() running_stat<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename running_stat<eT>::T T; // typedef typename running_stat<eT>::T T;
counter.reset(); counter.reset();
r_mean = eT(0); r_mean = eT(0);
r_var = T(0); r_var = T(0);
min_val = eT(0); min_val = eT(0);
max_val = eT(0); max_val = eT(0);
min_val_norm = T(0); min_val_norm = T(0);
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 subview_bones.hpp   subview_bones.hpp 
skipping to change at line 77 skipping to change at line 77
inline static void plus_inplace(Mat<eT>& out, const subview& in); inline static void plus_inplace(Mat<eT>& out, const subview& in);
inline static void minus_inplace(Mat<eT>& out, const subview& in); inline static void minus_inplace(Mat<eT>& out, const subview& in);
inline static void schur_inplace(Mat<eT>& out, const subview& in); inline static void schur_inplace(Mat<eT>& out, const subview& in);
inline static void div_inplace(Mat<eT>& out, const subview& in); inline static void div_inplace(Mat<eT>& out, const subview& in);
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void ones(); inline void ones();
inline void eye(); inline void eye();
inline eT& operator[](const uword i); inline eT& operator[](const uword ii);
inline eT operator[](const uword i) const; inline eT operator[](const uword ii) const;
inline eT& operator()(const uword i); inline eT& operator()(const uword ii);
inline eT operator()(const uword i) const; inline eT operator()(const uword ii) const;
inline eT& operator()(const uword in_row, const uword in_col); inline eT& operator()(const uword in_row, const uword in_col);
inline eT operator()(const uword in_row, const uword in_col) const; inline eT operator()(const uword in_row, const uword in_col) const;
inline eT& at(const uword in_row, const uword in_col); inline eT& at(const uword in_row, const uword in_col);
inline eT at(const uword in_row, const uword in_col) const; inline eT at(const uword in_row, const uword in_col) const;
arma_inline eT* colptr(const uword in_col); arma_inline eT* colptr(const uword in_col);
arma_inline const eT* colptr(const uword in_col) const; arma_inline const eT* colptr(const uword in_col) const;
skipping to change at line 209 skipping to change at line 209
arma_inline eT* colptr(const uword in_col); arma_inline eT* colptr(const uword in_col);
arma_inline const eT* colptr(const uword in_col) const; arma_inline const eT* colptr(const uword in_col) const;
inline subview_col<eT> rows(const uword in_row1, const uword in_row 2); inline subview_col<eT> rows(const uword in_row1, const uword in_row 2);
inline const subview_col<eT> rows(const uword in_row1, const uword in_row 2) const; inline const subview_col<eT> rows(const uword in_row1, const uword in_row 2) const;
inline subview_col<eT> subvec(const uword in_row1, const uword in_r ow2); inline subview_col<eT> subvec(const uword in_row1, const uword in_r ow2);
inline const subview_col<eT> subvec(const uword in_row1, const uword in_r ow2) const; inline const subview_col<eT> subvec(const uword in_row1, const uword in_r ow2) const;
// TODO: add operator()(span)
protected: protected:
inline subview_col(const Mat<eT>& in_m, const uword in_col); inline subview_col(const Mat<eT>& in_m, const uword in_col);
inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword i n_row1, const uword in_n_rows); inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword i n_row1, const uword in_n_rows);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Col<eT>; friend class Col<eT>;
friend class subview<eT>; friend class subview<eT>;
skipping to change at line 262 skipping to change at line 264
inline eT& at(const uword in_row, const uword in_col); inline eT& at(const uword in_row, const uword in_col);
inline eT at(const uword in_row, const uword in_col) const; inline eT at(const uword in_row, const uword in_col) const;
inline subview_row<eT> cols(const uword in_col1, const uword in_col 2); inline subview_row<eT> cols(const uword in_col1, const uword in_col 2);
inline const subview_row<eT> cols(const uword in_col1, const uword in_col 2) const; inline const subview_row<eT> cols(const uword in_col1, const uword in_col 2) const;
inline subview_row<eT> subvec(const uword in_col1, const uword in_c ol2); inline subview_row<eT> subvec(const uword in_col1, const uword in_c ol2);
inline const subview_row<eT> subvec(const uword in_col1, const uword in_c ol2) const; inline const subview_row<eT> subvec(const uword in_col1, const uword in_c ol2) const;
// TODO: add operator()(span)
protected: protected:
inline subview_row(const Mat<eT>& in_m, const uword in_row); inline subview_row(const Mat<eT>& in_m, const uword in_row);
inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword i n_col1, const uword in_n_cols); inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword i n_col1, const uword in_n_cols);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Row<eT>; friend class Row<eT>;
friend class subview<eT>; friend class subview<eT>;
 End of changes. 4 change blocks. 
4 lines changed or deleted 8 lines changed or added


 subview_elem1_meat.hpp   subview_elem1_meat.hpp 
skipping to change at line 57 skipping to change at line 57
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const uword* aa_mem = aa.memptr(); const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem; const uword aa_n_elem = aa.n_elem;
uword i,j; uword iq,jq;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[iq];
const uword jj = aa_mem[j]; const uword jj = aa_mem[jq];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem( ): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; m_mem[jj] = val; } if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; m_mem[jj] = val; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; m_mem[jj] += val; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; m_mem[jj] += val; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; m_mem[jj] -= val; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; m_mem[jj] -= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; m_mem[jj] *= val; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; m_mem[jj] *= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; m_mem[jj] /= val; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; m_mem[jj] /= val; }
} }
if(i < aa_n_elem) if(iq < aa_n_elem)
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[iq];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; } if(is_same_type<op_type, op_subview_elem_equ >::value == true) { m_mem[ii] = val; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { m_mem[ii] += val; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { m_mem[ii] -= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { m_mem[ii] *= val; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; }
} }
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type, typename T2> template<typename op_type, typename T2>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const subview_elem1<eT,T2>& x) subview_elem1<eT,T1>::inplace_op(const subview_elem1<eT,T2>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_elem1<eT,T1>& t = *this; subview_elem1<eT,T1>& s = *this;
if(&(t.m) == &(x.m)) if(&(s.m) == &(x.m))
{ {
arma_extra_debug_print("subview_elem1::inplace_op(): aliasing detected" ); arma_extra_debug_print("subview_elem1::inplace_op(): aliasing detected" );
const Mat<eT> tmp(x); const Mat<eT> tmp(x);
if(is_same_type<op_type, op_subview_elem_equ >::value == if(is_same_type<op_type, op_subview_elem_equ >::value ==
true) { t.operator= (tmp); } true) { s.operator= (tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value ==
true) { t.operator+=(tmp); } true) { s.operator+=(tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value ==
true) { t.operator-=(tmp); } true) { s.operator-=(tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value ==
true) { t.operator%=(tmp); } true) { s.operator%=(tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == else if(is_same_type<op_type, op_subview_elem_inplace_div >::value ==
true) { t.operator/=(tmp); } true) { s.operator/=(tmp); }
} }
else else
{ {
Mat<eT>& t_m_local = const_cast< Mat<eT>& >(t.m); Mat<eT>& s_m_local = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& x_m_local = x.m; const Mat<eT>& x_m_local = x.m;
const unwrap_check_mixed<T1> t_tmp(t.a.get_ref(), t_m_local); const unwrap_check_mixed<T1> s_tmp(s.a.get_ref(), s_m_local);
const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), t_m_local); const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), s_m_local);
const umat& t_aa = t_tmp.M; const umat& s_aa = s_tmp.M;
const umat& x_aa = x_tmp.M; const umat& x_aa = x_tmp.M;
arma_debug_check arma_debug_check
( (
( (t_aa.is_vec() == false) || (x_aa.is_vec() == false) ), ( (s_aa.is_vec() == false) || (x_aa.is_vec() == false) ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const uword* t_aa_mem = t_aa.memptr(); const uword* s_aa_mem = s_aa.memptr();
const uword* x_aa_mem = x_aa.memptr(); const uword* x_aa_mem = x_aa.memptr();
const uword t_aa_n_elem = t_aa.n_elem; const uword s_aa_n_elem = s_aa.n_elem;
arma_debug_check( (t_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mism atch" ); arma_debug_check( (s_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mism atch" );
eT* t_m_mem = t_m_local.memptr(); eT* s_m_mem = s_m_local.memptr();
const uword t_m_n_elem = t_m_local.n_elem; const uword s_m_n_elem = s_m_local.n_elem;
const eT* x_m_mem = x_m_local.memptr(); const eT* x_m_mem = x_m_local.memptr();
const uword x_m_n_elem = x_m_local.n_elem; const uword x_m_n_elem = x_m_local.n_elem;
uword i,j; uword iq,jq;
for(i=0, j=1; j<t_aa_n_elem; i+=2, j+=2) for(iq=0, jq=1; jq < s_aa_n_elem; iq+=2, jq+=2)
{ {
const uword t_ii = t_aa_mem[i]; const uword s_ii = s_aa_mem[iq];
const uword t_jj = t_aa_mem[j]; const uword s_jj = s_aa_mem[jq];
const uword x_ii = x_aa_mem[i]; const uword x_ii = x_aa_mem[iq];
const uword x_jj = x_aa_mem[j]; const uword x_jj = x_aa_mem[jq];
arma_debug_check arma_debug_check
( (
(t_ii >= t_m_n_elem) || (t_jj >= t_m_n_elem) || (x_ii >= x_m_n_elem ) || (x_jj >= x_m_n_elem), (s_ii >= s_m_n_elem) || (s_jj >= s_m_n_elem) || (x_ii >= x_m_n_elem ) || (x_jj >= x_m_n_elem),
"Mat::elem(): index out of bounds" "Mat::elem(): index out of bounds"
); );
if(is_same_type<op_type, op_subview_elem_equ >::value = if(is_same_type<op_type, op_subview_elem_equ >::value =
= true) { t_m_mem[t_ii] = x_m_mem[x_ii]; t_m_mem[t_jj] = x_m_mem[x_jj]; } = true) { s_m_mem[s_ii] = x_m_mem[x_ii]; s_m_mem[s_jj] = x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value =
= true) { t_m_mem[t_ii] += x_m_mem[x_ii]; t_m_mem[t_jj] += x_m_mem[x_jj]; } = true) { s_m_mem[s_ii] += x_m_mem[x_ii]; s_m_mem[s_jj] += x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value =
= true) { t_m_mem[t_ii] -= x_m_mem[x_ii]; t_m_mem[t_jj] -= x_m_mem[x_jj]; } = true) { s_m_mem[s_ii] -= x_m_mem[x_ii]; s_m_mem[s_jj] -= x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value =
= true) { t_m_mem[t_ii] *= x_m_mem[x_ii]; t_m_mem[t_jj] *= x_m_mem[x_jj]; } = true) { s_m_mem[s_ii] *= x_m_mem[x_ii]; s_m_mem[s_jj] *= x_m_mem[x_jj]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = else if(is_same_type<op_type, op_subview_elem_inplace_div >::value =
= true) { t_m_mem[t_ii] /= x_m_mem[x_ii]; t_m_mem[t_jj] /= x_m_mem[x_jj]; } = true) { s_m_mem[s_ii] /= x_m_mem[x_ii]; s_m_mem[s_jj] /= x_m_mem[x_jj]; }
} }
if(i < t_aa_n_elem) if(iq < s_aa_n_elem)
{ {
const uword t_ii = t_aa_mem[i]; const uword s_ii = s_aa_mem[iq];
const uword x_ii = x_aa_mem[i]; const uword x_ii = x_aa_mem[iq];
arma_debug_check arma_debug_check
( (
( (t_ii >= t_m_n_elem) || (x_ii >= x_m_n_elem) ), ( (s_ii >= s_m_n_elem) || (x_ii >= x_m_n_elem) ),
"Mat::elem(): index out of bounds" "Mat::elem(): index out of bounds"
); );
if(is_same_type<op_type, op_subview_elem_equ >::value = if(is_same_type<op_type, op_subview_elem_equ >::value =
= true) { t_m_mem[t_ii] = x_m_mem[x_ii]; } = true) { s_m_mem[s_ii] = x_m_mem[x_ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value =
= true) { t_m_mem[t_ii] += x_m_mem[x_ii]; } = true) { s_m_mem[s_ii] += x_m_mem[x_ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value =
= true) { t_m_mem[t_ii] -= x_m_mem[x_ii]; } = true) { s_m_mem[s_ii] -= x_m_mem[x_ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value =
= true) { t_m_mem[t_ii] *= x_m_mem[x_ii]; } = true) { s_m_mem[s_ii] *= x_m_mem[x_ii]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = else if(is_same_type<op_type, op_subview_elem_inplace_div >::value =
= true) { t_m_mem[t_ii] /= x_m_mem[x_ii]; } = true) { s_m_mem[s_ii] /= x_m_mem[x_ii]; }
} }
} }
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type, typename T2> template<typename op_type, typename T2>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x) subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& m_local = const_cast< Mat<eT>& >(m); Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> aa_tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = aa_tmp.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
"Mat::elem(): given object is not a vector" "Mat::elem(): given object is not a vector"
); );
const uword* aa_mem = aa.memptr(); const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem; const uword aa_n_elem = aa.n_elem;
const Proxy<T2> P(x.get_ref()); const Proxy<T2> P(x.get_ref());
arma_debug_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size misma tch" ); arma_debug_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size misma tch" );
if( (P.is_alias(m) == false) && (Proxy<T2>::prefer_at_accessor == false) const bool is_alias = P.is_alias(m);
)
if( (is_alias == false) && (Proxy<T2>::prefer_at_accessor == false) )
{ {
typename Proxy<T2>::ea_type X = P.get_ea(); typename Proxy<T2>::ea_type X = P.get_ea();
uword i,j; uword iq,jq;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[iq];
const uword jj = aa_mem[j]; const uword jj = aa_mem[jq];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value = if(is_same_type<op_type, op_subview_elem_equ >::value =
= true) { m_mem[ii] = X[i]; m_mem[jj] = X[j]; } = true) { m_mem[ii] = X[iq]; m_mem[jj] = X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value =
= true) { m_mem[ii] += X[i]; m_mem[jj] += X[j]; } = true) { m_mem[ii] += X[iq]; m_mem[jj] += X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value =
= true) { m_mem[ii] -= X[i]; m_mem[jj] -= X[j]; } = true) { m_mem[ii] -= X[iq]; m_mem[jj] -= X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value =
= true) { m_mem[ii] *= X[i]; m_mem[jj] *= X[j]; } = true) { m_mem[ii] *= X[iq]; m_mem[jj] *= X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = else if(is_same_type<op_type, op_subview_elem_inplace_div >::value =
= true) { m_mem[ii] /= X[i]; m_mem[jj] /= X[j]; } = true) { m_mem[ii] /= X[iq]; m_mem[jj] /= X[jq]; }
} }
if(i < aa_n_elem) if(iq < aa_n_elem)
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[iq];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" );
if(is_same_type<op_type, op_subview_elem_equ >::value = if(is_same_type<op_type, op_subview_elem_equ >::value =
= true) { m_mem[ii] = X[i]; } = true) { m_mem[ii] = X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value =
= true) { m_mem[ii] += X[i]; } = true) { m_mem[ii] += X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value =
= true) { m_mem[ii] -= X[i]; } = true) { m_mem[ii] -= X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value =
= true) { m_mem[ii] *= X[i]; } = true) { m_mem[ii] *= X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = else if(is_same_type<op_type, op_subview_elem_inplace_div >::value =
= true) { m_mem[ii] /= X[i]; } = true) { m_mem[ii] /= X[iq]; }
} }
} }
else else
{ {
arma_extra_debug_print("subview_elem1::inplace_op(): aliasing or prefer _at_accessor detected"); arma_extra_debug_print("subview_elem1::inplace_op(): aliasing or prefer _at_accessor detected");
const unwrap_check<typename Proxy<T2>::stored_type> tmp(P.Q, m_local); const unwrap_check<typename Proxy<T2>::stored_type> tmp(P.Q, is_alias);
const Mat<eT>& M = tmp.M; const Mat<eT>& M = tmp.M;
const eT* X = M.memptr(); const eT* X = M.memptr();
uword i,j; uword iq,jq;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2) for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[iq];
const uword jj = aa_mem[j]; const uword jj = aa_mem[jq];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" ); arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::ele m(): index out of bounds" );
if(is_same_type<op_type, op_subview_elem_equ >::value = if(is_same_type<op_type, op_subview_elem_equ >::value =
= true) { m_mem[ii] = X[i]; m_mem[jj] = X[j]; } = true) { m_mem[ii] = X[iq]; m_mem[jj] = X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value =
= true) { m_mem[ii] += X[i]; m_mem[jj] += X[j]; } = true) { m_mem[ii] += X[iq]; m_mem[jj] += X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value =
= true) { m_mem[ii] -= X[i]; m_mem[jj] -= X[j]; } = true) { m_mem[ii] -= X[iq]; m_mem[jj] -= X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value =
= true) { m_mem[ii] *= X[i]; m_mem[jj] *= X[j]; } = true) { m_mem[ii] *= X[iq]; m_mem[jj] *= X[jq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = else if(is_same_type<op_type, op_subview_elem_inplace_div >::value =
= true) { m_mem[ii] /= X[i]; m_mem[jj] /= X[j]; } = true) { m_mem[ii] /= X[iq]; m_mem[jj] /= X[jq]; }
} }
if(i < aa_n_elem) if(iq < aa_n_elem)
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[iq];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bound s" );
if(is_same_type<op_type, op_subview_elem_equ >::value = if(is_same_type<op_type, op_subview_elem_equ >::value =
= true) { m_mem[ii] = X[i]; } = true) { m_mem[ii] = X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value = else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value =
= true) { m_mem[ii] += X[i]; } = true) { m_mem[ii] += X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value = else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value =
= true) { m_mem[ii] -= X[i]; } = true) { m_mem[ii] -= X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value =
= true) { m_mem[ii] *= X[i]; } = true) { m_mem[ii] *= X[iq]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = else if(is_same_type<op_type, op_subview_elem_inplace_div >::value =
= true) { m_mem[ii] /= X[i]; } = true) { m_mem[ii] /= X[iq]; }
} }
} }
} }
// //
// //
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline arma_inline
const Op<subview_elem1<eT,T1>,op_htrans> const Op<subview_elem1<eT,T1>,op_htrans>
 End of changes. 39 change blocks. 
116 lines changed or deleted 117 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 51 skipping to change at line 51
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = const_cast< Mat<eT>& >(m); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword ii,jj;
for(ii=start_col, jj=start_col+1; jj < end_col_plus1; ii+=2, jj+=2)
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) += val; X.at(urow, ii) += val;
X.at(row, j) += val; X.at(urow, jj) += val;
} }
if(i < end_col_plus1) if(ii < end_col_plus1)
{ {
X.at(row, i) += val; X.at(urow, ii) += val;
} }
} }
else else
{ {
for(uword col=0; col<local_n_cols; ++col) for(uword ucol=0; ucol < local_n_cols; ++ucol)
{ {
arrayops::inplace_plus( colptr(col), val, local_n_rows ); arrayops::inplace_plus( colptr(ucol), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator-= (const eT val) subview<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = const_cast< Mat<eT>& >(m); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword ii,jj;
for(ii=start_col, jj=start_col+1; jj < end_col_plus1; ii+=2, jj+=2)
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) -= val; X.at(urow, ii) -= val;
X.at(row, j) -= val; X.at(urow, jj) -= val;
} }
if(i < end_col_plus1) if(ii < end_col_plus1)
{ {
X.at(row, i) -= val; X.at(urow, ii) -= val;
} }
} }
else else
{ {
for(uword col=0; col<local_n_cols; ++col) for(uword ucol=0; ucol < local_n_cols; ++ucol)
{ {
arrayops::inplace_minus( colptr(col), val, local_n_rows ); arrayops::inplace_minus( colptr(ucol), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator*= (const eT val) subview<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = const_cast< Mat<eT>& >(m); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword ii,jj;
for(ii=start_col, jj=start_col+1; jj < end_col_plus1; ii+=2, jj+=2)
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) *= val; X.at(urow, ii) *= val;
X.at(row, j) *= val; X.at(urow, jj) *= val;
} }
if(i < end_col_plus1) if(ii < end_col_plus1)
{ {
X.at(row, i) *= val; X.at(urow, ii) *= val;
} }
} }
else else
{ {
for(uword col=0; col<local_n_cols; ++col) for(uword ucol=0; ucol < local_n_cols; ++ucol)
{ {
arrayops::inplace_mul( colptr(col), val, local_n_rows ); arrayops::inplace_mul( colptr(ucol), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator/= (const eT val) subview<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = const_cast< Mat<eT>& >(m); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword ii,jj;
for(ii=start_col, jj=start_col+1; jj < end_col_plus1; ii+=2, jj+=2)
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) /= val; X.at(urow, ii) /= val;
X.at(row, j) /= val; X.at(urow, jj) /= val;
} }
if(i < end_col_plus1) if(ii < end_col_plus1)
{ {
X.at(row, i) /= val; X.at(urow, ii) /= val;
} }
} }
else else
{ {
for(uword col=0; col<local_n_cols; ++col) for(uword ucol=0; ucol < local_n_cols; ++ucol)
{ {
arrayops::inplace_div( colptr(col), val, local_n_rows ); arrayops::inplace_div( colptr(ucol), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator= (const Base<eT,T1>& in) subview<eT>::operator= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& s = *this;
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
arma_debug_assert_same_size(t, P, "copy into submatrix"); arma_debug_assert_same_size(s, P, "copy into submatrix");
const bool alias = P.is_alias(t.m); const bool is_alias = P.is_alias(s.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(is_alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (is_alias == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) = x_mem[i]; A.at(urow, start_col+ii) = x_mem[ii];
A.at(row, start_col+j) = x_mem[j]; A.at(urow, start_col+jj) = x_mem[jj];
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) = x_mem[i]; A.at(urow, start_col+ii) = x_mem[ii];
} }
} }
else else
{ {
for(uword col=0; col < t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,ii) : P[ii
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; ];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,jj) : P[jj
];
A.at(row, start_col+i) = tmp1; A.at(urow, start_col+ii) = tmp1;
A.at(row, start_col+j) = tmp2; A.at(urow, start_col+jj) = tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i ) : P[i]; A.at(urow, start_col+ii) = (Proxy<T1>::prefer_at_accessor) ? P.at(0 ,ii) : P[ii];
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
eT* t_col_data = t.colptr(col); eT* s_col_data = s.colptr(ucol);
uword i,j; uword ii,jj;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(ii=0, jj=1; jj < s_n_rows; ii+=2, jj+=2)
{ {
const eT tmp1 = P.at(i,col); const eT tmp1 = P.at(ii,ucol);
const eT tmp2 = P.at(j,col); const eT tmp2 = P.at(jj,ucol);
t_col_data[i] = tmp1; s_col_data[ii] = tmp1;
t_col_data[j] = tmp2; s_col_data[jj] = tmp2;
} }
if(i < t_n_rows) if(ii < s_n_rows)
{ {
t_col_data[i] = P.at(i,col); s_col_data[ii] = P.at(ii,ucol);
} }
} }
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator+= (const Base<eT,T1>& in) subview<eT>::operator+= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& s = *this;
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
arma_debug_assert_same_size(t, P, "addition"); arma_debug_assert_same_size(s, P, "addition");
const bool alias = P.is_alias(t.m); const bool is_alias = P.is_alias(s.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(is_alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (is_alias == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) += x_mem[i]; A.at(urow, start_col+ii) += x_mem[ii];
A.at(row, start_col+j) += x_mem[j]; A.at(urow, start_col+jj) += x_mem[jj];
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) += x_mem[i]; A.at(urow, start_col+ii) += x_mem[ii];
} }
} }
else else
{ {
for(uword col=0; col < t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,ii) : P[ii
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; ];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,jj) : P[jj
];
A.at(row, start_col+i) += tmp1; A.at(urow, start_col+ii) += tmp1;
A.at(row, start_col+j) += tmp2; A.at(urow, start_col+jj) += tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) += (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(urow, start_col+ii) += (Proxy<T1>::prefer_at_accessor) ? P.at( 0,ii) : P[ii];
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
eT* t_col_data = t.colptr(col); eT* s_col_data = s.colptr(ucol);
uword i,j; uword ii,jj;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(ii=0, jj=1; jj < s_n_rows; ii+=2, jj+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(ii,ucol);
const eT val2 = P.at(j,col); const eT val2 = P.at(jj,ucol);
t_col_data[i] += val1; s_col_data[ii] += val1;
t_col_data[j] += val2; s_col_data[jj] += val2;
} }
if(i < t_n_rows) if(ii < s_n_rows)
{ {
t_col_data[i] += P.at(i,col); s_col_data[ii] += P.at(ii,ucol);
} }
} }
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator-= (const Base<eT,T1>& in) subview<eT>::operator-= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& s = *this;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
const uword t_n_rows = t.n_rows; arma_debug_assert_same_size(s, P, "subtraction");
const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "subtraction"); const bool is_alias = P.is_alias(s.m);
const bool alias = P.is_alias(t.m); arma_extra_debug_warn(is_alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (is_alias == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) -= x_mem[i]; A.at(urow, start_col+ii) -= x_mem[ii];
A.at(row, start_col+j) -= x_mem[j]; A.at(urow, start_col+jj) -= x_mem[jj];
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) -= x_mem[i]; A.at(urow, start_col+ii) -= x_mem[ii];
} }
} }
else else
{ {
for(uword col=0; col < t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( s.colptr(ucol), x.colptr(ucol), s_n_rows ) ;
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,ii) : P[ii
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; ];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,jj) : P[jj
];
A.at(row, start_col+i) -= tmp1; A.at(urow, start_col+ii) -= tmp1;
A.at(row, start_col+j) -= tmp2; A.at(urow, start_col+jj) -= tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) -= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(urow, start_col+ii) -= (Proxy<T1>::prefer_at_accessor) ? P.at( 0,ii) : P[ii];
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
eT* t_col_data = t.colptr(col); eT* s_col_data = s.colptr(ucol);
uword i,j; uword ii,jj;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(ii=0, jj=1; jj < s_n_rows; ii+=2, jj+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(ii,ucol);
const eT val2 = P.at(j,col); const eT val2 = P.at(jj,ucol);
t_col_data[i] -= val1; s_col_data[ii] -= val1;
t_col_data[j] -= val2; s_col_data[jj] -= val2;
} }
if(i < t_n_rows) if(ii < s_n_rows)
{ {
t_col_data[i] -= P.at(i,col); s_col_data[ii] -= P.at(ii,ucol);
} }
} }
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator%= (const Base<eT,T1>& in) subview<eT>::operator%= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& s = *this;
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
arma_debug_assert_same_size(t, P, "element-wise multiplication"); arma_debug_assert_same_size(s, P, "element-wise multiplication");
const bool alias = P.is_alias(t.m); const bool is_alias = P.is_alias(s.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(is_alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (is_alias == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) *= x_mem[i]; A.at(urow, start_col+ii) *= x_mem[ii];
A.at(row, start_col+j) *= x_mem[j]; A.at(urow, start_col+jj) *= x_mem[jj];
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) *= x_mem[i]; A.at(urow, start_col+ii) *= x_mem[ii];
} }
} }
else else
{ {
for(uword col=0; col < t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,ii) : P[ii
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; ];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,jj) : P[jj
];
A.at(row, start_col+i) *= tmp1; A.at(urow, start_col+ii) *= tmp1;
A.at(row, start_col+j) *= tmp2; A.at(urow, start_col+jj) *= tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) *= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(urow, start_col+ii) *= (Proxy<T1>::prefer_at_accessor) ? P.at( 0,ii) : P[ii];
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
eT* t_col_data = t.colptr(col); eT* s_col_data = s.colptr(ucol);
uword i,j; uword ii,jj;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(ii=0, jj=1; jj < s_n_rows; ii+=2, jj+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(ii,ucol);
const eT val2 = P.at(j,col); const eT val2 = P.at(jj,ucol);
t_col_data[i] *= val1; s_col_data[ii] *= val1;
t_col_data[j] *= val2; s_col_data[jj] *= val2;
} }
if(i < t_n_rows) if(ii < s_n_rows)
{ {
t_col_data[i] *= P.at(i,col); s_col_data[ii] *= P.at(ii,ucol);
} }
} }
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator/= (const Base<eT,T1>& in) subview<eT>::operator/= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& s = *this;
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
arma_debug_assert_same_size(t, P, "element-wise division"); arma_debug_assert_same_size(s, P, "element-wise division");
const bool alias = P.is_alias(t.m); const bool is_alias = P.is_alias(s.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(is_alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) || (is_alias == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, is_alias);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) /= x_mem[i]; A.at(urow, start_col+ii) /= x_mem[ii];
A.at(row, start_col+j) /= x_mem[j]; A.at(urow, start_col+jj) /= x_mem[jj];
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) /= x_mem[i]; A.at(urow, start_col+ii) /= x_mem[ii];
} }
} }
else else
{ {
for(uword col=0; col < t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(m); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,ii) : P[ii
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; ];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,jj) : P[jj
];
A.at(row, start_col+i) /= tmp1; A.at(urow, start_col+ii) /= tmp1;
A.at(row, start_col+j) /= tmp2; A.at(urow, start_col+jj) /= tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row, start_col+i) /= (Proxy<T1>::prefer_at_accessor) ? P.at(0, i) : P[i]; A.at(urow, start_col+ii) /= (Proxy<T1>::prefer_at_accessor) ? P.at( 0,ii) : P[ii];
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
eT* t_col_data = t.colptr(col); eT* s_col_data = s.colptr(ucol);
uword i,j; uword ii,jj;
for(i=0, j=1; j<t_n_rows; i+=2, j+=2) for(ii=0, jj=1; jj < s_n_rows; ii+=2, jj+=2)
{ {
const eT val1 = P.at(i,col); const eT val1 = P.at(ii,ucol);
const eT val2 = P.at(j,col); const eT val2 = P.at(jj,ucol);
t_col_data[i] /= val1; s_col_data[ii] /= val1;
t_col_data[j] /= val2; s_col_data[jj] /= val2;
} }
if(i < t_n_rows) if(ii < s_n_rows)
{ {
t_col_data[i] /= P.at(i,col); s_col_data[ii] /= P.at(ii,ucol);
} }
} }
} }
} }
} }
//! x.submat(...) = y.submat(...) //! x.submat(...) = y.submat(...)
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::operator= (const subview<eT>& x_in) subview<eT>::operator= (const subview<eT>& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& s = *this;
arma_debug_assert_same_size(t, x, "copy into submatrix"); arma_debug_assert_same_size(s, x, "copy into submatrix");
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(t.m); Mat<eT>& A = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = s.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = s.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + ii);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + jj);
A.at(row_A, start_col_A + i) = tmp1; A.at(row_A, start_col_A + ii) = tmp1;
A.at(row_A, start_col_A + j) = tmp2; A.at(row_A, start_col_A + jj) = tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row_A, start_col_A + i) = B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + ii) = B.at(row_B, start_col_B + ii);
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 801 skipping to change at line 788
subview<eT>::operator+= (const subview<eT>& x_in) subview<eT>::operator+= (const subview<eT>& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& s = *this;
arma_debug_assert_same_size(t, x, "addition"); arma_debug_assert_same_size(s, x, "addition");
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(t.m); Mat<eT>& A = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = s.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = s.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword ii,jj;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + ii);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + jj);
A.at(row_A, start_col_A + i) += tmp1; A.at(row_A, start_col_A + ii) += tmp1;
A.at(row_A, start_col_A + j) += tmp2; A.at(row_A, start_col_A + jj) += tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row_A, start_col_A + i) += B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + ii) += B.at(row_B, start_col_B + ii);
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 863 skipping to change at line 850
subview<eT>::operator-= (const subview<eT>& x_in) subview<eT>::operator-= (const subview<eT>& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& s = *this;
arma_debug_assert_same_size(t, x, "subtraction"); arma_debug_assert_same_size(s, x, "subtraction");
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(t.m); Mat<eT>& A = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = s.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = s.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + ii);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + jj);
A.at(row_A, start_col_A + i) -= tmp1; A.at(row_A, start_col_A + ii) -= tmp1;
A.at(row_A, start_col_A + j) -= tmp2; A.at(row_A, start_col_A + jj) -= tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row_A, start_col_A + i) -= B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + ii) -= B.at(row_B, start_col_B + ii);
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 926 skipping to change at line 912
subview<eT>::operator%= (const subview& x_in) subview<eT>::operator%= (const subview& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& s = *this;
arma_debug_assert_same_size(t, x, "element-wise multiplication"); arma_debug_assert_same_size(s, x, "element-wise multiplication");
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(t.m); Mat<eT>& A = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = s.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = s.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + ii);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + jj);
A.at(row_A, start_col_A + i) *= tmp1; A.at(row_A, start_col_A + ii) *= tmp1;
A.at(row_A, start_col_A + j) *= tmp2; A.at(row_A, start_col_A + jj) *= tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row_A, start_col_A + i) *= B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + ii) *= B.at(row_B, start_col_B + ii);
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 989 skipping to change at line 974
subview<eT>::operator/= (const subview& x_in) subview<eT>::operator/= (const subview& x_in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux _row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& s = *this;
arma_debug_assert_same_size(t, x, "element-wise division"); arma_debug_assert_same_size(s, x, "element-wise division");
const uword t_n_rows = t.n_rows; const uword s_n_rows = s.n_rows;
const uword t_n_cols = t.n_cols; const uword s_n_cols = s.n_cols;
if(t_n_rows == 1) if(s_n_rows == 1)
{ {
Mat<eT>& A = const_cast< Mat<eT>& >(t.m); Mat<eT>& A = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = s.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = s.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword ii,jj;
for(ii=0, jj=1; jj < s_n_cols; ii+=2, jj+=2)
for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = B.at(row_B, start_col_B + i); const eT tmp1 = B.at(row_B, start_col_B + ii);
const eT tmp2 = B.at(row_B, start_col_B + j); const eT tmp2 = B.at(row_B, start_col_B + jj);
A.at(row_A, start_col_A + i) /= tmp1; A.at(row_A, start_col_A + ii) /= tmp1;
A.at(row_A, start_col_A + j) /= tmp2; A.at(row_A, start_col_A + jj) /= tmp2;
} }
if(i < t_n_cols) if(ii < s_n_cols)
{ {
A.at(row_A, start_col_A + i) /= B.at(row_B, start_col_B + i); A.at(row_A, start_col_A + ii) /= B.at(row_B, start_col_B + ii);
} }
} }
else else
{ {
for(uword col=0; col<t_n_cols; ++col) for(uword ucol=0; ucol < s_n_cols; ++ucol)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( s.colptr(ucol), x.colptr(ucol), s_n_rows );
} }
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 1053 skipping to change at line 1037
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = const_cast< Mat<eT>& >(m); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword urow = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword ii,jj;
for(ii=start_col, jj=start_col+1; jj < end_col_plus1; ii+=2, jj+=2)
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) = val; X.at(urow, ii) = val;
X.at(row, j) = val; X.at(urow, jj) = val;
} }
if(i < end_col_plus1) if(ii < end_col_plus1)
{ {
X.at(row, i) = val; X.at(urow, ii) = val;
} }
} }
else else
{ {
for(uword col=0; col < local_n_cols; ++col) for(uword ucol=0; ucol < local_n_cols; ++ucol)
{ {
arrayops::inplace_set( colptr(col), val, local_n_rows ); arrayops::inplace_set( colptr(ucol), val, local_n_rows );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::zeros() subview<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1110 skipping to change at line 1093
inline inline
void void
subview<eT>::eye() subview<eT>::eye()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); fill(eT(0));
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword ii=0; ii < N; ++ii)
{ {
at(i,i) = eT(1); at(ii,ii) = eT(1);
} }
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator[](const uword i) subview<eT>::operator[](const uword ii)
{ {
const uword in_col = i / n_rows; const uword in_col = ii / n_rows;
const uword in_row = i % n_rows; const uword in_row = ii % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] ); return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator[](const uword i) const subview<eT>::operator[](const uword ii) const
{ {
const uword in_col = i / n_rows; const uword in_col = ii / n_rows;
const uword in_row = i % n_rows; const uword in_row = ii % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator()(const uword i) subview<eT>::operator()(const uword ii)
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (ii >= n_elem), "subview::operator(): index out of boun ds");
const uword in_col = i / n_rows; const uword in_col = ii / n_rows;
const uword in_row = i % n_rows; const uword in_row = ii % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] ); return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator()(const uword i) const subview<eT>::operator()(const uword ii) const
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (ii >= n_elem), "subview::operator(): index out of boun ds");
const uword in_col = i / n_rows; const uword in_col = ii / n_rows;
const uword in_row = i % n_rows; const uword in_row = ii % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator()(const uword in_row, const uword in_col) subview<eT>::operator()(const uword in_row, const uword in_col)
skipping to change at line 1237 skipping to change at line 1220
subview<eT>::colptr(const uword in_col) const subview<eT>::colptr(const uword in_col) const
{ {
return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview<eT>::check_overlap(const subview<eT>& x) const subview<eT>::check_overlap(const subview<eT>& x) const
{ {
const subview<eT>& t = *this; const subview<eT>& s = *this;
if(&t.m != &x.m) if(&s.m != &x.m)
{ {
return false; return false;
} }
else else
{ {
if( (t.n_elem == 0) || (x.n_elem == 0) ) if( (s.n_elem == 0) || (x.n_elem == 0) )
{ {
return false; return false;
} }
else else
{ {
const uword t_row_start = t.aux_row1; const uword s_row_start = s.aux_row1;
const uword t_row_end_p1 = t_row_start + t.n_rows; const uword s_row_end_p1 = s_row_start + s.n_rows;
const uword t_col_start = t.aux_col1; const uword s_col_start = s.aux_col1;
const uword t_col_end_p1 = t_col_start + t.n_cols; const uword s_col_end_p1 = s_col_start + s.n_cols;
const uword x_row_start = x.aux_row1; const uword x_row_start = x.aux_row1;
const uword x_row_end_p1 = x_row_start + x.n_rows; const uword x_row_end_p1 = x_row_start + x.n_rows;
const uword x_col_start = x.aux_col1; const uword x_col_start = x.aux_col1;
const uword x_col_end_p1 = x_col_start + x.n_cols; const uword x_col_end_p1 = x_col_start + x.n_cols;
const bool outside_rows = ( (x_row_start >= t_row_end_p1) || (t_row_s const bool outside_rows = ( (x_row_start >= s_row_end_p1) || (s_row_s
tart >= x_row_end_p1) ); tart >= x_row_end_p1) );
const bool outside_cols = ( (x_col_start >= t_col_end_p1) || (t_col_s const bool outside_cols = ( (x_col_start >= s_col_end_p1) || (s_col_s
tart >= x_col_end_p1) ); tart >= x_col_end_p1) );
return ( (outside_rows == false) && (outside_cols == false) ); return ( (outside_rows == false) && (outside_cols == false) );
} }
} }
} }
template<typename eT> template<typename eT>
inline inline
bool bool
subview<eT>::is_vec() const subview<eT>::is_vec() const
skipping to change at line 2026 skipping to change at line 2009
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 >= n_rows) || (in_row2 >= n_rows), (in_row1 >= n_rows) || (in_row2 >= n_rows),
"subview::swap_rows(): out of bounds" "subview::swap_rows(): out of bounds"
); );
eT* mem = (const_cast< Mat<eT>& >(m)).memptr(); eT* mem = (const_cast< Mat<eT>& >(m)).memptr();
for(uword col=0; col<n_cols; ++col) if(n_elem > 0)
{ {
const uword offset = (aux_col1 + col) * m.n_rows; const uword m_n_rows = m.n_rows;
const uword pos1 = aux_row1 + in_row1 + offset;
const uword pos2 = aux_row1 + in_row2 + offset; for(uword ucol=0; ucol < n_cols; ++ucol)
{
const eT tmp = mem[pos1]; const uword offset = (aux_col1 + ucol) * m_n_rows;
access::rw(mem[pos1]) = mem[pos2]; const uword pos1 = aux_row1 + in_row1 + offset;
access::rw(mem[pos2]) = tmp; const uword pos2 = aux_row1 + in_row2 + offset;
std::swap( access::rw(mem[pos1]), access::rw(mem[pos2]) );
}
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
subview<eT>::swap_cols(const uword in_col1, const uword in_col2) subview<eT>::swap_cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2056 skipping to change at line 2042
( (
(in_col1 >= n_cols) || (in_col2 >= n_cols), (in_col1 >= n_cols) || (in_col2 >= n_cols),
"subview::swap_cols(): out of bounds" "subview::swap_cols(): out of bounds"
); );
if(n_elem > 0) if(n_elem > 0)
{ {
eT* ptr1 = colptr(in_col1); eT* ptr1 = colptr(in_col1);
eT* ptr2 = colptr(in_col2); eT* ptr2 = colptr(in_col2);
for(uword row=0; row<n_rows; ++row) for(uword urow=0; urow < n_rows; ++urow)
{ {
const eT tmp = ptr1[row]; std::swap( ptr1[urow], ptr2[urow] );
ptr1[row] = ptr2[row];
ptr2[row] = tmp;
} }
} }
} }
// template<typename eT> // template<typename eT>
// inline // inline
// subview<eT>::iter::iter(const subview<eT>& S) // subview<eT>::iter::iter(const subview<eT>& S)
// : mem (S.m.mem) // : mem (S.m.mem)
// , n_rows (S.m.n_rows) // , n_rows (S.m.n_rows)
// , row_start (S.aux_row1) // , row_start (S.aux_row1)
skipping to change at line 2213 skipping to change at line 2197
arma_inline arma_inline
const Op<subview_col<eT>,op_strans> const Op<subview_col<eT>,op_strans>
subview_col<eT>::st() const subview_col<eT>::st() const
{ {
return Op<subview_col<eT>,op_strans>(*this); return Op<subview_col<eT>,op_strans>(*this);
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_col<eT>::operator[](const uword i) subview_col<eT>::operator[](const uword ii)
{ {
return access::rw( colmem[i] ); return access::rw( colmem[ii] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_col<eT>::operator[](const uword i) const subview_col<eT>::operator[](const uword ii) const
{ {
return colmem[i]; return colmem[ii];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_col<eT>::operator()(const uword i) subview_col<eT>::operator()(const uword ii)
{ {
arma_debug_check( (i >= subview<eT>::n_elem), "subview::operator(): index out of bounds"); arma_debug_check( (ii >= subview<eT>::n_elem), "subview::operator(): inde x out of bounds");
return access::rw( colmem[i] ); return access::rw( colmem[ii] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_col<eT>::operator()(const uword i) const subview_col<eT>::operator()(const uword ii) const
{ {
arma_debug_check( (i >= subview<eT>::n_elem), "subview::operator(): index out of bounds"); arma_debug_check( (ii >= subview<eT>::n_elem), "subview::operator(): inde x out of bounds");
return colmem[i]; return colmem[ii];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_col<eT>::operator()(const uword in_row, const uword in_col) subview_col<eT>::operator()(const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= subview<eT>::n_rows) || (in_col > 0)), "sub view::operator(): index out of bounds"); arma_debug_check( ((in_row >= subview<eT>::n_rows) || (in_col > 0)), "sub view::operator(): index out of bounds");
return access::rw( colmem[in_row] ); return access::rw( colmem[in_row] );
skipping to change at line 2443 skipping to change at line 2427
arma_inline arma_inline
const Op<subview_row<eT>,op_strans> const Op<subview_row<eT>,op_strans>
subview_row<eT>::st() const subview_row<eT>::st() const
{ {
return Op<subview_row<eT>,op_strans>(*this); return Op<subview_row<eT>,op_strans>(*this);
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_row<eT>::operator[](const uword i) subview_row<eT>::operator[](const uword ii)
{ {
const uword index = (i + (subview<eT>::aux_col1))*(subview<eT>::m).n_rows + (subview<eT>::aux_row1); const uword index = (ii + (subview<eT>::aux_col1))*(subview<eT>::m).n_row s + (subview<eT>::aux_row1);
return access::rw( (const_cast< Mat<eT>& >(subview<eT>::m)).mem[index] ); return access::rw( (const_cast< Mat<eT>& >(subview<eT>::m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_row<eT>::operator[](const uword i) const subview_row<eT>::operator[](const uword ii) const
{ {
const uword index = (i + (subview<eT>::aux_col1))*(subview<eT>::m).n_rows + (subview<eT>::aux_row1); const uword index = (ii + (subview<eT>::aux_col1))*(subview<eT>::m).n_row s + (subview<eT>::aux_row1);
return subview<eT>::m.mem[index]; return subview<eT>::m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_row<eT>::operator()(const uword i) subview_row<eT>::operator()(const uword ii)
{ {
arma_debug_check( (i >= subview<eT>::n_elem), "subview::operator(): index out of bounds"); arma_debug_check( (ii >= subview<eT>::n_elem), "subview::operator(): inde x out of bounds");
const uword index = (i + (subview<eT>::aux_col1))*(subview<eT>::m).n_rows + (subview<eT>::aux_row1); const uword index = (ii + (subview<eT>::aux_col1))*(subview<eT>::m).n_row s + (subview<eT>::aux_row1);
return access::rw( (const_cast< Mat<eT>& >(subview<eT>::m)).mem[index] ); return access::rw( (const_cast< Mat<eT>& >(subview<eT>::m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_row<eT>::operator()(const uword i) const subview_row<eT>::operator()(const uword ii) const
{ {
arma_debug_check( (i >= subview<eT>::n_elem), "subview::operator(): index out of bounds"); arma_debug_check( (ii >= subview<eT>::n_elem), "subview::operator(): inde x out of bounds");
const uword index = (i + (subview<eT>::aux_col1))*(subview<eT>::m).n_rows + (subview<eT>::aux_row1); const uword index = (ii + (subview<eT>::aux_col1))*(subview<eT>::m).n_row s + (subview<eT>::aux_row1);
return subview<eT>::m.mem[index]; return subview<eT>::m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_row<eT>::operator()(const uword in_row, const uword in_col) subview_row<eT>::operator()(const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row > 0) || (in_col >= subview<eT>::n_cols)), "sub view::operator(): index out of bounds"); arma_debug_check( ((in_row > 0) || (in_col >= subview<eT>::n_cols)), "sub view::operator(): index out of bounds");
 End of changes. 292 change blocks. 
402 lines changed or deleted 396 lines changed or added


 unwrap.hpp   unwrap.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 unwrap //! \addtogroup unwrap
//! @{ //! @{
template<typename T1> template<typename T1>
struct unwrap_default struct unwrap_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline unwrap_default(const T1& A) // TODO: change this to Base ? inline
unwrap_default(const T1& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct unwrap_Mat_fixed struct unwrap_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit unwrap_Mat_fixed(const T1& A) inline explicit
unwrap_fixed(const T1& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct unwrap_redirect {}; struct unwrap_redirect {};
template<typename T1> template<typename T1>
struct unwrap_redirect<T1, false> { typedef unwrap_default<T1> result; }; struct unwrap_redirect<T1, false> { typedef unwrap_default<T1> result; };
template<typename T1> template<typename T1>
struct unwrap_redirect<T1, true> { typedef unwrap_Mat_fixed<T1> result; }; struct unwrap_redirect<T1, true> { typedef unwrap_fixed<T1> result; };
template<typename T1> template<typename T1>
class unwrap : public unwrap_redirect<T1, is_Mat_fixed<T1>::value >::result struct unwrap : public unwrap_redirect<T1, is_Mat_fixed<T1>::value >::resul t
{ {
public: inline
unwrap(const T1& A)
inline unwrap(const T1& A)
: unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A) : unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
{ {
} }
}; };
template<typename eT> template<typename eT>
class unwrap< Mat<eT> > struct unwrap< Mat<eT> >
{
inline
unwrap(const Mat<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
};
template<typename eT>
struct unwrap< Row<eT> >
{
inline
unwrap(const Row<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
}
const Row<eT>& M;
};
template<typename eT>
struct unwrap< Col<eT> >
{
inline
unwrap(const Col<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
}
const Col<eT>& M;
};
template<typename out_eT, typename T1, typename T2, typename glue_type>
struct unwrap< mtGlue<out_eT, T1, T2, glue_type> >
{ {
public: inline
unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
: M(A)
{
arma_extra_debug_sigprint();
}
const Mat<out_eT> M;
};
template<typename out_eT, typename T1, typename op_type>
struct unwrap< mtOp<out_eT, T1, op_type> >
{
inline
unwrap(const mtOp<out_eT, T1, op_type>& A)
: M(A)
{
arma_extra_debug_sigprint();
}
const Mat<out_eT> M;
};
//
//
//
template<typename T1>
struct quasi_unwrap_default
{
typedef typename T1::elem_type eT;
inline unwrap(const Mat<eT>& A) static const bool has_subview = false;
inline
quasi_unwrap_default(const T1& A)
: M(A)
{
arma_extra_debug_sigprint();
}
// NOTE: DO NOT DIRECTLY CHECK FOR ALIASING BY TAKING THE ADDRESS OF THE
"M" OBJECT IN ANY quasi_unwrap CLASS !!!
const Mat<eT> M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
};
template<typename T1>
struct quasi_unwrap_fixed
{
typedef typename T1::elem_type eT;
static const bool has_subview = false;
inline explicit
quasi_unwrap_fixed(const T1& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<eT>& M; const Mat<eT>& M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M)
== void_ptr(&X)); }
};
template<typename T1, bool condition>
struct quasi_unwrap_redirect {};
template<typename T1>
struct quasi_unwrap_redirect<T1, false> { typedef quasi_unwrap_default<T1>
result; };
template<typename T1>
struct quasi_unwrap_redirect<T1, true> { typedef quasi_unwrap_fixed<T1>
result; };
template<typename T1>
struct quasi_unwrap : public quasi_unwrap_redirect<T1, is_Mat_fixed<T1>::va
lue >::result
{
typedef typename quasi_unwrap_redirect<T1, is_Mat_fixed<T1>::value >::res
ult quasi_unwrap_extra;
static const bool has_subview = quasi_unwrap_extra::has_subview;
inline
quasi_unwrap(const T1& A)
: quasi_unwrap_extra(A)
{
}
using quasi_unwrap_extra::M;
using quasi_unwrap_extra::is_alias;
}; };
template<typename eT> template<typename eT>
class unwrap< Row<eT> > struct quasi_unwrap< Mat<eT> >
{ {
public: static const bool has_subview = false;
inline unwrap(const Row<eT>& A) inline
quasi_unwrap(const Mat<eT>& A)
: M(A)
{
arma_extra_debug_sigprint();
}
const Mat<eT>& M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M)
== void_ptr(&X)); }
};
template<typename eT>
struct quasi_unwrap< Row<eT> >
{
static const bool has_subview = false;
inline
quasi_unwrap(const Row<eT>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Row<eT>& M; const Row<eT>& M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M)
== void_ptr(&X)); }
}; };
template<typename eT> template<typename eT>
class unwrap< Col<eT> > struct quasi_unwrap< Col<eT> >
{ {
public: static const bool has_subview = false;
inline unwrap(const Col<eT>& A) inline
quasi_unwrap(const Col<eT>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Col<eT>& M; const Col<eT>& M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M)
== void_ptr(&X)); }
};
template<typename eT>
struct quasi_unwrap< subview_col<eT> >
{
static const bool has_subview = true;
inline
quasi_unwrap(const subview_col<eT>& A)
: M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, false, false )
, src( A.m )
{
arma_extra_debug_sigprint();
}
const Mat<eT> M;
const Mat<eT>& src;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&sr
c) == void_ptr(&X)); }
}; };
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class unwrap< mtGlue<out_eT, T1, T2, glue_type> > struct quasi_unwrap< mtGlue<out_eT, T1, T2, glue_type> >
{ {
public: static const bool has_subview = false;
inline unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A) inline
quasi_unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<out_eT> M; const Mat<out_eT> M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class unwrap< mtOp<out_eT, T1, op_type> > struct quasi_unwrap< mtOp<out_eT, T1, op_type> >
{ {
public: static const bool has_subview = false;
inline unwrap(const mtOp<out_eT, T1, op_type>& A) inline
quasi_unwrap(const mtOp<out_eT, T1, op_type>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<out_eT> M; const Mat<out_eT> M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
// //
// //
// //
template<typename T1> template<typename T1>
class unwrap_check struct unwrap_check_default
{ {
public:
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
unwrap_check(const T1& A, const Mat<eT>&) unwrap_check_default(const T1& A, const Mat<eT>&)
: M(A)
{
arma_extra_debug_sigprint();
}
inline
unwrap_check_default(const T1& A, const bool)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename eT> template<typename T1>
class unwrap_check< Mat<eT> > struct unwrap_check_fixed
{ {
public: typedef typename T1::elem_type eT;
inline
unwrap_check_fixed(const T1& A, const Mat<eT>& B)
: M_local( (&A == &B) ? new Mat<eT>(A) : 0 )
, M ( (&A == &B) ? *M_local : A )
{
arma_extra_debug_sigprint();
}
inline inline
unwrap_check_fixed(const T1& A, const bool is_alias)
: M_local( is_alias ? new Mat<eT>(A) : 0 )
, M ( is_alias ? *M_local : A )
{
arma_extra_debug_sigprint();
}
inline
~unwrap_check_fixed()
{
arma_extra_debug_sigprint();
if(M_local) { delete M_local; }
}
// the order below is important
const Mat<eT>* M_local;
const Mat<eT>& M;
};
template<typename T1, bool condition>
struct unwrap_check_redirect {};
template<typename T1>
struct unwrap_check_redirect<T1, false> { typedef unwrap_check_default<T1>
result; };
template<typename T1>
struct unwrap_check_redirect<T1, true> { typedef unwrap_check_fixed<T1>
result; };
template<typename T1>
struct unwrap_check : public unwrap_check_redirect<T1, is_Mat_fixed<T1>::va
lue >::result
{
inline unwrap_check(const T1& A, const Mat<typename T1::elem_type>& B)
: unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
{
}
inline unwrap_check(const T1& A, const bool is_alias)
: unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result(A, is_al
ias)
{
}
};
template<typename eT>
struct unwrap_check< Mat<eT> >
{
inline
unwrap_check(const Mat<eT>& A, const Mat<eT>& B) unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
: M_local( (&A == &B) ? new Mat<eT>(A) : 0 ) : M_local( (&A == &B) ? new Mat<eT>(A) : 0 )
, M ( (&A == &B) ? (*M_local) : A ) , M ( (&A == &B) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
unwrap_check(const Mat<eT>& A, const bool is_alias)
: M_local( is_alias ? new Mat<eT>(A) : 0 )
, M ( is_alias ? (*M_local) : A )
{
arma_extra_debug_sigprint();
}
inline inline
~unwrap_check() ~unwrap_check()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class unwrap_check< Row<eT> > struct unwrap_check< Row<eT> >
{ {
public:
inline inline
unwrap_check(const Row<eT>& A, const Mat<eT>& B) unwrap_check(const Row<eT>& A, const Mat<eT>& B)
: M_local( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? new Row<eT>(A : M_local( (&A == &B) ? new Row<eT>(A) : 0 )
) : 0 ) , M ( (&A == &B) ? (*M_local) : A )
, M ( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? (*M_local) {
: A ) arma_extra_debug_sigprint();
}
unwrap_check(const Row<eT>& A, const bool is_alias)
: M_local( is_alias ? new Row<eT>(A) : 0 )
, M ( is_alias ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~unwrap_check() ~unwrap_check()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
// the order below is important // the order below is important
const Row<eT>* M_local; const Row<eT>* M_local;
const Row<eT>& M; const Row<eT>& M;
}; };
template<typename eT> template<typename eT>
class unwrap_check< Col<eT> > struct unwrap_check< Col<eT> >
{ {
public:
inline inline
unwrap_check(const Col<eT>& A, const Mat<eT>& B) unwrap_check(const Col<eT>& A, const Mat<eT>& B)
: M_local( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? new Col<eT>(A : M_local( (&A == &B) ? new Col<eT>(A) : 0 )
) : 0 ) , M ( (&A == &B) ? (*M_local) : A )
, M ( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? (*M_local) {
: A ) arma_extra_debug_sigprint();
}
unwrap_check(const Col<eT>& A, const bool is_alias)
: M_local( is_alias ? new Col<eT>(A) : 0 )
, M ( is_alias ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~unwrap_check() ~unwrap_check()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
// the order below is important // the order below is important
const Col<eT>* M_local; const Col<eT>* M_local;
const Col<eT>& M; const Col<eT>& M;
}; };
// //
// //
// //
template<typename T1> template<typename T1>
class unwrap_check_mixed struct unwrap_check_mixed
{ {
public:
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const T1& A, const Mat<eT2>&) unwrap_check_mixed(const T1& A, const Mat<eT2>&)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2>
inline
unwrap_check_mixed(const T1& A, const bool)
: M(A)
{
arma_extra_debug_sigprint();
}
const Mat<eT1> M; const Mat<eT1> M;
}; };
template<typename eT1> template<typename eT1>
class unwrap_check_mixed< Mat<eT1> > struct unwrap_check_mixed< Mat<eT1> >
{ {
public:
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const Mat<eT1>& A, const Mat<eT2>& B) unwrap_check_mixed(const Mat<eT1>& A, const Mat<eT2>& B)
: M_local( (void_ptr(&A) == void_ptr(&B)) ? new Mat<eT1>(A) : 0 ) : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Mat<eT1>(A) : 0 )
, M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2>
inline
unwrap_check_mixed(const Mat<eT1>& A, const bool is_alias)
: M_local( is_alias ? new Mat<eT1>(A) : 0 )
, M ( is_alias ? (*M_local) : A )
{
arma_extra_debug_sigprint();
}
inline inline
~unwrap_check_mixed() ~unwrap_check_mixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
// the order below is important // the order below is important
const Mat<eT1>* M_local; const Mat<eT1>* M_local;
const Mat<eT1>& M; const Mat<eT1>& M;
}; };
template<typename eT1> template<typename eT1>
class unwrap_check_mixed< Row<eT1> > struct unwrap_check_mixed< Row<eT1> >
{ {
public:
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const Row<eT1>& A, const Mat<eT2>& B) unwrap_check_mixed(const Row<eT1>& A, const Mat<eT2>& B)
: M_local( (void_ptr(&A) == void_ptr(&B)) ? new Row<eT1>(A) : 0 ) : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Row<eT1>(A) : 0 )
, M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2>
inline
unwrap_check_mixed(const Row<eT1>& A, const bool is_alias)
: M_local( is_alias ? new Row<eT1>(A) : 0 )
, M ( is_alias ? (*M_local) : A )
{
arma_extra_debug_sigprint();
}
inline inline
~unwrap_check_mixed() ~unwrap_check_mixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
// the order below is important // the order below is important
const Row<eT1>* M_local; const Row<eT1>* M_local;
const Row<eT1>& M; const Row<eT1>& M;
}; };
template<typename eT1> template<typename eT1>
class unwrap_check_mixed< Col<eT1> > struct unwrap_check_mixed< Col<eT1> >
{ {
public:
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const Col<eT1>& A, const Mat<eT2>& B) unwrap_check_mixed(const Col<eT1>& A, const Mat<eT2>& B)
: M_local( (void_ptr(&A) == void_ptr(&B)) ? new Col<eT1>(A) : 0 ) : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Col<eT1>(A) : 0 )
, M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2>
inline
unwrap_check_mixed(const Col<eT1>& A, const bool is_alias)
: M_local( is_alias ? new Col<eT1>(A) : 0 )
, M ( is_alias ? (*M_local) : A )
{
arma_extra_debug_sigprint();
}
inline inline
~unwrap_check_mixed() ~unwrap_check_mixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
// the order below is important // the order below is important
const Col<eT1>* M_local; const Col<eT1>* M_local;
const Col<eT1>& M; const Col<eT1>& M;
}; };
// //
//
//
template<typename T1> template<typename T1>
struct partial_unwrap_default struct partial_unwrap_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_default(const T1& A) inline
partial_unwrap_default(const T1& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_Mat_fixed struct partial_unwrap_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_Mat_fixed(const T1& A) inline explicit
partial_unwrap_fixed(const T1& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_redirect {}; struct partial_unwrap_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_redirect<T1, false> { typedef partial_unwrap_default< T1> result; }; struct partial_unwrap_redirect<T1, false> { typedef partial_unwrap_default< T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_redirect<T1, true> { typedef partial_unwrap_Mat_fixe d<T1> result; }; struct partial_unwrap_redirect<T1, true> { typedef partial_unwrap_fixed<T1 > result; };
template<typename T1> template<typename T1>
class partial_unwrap : public partial_unwrap_redirect<T1, is_Mat_fixed<T1>: :value >::result struct partial_unwrap : public partial_unwrap_redirect<T1, is_Mat_fixed<T1> ::value >::result
{ {
public: inline
partial_unwrap(const T1& A)
inline partial_unwrap(const T1& A)
: partial_unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A) : partial_unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Mat<eT> > struct partial_unwrap< Mat<eT> >
{ {
public:
inline inline
partial_unwrap(const Mat<eT>& A) partial_unwrap(const Mat<eT>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return eT(1); } inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Row<eT> > struct partial_unwrap< Row<eT> >
{ {
public:
inline inline
partial_unwrap(const Row<eT>& A) partial_unwrap(const Row<eT>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return eT(1); } inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Col<eT> > struct partial_unwrap< Col<eT> >
{ {
public:
inline inline
partial_unwrap(const Col<eT>& A) partial_unwrap(const Col<eT>& A)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return eT(1); } inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap class is
only used by as_scalar(),
// NOTE: which doesn't need to check for aliasing (ie. it doesn't need to c
ompare the address of M with another matrix)
template<typename eT> template<typename eT>
class partial_unwrap< subview_col<eT> > struct partial_unwrap< subview_col<eT> >
{ {
public:
inline inline
partial_unwrap(const subview_col<eT>& A) partial_unwrap(const subview_col<eT>& A)
: M( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, false, false ) : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, false, false )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return eT(1); } inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const subview_col<eT>& ref;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_htrans_default struct partial_unwrap_htrans_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_htrans_default(const Op<T1, op_htrans>& A) inline
partial_unwrap_htrans_default(const Op<T1, op_htrans>& A)
: M(A.m) : M(A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_htrans_Mat_fixed struct partial_unwrap_htrans_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_htrans_Mat_fixed(const Op<T1, op_htrans>& inline explicit
A) partial_unwrap_htrans_fixed(const Op<T1, op_htrans>& A)
: M(A.m) : M(A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_htrans_redirect {}; struct partial_unwrap_htrans_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_htrans_redirect<T1, false> { typedef partial_unwrap_h trans_default<T1> result; }; struct partial_unwrap_htrans_redirect<T1, false> { typedef partial_unwrap_h trans_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_htrans_redirect<T1, true> { typedef partial_unwrap_h trans_Mat_fixed<T1> result; }; struct partial_unwrap_htrans_redirect<T1, true> { typedef partial_unwrap_h trans_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap< Op<T1, op_htrans> > : public partial_unwrap_htrans_re direct<T1, is_Mat_fixed<T1>::value >::result struct partial_unwrap< Op<T1, op_htrans> > : public partial_unwrap_htrans_r edirect<T1, is_Mat_fixed<T1>::value >::result
{ {
public:
inline partial_unwrap(const Op<T1, op_htrans>& A) inline partial_unwrap(const Op<T1, op_htrans>& A)
: partial_unwrap_htrans_redirect< T1, is_Mat_fixed<T1>::value >::result (A) : partial_unwrap_htrans_redirect< T1, is_Mat_fixed<T1>::value >::result (A)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Mat<eT>, op_htrans> > struct partial_unwrap< Op< Mat<eT>, op_htrans> >
{ {
public:
inline inline
partial_unwrap(const Op< Mat<eT>, op_htrans>& A) partial_unwrap(const Op< Mat<eT>, op_htrans>& A)
: M(A.m) : M(A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline eT get_val() const { return eT(1); } arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Row<eT>, op_htrans> > struct partial_unwrap< Op< Row<eT>, op_htrans> >
{ {
public:
inline inline
partial_unwrap(const Op< Row<eT>, op_htrans>& A) partial_unwrap(const Op< Row<eT>, op_htrans>& A)
: M(A.m) : M(A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline eT get_val() const { return eT(1); } arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Col<eT>, op_htrans> > struct partial_unwrap< Op< Col<eT>, op_htrans> >
{ {
public:
inline inline
partial_unwrap(const Op< Col<eT>, op_htrans>& A) partial_unwrap(const Op< Col<eT>, op_htrans>& A)
: M(A.m) : M(A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline eT get_val() const { return eT(1); } arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap class is
only used by as_scalar(),
// NOTE: which doesn't need to check for aliasing (ie. it doesn't need to c
ompare the address of M with another matrix)
template<typename eT> template<typename eT>
class partial_unwrap< Op< subview_col<eT>, op_htrans> > struct partial_unwrap< Op< subview_col<eT>, op_htrans> >
{ {
public:
inline inline
partial_unwrap(const Op< subview_col<eT>, op_htrans>& A) partial_unwrap(const Op< subview_col<eT>, op_htrans>& A)
: M( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, false, false ) : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, false, false )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline eT get_val() const { return eT(1); } arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const Op< subview_col<eT>, op_htrans>& ref;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_htrans2_default struct partial_unwrap_htrans2_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_htrans2_default(const Op<T1, op_htrans2>& A) inline
partial_unwrap_htrans2_default(const Op<T1, op_htrans2>& A)
: val(A.aux) : val(A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline eT get_val() const { return val; } arma_inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_htrans2_Mat_fixed struct partial_unwrap_htrans2_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_htrans2_Mat_fixed(const Op<T1, op_htrans2> inline explicit
& A) partial_unwrap_htrans2_fixed(const Op<T1, op_htrans2>& A)
: val(A.aux) : val(A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline eT get_val() const { return val; } arma_inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_htrans2_redirect {}; struct partial_unwrap_htrans2_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_htrans2_redirect<T1, false> { typedef partial_unwrap_ htrans2_default<T1> result; }; struct partial_unwrap_htrans2_redirect<T1, false> { typedef partial_unwrap_ htrans2_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_htrans2_redirect<T1, true> { typedef partial_unwrap_ htrans2_Mat_fixed<T1> result; }; struct partial_unwrap_htrans2_redirect<T1, true> { typedef partial_unwrap_ htrans2_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap< Op<T1, op_htrans2> > : public partial_unwrap_htrans2_ redirect<T1, is_Mat_fixed<T1>::value >::result struct partial_unwrap< Op<T1, op_htrans2> > : public partial_unwrap_htrans2 _redirect<T1, is_Mat_fixed<T1>::value >::result
{ {
public:
inline partial_unwrap(const Op<T1, op_htrans2>& A) inline partial_unwrap(const Op<T1, op_htrans2>& A)
: partial_unwrap_htrans2_redirect< T1, is_Mat_fixed<T1>::value >::resul t(A) : partial_unwrap_htrans2_redirect< T1, is_Mat_fixed<T1>::value >::resul t(A)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Mat<eT>, op_htrans2> > struct partial_unwrap< Op< Mat<eT>, op_htrans2> >
{ {
public:
inline inline
partial_unwrap(const Op< Mat<eT>, op_htrans2>& A) partial_unwrap(const Op< Mat<eT>, op_htrans2>& A)
: val(A.aux) : val(A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Row<eT>, op_htrans2> > struct partial_unwrap< Op< Row<eT>, op_htrans2> >
{ {
public:
inline inline
partial_unwrap(const Op< Row<eT>, op_htrans2>& A) partial_unwrap(const Op< Row<eT>, op_htrans2>& A)
: val(A.aux) : val(A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< Op< Col<eT>, op_htrans2> > struct partial_unwrap< Op< Col<eT>, op_htrans2> >
{ {
public:
inline inline
partial_unwrap(const Op< Col<eT>, op_htrans2>& A) partial_unwrap(const Op< Col<eT>, op_htrans2>& A)
: val(A.aux) : val(A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap class is
only used by as_scalar(),
// NOTE: which doesn't need to check for aliasing (ie. it doesn't need to c
ompare the address of M with another matrix)
template<typename eT> template<typename eT>
class partial_unwrap< Op< subview_col<eT>, op_htrans2> > struct partial_unwrap< Op< subview_col<eT>, op_htrans2> >
{ {
public:
inline inline
partial_unwrap(const Op< subview_col<eT>, op_htrans2>& A) partial_unwrap(const Op< subview_col<eT>, op_htrans2>& A)
: val( A.aux ) : val( A.aux )
, M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, false, false ) , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, false, false )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const Op< subview_col<eT>, op_htrans2>& ref;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_scalar_times_default struct partial_unwrap_scalar_times_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_scalar_times_default(const eOp<T1, eop_scalar_times inline
>& A) partial_unwrap_scalar_times_default(const eOp<T1, eop_scalar_times>& A)
: val(A.aux) : val(A.aux)
, M (A.P.Q) , M (A.P.Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_scalar_times_Mat_fixed struct partial_unwrap_scalar_times_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_scalar_times_Mat_fixed(const eOp<T1, eop_s inline explicit
calar_times>& A) partial_unwrap_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A)
: val(A.aux) : val(A.aux)
, M (A.P.Q) , M (A.P.Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_scalar_times_redirect {}; struct partial_unwrap_scalar_times_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_scalar_times_redirect<T1, false> { typedef partial_un wrap_scalar_times_default<T1> result; }; struct partial_unwrap_scalar_times_redirect<T1, false> { typedef partial_un wrap_scalar_times_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_scalar_times_redirect<T1, true> { typedef partial_un wrap_scalar_times_Mat_fixed<T1> result; }; struct partial_unwrap_scalar_times_redirect<T1, true> { typedef partial_un wrap_scalar_times_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap< eOp<T1, eop_scalar_times> > : public partial_unwrap_s calar_times_redirect<T1, is_Mat_fixed<T1>::value >::result struct partial_unwrap< eOp<T1, eop_scalar_times> > : public partial_unwrap_ scalar_times_redirect<T1, is_Mat_fixed<T1>::value >::result
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
public: inline
inline partial_unwrap(const eOp<T1, eop_scalar_times>& A) partial_unwrap(const eOp<T1, eop_scalar_times>& A)
: partial_unwrap_scalar_times_redirect< T1, is_Mat_fixed<T1>::value >:: result(A) : partial_unwrap_scalar_times_redirect< T1, is_Mat_fixed<T1>::value >:: result(A)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap< eOp<Mat<eT>, eop_scalar_times> > struct partial_unwrap< eOp<Mat<eT>, eop_scalar_times> >
{ {
public:
inline inline
partial_unwrap(const eOp<Mat<eT>,eop_scalar_times>& A) partial_unwrap(const eOp<Mat<eT>,eop_scalar_times>& A)
: val(A.aux) : val(A.aux)
, M (A.P.Q) , M (A.P.Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< eOp<Row<eT>, eop_scalar_times> > struct partial_unwrap< eOp<Row<eT>, eop_scalar_times> >
{ {
public:
inline inline
partial_unwrap(const eOp<Row<eT>,eop_scalar_times>& A) partial_unwrap(const eOp<Row<eT>,eop_scalar_times>& A)
: val(A.aux) : val(A.aux)
, M (A.P.Q) , M (A.P.Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap< eOp<Col<eT>, eop_scalar_times> > struct partial_unwrap< eOp<Col<eT>, eop_scalar_times> >
{ {
public:
inline inline
partial_unwrap(const eOp<Col<eT>,eop_scalar_times>& A) partial_unwrap(const eOp<Col<eT>,eop_scalar_times>& A)
: val(A.aux) : val(A.aux)
, M (A.P.Q) , M (A.P.Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline eT get_val() const { return val; } inline eT get_val() const { return val; }
skipping to change at line 901 skipping to change at line 1174
const Mat<eT>& M; const Mat<eT>& M;
}; };
// //
template<typename T1> template<typename T1>
struct partial_unwrap_check_default struct partial_unwrap_check_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_check_default(const T1& A, const Mat<eT>&) inline
partial_unwrap_check_default(const T1& A, const Mat<eT>&)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_Mat_fixed struct partial_unwrap_check_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_check_Mat_fixed(const T1& A, const Mat<eT> inline explicit
& B) partial_unwrap_check_fixed(const T1& A, const Mat<eT>& B)
: M_local( (&A == &B) ? new Mat<eT>(A) : 0 ) : M_local( (&A == &B) ? new Mat<eT>(A) : 0 )
, M ( (&A == &B) ? (*M_local) : A ) , M ( (&A == &B) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check_Mat_fixed() ~partial_unwrap_check_fixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_check_redirect {}; struct partial_unwrap_check_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_check_redirect<T1, false> { typedef partial_unwrap_ch eck_default<T1> result; }; struct partial_unwrap_check_redirect<T1, false> { typedef partial_unwrap_ch eck_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_redirect<T1, true> { typedef partial_unwrap_ch eck_Mat_fixed<T1> result; }; struct partial_unwrap_check_redirect<T1, true> { typedef partial_unwrap_ch eck_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap_check : public partial_unwrap_check_redirect<T1, is_Ma t_fixed<T1>::value >::result struct partial_unwrap_check : public partial_unwrap_check_redirect<T1, is_M at_fixed<T1>::value >::result
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
public:
inline partial_unwrap_check(const T1& A, const Mat<eT>& B) inline partial_unwrap_check(const T1& A, const Mat<eT>& B)
: partial_unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result( A, B) : partial_unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result( A, B)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Mat<eT> > struct partial_unwrap_check< Mat<eT> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Mat<eT>& A, const Mat<eT>& B) partial_unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
: M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) : M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
, M ( (&A == &B) ? (*M_local) : A ) , M ( (&A == &B) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 997 skipping to change at line 1269
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Row<eT> > struct partial_unwrap_check< Row<eT> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Row<eT>& A, const Mat<eT>& B) partial_unwrap_check(const Row<eT>& A, const Mat<eT>& B)
: M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) : M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
, M ( (&A == &B) ? (*M_local) : A ) , M ( (&A == &B) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 1028 skipping to change at line 1298
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Col<eT> > struct partial_unwrap_check< Col<eT> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Col<eT>& A, const Mat<eT>& B) partial_unwrap_check(const Col<eT>& A, const Mat<eT>& B)
: M_local ( (&A == &B) ? new Mat<eT>(A) : 0 ) : M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
, M ( (&A == &B) ? (*M_local) : A ) , M ( (&A == &B) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 1058 skipping to change at line 1326
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla
ss is only used by the glue_times class,
// NOTE: which relies on partial_unwrap_check to check for aliasing
template<typename eT> template<typename eT>
class partial_unwrap_check< subview_col<eT> > struct partial_unwrap_check< subview_col<eT> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const subview_col<eT>& A, const Mat<eT>& B) partial_unwrap_check(const subview_col<eT>& A, const Mat<eT>& B)
: M( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, (&(A.m) == &B), false : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, (&(A.m) == &B), fal
) se )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const subview_col<eT>& ref;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans_default struct partial_unwrap_check_htrans_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_check_htrans_default(const Op<T1, op_htrans>& A, co inline
nst Mat<eT>&) partial_unwrap_check_htrans_default(const Op<T1, op_htrans>& A, const Mat
<eT>&)
: M(A.m) : M(A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans_Mat_fixed struct partial_unwrap_check_htrans_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_check_htrans_Mat_fixed(const Op<T1, op_htr inline explicit
ans>& A, const Mat<eT>& B) partial_unwrap_check_htrans_fixed(const Op<T1, op_htrans>& A, const Mat<e
T>& B)
: M_local( (&(A.m) == &B) ? new Mat<eT>(A.m) : 0 ) : M_local( (&(A.m) == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&(A.m) == &B) ? (*M_local) : A.m ) , M ( (&(A.m) == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check_htrans_Mat_fixed() ~partial_unwrap_check_htrans_fixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_check_htrans_redirect {}; struct partial_unwrap_check_htrans_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans_redirect<T1, false> { typedef partial_un wrap_check_htrans_default<T1> result; }; struct partial_unwrap_check_htrans_redirect<T1, false> { typedef partial_un wrap_check_htrans_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans_redirect<T1, true> { typedef partial_un wrap_check_htrans_Mat_fixed<T1> result; }; struct partial_unwrap_check_htrans_redirect<T1, true> { typedef partial_un wrap_check_htrans_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap_check< Op<T1, op_htrans> > : public partial_unwrap_che ck_htrans_redirect<T1, is_Mat_fixed<T1>::value >::result struct partial_unwrap_check< Op<T1, op_htrans> > : public partial_unwrap_ch eck_htrans_redirect<T1, is_Mat_fixed<T1>::value >::result
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
public:
inline partial_unwrap_check(const Op<T1, op_htrans>& A, const Mat<eT>& B) inline partial_unwrap_check(const Op<T1, op_htrans>& A, const Mat<eT>& B)
: partial_unwrap_check_htrans_redirect< T1, is_Mat_fixed<T1>::value >:: result(A, B) : partial_unwrap_check_htrans_redirect< T1, is_Mat_fixed<T1>::value >:: result(A, B)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Mat<eT>, op_htrans> > struct partial_unwrap_check< Op< Mat<eT>, op_htrans> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< Mat<eT>, op_htrans>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Mat<eT>, op_htrans>& A, const Mat<eT>& B)
: M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) : M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 1179 skipping to change at line 1450
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Row<eT>, op_htrans> > struct partial_unwrap_check< Op< Row<eT>, op_htrans> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< Row<eT>, op_htrans>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Row<eT>, op_htrans>& A, const Mat<eT>& B)
: M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) : M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 1210 skipping to change at line 1479
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Col<eT>, op_htrans> > struct partial_unwrap_check< Op< Col<eT>, op_htrans> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< Col<eT>, op_htrans>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Col<eT>, op_htrans>& A, const Mat<eT>& B)
: M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) : M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check() ~partial_unwrap_check()
skipping to change at line 1240 skipping to change at line 1507
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
// the order below is important // the order below is important
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla
ss is only used by the glue_times class,
// NOTE: which relies on partial_unwrap_check to check for aliasing
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< subview_col<eT>, op_htrans> > struct partial_unwrap_check< Op< subview_col<eT>, op_htrans> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< subview_col<eT>, op_htrans>& A, const Mat< eT>& B) partial_unwrap_check(const Op< subview_col<eT>, op_htrans>& A, const Mat< eT>& B)
: M( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, (&(A.m.m) == &B), : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, (&(A.m.m) == &B
false ) ), false )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return eT(1); } arma_hot arma_inline eT get_val() const { return eT(1); }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = false; static const bool do_times = false;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const Op< subview_col<eT>, op_htrans>& ref;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans2_default struct partial_unwrap_check_htrans2_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_check_htrans2_default(const Op<T1, op_htrans2>& A, inline
const Mat<eT>&) partial_unwrap_check_htrans2_default(const Op<T1, op_htrans2>& A, const M
at<eT>&)
: val(A.aux) : val(A.aux)
, M (A.m) , M (A.m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans2_Mat_fixed struct partial_unwrap_check_htrans2_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_check_htrans2_Mat_fixed(const Op<T1, op_ht inline explicit
rans2>& A, const Mat<eT>& B) partial_unwrap_check_htrans2_fixed(const Op<T1, op_htrans2>& A, const Mat
<eT>& B)
: val (A.aux) : val (A.aux)
, M_local( (&(A.m) == &B) ? new Mat<eT>(A.m) : 0 ) , M_local( (&(A.m) == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&(A.m) == &B) ? (*M_local) : A.m ) , M ( (&(A.m) == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check_htrans2_Mat_fixed() ~partial_unwrap_check_htrans2_fixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_check_htrans2_redirect {}; struct partial_unwrap_check_htrans2_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans2_redirect<T1, false> { typedef partial_u nwrap_check_htrans2_default<T1> result; }; struct partial_unwrap_check_htrans2_redirect<T1, false> { typedef partial_u nwrap_check_htrans2_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_htrans2_redirect<T1, true> { typedef partial_u nwrap_check_htrans2_Mat_fixed<T1> result; }; struct partial_unwrap_check_htrans2_redirect<T1, true> { typedef partial_u nwrap_check_htrans2_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap_check< Op<T1, op_htrans2> > : public partial_unwrap_ch eck_htrans2_redirect<T1, is_Mat_fixed<T1>::value >::result struct partial_unwrap_check< Op<T1, op_htrans2> > : public partial_unwrap_c heck_htrans2_redirect<T1, is_Mat_fixed<T1>::value >::result
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
public:
inline partial_unwrap_check(const Op<T1, op_htrans2>& A, const Mat<eT>& B ) inline partial_unwrap_check(const Op<T1, op_htrans2>& A, const Mat<eT>& B )
: partial_unwrap_check_htrans2_redirect< T1, is_Mat_fixed<T1>::value >: :result(A, B) : partial_unwrap_check_htrans2_redirect< T1, is_Mat_fixed<T1>::value >: :result(A, B)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Mat<eT>, op_htrans2> > struct partial_unwrap_check< Op< Mat<eT>, op_htrans2> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B)
: val (A.aux) : val (A.aux)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1367 skipping to change at line 1637
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
// the order below is important // the order below is important
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Row<eT>, op_htrans2> > struct partial_unwrap_check< Op< Row<eT>, op_htrans2> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< Row<eT>, op_htrans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Row<eT>, op_htrans2>& A, const Mat<eT>& B)
: val (A.aux) : val (A.aux)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1400 skipping to change at line 1668
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
// the order below is important // the order below is important
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< Col<eT>, op_htrans2> > struct partial_unwrap_check< Op< Col<eT>, op_htrans2> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< Col<eT>, op_htrans2>& A, const Mat<eT>& B) partial_unwrap_check(const Op< Col<eT>, op_htrans2>& A, const Mat<eT>& B)
: val (A.aux) : val (A.aux)
, M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 ) , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
, M ( (&A.m == &B) ? (*M_local) : A.m ) , M ( (&A.m == &B) ? (*M_local) : A.m )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1432 skipping to change at line 1698
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
// the order below is important // the order below is important
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla
ss is only used by the glue_times class,
// NOTE: which relies on partial_unwrap_check to check for aliasing
template<typename eT> template<typename eT>
class partial_unwrap_check< Op< subview_col<eT>, op_htrans2> > struct partial_unwrap_check< Op< subview_col<eT>, op_htrans2> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const Op< subview_col<eT>, op_htrans2>& A, const Mat <eT>& B) partial_unwrap_check(const Op< subview_col<eT>, op_htrans2>& A, const Mat <eT>& B)
: val( A.aux ) : val( A.aux )
, M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, (&(A.m.m) == &B ), false ) , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, 1, (&(A.m.m) == &B ), false )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = true; static const bool do_trans = true;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const Op< subview_col<eT>, op_htrans2>& ref;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_scalar_times_default struct partial_unwrap_check_scalar_times_default
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline partial_unwrap_check_scalar_times_default(const eOp<T1, eop_scalar inline
_times>& A, const Mat<eT>&) partial_unwrap_check_scalar_times_default(const eOp<T1, eop_scalar_times>
& A, const Mat<eT>&)
: val(A.aux) : val(A.aux)
, M (A.P.Q) , M (A.P.Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
}; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_scalar_times_Mat_fixed struct partial_unwrap_check_scalar_times_fixed
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline explicit partial_unwrap_check_scalar_times_Mat_fixed(const eOp<T1, inline explicit
eop_scalar_times>& A, const Mat<eT>& B) partial_unwrap_check_scalar_times_fixed(const eOp<T1, eop_scalar_times>&
A, const Mat<eT>& B)
: val ( A.aux ) : val ( A.aux )
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) , M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 )
, M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q ) , M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~partial_unwrap_check_scalar_times_Mat_fixed() ~partial_unwrap_check_scalar_times_fixed()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(M_local) { delete M_local; } if(M_local) { delete M_local; }
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename T1, bool condition> template<typename T1, bool condition>
struct partial_unwrap_check_scalar_times_redirect {}; struct partial_unwrap_check_scalar_times_redirect {};
template<typename T1> template<typename T1>
struct partial_unwrap_check_scalar_times_redirect<T1, false> { typedef part ial_unwrap_check_scalar_times_default<T1> result; }; struct partial_unwrap_check_scalar_times_redirect<T1, false> { typedef part ial_unwrap_check_scalar_times_default<T1> result; };
template<typename T1> template<typename T1>
struct partial_unwrap_check_scalar_times_redirect<T1, true> { typedef part ial_unwrap_check_scalar_times_Mat_fixed<T1> result; }; struct partial_unwrap_check_scalar_times_redirect<T1, true> { typedef part ial_unwrap_check_scalar_times_fixed<T1> result; };
template<typename T1> template<typename T1>
class partial_unwrap_check< eOp<T1, eop_scalar_times> > : public partial_un wrap_check_scalar_times_redirect<T1, is_Mat_fixed<T1>::value >::result struct partial_unwrap_check< eOp<T1, eop_scalar_times> > : public partial_u nwrap_check_scalar_times_redirect<T1, is_Mat_fixed<T1>::value >::result
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
public:
inline partial_unwrap_check(const eOp<T1, eop_scalar_times>& A, const Mat <eT>& B) inline partial_unwrap_check(const eOp<T1, eop_scalar_times>& A, const Mat <eT>& B)
: partial_unwrap_check_scalar_times_redirect< T1, is_Mat_fixed<T1>::val ue >::result(A, B) : partial_unwrap_check_scalar_times_redirect< T1, is_Mat_fixed<T1>::val ue >::result(A, B)
{ {
} }
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< eOp<Mat<eT>, eop_scalar_times> > struct partial_unwrap_check< eOp<Mat<eT>, eop_scalar_times> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const eOp<Mat<eT>,eop_scalar_times>& A, const Mat<eT >& B) partial_unwrap_check(const eOp<Mat<eT>,eop_scalar_times>& A, const Mat<eT >& B)
: val (A.aux) : val (A.aux)
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) , M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 )
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1560 skipping to change at line 1829
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< eOp<Row<eT>, eop_scalar_times> > struct partial_unwrap_check< eOp<Row<eT>, eop_scalar_times> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const eOp<Row<eT>,eop_scalar_times>& A, const Mat<eT >& B) partial_unwrap_check(const eOp<Row<eT>,eop_scalar_times>& A, const Mat<eT >& B)
: val(A.aux) : val(A.aux)
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) , M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 )
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1592 skipping to change at line 1859
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
template<typename eT> template<typename eT>
class partial_unwrap_check< eOp<Col<eT>, eop_scalar_times> > struct partial_unwrap_check< eOp<Col<eT>, eop_scalar_times> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const eOp<Col<eT>,eop_scalar_times>& A, const Mat<eT >& B) partial_unwrap_check(const eOp<Col<eT>,eop_scalar_times>& A, const Mat<eT >& B)
: val ( A.aux ) : val ( A.aux )
, M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 ) , M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 )
, M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q ) , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
skipping to change at line 1623 skipping to change at line 1888
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT>* M_local; const Mat<eT>* M_local;
const Mat<eT>& M; const Mat<eT>& M;
}; };
// NOTE: we can get away with this shortcut as the partial_unwrap_check cla
ss is only used by the glue_times class,
// NOTE: which relies on partial_unwrap_check to check for aliasing
template<typename eT> template<typename eT>
class partial_unwrap_check< eOp<subview_col<eT>, eop_scalar_times> > struct partial_unwrap_check< eOp<subview_col<eT>, eop_scalar_times> >
{ {
public:
arma_hot inline arma_hot inline
partial_unwrap_check(const eOp<subview_col<eT>,eop_scalar_times>& A, cons t Mat<eT>& B) partial_unwrap_check(const eOp<subview_col<eT>,eop_scalar_times>& A, cons t Mat<eT>& B)
: val( A.aux ) : val( A.aux )
, M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, 1, (&(A.P.Q.m) == &B), false ) , M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, 1, (&(A.P.Q.m) == &B), false )
//, ref( A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_hot arma_inline eT get_val() const { return val; } arma_hot arma_inline eT get_val() const { return val; }
static const bool do_trans = false; static const bool do_trans = false;
static const bool do_times = true; static const bool do_times = true;
const eT val; const eT val;
const Mat<eT> M; const Mat<eT> M;
//// prevents the compiler from potentially deleting the subview object b
efore we're done with it
//const eOp<subview_col<eT>,eop_scalar_times>& ref;
}; };
//! @} //! @}
 End of changes. 197 change blocks. 
233 lines changed or deleted 524 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/