Base_bones.hpp   Base_bones.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup Base //! \addtogroup Base
//! @{ //! @{
template<typename derived> template<typename derived>
struct Base_blas_elem_type struct Base_blas_elem_type
{ {
arma_inline const Op<derived,op_inv> i(const bool slow = false) const; arma_inline const Op<derived,op_inv> i(const bool slow = false) const;
//!< matrix inverse //!< matrix inverse
arma_inline const Op<derived,op_inv> i(const char* method ) const;
//!< matrix inverse
}; };
template<typename derived> template<typename derived>
struct Base_other_elem_type struct Base_other_elem_type
{ {
}; };
template<typename derived, bool condition> template<typename derived, bool condition>
struct Base_extra {}; struct Base_extra {};
 End of changes. 2 change blocks. 
4 lines changed or deleted 6 lines changed or added


 Base_meat.hpp   Base_meat.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup Base //! \addtogroup Base
//! @{ //! @{
template<typename elem_type, typename derived> template<typename elem_type, typename derived>
arma_inline arma_inline
skipping to change at line 102 skipping to change at line 102
// extra functions defined in Base_blas_elem_type // extra functions defined in Base_blas_elem_type
template<typename derived> template<typename derived>
arma_inline arma_inline
const Op<derived,op_inv> const Op<derived,op_inv>
Base_blas_elem_type<derived>::i(const bool slow) const Base_blas_elem_type<derived>::i(const bool slow) const
{ {
return Op<derived,op_inv>( static_cast<const derived&>(*this), ((slow == false) ? 0 : 1), 0 ); return Op<derived,op_inv>( static_cast<const derived&>(*this), ((slow == false) ? 0 : 1), 0 );
} }
template<typename derived>
arma_inline
const Op<derived,op_inv>
Base_blas_elem_type<derived>::i(const char* method) const
{
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "Base::i(): unknown met
hod specified" );
return Op<derived,op_inv>( static_cast<const derived&>(*this), ((sig == '
f') ? 0 : 1), 0 );
}
// //
// extra functions defined in Base_eval_Mat // extra functions defined in Base_eval_Mat
template<typename elem_type, typename derived> template<typename elem_type, typename derived>
arma_inline arma_inline
const derived& const derived&
Base_eval_Mat<elem_type, derived>::eval() const Base_eval_Mat<elem_type, derived>::eval() const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 2 change blocks. 
2 lines changed or deleted 16 lines changed or added


 Col_meat.hpp   Col_meat.hpp 
skipping to change at line 215 skipping to change at line 215
access::rw(Mat<eT>::vec_state) = 1; access::rw(Mat<eT>::vec_state) = 1;
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(Col<eT>&& X) Col<eT>::Col(Col<eT>&& X)
: Mat<eT>(arma_vec_indicator(), 1) : Mat<eT>(arma_vec_indicator(), 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint(arma_boost::format("this = %x X = %x") % th is % &X);
(*this).steal_mem(X); access::rw(Mat<eT>::n_rows) = X.n_rows;
access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = X.n_elem;
if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || (
X.mem_state == 1) || (X.mem_state == 2) )
{
access::rw(Mat<eT>::mem_state) = X.mem_state;
access::rw(Mat<eT>::mem) = X.mem;
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem_state) = 0;
access::rw(X.mem) = 0;
}
else
{
(*this).init_cold();
arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
}
} }
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(Col<eT>&& X) Col<eT>::operator=(Col<eT>&& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
(*this).steal_mem(X); (*this).steal_mem(X);
 End of changes. 2 change blocks. 
2 lines changed or deleted 23 lines changed or added


 Cube_bones.hpp   Cube_bones.hpp 
skipping to change at line 51 skipping to change at line 51
protected: protected:
arma_align_mem Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ]; arma_align_mem Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ];
arma_align_mem eT mem_local[ Cube_prealloc::mem_n_elem ]; arma_align_mem eT mem_local[ Cube_prealloc::mem_n_elem ];
public: public:
inline ~Cube(); inline ~Cube();
inline Cube(); inline Cube();
inline Cube(const uword in_rows, const uword in_cols, const uword in_slic es); inline Cube(const uword in_rows, const uword in_cols, const uwor d in_slices);
template<typename fill_type> template<typename fill_type>
inline Cube(const uword in_rows, const uword in_cols, const uword in_slic es, const fill::fill_class<fill_type>& f); inline Cube(const uword in_rows, const uword in_cols, const uword in_slic es, const fill::fill_class<fill_type>& f);
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
inline Cube(Cube&& m); inline Cube(Cube&& m);
inline const Cube& operator=(Cube&& m); inline const Cube& operator=(Cube&& m);
#endif #endif
inline Cube( eT* aux_mem, const uword aux_n_rows, const uword aux_n_ cols, const uword aux_n_slices, const bool copy_aux_mem = true, const bool strict = true); inline Cube( eT* aux_mem, const uword aux_n_rows, const uword aux_n_ cols, const uword aux_n_slices, const bool copy_aux_mem = true, const bool strict = true);
skipping to change at line 96 skipping to change at line 96
arma_inline Mat<eT>& slice(const uword in_slice); arma_inline Mat<eT>& slice(const uword in_slice);
arma_inline const Mat<eT>& slice(const uword in_slice) const; arma_inline const Mat<eT>& slice(const uword in_slice) const;
arma_inline subview_cube<eT> slices(const uword in_slice1, const uw ord in_slice2); arma_inline subview_cube<eT> slices(const uword in_slice1, const uw ord in_slice2);
arma_inline const subview_cube<eT> slices(const uword in_slice1, const uw ord in_slice2) const; arma_inline const subview_cube<eT> slices(const uword in_slice1, const uw ord in_slice2) const;
arma_inline subview_cube<eT> subcube(const uword in_row1, const uwo rd in_col1, const uword in_slice1, const uword in_row2, const uword in_col2 , const uword in_slice2); arma_inline subview_cube<eT> subcube(const uword in_row1, const uwo rd in_col1, const uword in_slice1, const uword in_row2, const uword in_col2 , const uword in_slice2);
arma_inline const subview_cube<eT> subcube(const uword in_row1, const uwo rd in_col1, const uword in_slice1, const uword in_row2, const uword in_col2 , const uword in_slice2) const; arma_inline const subview_cube<eT> subcube(const uword in_row1, const uwo rd in_col1, const uword in_slice1, const uword in_row2, const uword in_col2 , const uword in_slice2) const;
inline subview_cube<eT> subcube(const uword in_row1, const uwo
rd in_col1, const uword in_slice1, const SizeCube& s);
inline const subview_cube<eT> subcube(const uword in_row1, const uwo
rd in_col1, const uword in_slice1, const SizeCube& s) const;
inline subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span); inline subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span);
inline const subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span) const; inline const subview_cube<eT> subcube(const span& row_span, const sp an& col_span, const span& slice_span) const;
inline subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span); inline subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span);
inline const subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span) const; inline const subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span) const;
inline subview_cube<eT> operator()(const uword in_row1, const
uword in_col1, const uword in_slice1, const SizeCube& s);
inline const subview_cube<eT> operator()(const uword in_row1, const
uword in_col1, const uword in_slice1, const SizeCube& s) const;
arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1); arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1);
arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1) const; arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1) const;
arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2); arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const; arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
arma_inline subview_cube<eT> tube(const uword in_row1, const uword
in_col1, const SizeMat& s);
arma_inline const subview_cube<eT> tube(const uword in_row1, const uword
in_col1, const SizeMat& s) const;
inline subview_cube<eT> tube(const span& row_span, const span& col_span); inline subview_cube<eT> tube(const span& row_span, const span& col_span);
inline const subview_cube<eT> tube(const span& row_span, const span& col_span) const; inline const subview_cube<eT> tube(const span& row_span, const span& col_span) const;
inline void shed_slice(const uword slice_num); inline void shed_slice(const uword slice_num);
inline void shed_slices(const uword in_slice1, const uword in_slice2); inline void shed_slices(const uword in_slice1, const uword in_slice2);
inline void insert_slices(const uword slice_num, const uword N, const boo l set_to_zero = true); inline void insert_slices(const uword slice_num, const uword N, const boo l set_to_zero = true);
template<typename T1> template<typename T1>
skipping to change at line 201 skipping to change at line 210
arma_inline arma_warn_unused bool is_finite() const; arma_inline arma_warn_unused bool is_finite() const;
arma_inline arma_warn_unused bool is_empty() const; arma_inline arma_warn_unused bool is_empty() const;
arma_inline arma_warn_unused bool in_range(const uword i) const; arma_inline arma_warn_unused bool in_range(const uword i) 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 uword in_slice) const; arma_inline arma_warn_unused bool in_range(const uword in_row, const uw ord in_col, const uword in_slice) const;
inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span, const span& slice_span) const; inline arma_warn_unused bool in_range(const span& row_span, const sp an& col_span, const span& slice_span) const;
inline arma_warn_unused bool in_range(const uword in_row, const uw
ord in_col, const uword in_slice, const SizeCube& s) 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;
arma_inline arma_warn_unused eT* slice_memptr(const uword slice); arma_inline arma_warn_unused eT* slice_memptr(const uword slice);
arma_inline arma_warn_unused const eT* slice_memptr(const uword slice) co nst; arma_inline arma_warn_unused const eT* slice_memptr(const uword slice) co nst;
arma_inline arma_warn_unused eT* slice_colptr(const uword in_slice, const uword in_col); arma_inline arma_warn_unused eT* slice_colptr(const uword in_slice, const uword in_col);
arma_inline arma_warn_unused const eT* slice_colptr(const uword in_slice, const uword in_col) const; arma_inline arma_warn_unused const eT* slice_colptr(const uword in_slice, const uword in_col) const;
inline void impl_print(const std::string& extra_text) const; inline void impl_print(const std::string& extra_text) const;
skipping to change at line 294 skipping to change at line 305
inline slice_iterator begin_slice(const uword slice_num); inline slice_iterator begin_slice(const uword slice_num);
inline const_slice_iterator begin_slice(const uword slice_num) const; inline const_slice_iterator begin_slice(const uword slice_num) const;
inline slice_iterator end_slice(const uword slice_num); inline slice_iterator end_slice(const uword slice_num);
inline const_slice_iterator end_slice(const uword slice_num) const; inline const_slice_iterator end_slice(const uword slice_num) const;
inline void clear(); inline void clear();
inline bool empty() const; inline bool empty() const;
inline uword size() const; inline uword size() const;
// inline void swap(Cube& B); // TODO inline void swap(Cube& B);
inline void steal_mem(Cube& X); //!< don't use this unless you're writin g code internal to Armadillo inline void steal_mem(Cube& X); //!< don't use this unless you're writin g code internal to Armadillo
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> cl ass fixed; template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> cl ass fixed;
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);
 End of changes. 6 change blocks. 
2 lines changed or deleted 20 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 149 skipping to change at line 149
( (
( (n_rows > 0x0FFF) || (n_cols > 0x0FFF) || (n_slices > 0xFF) ) ( (n_rows > 0x0FFF) || (n_cols > 0x0FFF) || (n_slices > 0xFF) )
? ( (float(n_rows) * float(n_cols) * float(n_slices)) > float(ARMA_ MAX_UWORD) ) ? ( (float(n_rows) * float(n_cols) * float(n_slices)) > float(ARMA_ MAX_UWORD) )
: false : false
), ),
"Cube::init(): requested size is too large" "Cube::init(): requested size is too large"
); );
if(n_elem <= Cube_prealloc::mem_n_elem) if(n_elem <= Cube_prealloc::mem_n_elem)
{ {
arma_extra_debug_print("Cube::init(): using local memory");
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
else else
{ {
arma_extra_debug_print("Cube::init(): allocating memory"); arma_extra_debug_print("Cube::init(): allocating memory");
access::rw(mem) = memory::acquire<eT>(n_elem); access::rw(mem) = memory::acquire<eT>(n_elem);
arma_check_bad_alloc( (mem == 0), "Cube::init(): out of memory" );
} }
if(n_elem == 0) if(n_elem == 0)
{ {
access::rw(n_rows) = 0; access::rw(n_rows) = 0;
access::rw(n_cols) = 0; access::rw(n_cols) = 0;
access::rw(n_elem_slice) = 0; access::rw(n_elem_slice) = 0;
access::rw(n_slices) = 0; access::rw(n_slices) = 0;
} }
else else
skipping to change at line 251 skipping to change at line 251
arma_extra_debug_print("Cube::init(): freeing memory"); arma_extra_debug_print("Cube::init(): freeing memory");
memory::release( access::rw(mem) ); memory::release( access::rw(mem) );
} }
} }
access::rw(mem_state) = 0; access::rw(mem_state) = 0;
if(new_n_elem <= Cube_prealloc::mem_n_elem) if(new_n_elem <= Cube_prealloc::mem_n_elem)
{ {
arma_extra_debug_print("Cube::init(): using local memory");
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
else else
{ {
arma_extra_debug_print("Cube::init(): allocating memory"); arma_extra_debug_print("Cube::init(): allocating memory");
access::rw(mem) = memory::acquire<eT>(new_n_elem); access::rw(mem) = memory::acquire<eT>(new_n_elem);
arma_check_bad_alloc( (mem == 0), "Cube::init(): out of memory" );
} }
if(new_n_elem > 0) if(new_n_elem > 0)
{ {
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
access::rw(n_elem_slice) = in_n_rows*in_n_cols; access::rw(n_elem_slice) = in_n_rows*in_n_cols;
access::rw(n_slices) = in_n_slices; access::rw(n_slices) = in_n_slices;
access::rw(n_elem) = new_n_elem; access::rw(n_elem) = new_n_elem;
skipping to change at line 853 skipping to change at line 853
const uword subcube_n_cols = in_col2 - in_col1 + 1; const uword subcube_n_cols = in_col2 - in_col1 + 1;
const uword subcube_n_slices = in_slice2 - in_slice1 + 1; const uword subcube_n_slices = in_slice2 - in_slice1 + 1;
return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_row s, subcube_n_cols, subcube_n_slices); return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_row s, subcube_n_cols, subcube_n_slices);
} }
//! creation of subview_cube (generic subcube) //! creation of subview_cube (generic subcube)
template<typename eT> template<typename eT>
inline inline
subview_cube<eT> subview_cube<eT>
Cube<eT>::subcube(const uword in_row1, const uword in_col1, const uword in_
slice1, const SizeCube& s)
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword l_n_slices = n_slices;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
const uword s_n_slices = s.n_slices;
arma_debug_check
(
( in_row1 >= l_n_rows) || ( in_col1 >= l_n_c
ols) || ( in_slice1 >= l_n_slices)
|| ((in_row1 + s_n_rows) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_c
ols) || ((in_slice1 + s_n_slices) > l_n_slices),
"Cube::subcube(): indices or size out of bounds"
);
return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, s_n_rows, s_n
_cols, s_n_slices);
}
//! creation of subview_cube (generic subcube)
template<typename eT>
inline
const subview_cube<eT>
Cube<eT>::subcube(const uword in_row1, const uword in_col1, const uword in_
slice1, const SizeCube& s) const
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword l_n_slices = n_slices;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
const uword s_n_slices = s.n_slices;
arma_debug_check
(
( in_row1 >= l_n_rows) || ( in_col1 >= l_n_c
ols) || ( in_slice1 >= l_n_slices)
|| ((in_row1 + s_n_rows) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_c
ols) || ((in_slice1 + s_n_slices) > l_n_slices),
"Cube::subcube(): indices or size out of bounds"
);
return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, s_n_rows, s_n
_cols, s_n_slices);
}
//! creation of subview_cube (generic subcube)
template<typename eT>
inline
subview_cube<eT>
Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s lice_span) Cube<eT>::subcube(const span& row_span, const span& col_span, const span& s lice_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const bool slice_all = slice_span.whole; const bool slice_all = slice_span.whole;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
skipping to change at line 954 skipping to change at line 1006
inline inline
const subview_cube<eT> const subview_cube<eT>
Cube<eT>::operator()(const span& row_span, const span& col_span, const span & slice_span) const Cube<eT>::operator()(const span& row_span, const span& col_span, const span & slice_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).subcube(row_span, col_span, slice_span); return (*this).subcube(row_span, col_span, slice_span);
} }
template<typename eT> template<typename eT>
inline
subview_cube<eT>
Cube<eT>::operator()(const uword in_row1, const uword in_col1, const uword
in_slice1, const SizeCube& s)
{
arma_extra_debug_sigprint();
return (*this).subcube(in_row1, in_col1, in_slice1, s);
}
template<typename eT>
inline
const subview_cube<eT>
Cube<eT>::operator()(const uword in_row1, const uword in_col1, const uword
in_slice1, const SizeCube& s) const
{
arma_extra_debug_sigprint();
return (*this).subcube(in_row1, in_col1, in_slice1, s);
}
template<typename eT>
arma_inline arma_inline
subview_cube<eT> subview_cube<eT>
Cube<eT>::tube(const uword in_row1, const uword in_col1) Cube<eT>::tube(const uword in_row1, const uword in_col1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
((in_row1 >= n_rows) || (in_col1 >= n_cols)), ((in_row1 >= n_rows) || (in_col1 >= n_cols)),
"Cube::tube(): indices out of bounds" "Cube::tube(): indices out of bounds"
skipping to change at line 1026 skipping to change at line 1098
"Cube::tube(): indices out of bounds or incorrectly used" "Cube::tube(): indices out of bounds or incorrectly used"
); );
const uword subcube_n_rows = in_row2 - in_row1 + 1; const uword subcube_n_rows = in_row2 - in_row1 + 1;
const uword subcube_n_cols = in_col2 - in_col1 + 1; const uword subcube_n_cols = in_col2 - in_col1 + 1;
return subview_cube<eT>(*this, in_row1, in_col1, 0, subcube_n_rows, subcu be_n_cols, n_slices); return subview_cube<eT>(*this, in_row1, in_col1, 0, subcube_n_rows, subcu be_n_cols, n_slices);
} }
template<typename eT> template<typename eT>
arma_inline
subview_cube<eT>
Cube<eT>::tube(const uword in_row1, const uword in_col1, const SizeMat& s)
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"Cube::tube(): indices or size out of bounds"
);
return subview_cube<eT>(*this, in_row1, in_col1, 0, s_n_rows, s_n_cols, n
_slices);
}
template<typename eT>
arma_inline
const subview_cube<eT>
Cube<eT>::tube(const uword in_row1, const uword in_col1, const SizeMat& s)
const
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"Cube::tube(): indices or size out of bounds"
);
return subview_cube<eT>(*this, in_row1, in_col1, 0, s_n_rows, s_n_cols, n
_slices);
}
template<typename eT>
inline inline
subview_cube<eT> subview_cube<eT>
Cube<eT>::tube(const span& row_span, const span& col_span) Cube<eT>::tube(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
skipping to change at line 2195 skipping to change at line 2311
const uword in_slice1 = slice_span.a; const uword in_slice1 = slice_span.a;
const uword in_slice2 = slice_span.b; const uword in_slice2 = slice_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (in_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (in_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (in_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (in_col2 < n_cols) );
const bool slices_ok = slice_span.whole ? true : ( (in_slice1 <= in_slice 2) && (in_slice2 < n_slices) ); const bool slices_ok = slice_span.whole ? true : ( (in_slice1 <= in_slice 2) && (in_slice2 < n_slices) );
return ( (rows_ok == true) && (cols_ok == true) && (slices_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) && (slices_ok == true) );
} }
template<typename eT>
inline
arma_warn_unused
bool
Cube<eT>::in_range(const uword in_row, const uword in_col, const uword in_s
lice, const SizeCube& s) const
{
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword l_n_slices = n_slices;
if(
( in_row >= l_n_rows) || ( in_col >= l_n_col
s) || ( in_slice >= l_n_slices)
|| ((in_row + s.n_rows) > l_n_rows) || ((in_col + s.n_cols) > l_n_col
s) || ((in_slice + s.n_slices) > l_n_slices)
)
{
return false;
}
else
{
return true;
}
}
//! returns a pointer to array of eTs used by the cube //! returns a pointer to array of eTs used by the cube
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Cube<eT>::memptr() Cube<eT>::memptr()
{ {
return const_cast<eT*>(mem); return const_cast<eT*>(mem);
} }
skipping to change at line 2509 skipping to change at line 2648
return (*this).fill(eT(1)); return (*this).fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randu() Cube<eT>::randu()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eop_aux_randu<eT>::fill( memptr(), n_elem ); arma_rng::randu<eT>::fill( memptr(), n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randu(const uword in_rows, const uword in_cols, const uword in_sl ices) Cube<eT>::randu(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2533 skipping to change at line 2672
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randn() Cube<eT>::randn()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eop_aux_randn<eT>::fill( memptr(), n_elem ); arma_rng::randn<eT>::fill( memptr(), n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Cube<eT>& const Cube<eT>&
Cube<eT>::randn(const uword in_rows, const uword in_cols, const uword in_sl ices) Cube<eT>::randn(const uword in_rows, const uword in_cols, const uword in_sl ices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 3075 skipping to change at line 3214
//! returns the number of elements in this cube //! returns the number of elements in this cube
template<typename eT> template<typename eT>
inline inline
uword uword
Cube<eT>::size() const Cube<eT>::size() const
{ {
return n_elem; return n_elem;
} }
// template<typename eT> template<typename eT>
// inline inline
// void void
// Cube<eT>::swap(Cube<eT>& B) Cube<eT>::swap(Cube<eT>& B)
// { {
// // TODO Cube<eT>& A = (*this);
// }
arma_extra_debug_sigprint(arma_boost::format("A = %x B = %x") % &A % &B
);
if( (A.mem_state == 0) && (B.mem_state == 0) && (A.n_elem > Cube_prealloc
::mem_n_elem) && (B.n_elem > Cube_prealloc::mem_n_elem) )
{
A.delete_mat();
B.delete_mat();
std::swap( access::rw(A.n_rows), access::rw(B.n_rows) );
std::swap( access::rw(A.n_cols), access::rw(B.n_cols) );
std::swap( access::rw(A.n_elem_slice), access::rw(B.n_elem_slice) );
std::swap( access::rw(A.n_slices), access::rw(B.n_slices) );
std::swap( access::rw(A.n_elem), access::rw(B.n_elem) );
std::swap( access::rw(A.mem), access::rw(B.mem) );
A.create_mat();
B.create_mat();
}
else
if( (A.mem_state == 0) && (B.mem_state == 0) && (A.n_elem <= Cube_preallo
c::mem_n_elem) && (B.n_elem <= Cube_prealloc::mem_n_elem) )
{
A.delete_mat();
B.delete_mat();
std::swap( access::rw(A.n_rows), access::rw(B.n_rows) );
std::swap( access::rw(A.n_cols), access::rw(B.n_cols) );
std::swap( access::rw(A.n_elem_slice), access::rw(B.n_elem_slice) );
std::swap( access::rw(A.n_slices), access::rw(B.n_slices) );
std::swap( access::rw(A.n_elem), access::rw(B.n_elem) );
const uword N = (std::max)(A.n_elem, B.n_elem);
eT* A_mem = A.memptr();
eT* B_mem = B.memptr();
for(uword i=0; i<N; ++i) { std::swap( A_mem[i], B_mem[i] ); }
A.create_mat();
B.create_mat();
}
else
{
// generic swap
if(A.n_elem <= B.n_elem)
{
Cube<eT> C = A;
A.steal_mem(B);
B.steal_mem(C);
}
else
{
Cube<eT> C = B;
B.steal_mem(A);
A.steal_mem(C);
}
}
}
//! 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
void void
Cube<eT>::steal_mem(Cube<eT>& x) Cube<eT>::steal_mem(Cube<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
if( (mem_state <= 1) && (x.mem_state <= 1) && (x.n_elem > Cube_prealloc ::mem_n_elem) ) if( (mem_state <= 1) && ( ((x.mem_state == 0) && (x.n_elem > Cube_preal loc::mem_n_elem)) || (x.mem_state == 1) ) )
{ {
reset(); reset();
const uword x_n_slices = x.n_slices; const uword x_n_slices = x.n_slices;
access::rw(n_rows) = x.n_rows; access::rw(n_rows) = x.n_rows;
access::rw(n_cols) = x.n_cols; access::rw(n_cols) = x.n_cols;
access::rw(n_elem_slice) = x.n_elem_slice; access::rw(n_elem_slice) = x.n_elem_slice;
access::rw(n_slices) = x_n_slices; access::rw(n_slices) = x_n_slices;
access::rw(n_elem) = x.n_elem; access::rw(n_elem) = x.n_elem;
access::rw(mem_state) = x.mem_state;
access::rw(mem) = x.mem; access::rw(mem) = x.mem;
if(x_n_slices > Cube_prealloc::mat_ptrs_size) if(x_n_slices > Cube_prealloc::mat_ptrs_size)
{ {
access::rw( mat_ptrs) = x.mat_ptrs; access::rw( mat_ptrs) = x.mat_ptrs;
access::rw(x.mat_ptrs) = 0; access::rw(x.mat_ptrs) = 0;
} }
else else
{ {
access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local ); access::rw(mat_ptrs) = const_cast< const Mat<eT>** >(mat_ptrs_local );
 End of changes. 13 change blocks. 
14 lines changed or deleted 234 lines changed or added


 GenCube_meat.hpp   GenCube_meat.hpp 
skipping to change at line 33 skipping to change at line 33
GenCube<eT, gen_type>::~GenCube() GenCube<eT, gen_type>::~GenCube()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename gen_type> template<typename eT, typename gen_type>
arma_inline arma_inline
eT eT
GenCube<eT, gen_type>::generate() GenCube<eT, gen_type>::generate()
{ {
if(is_same_type<gen_type, gen_ones_full>::yes) { return eT(1); if(is_same_type<gen_type, gen_ones_full>::yes) { return eT(1);
} }
else if(is_same_type<gen_type, gen_zeros >::yes) { return eT(0); else if(is_same_type<gen_type, gen_zeros >::yes) { return eT(0);
} }
else if(is_same_type<gen_type, gen_randu >::yes) { return eT(eop_aux_r else if(is_same_type<gen_type, gen_randu >::yes) { return eT(arma_rng:
andu<eT>()); } :randu<eT>()); }
else if(is_same_type<gen_type, gen_randn >::yes) { return eT(eop_aux_r else if(is_same_type<gen_type, gen_randn >::yes) { return eT(arma_rng:
andn<eT>()); } :randn<eT>()); }
else { return eT(); else { return eT();
} }
} }
template<typename eT, typename gen_type> template<typename eT, typename gen_type>
arma_inline arma_inline
eT eT
GenCube<eT, gen_type>::operator[](const uword) const GenCube<eT, gen_type>::operator[](const uword) const
{ {
return GenCube<eT, gen_type>::generate(); return GenCube<eT, gen_type>::generate();
} }
 End of changes. 1 change blocks. 
10 lines changed or deleted 10 lines changed or added


 Gen_meat.hpp   Gen_meat.hpp 
skipping to change at line 34 skipping to change at line 34
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
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>::generate() Gen<T1, gen_type>::generate()
{ {
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_full>::yes) { return eT(1); if(is_same_type<gen_type, gen_ones_full>::yes) { return eT(1);
} }
else if(is_same_type<gen_type, gen_zeros >::yes) { return eT(0); else if(is_same_type<gen_type, gen_zeros >::yes) { return eT(0);
} }
else if(is_same_type<gen_type, gen_randu >::yes) { return eT(eop_aux_r else if(is_same_type<gen_type, gen_randu >::yes) { return eT(arma_rng:
andu<eT>()); } :randu<eT>()); }
else if(is_same_type<gen_type, gen_randn >::yes) { return eT(eop_aux_r else if(is_same_type<gen_type, gen_randn >::yes) { return eT(arma_rng:
andn<eT>()); } :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 ii) 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>::yes) if(is_same_type<gen_type, gen_ones_diag>::yes)
 End of changes. 1 change blocks. 
10 lines changed or deleted 10 lines changed or added


 Mat_bones.hpp   Mat_bones.hpp 
skipping to change at line 184 skipping to change at line 184
inline subview<eT> rows(const span& row_span); inline subview<eT> rows(const span& row_span);
inline const subview<eT> rows(const span& row_span) const; inline const subview<eT> rows(const span& row_span) const;
arma_inline subview<eT> cols(const span& col_span); arma_inline subview<eT> cols(const span& col_span);
arma_inline const subview<eT> cols(const span& col_span) const; arma_inline const subview<eT> cols(const span& col_span) const;
arma_inline subview<eT> submat(const uword in_row1, const uword in_ col1, const uword in_row2, const uword in_col2); arma_inline subview<eT> submat(const uword in_row1, const uword in_ col1, const uword in_row2, const uword in_col2);
arma_inline const subview<eT> submat(const uword in_row1, const uword in_ col1, const uword in_row2, const uword in_col2) const; arma_inline const subview<eT> submat(const uword in_row1, const uword in_ col1, const uword in_row2, const uword in_col2) const;
arma_inline subview<eT> submat(const uword in_row1, const uword in_
col1, const SizeMat& s);
arma_inline const subview<eT> submat(const uword in_row1, const uword in_
col1, const SizeMat& s) const;
inline subview<eT> submat (const span& row_span, const span & col_span); inline subview<eT> submat (const span& row_span, const span & col_span);
inline const subview<eT> submat (const span& row_span, const span & col_span) const; inline const subview<eT> submat (const span& row_span, const span & col_span) const;
inline subview<eT> operator()(const span& row_span, const span & col_span); inline subview<eT> operator()(const span& row_span, const span & col_span);
inline const subview<eT> operator()(const span& row_span, const span & col_span) const; inline const subview<eT> operator()(const span& row_span, const span & col_span) const;
inline subview<eT> operator()(const uword in_row1, const uword
in_col1, const SizeMat& s);
inline const subview<eT> operator()(const uword in_row1, const uword
in_col1, const SizeMat& s) const;
template<typename T1> arma_inline subview_elem1<eT,T1> elem(const B ase<uword,T1>& a); template<typename T1> arma_inline subview_elem1<eT,T1> elem(const B ase<uword,T1>& a);
template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const B ase<uword,T1>& a) const; template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const B ase<uword,T1>& a) const;
template<typename T1> arma_inline subview_elem1<eT,T1> operator()(c onst Base<uword,T1>& a); template<typename T1> arma_inline subview_elem1<eT,T1> operator()(c onst Base<uword,T1>& a);
template<typename T1> arma_inline const subview_elem1<eT,T1> operator()(c onst Base<uword,T1>& a) const; template<typename T1> arma_inline const subview_elem1<eT,T1> operator()(c onst Base<uword,T1>& a) const;
template<typename T1, typename T2> arma_inline subview_elem2<eT,T1, T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci); template<typename T1, typename T2> arma_inline subview_elem2<eT,T1, T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci);
template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1, T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const; template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1, T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const;
template<typename T1, typename T2> arma_inline subview_elem2<eT,T1, T2> submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci); template<typename T1, typename T2> arma_inline subview_elem2<eT,T1, T2> submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci);
skipping to change at line 329 skipping to change at line 335
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 ii) 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 bool in_range(const uword in_row, const uwor
d in_col, const SizeMat& s) 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_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;
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);
template<typename functor> template<typename functor>
inline const Mat& transform(functor F); inline const Mat& transform(functor F);
template<typename functor> template<typename functor>
inline const Mat& imbue(functor F); inline const Mat& imbue(functor F);
arma_hot inline const Mat& fill(const eT val); arma_hot inline const Mat& fill(const eT val);
 End of changes. 4 change blocks. 
0 lines changed or deleted 14 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 147 skipping to change at line 147
( (
( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) ) ( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
? ( (float(n_rows) * float(n_cols)) > float(ARMA_MAX_UWORD) ) ? ( (float(n_rows) * float(n_cols)) > float(ARMA_MAX_UWORD) )
: false : false
), ),
"Mat::init(): requested size is too large" "Mat::init(): requested size is too large"
); );
if(n_elem <= arma_config::mat_prealloc) if(n_elem <= arma_config::mat_prealloc)
{ {
arma_extra_debug_print("Mat::init(): using local memory");
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
else else
{ {
arma_extra_debug_print("Mat::init(): allocating memory"); arma_extra_debug_print("Mat::init(): allocating memory");
access::rw(mem) = memory::acquire<eT>(n_elem); access::rw(mem) = memory::acquire<eT>(n_elem);
arma_check_bad_alloc( (mem == 0), "Mat::init(): out of memory" );
} }
} }
//! internal matrix construction; if the requested size is small enough, me mory from the stack is used. otherwise memory is allocated via 'new' //! internal matrix construction; if the requested size is small enough, me mory from the stack is used. otherwise memory is allocated via 'new'
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols) Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
{ {
arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols ); arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols );
skipping to change at line 202 skipping to change at line 202
in_n_cols = 1; in_n_cols = 1;
} }
else else
if(t_vec_state == 2) if(t_vec_state == 2)
{ {
in_n_rows = 1; in_n_rows = 1;
} }
} }
else else
{ {
arma_debug_set_error if(t_vec_state == 1)
( {
err_state, arma_debug_set_error
err_msg, (
( ((t_vec_state == 1) && (in_n_cols != 1)) || ((t_vec_state == 2) & err_state,
& (in_n_rows != 1)) ), err_msg,
"Mat::init(): object is a row or column vector; requested size is n (in_n_cols != 1),
ot compatible" "Mat::init(): requested size is not compatible with column vector
); layout"
);
}
else
if(t_vec_state == 2)
{
arma_debug_set_error
(
err_state,
err_msg,
(in_n_rows != 1),
"Mat::init(): requested size is not compatible with row vector la
yout"
);
}
} }
} }
// ensure that n_elem can hold the result of (n_rows * n_cols) // ensure that n_elem can hold the result of (n_rows * n_cols)
arma_debug_set_error arma_debug_set_error
( (
err_state, err_state,
err_msg, err_msg,
( (
skipping to change at line 258 skipping to change at line 272
if(old_n_elem > arma_config::mat_prealloc) if(old_n_elem > arma_config::mat_prealloc)
{ {
arma_extra_debug_print("Mat::init(): freeing memory"); arma_extra_debug_print("Mat::init(): freeing memory");
memory::release( access::rw(mem) ); memory::release( access::rw(mem) );
} }
} }
if(new_n_elem <= arma_config::mat_prealloc) if(new_n_elem <= arma_config::mat_prealloc)
{ {
arma_extra_debug_print("Mat::init(): using local memory");
access::rw(mem) = mem_local; access::rw(mem) = mem_local;
} }
else else
{ {
arma_extra_debug_print("Mat::init(): allocating memory"); arma_extra_debug_print("Mat::init(): allocating memory");
access::rw(mem) = memory::acquire<eT>(new_n_elem); access::rw(mem) = memory::acquire<eT>(new_n_elem);
arma_check_bad_alloc( (mem == 0), "Mat::init(): out of memory" );
} }
access::rw(n_rows) = in_n_rows; access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols; access::rw(n_cols) = in_n_cols;
access::rw(n_elem) = new_n_elem; access::rw(n_elem) = new_n_elem;
access::rw(mem_state) = 0; access::rw(mem_state) = 0;
} }
} }
//! create the matrix from a textual description //! create the matrix from a textual description
skipping to change at line 336 skipping to change at line 350
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(text); init(text);
return *this; return *this;
} }
//! internal function to create the matrix from a textual description //! internal function to create the matrix from a textual description
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init(const std::string& text) Mat<eT>::init(const std::string& text_orig)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool replace_commas = (is_cx<eT>::yes) ? false : ( text_orig.find('
,') != std::string::npos );
std::string* text_mod = (replace_commas) ? new std::string(text_orig) : N
ULL;
const std::string& text = (replace_commas) ? ( std::replace((*text_mod).b
egin(), (*text_mod).end(), ',', ' '), (*text_mod) ) : text_orig;
// //
// work out the size // work out the size
uword t_n_rows = 0; uword t_n_rows = 0;
uword t_n_cols = 0; uword t_n_cols = 0;
bool t_n_cols_found = false; bool t_n_cols_found = false;
std::string token; std::string token;
std::string::size_type line_start = 0; std::string::size_type line_start = 0;
std::string::size_type line_end = 0; std::string::size_type line_end = 0;
std::stringstream line_stream;
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) );
line_stream.clear();
line_stream.str( text.substr(line_start,line_len) );
uword line_n_cols = 0; uword line_n_cols = 0;
while(line_stream >> token) while(line_stream >> token)
{ {
++line_n_cols; ++line_n_cols;
} }
if(line_n_cols > 0) if(line_n_cols > 0)
{ {
if(t_n_cols_found == false) if(t_n_cols_found == false)
{ {
t_n_cols = line_n_cols; t_n_cols = line_n_cols;
t_n_cols_found = true; t_n_cols_found = true;
} }
else else
{
arma_check( (line_n_cols != t_n_cols), "Mat::init(): inconsistent n umber of columns in given string"); arma_check( (line_n_cols != t_n_cols), "Mat::init(): inconsistent n umber of columns in given string");
}
++t_n_rows; ++t_n_rows;
} }
line_start = line_end+1;
line_start = line_end+1;
} }
Mat<eT>& x = *this; Mat<eT>& x = *this;
x.set_size(t_n_rows, t_n_cols); x.set_size(t_n_rows, t_n_cols);
line_start = 0; line_start = 0;
line_end = 0; line_end = 0;
uword urow = 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) );
line_stream.clear();
line_stream.str( text.substr(line_start,line_len) );
// uword ucol = 0; // uword ucol = 0;
// while(line_stream >> token) // while(line_stream >> token)
// { // {
// x.at(urow,ucol) = strtod(token.c_str(), 0); // x.at(urow,ucol) = strtod(token.c_str(), 0);
// ++ucol; // ++ucol;
// } // }
uword ucol = 0; uword ucol = 0;
eT val; eT val;
while(line_stream >> val) while(line_stream >> val)
{ {
x.at(urow,ucol) = val; x.at(urow,ucol) = val;
++ucol; ++ucol;
} }
++urow; ++urow;
line_start = line_end+1; line_start = line_end+1;
} }
if(replace_commas)
{
delete text_mod;
}
} }
//! create the matrix from std::vector //! create the matrix from std::vector
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(const std::vector<eT>& x) Mat<eT>::Mat(const std::vector<eT>& x)
: n_rows(uword(x.size())) : n_rows(uword(x.size()))
, n_cols(1) , n_cols(1)
, n_elem(uword(x.size())) , n_elem(uword(x.size()))
, vec_state(0) , vec_state(0)
skipping to change at line 496 skipping to change at line 530
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(list); init(list);
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::Mat(Mat<eT>&& in_mat) Mat<eT>::Mat(Mat<eT>&& X)
: n_rows(0) : n_rows (X.n_rows)
, n_cols(0) , n_cols (X.n_cols)
, n_elem(0) , n_elem (X.n_elem)
, vec_state(0) , vec_state(0 )
, mem_state(0) , mem_state(0 )
, mem() , mem ( )
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint(arma_boost::format("this = %x X = %x") % th
arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") is % &X);
% this % &in_mat);
if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || (
X.mem_state == 1) || (X.mem_state == 2) )
{
access::rw(mem_state) = X.mem_state;
access::rw(mem) = X.mem;
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem_state) = 0;
access::rw(X.mem) = 0;
}
else
{
init_cold();
(*this).steal_mem(in_mat); arrayops::copy( memptr(), X.mem, X.n_elem );
}
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(Mat<eT>&& in_mat) Mat<eT>::operator=(Mat<eT>&& X)
{ {
arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x") % this % &in_mat); arma_extra_debug_sigprint(arma_boost::format("this = %x X = %x") % th is % &X);
(*this).steal_mem(in_mat); (*this).steal_mem(X);
return *this; return *this;
} }
#endif #endif
//! Set the matrix to be equal to the specified scalar. //! Set the matrix to be equal to the specified scalar.
//! NOTE: the size of the matrix will be 1x1 //! NOTE: the size of the matrix will be 1x1
template<typename eT> template<typename eT>
arma_inline arma_inline
skipping to change at line 704 skipping to change at line 753
{ {
for(uword ucol=0; ucol < local_n_cols; ++ucol) for(uword ucol=0; ucol < local_n_cols; ++ucol)
for(uword urow=0; urow < local_n_rows; ++urow) for(uword urow=0; urow < local_n_rows; ++urow)
{ {
*out_mem = std::complex<T>(PX.at(urow,ucol), PY.at(urow,ucol)); *out_mem = std::complex<T>(PX.at(urow,ucol), PY.at(urow,ucol));
out_mem++; out_mem++;
} }
} }
} }
//! EXPERIMENTAL: swap the contents of this matrix, denoted as matrix A, wi th given matrix B //! swap the contents of this matrix, denoted as matrix A, with given matri x B
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::swap(Mat<eT>& B) Mat<eT>::swap(Mat<eT>& B)
{ {
Mat<eT>& A = (*this); Mat<eT>& A = (*this);
arma_extra_debug_sigprint(arma_boost::format("A = %x B = %x") % &A % &B ); arma_extra_debug_sigprint(arma_boost::format("A = %x B = %x") % &A % &B );
arma_debug_check( (A.vec_state != B.vec_state), "Mat::swap(): incompatibl bool layout_ok = false;
e object types" );
if(A.vec_state == B.vec_state)
{
layout_ok = true;
}
else
{
const uhword A_vec_state = A.vec_state;
const uhword B_vec_state = B.vec_state;
const bool A_absorbs_B = (A_vec_state == 0) || ( (A_vec_state == 1) &&
(B.n_cols == 1) ) || ( (A_vec_state == 2) && (B.n_rows == 1) );
const bool B_absorbs_A = (B_vec_state == 0) || ( (B_vec_state == 1) &&
(A.n_cols == 1) ) || ( (B_vec_state == 2) && (A.n_rows == 1) );
layout_ok = A_absorbs_B && B_absorbs_A;
}
const uhword A_mem_state = A.mem_state; const uhword A_mem_state = A.mem_state;
const uhword B_mem_state = B.mem_state; const uhword B_mem_state = B.mem_state;
if( (A_mem_state == 0) && (B_mem_state == 0) ) if( (A_mem_state == 0) && (B_mem_state == 0) && layout_ok )
{ {
const uword A_n_elem = A.n_elem; const uword A_n_elem = A.n_elem;
const uword B_n_elem = B.n_elem; const uword B_n_elem = B.n_elem;
const bool A_use_local_mem = (A_n_elem <= arma_config::mat_prealloc); const bool A_use_local_mem = (A_n_elem <= arma_config::mat_prealloc);
const bool B_use_local_mem = (B_n_elem <= arma_config::mat_prealloc); const bool B_use_local_mem = (B_n_elem <= arma_config::mat_prealloc);
if( (A_use_local_mem == false) && (B_use_local_mem == false) ) if( (A_use_local_mem == false) && (B_use_local_mem == false) )
{ {
std::swap( access::rw(A.mem), access::rw(B.mem) ); std::swap( access::rw(A.mem), access::rw(B.mem) );
skipping to change at line 772 skipping to change at line 836
access::rw(B.mem) = A.mem; access::rw(B.mem) = A.mem;
access::rw(A.mem) = A_mem_local; access::rw(A.mem) = A_mem_local;
} }
std::swap( access::rw(A.n_rows), access::rw(B.n_rows) ); std::swap( access::rw(A.n_rows), access::rw(B.n_rows) );
std::swap( access::rw(A.n_cols), access::rw(B.n_cols) ); std::swap( access::rw(A.n_cols), access::rw(B.n_cols) );
std::swap( access::rw(A.n_elem), access::rw(B.n_elem) ); std::swap( access::rw(A.n_elem), access::rw(B.n_elem) );
} }
else else
if( (A_mem_state == 3) && (B_mem_state == 3) ) if( (A_mem_state <= 2) && (B_mem_state <= 2) && (A.n_elem == B.n_elem) && layout_ok )
{ {
arma_debug_check( ((A.n_rows != B.n_rows) || (A.n_cols != B.n_cols)), " std::swap( access::rw(A.n_rows), access::rw(B.n_rows) );
Mat::swap(): incompatible object types" ); std::swap( access::rw(A.n_cols), access::rw(B.n_cols) );
const uword N = A.n_elem; const uword N = A.n_elem;
eT* A_mem = A.memptr(); eT* A_mem = A.memptr();
eT* B_mem = B.memptr(); eT* B_mem = B.memptr();
for(uword ii=0; ii < N; ++ii) { std::swap(A_mem[ii], B_mem[ii]); } for(uword ii=0; ii < N; ++ii) { std::swap(A_mem[ii], B_mem[ii]); }
} }
else else
if( (A.n_rows == B.n_rows) && (A.n_cols == B.n_cols) )
{ {
arma_bad("Mat::swap(): incompatible object types"); const uword N = A.n_elem;
eT* A_mem = A.memptr();
eT* B_mem = B.memptr();
for(uword ii=0; ii < N; ++ii) { std::swap(A_mem[ii], B_mem[ii]); }
}
else
{
// generic swap to handle remaining cases
if(A.n_elem <= B.n_elem)
{
Mat<eT> C = A;
A.steal_mem(B);
B.steal_mem(C);
}
else
{
Mat<eT> C = B;
B.steal_mem(A);
A.steal_mem(C);
}
} }
} }
//! 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 817 skipping to change at line 907
const uword t_mem_state = mem_state; const uword t_mem_state = mem_state;
bool layout_ok = false; bool layout_ok = false;
if(t_vec_state == x_vec_state) if(t_vec_state == x_vec_state)
{ {
layout_ok = true; layout_ok = true;
} }
else else
{ {
if( (t_vec_state == 1) && ( x_n_cols == 1) ) if( (t_vec_state == 1) && (x_n_cols == 1) ) { layout_ok = true; }
{ if( (t_vec_state == 2) && (x_n_rows == 1) ) { layout_ok = true; }
layout_ok = true;
}
if( (t_vec_state == 2) && ( x_n_rows == 1) )
{
layout_ok = true;
}
} }
if( (t_mem_state <= 1) && (x_mem_state <= 1) && (x_n_elem > arma_config ::mat_prealloc) && (layout_ok == true) ) if( (t_mem_state <= 1) && ( ((x_mem_state == 0) && (x_n_elem > arma_con fig::mat_prealloc)) || (x_mem_state == 1) ) && layout_ok )
{ {
reset(); reset();
// note: calling reset() also prevents fixed size matrices from chang ing size or using non-local memory
access::rw(n_rows) = x_n_rows; access::rw(n_rows) = x_n_rows;
access::rw(n_cols) = x_n_cols; access::rw(n_cols) = x_n_cols;
access::rw(n_elem) = x_n_elem; access::rw(n_elem) = x_n_elem;
access::rw(mem) = x.mem; access::rw(mem_state) = x_mem_state;
access::rw(mem) = x.mem;
access::rw(x.n_rows) = 0; access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0; access::rw(x.n_cols) = 0;
access::rw(x.n_elem) = 0; access::rw(x.n_elem) = 0;
access::rw(x.mem_state) = 0; access::rw(x.mem_state) = 0;
access::rw(x.mem) = 0; access::rw(x.mem) = 0;
} }
else else
{ {
(*this).operator=(x); (*this).operator=(x);
skipping to change at line 2011 skipping to change at line 2094
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
const SpProxy<T1> p(m.get_ref()); const SpProxy<T1> p(m.get_ref());
access::rw(n_rows) = p.get_n_rows(); access::rw(n_rows) = p.get_n_rows();
access::rw(n_cols) = p.get_n_cols(); access::rw(n_cols) = p.get_n_cols();
access::rw(n_elem) = p.get_n_elem(); access::rw(n_elem) = p.get_n_elem();
init_cold(); init_cold();
fill(eT(0));
zeros();
typename SpProxy<T1>::const_iterator_type it = p.begin(); typename SpProxy<T1>::const_iterator_type it = p.begin();
typename SpProxy<T1>::const_iterator_type it_end = p.end(); typename SpProxy<T1>::const_iterator_type it_end = p.end();
while(it != it_end) while(it != it_end)
{ {
at(it.row(), it.col()) = (*it); at(it.row(), it.col()) = (*it);
++it; ++it;
} }
} }
skipping to change at line 2035 skipping to change at line 2119
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const SpBase<eT, T1>& m) Mat<eT>::operator=(const SpBase<eT, T1>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const SpProxy<T1> p(m.get_ref()); const SpProxy<T1> p(m.get_ref());
init_warm(p.get_n_rows(), p.get_n_cols()); init_warm(p.get_n_rows(), p.get_n_cols());
fill(eT(0)); zeros();
typename SpProxy<T1>::const_iterator_type it = p.begin(); typename SpProxy<T1>::const_iterator_type it = p.begin();
typename SpProxy<T1>::const_iterator_type it_end = p.end(); typename SpProxy<T1>::const_iterator_type it_end = p.end();
while(it != it_end) while(it != it_end)
{ {
at(it.row(), it.col()) = (*it); at(it.row(), it.col()) = (*it);
++it; ++it;
} }
skipping to change at line 2605 skipping to change at line 2689
); );
const uword subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const uword subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_col s); return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_col s);
} }
//! creation of subview (submatrix) //! creation of subview (submatrix)
template<typename eT> template<typename eT>
arma_inline
subview<eT>
Mat<eT>::submat(const uword in_row1, const uword in_col1, const SizeMat& s)
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"Mat::submat(): indices or size out of bounds"
);
return subview<eT>(*this, in_row1, in_col1, s_n_rows, s_n_cols);
}
//! creation of subview (submatrix)
template<typename eT>
arma_inline
const subview<eT>
Mat<eT>::submat(const uword in_row1, const uword in_col1, const SizeMat& s)
const
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"Mat::submat(): indices or size out of bounds"
);
return subview<eT>(*this, in_row1, in_col1, s_n_rows, s_n_cols);
}
//! creation of subview (submatrix)
template<typename eT>
inline inline
subview<eT> subview<eT>
Mat<eT>::submat(const span& row_span, const span& col_span) Mat<eT>::submat(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
skipping to change at line 2692 skipping to change at line 2822
inline inline
const subview<eT> const subview<eT>
Mat<eT>::operator()(const span& row_span, const span& col_span) const Mat<eT>::operator()(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return (*this).submat(row_span, col_span); return (*this).submat(row_span, col_span);
} }
template<typename eT> template<typename eT>
inline
subview<eT>
Mat<eT>::operator()(const uword in_row1, const uword in_col1, const SizeMat
& s)
{
arma_extra_debug_sigprint();
return (*this).submat(in_row1, in_col1, s);
}
template<typename eT>
inline
const subview<eT>
Mat<eT>::operator()(const uword in_row1, const uword in_col1, const SizeMat
& s) const
{
arma_extra_debug_sigprint();
return (*this).submat(in_row1, in_col1, s);
}
template<typename eT>
template<typename T1> template<typename T1>
arma_inline arma_inline
subview_elem1<eT,T1> subview_elem1<eT,T1>
Mat<eT>::elem(const Base<uword,T1>& a) Mat<eT>::elem(const Base<uword,T1>& a)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a); return subview_elem1<eT,T1>(*this, a);
} }
skipping to change at line 4481 skipping to change at line 4631
const uword in_col1 = col_span.a; const uword in_col1 = col_span.a;
const uword in_col2 = col_span.b; const uword in_col2 = col_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) );
return ( (rows_ok == true) && (cols_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) );
} }
template<typename eT>
arma_inline
arma_warn_unused
bool
Mat<eT>::in_range(const uword in_row, const uword in_col, const SizeMat& s)
const
{
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
if( (in_row >= l_n_rows) || (in_col >= l_n_cols) || ((in_row + s.n_rows)
> l_n_rows) || ((in_col + s.n_cols) > l_n_cols) )
{
return false;
}
else
{
return true;
}
}
//! returns a pointer to array of eTs for a specified column; no bounds che ck //! returns a pointer to array of eTs for a specified column; no bounds che ck
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT* eT*
Mat<eT>::colptr(const uword in_col) Mat<eT>::colptr(const uword in_col)
{ {
return & access::rw(mem[in_col*n_rows]); return & access::rw(mem[in_col*n_rows]);
} }
skipping to change at line 4888 skipping to change at line 5057
return fill(eT(1)); return fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu() Mat<eT>::randu()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eop_aux_randu<eT>::fill( memptr(), n_elem ); arma_rng::randu<eT>::fill( memptr(), n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randu(const uword in_elem) Mat<eT>::randu(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 4924 skipping to change at line 5093
return (*this).randu(); return (*this).randu();
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn() Mat<eT>::randn()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eop_aux_randn<eT>::fill( memptr(), n_elem ); arma_rng::randn<eT>::fill( memptr(), n_elem );
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::randn(const uword in_elem) Mat<eT>::randn(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 46 change blocks. 
63 lines changed or deleted 243 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 181 skipping to change at line 181
Mat<eT>::operator=(list); Mat<eT>::operator=(list);
return *this; return *this;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(Row<eT>&& X) Row<eT>::Row(Row<eT>&& X)
: Mat<eT>(arma_vec_indicator(), 2) : Mat<eT>(arma_vec_indicator(), 2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint(arma_boost::format("this = %x X = %x") % th is % &X);
(*this).steal_mem(X); access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = X.n_cols;
access::rw(Mat<eT>::n_elem) = X.n_elem;
if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || (
X.mem_state == 1) || (X.mem_state == 2) )
{
access::rw(Mat<eT>::mem_state) = X.mem_state;
access::rw(Mat<eT>::mem) = X.mem;
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem_state) = 0;
access::rw(X.mem) = 0;
}
else
{
(*this).init_cold();
arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
}
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(Row<eT>&& X) Row<eT>::operator=(Row<eT>&& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
(*this).steal_mem(X); (*this).steal_mem(X);
 End of changes. 2 change blocks. 
2 lines changed or deleted 23 lines changed or added


 SpMat_bones.hpp   SpMat_bones.hpp 
skipping to change at line 66 skipping to change at line 66
* row row_indices[col_ptrs[i]]. This array is of length (n_cols + 2); t he * row row_indices[col_ptrs[i]]. This array is of length (n_cols + 2); t he
* element col_ptrs[n_cols] should be equal to n_nonzero, and the element * element col_ptrs[n_cols] should be equal to n_nonzero, and the element
* col_ptrs[n_cols + 1] is an invalid very large value that ensures the * col_ptrs[n_cols + 1] is an invalid very large value that ensures the
* integrity of iterators. * integrity of iterators.
*/ */
const uword* const col_ptrs; const uword* const col_ptrs;
inline SpMat(); //! Size will be 0x0 (empty). inline SpMat(); //! Size will be 0x0 (empty).
inline ~SpMat(); inline ~SpMat();
inline SpMat(const uword in_rows, const uword in_cols); inline SpMat(const uword in_rows, const uword in_cols);
inline SpMat(const char* text); inline SpMat(const char* text);
inline const SpMat& operator=(const char* text); inline const SpMat& operator=(const char* text);
inline SpMat(const std::string& text); inline SpMat(const std::string& text);
inline const SpMat& operator=(const std::string& text); inline const SpMat& operator=(const std::string& text);
inline SpMat(const SpMat<eT>& x); inline SpMat(const SpMat<eT>& x);
#if defined(ARMA_USE_CXX11)
inline SpMat(SpMat&& m);
inline const SpMat& operator=(SpMat&& m);
#endif
template<typename T1, typename T2> inline SpMat(const Base<uword,T1>& loc ations, const Base<eT,T2>& values, const bool sort_locations = true); template<typename T1, typename T2> inline SpMat(const Base<uword,T1>& loc ations, const Base<eT,T2>& values, const bool sort_locations = true);
template<typename T1, typename T2> inline SpMat(const Base<uword,T1>& loc ations, const Base<eT,T2>& values, const uword n_rows, const uword n_cols, const bool sort_locations = true); template<typename T1, typename T2> inline SpMat(const Base<uword,T1>& loc ations, const Base<eT,T2>& values, const uword n_rows, const uword n_cols, const bool sort_locations = true);
template<typename T1, typename T2, typename T3> inline SpMat(const Base<u word,T1>& rowind, const Base<uword,T2>& colptr, const Base<eT,T3>& values, const uword n_rows, const uword n_cols); template<typename T1, typename T2, typename T3> inline SpMat(const Base<u word,T1>& rowind, const Base<uword,T2>& colptr, const Base<eT,T3>& values, const uword n_rows, const uword n_cols);
inline const SpMat& operator=(const eT val); //! Sets size to 1x1. inline const SpMat& operator=(const eT val); //! Sets size to 1x1.
inline const SpMat& operator*=(const eT val); inline const SpMat& operator*=(const eT val);
inline const SpMat& operator/=(const eT val); inline const SpMat& operator/=(const eT val);
// operator+=(val) and operator-=(val) are not defined as they don't make sense for sparse matrices // operator+=(val) and operator-=(val) are not defined as they don't make sense for sparse matrices
skipping to change at line 192 skipping to change at line 197
arma_inline SpSubview<eT> rows(const uword in_row1, const uword in_ row2); arma_inline SpSubview<eT> rows(const uword in_row1, const uword in_ row2);
arma_inline const SpSubview<eT> rows(const uword in_row1, const uword in_ row2) const; arma_inline const SpSubview<eT> rows(const uword in_row1, const uword in_ row2) const;
arma_inline SpSubview<eT> cols(const uword in_col1, const uword in_ col2); arma_inline SpSubview<eT> cols(const uword in_col1, const uword in_ col2);
arma_inline const SpSubview<eT> cols(const uword in_col1, const uword in_ col2) const; arma_inline const SpSubview<eT> cols(const uword in_col1, const uword in_ col2) const;
arma_inline SpSubview<eT> submat(const uword in_row1, const uword i n_col1, const uword in_row2, const uword in_col2); arma_inline SpSubview<eT> submat(const uword in_row1, const uword i n_col1, const uword in_row2, const uword in_col2);
arma_inline const SpSubview<eT> submat(const uword in_row1, const uword i n_col1, const uword in_row2, const uword in_col2) const; arma_inline const SpSubview<eT> submat(const uword in_row1, const uword i n_col1, const uword in_row2, const uword in_col2) const;
arma_inline SpSubview<eT> submat(const uword in_row1, const uword i
n_col1, const SizeMat& s);
arma_inline const SpSubview<eT> submat(const uword in_row1, const uword i
n_col1, const SizeMat& s) const;
inline SpSubview<eT> submat (const span& row_span, const sp an& col_span); inline SpSubview<eT> submat (const span& row_span, const sp an& col_span);
inline const SpSubview<eT> submat (const span& row_span, const sp an& col_span) const; inline const SpSubview<eT> submat (const span& row_span, const sp an& col_span) const;
inline SpSubview<eT> operator()(const span& row_span, const sp an& col_span); inline SpSubview<eT> operator()(const span& row_span, const sp an& col_span);
inline const SpSubview<eT> operator()(const span& row_span, const sp an& col_span) const; inline const SpSubview<eT> operator()(const span& row_span, const sp an& col_span) const;
arma_inline SpSubview<eT> operator()(const uword in_row1, const uwo
rd in_col1, const SizeMat& s);
arma_inline const SpSubview<eT> operator()(const uword in_row1, const uwo
rd in_col1, const SizeMat& s) const;
/** /**
* Element access; access the i'th element (works identically to the Mat accessors). * Element access; access the i'th element (works identically to the Mat accessors).
* If there is nothing at element i, 0 is returned. * If there is nothing at element i, 0 is returned.
* *
* @param i Element to access. * @param i Element to access.
*/ */
arma_inline arma_warn_unused SpValProxy<SpMat<eT> > operator[] (const uwo rd i); arma_inline arma_warn_unused SpValProxy<SpMat<eT> > operator[] (const uwo rd i);
arma_inline arma_warn_unused eT operator[] (const uwo rd i) const; arma_inline arma_warn_unused eT operator[] (const uwo rd i) const;
arma_inline arma_warn_unused SpValProxy<SpMat<eT> > at (const uwo rd i); arma_inline arma_warn_unused SpValProxy<SpMat<eT> > at (const uwo rd i);
arma_inline arma_warn_unused eT at (const uwo rd i) const; arma_inline arma_warn_unused eT at (const uwo rd i) const;
skipping to change at line 238 skipping to change at line 249
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 i) 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 bool in_range(const uword in_row, const uwor
d in_col, const SizeMat& s) const;
/** /**
* Printing the matrix. * Printing the matrix.
* *
* @param extra_text Text to prepend to output. * @param extra_text Text to prepend to output.
*/ */
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_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;
skipping to change at line 287 skipping to change at line 300
inline const SpMat& zeros(const uword in_elem); inline const SpMat& zeros(const uword in_elem);
inline const SpMat& zeros(const uword in_rows, const uword in_cols); inline const SpMat& zeros(const uword in_rows, const uword in_cols);
inline const SpMat& eye(); inline const SpMat& eye();
inline const SpMat& eye(const uword in_rows, const uword in_cols); inline const SpMat& eye(const uword in_rows, const uword in_cols);
inline const SpMat& speye(); inline const SpMat& speye();
inline const SpMat& speye(const uword in_rows, const uword in_cols); inline const SpMat& speye(const uword in_rows, const uword in_cols);
inline const SpMat& sprandu(const uword in_rows, const uword in_cols, con st double density); inline const SpMat& sprandu(const uword in_rows, const uword in_cols, con st double density);
inline const SpMat& sprandn(const uword in_rows, const uword in_cols, con st double density); inline const SpMat& sprandn(const uword in_rows, const uword in_cols, con st double density);
inline void reset(); inline void reset();
/** /**
* Get the minimum or maximum of the matrix. * Get the minimum or maximum of the matrix.
*/ */
inline arma_warn_unused eT min() const; inline arma_warn_unused eT min() const;
inline eT min(uword& index_of_min_val) const; inline eT min(uword& index_of_min_val) const;
inline eT min(uword& row_of_min_val, uword& col_of_min_v al) const; inline eT min(uword& row_of_min_val, uword& col_of_min_v al) const;
 End of changes. 6 change blocks. 
1 lines changed or deleted 20 lines changed or added


 SpMat_meat.hpp   SpMat_meat.hpp 
skipping to change at line 45 skipping to change at line 45
/** /**
* Clean up the memory of a sparse matrix and destruct it. * Clean up the memory of a sparse matrix and destruct it.
*/ */
template<typename eT> template<typename eT>
inline inline
SpMat<eT>::~SpMat() SpMat<eT>::~SpMat()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
// If necessary, release the memory. if(values ) { memory::release(access::rw(values)); }
if (values) if(row_indices) { memory::release(access::rw(row_indices)); }
{ if(col_ptrs ) { memory::release(access::rw(col_ptrs)); }
// values being non-NULL implies row_indices is non-NULL.
memory::release(access::rw(values));
memory::release(access::rw(row_indices));
}
// Column pointers always must be deleted.
memory::release(access::rw(col_ptrs));
} }
/** /**
* Constructor with size given. * Constructor with size given.
*/ */
template<typename eT> template<typename eT>
inline inline
SpMat<eT>::SpMat(const uword in_rows, const uword in_cols) SpMat<eT>::SpMat(const uword in_rows, const uword in_cols)
: n_rows(0) : n_rows(0)
, n_cols(0) , n_cols(0)
skipping to change at line 151 skipping to change at line 144
, vec_state(0) , vec_state(0)
, values(NULL) , values(NULL)
, row_indices(NULL) , row_indices(NULL)
, col_ptrs(NULL) , col_ptrs(NULL)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(x); init(x);
} }
#if defined(ARMA_USE_CXX11)
template<typename eT>
inline
SpMat<eT>::SpMat(SpMat<eT>&& in_mat)
: n_rows(0)
, n_cols(0)
, n_elem(0)
, n_nonzero(0)
, vec_state(0)
, values(NULL)
, row_indices(NULL)
, col_ptrs(NULL)
{
arma_extra_debug_sigprint_this(this);
arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x")
% this % &in_mat);
(*this).steal_mem(in_mat);
}
template<typename eT>
inline
const SpMat<eT>&
SpMat<eT>::operator=(SpMat<eT>&& in_mat)
{
arma_extra_debug_sigprint(arma_boost::format("this = %x in_mat = %x")
% this % &in_mat);
(*this).steal_mem(in_mat);
return *this;
}
#endif
//! Insert a large number of values at once. //! Insert a large number of values at once.
//! locations.row[0] should be row indices, locations.row[1] should be colu mn indices, //! locations.row[0] should be row indices, locations.row[1] should be colu mn indices,
//! and values should be the corresponding values. //! and values should be the corresponding values.
//! If sort_locations is false, then it is assumed that the locations and v alues //! If sort_locations is false, then it is assumed that the locations and v alues
//! are already sorted in column-major ordering. //! are already sorted in column-major ordering.
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
SpMat<eT>::SpMat(const Base<uword,T1>& locations_expr, const Base<eT,T2>& v als_expr, const bool sort_locations) SpMat<eT>::SpMat(const Base<uword,T1>& locations_expr, const Base<eT,T2>& v als_expr, const bool sort_locations)
: n_rows(0) : n_rows(0)
skipping to change at line 2239 skipping to change at line 2266
"SpMat::submat(): indices out of bounds or incorrectly used" "SpMat::submat(): indices out of bounds or incorrectly used"
); );
const uword subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const uword subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
return SpSubview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_c ols); return SpSubview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_c ols);
} }
template<typename eT> template<typename eT>
arma_inline
SpSubview<eT>
SpMat<eT>::submat(const uword in_row1, const uword in_col1, const SizeMat&
s)
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"SpMat::submat(): indices or size out of bounds"
);
return SpSubview<eT>(*this, in_row1, in_col1, s_n_rows, s_n_cols);
}
template<typename eT>
arma_inline
const SpSubview<eT>
SpMat<eT>::submat(const uword in_row1, const uword in_col1, const SizeMat&
s) const
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"SpMat::submat(): indices or size out of bounds"
);
return SpSubview<eT>(*this, in_row1, in_col1, s_n_rows, s_n_cols);
}
template<typename eT>
inline inline
SpSubview<eT> SpSubview<eT>
SpMat<eT>::submat (const span& row_span, const span& col_span) SpMat<eT>::submat(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
skipping to change at line 2274 skipping to change at line 2345
, ,
"SpMat::submat(): indices out of bounds or incorrectly used" "SpMat::submat(): indices out of bounds or incorrectly used"
); );
return SpSubview<eT>(*this, in_row1, in_col1, submat_n_rows, submat_n_col s); return SpSubview<eT>(*this, in_row1, in_col1, submat_n_rows, submat_n_col s);
} }
template<typename eT> template<typename eT>
inline inline
const SpSubview<eT> const SpSubview<eT>
SpMat<eT>::submat (const span& row_span, const span& col_span) const SpMat<eT>::submat(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword in_row1 = row_all ? 0 : row_span.a; const uword in_row1 = row_all ? 0 : row_span.a;
skipping to change at line 2324 skipping to change at line 2395
template<typename eT> template<typename eT>
inline inline
const SpSubview<eT> const SpSubview<eT>
SpMat<eT>::operator()(const span& row_span, const span& col_span) const SpMat<eT>::operator()(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return submat(row_span, col_span); return submat(row_span, col_span);
} }
template<typename eT>
arma_inline
SpSubview<eT>
SpMat<eT>::operator()(const uword in_row1, const uword in_col1, const SizeM
at& s)
{
arma_extra_debug_sigprint();
return (*this).submat(in_row1, in_col1, s);
}
template<typename eT>
arma_inline
const SpSubview<eT>
SpMat<eT>::operator()(const uword in_row1, const uword in_col1, const SizeM
at& s) const
{
arma_extra_debug_sigprint();
return (*this).submat(in_row1, in_col1, s);
}
/** /**
* Element access; acces the i'th element (works identically to the Mat acc essors). * Element access; acces the i'th element (works identically to the Mat acc essors).
* If there is nothing at element i, 0 is returned. * If there is nothing at element i, 0 is returned.
* *
* @param i Element to access. * @param i Element to access.
*/ */
template<typename eT> template<typename eT>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
skipping to change at line 2605 skipping to change at line 2696
const uword in_col1 = col_span.a; const uword in_col1 = col_span.a;
const uword in_col2 = col_span.b; const uword in_col2 = col_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) );
return ( (rows_ok == true) && (cols_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) );
} }
template<typename eT> template<typename eT>
arma_inline
arma_warn_unused
bool
SpMat<eT>::in_range(const uword in_row, const uword in_col, const SizeMat&
s) const
{
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
if( (in_row >= l_n_rows) || (in_col >= l_n_cols) || ((in_row + s.n_rows)
> l_n_rows) || ((in_col + s.n_cols) > l_n_cols) )
{
return false;
}
else
{
return true;
}
}
template<typename eT>
inline inline
void void
SpMat<eT>::impl_print(const std::string& extra_text) const SpMat<eT>::impl_print(const std::string& extra_text) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(extra_text.length() != 0) if(extra_text.length() != 0)
{ {
const std::streamsize orig_width = ARMA_DEFAULT_OSTREAM.width(); const std::streamsize orig_width = ARMA_DEFAULT_OSTREAM.width();
skipping to change at line 3010 skipping to change at line 3120
zeros(in_rows, in_cols); zeros(in_rows, in_cols);
mem_resize( uword(density * double(in_rows) * double(in_cols) + 0.5) ); mem_resize( uword(density * double(in_rows) * double(in_cols) + 0.5) );
if(n_nonzero == 0) if(n_nonzero == 0)
{ {
return *this; return *this;
} }
eop_aux_randu<eT>::fill( access::rwp(values), n_nonzero ); arma_rng::randu<eT>::fill( access::rwp(values), n_nonzero );
uvec indices = linspace<uvec>( 0u, in_rows*in_cols-1, n_nonzero ); uvec indices = linspace<uvec>( 0u, in_rows*in_cols-1, n_nonzero );
// perturb the indices // perturb the indices
for(uword i=1; i < n_nonzero-1; ++i) for(uword i=1; i < n_nonzero-1; ++i)
{ {
const uword index_left = indices[i-1]; const uword index_left = indices[i-1];
const uword index_right = indices[i+1]; const uword index_right = indices[i+1];
const uword center = (index_left + index_right) / 2; const uword center = (index_left + index_right) / 2;
skipping to change at line 3085 skipping to change at line 3195
zeros(in_rows, in_cols); zeros(in_rows, in_cols);
mem_resize( uword(density * double(in_rows) * double(in_cols) + 0.5) ); mem_resize( uword(density * double(in_rows) * double(in_cols) + 0.5) );
if(n_nonzero == 0) if(n_nonzero == 0)
{ {
return *this; return *this;
} }
eop_aux_randn<eT>::fill( access::rwp(values), n_nonzero ); arma_rng::randn<eT>::fill( access::rwp(values), n_nonzero );
uvec indices = linspace<uvec>( 0u, in_rows*in_cols-1, n_nonzero ); uvec indices = linspace<uvec>( 0u, in_rows*in_cols-1, n_nonzero );
// perturb the indices // perturb the indices
for(uword i=1; i < n_nonzero-1; ++i) for(uword i=1; i < n_nonzero-1; ++i)
{ {
const uword index_left = indices[i-1]; const uword index_left = indices[i-1];
const uword index_right = indices[i+1]; const uword index_right = indices[i+1];
const uword center = (index_left + index_right) / 2; const uword center = (index_left + index_right) / 2;
skipping to change at line 3904 skipping to change at line 4014
// Steal memory from another matrix. // Steal memory from another matrix.
template<typename eT> template<typename eT>
inline inline
void void
SpMat<eT>::steal_mem(SpMat<eT>& x) SpMat<eT>::steal_mem(SpMat<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(this != &x) if(this != &x)
{ {
// Release all the memory. if(values ) { memory::release(access::rw(values)); }
memory::release(values); if(row_indices) { memory::release(access::rw(row_indices)); }
memory::release(row_indices); if(col_ptrs ) { memory::release(access::rw(col_ptrs)); }
memory::release(col_ptrs);
access::rw(n_rows) = x.n_rows;
// We'll have to copy everything about the other matrix. access::rw(n_cols) = x.n_cols;
const uword x_n_rows = x.n_rows; access::rw(n_elem) = x.n_elem;
const uword x_n_cols = x.n_cols; access::rw(n_nonzero) = x.n_nonzero;
const uword x_n_elem = x.n_elem;
const uword x_n_nonzero = x.n_nonzero;
access::rw(n_rows) = x_n_rows;
access::rw(n_cols) = x_n_cols;
access::rw(n_elem) = x_n_elem;
access::rw(n_nonzero) = x_n_nonzero;
access::rw(values) = x.values; access::rw(values) = x.values;
access::rw(row_indices) = x.row_indices; access::rw(row_indices) = x.row_indices;
access::rw(col_ptrs) = x.col_ptrs; access::rw(col_ptrs) = x.col_ptrs;
// Set other matrix to empty. // Set other matrix to empty.
access::rw(x.n_rows) = 0; access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0; access::rw(x.n_cols) = 0;
access::rw(x.n_elem) = 0; access::rw(x.n_elem) = 0;
access::rw(x.n_nonzero) = 0; access::rw(x.n_nonzero) = 0;
 End of changes. 10 change blocks. 
29 lines changed or deleted 142 lines changed or added


 arma_config.hpp   arma_config.hpp 
skipping to change at line 43 skipping to change at line 43
#else #else
static const bool lapack = false; static const bool lapack = false;
#endif #endif
#if defined(ARMA_USE_BLAS) #if defined(ARMA_USE_BLAS)
static const bool blas = true; static const bool blas = true;
#else #else
static const bool blas = false; static const bool blas = false;
#endif #endif
#if defined(ARMA_USE_HDF5)
static const bool hdf5 = true;
#else
static const bool hdf5 = false;
#endif
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
static const bool boost = true; static const bool boost = true;
#else #else
static const bool boost = false; static const bool boost = false;
#endif #endif
#if defined(ARMA_USE_BOOST_DATE) #if defined(ARMA_USE_BOOST_DATE)
static const bool boost_date = true; static const bool boost_date = true;
#else #else
static const bool boost_date = false; static const bool boost_date = false;
#endif #endif
#if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) #if defined(ARMA_NO_DEBUG)
static const bool debug = true;
#else
static const bool debug = false; static const bool debug = false;
#else
static const bool debug = true;
#endif #endif
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
static const bool extra_debug = true; static const bool extra_debug = true;
#else #else
static const bool extra_debug = false; static const bool extra_debug = false;
#endif #endif
#if defined(ARMA_GOOD_COMPILER) #if defined(ARMA_GOOD_COMPILER)
static const bool good_comp = true; static const bool good_comp = true;
skipping to change at line 93 skipping to change at line 99
static const bool extra_code = true; static const bool extra_code = true;
#else #else
static const bool extra_code = false; static const bool extra_code = false;
#endif #endif
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
static const bool use_cxx11 = true; static const bool use_cxx11 = true;
#else #else
static const bool use_cxx11 = false; static const bool use_cxx11 = false;
#endif #endif
#if defined(ARMA_USE_WRAPPER)
static const bool use_wrapper = true;
#else
static const bool use_wrapper = false;
#endif
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
3 lines changed or deleted 15 lines changed or added


 arma_version.hpp   arma_version.hpp 
skipping to change at line 12 skipping to change at line 12
// Copyright (C) 2009-2013 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 3 #define ARMA_VERSION_MAJOR 3
#define ARMA_VERSION_MINOR 920 #define ARMA_VERSION_MINOR 930
#define ARMA_VERSION_PATCH 4 #define ARMA_VERSION_PATCH 0
#define ARMA_VERSION_NAME "Agencia Nacional Stasi" #define ARMA_VERSION_NAME "Dragon's Back"
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 15 skipping to change at line 15
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef ARMA_INCLUDES #ifndef ARMA_INCLUDES
#define ARMA_INCLUDES #define ARMA_INCLUDES
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <climits> #include <climits>
#include <cmath> #include <cmath>
#include <ctime>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <limits> #include <limits>
#include <algorithm> #include <algorithm>
#include <complex> #include <complex>
#include <vector> #include <vector>
#include "armadillo_bits/config.hpp" #include "armadillo_bits/config.hpp"
#include "armadillo_bits/compiler_setup.hpp" #include "armadillo_bits/compiler_setup.hpp"
#include "armadillo_bits/undefine_conflicts.hpp" #include "armadillo_bits/undefine_conflicts.hpp"
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
#include <initializer_list> #include <initializer_list>
#include <cstdint> #include <cstdint>
// TODO: extend wall_clock class to use C++11 chrono library #include <chrono>
#endif #include <random>
#if !defined(ARMA_HAVE_GETTIMEOFDAY) && !defined(ARMA_USE_BOOST_DATE) #undef ARMA_USE_BOOST_DATE
#include <ctime>
#endif #endif
#if defined(ARMA_HAVE_GETTIMEOFDAY) #if defined(ARMA_HAVE_GETTIMEOFDAY)
#include <sys/time.h> #include <sys/time.h>
#undef ARMA_USE_BOOST_DATE #undef ARMA_USE_BOOST_DATE
#endif #endif
#if defined(ARMA_USE_BOOST_DATE) #if defined(ARMA_USE_BOOST_DATE)
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#endif #endif
skipping to change at line 94 skipping to change at line 94
#endif #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_elem.hpp"
#include "armadillo_bits/typedef_blas_int.hpp" #include "armadillo_bits/typedef_elem_check.hpp"
#include "armadillo_bits/typedef_mat.hpp"
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/format_wrap.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
#include "armadillo_bits/memory.hpp"
#include "armadillo_bits/span.hpp" #include "armadillo_bits/span.hpp"
#include "armadillo_bits/distr_param.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
#include "armadillo_bits/constants_compat.hpp" #include "armadillo_bits/constants_compat.hpp"
#if defined(ARMA_USE_CXX11_RNG)
#include "armadillo_bits/arma_rng_cxx11.hpp"
#include "armadillo_bits/arma_rng.hpp"
#else
#include "armadillo_bits/arma_rng_cxx98.hpp"
#include "armadillo_bits/arma_rng.hpp"
#endif
// //
// class prototypes // class prototypes
#include "armadillo_bits/Base_bones.hpp" #include "armadillo_bits/Base_bones.hpp"
#include "armadillo_bits/BaseCube_bones.hpp" #include "armadillo_bits/BaseCube_bones.hpp"
#include "armadillo_bits/SpBase_bones.hpp" #include "armadillo_bits/SpBase_bones.hpp"
#include "armadillo_bits/blas_bones.hpp" #include "armadillo_bits/blas_bones.hpp"
#include "armadillo_bits/lapack_bones.hpp" #include "armadillo_bits/lapack_bones.hpp"
#include "armadillo_bits/atlas_bones.hpp" #include "armadillo_bits/atlas_bones.hpp"
skipping to change at line 136 skipping to change at line 145
#include "armadillo_bits/podarray_bones.hpp" #include "armadillo_bits/podarray_bones.hpp"
#include "armadillo_bits/auxlib_bones.hpp" #include "armadillo_bits/auxlib_bones.hpp"
#include "armadillo_bits/injector_bones.hpp" #include "armadillo_bits/injector_bones.hpp"
#include "armadillo_bits/Mat_bones.hpp" #include "armadillo_bits/Mat_bones.hpp"
#include "armadillo_bits/Col_bones.hpp" #include "armadillo_bits/Col_bones.hpp"
#include "armadillo_bits/Row_bones.hpp" #include "armadillo_bits/Row_bones.hpp"
#include "armadillo_bits/Cube_bones.hpp" #include "armadillo_bits/Cube_bones.hpp"
#include "armadillo_bits/xvec_htrans_bones.hpp" #include "armadillo_bits/xvec_htrans_bones.hpp"
#include "armadillo_bits/SizeMat_bones.hpp"
#include "armadillo_bits/SizeCube_bones.hpp"
#include "armadillo_bits/SpValProxy_bones.hpp" #include "armadillo_bits/SpValProxy_bones.hpp"
#include "armadillo_bits/SpMat_bones.hpp" #include "armadillo_bits/SpMat_bones.hpp"
#include "armadillo_bits/SpCol_bones.hpp" #include "armadillo_bits/SpCol_bones.hpp"
#include "armadillo_bits/SpRow_bones.hpp" #include "armadillo_bits/SpRow_bones.hpp"
#include "armadillo_bits/SpSubview_bones.hpp" #include "armadillo_bits/SpSubview_bones.hpp"
#include "armadillo_bits/typedef_fixed.hpp" #include "armadillo_bits/typedef_mat_fixed.hpp"
#include "armadillo_bits/field_bones.hpp" #include "armadillo_bits/field_bones.hpp"
#include "armadillo_bits/subview_bones.hpp" #include "armadillo_bits/subview_bones.hpp"
#include "armadillo_bits/subview_elem1_bones.hpp" #include "armadillo_bits/subview_elem1_bones.hpp"
#include "armadillo_bits/subview_elem2_bones.hpp" #include "armadillo_bits/subview_elem2_bones.hpp"
#include "armadillo_bits/subview_field_bones.hpp" #include "armadillo_bits/subview_field_bones.hpp"
#include "armadillo_bits/subview_cube_bones.hpp" #include "armadillo_bits/subview_cube_bones.hpp"
#include "armadillo_bits/diagview_bones.hpp" #include "armadillo_bits/diagview_bones.hpp"
#include "armadillo_bits/subview_each_bones.hpp" #include "armadillo_bits/subview_each_bones.hpp"
skipping to change at line 239 skipping to change at line 250
#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"
#include "armadillo_bits/glue_conv_bones.hpp" #include "armadillo_bits/glue_conv_bones.hpp"
#include "armadillo_bits/glue_toeplitz_bones.hpp" #include "armadillo_bits/glue_toeplitz_bones.hpp"
#include "armadillo_bits/glue_hist_bones.hpp" #include "armadillo_bits/glue_hist_bones.hpp"
#include "armadillo_bits/glue_histc_bones.hpp" #include "armadillo_bits/glue_histc_bones.hpp"
#include "armadillo_bits/glue_max_bones.hpp"
#include "armadillo_bits/glue_min_bones.hpp"
#include "armadillo_bits/spop_max_bones.hpp" #include "armadillo_bits/spop_max_bones.hpp"
#include "armadillo_bits/spop_min_bones.hpp" #include "armadillo_bits/spop_min_bones.hpp"
#include "armadillo_bits/spop_sum_bones.hpp" #include "armadillo_bits/spop_sum_bones.hpp"
#include "armadillo_bits/spop_strans_bones.hpp" #include "armadillo_bits/spop_strans_bones.hpp"
#include "armadillo_bits/spop_htrans_bones.hpp" #include "armadillo_bits/spop_htrans_bones.hpp"
#include "armadillo_bits/spop_misc_bones.hpp" #include "armadillo_bits/spop_misc_bones.hpp"
#include "armadillo_bits/spop_mean_bones.hpp" #include "armadillo_bits/spop_mean_bones.hpp"
#include "armadillo_bits/spop_var_bones.hpp" #include "armadillo_bits/spop_var_bones.hpp"
#include "armadillo_bits/spglue_plus_bones.hpp" #include "armadillo_bits/spglue_plus_bones.hpp"
#include "armadillo_bits/spglue_minus_bones.hpp" #include "armadillo_bits/spglue_minus_bones.hpp"
#include "armadillo_bits/spglue_times_bones.hpp" #include "armadillo_bits/spglue_times_bones.hpp"
// //
// debugging functions // low-level debugging and memory handling functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
#include "armadillo_bits/memory.hpp"
// //
// //
#include "armadillo_bits/cmath_wrap.hpp" #include "armadillo_bits/cmath_wrap.hpp"
// //
// classes that underlay metaprogramming // classes that underlay metaprogramming
#include "armadillo_bits/unwrap.hpp" #include "armadillo_bits/unwrap.hpp"
skipping to change at line 411 skipping to change at line 425
#include "armadillo_bits/fn_cumsum.hpp" #include "armadillo_bits/fn_cumsum.hpp"
#include "armadillo_bits/fn_symmat.hpp" #include "armadillo_bits/fn_symmat.hpp"
#include "armadillo_bits/fn_syl_lyap.hpp" #include "armadillo_bits/fn_syl_lyap.hpp"
#include "armadillo_bits/fn_hist.hpp" #include "armadillo_bits/fn_hist.hpp"
#include "armadillo_bits/fn_histc.hpp" #include "armadillo_bits/fn_histc.hpp"
#include "armadillo_bits/fn_unique.hpp" #include "armadillo_bits/fn_unique.hpp"
#include "armadillo_bits/fn_fft.hpp" #include "armadillo_bits/fn_fft.hpp"
#include "armadillo_bits/fn_fft2.hpp" #include "armadillo_bits/fn_fft2.hpp"
#include "armadillo_bits/fn_any.hpp" #include "armadillo_bits/fn_any.hpp"
#include "armadillo_bits/fn_all.hpp" #include "armadillo_bits/fn_all.hpp"
#include "armadillo_bits/fn_size.hpp"
#include "armadillo_bits/fn_numel.hpp"
#include "armadillo_bits/fn_inplace_strans.hpp"
#include "armadillo_bits/fn_inplace_trans.hpp"
#include "armadillo_bits/fn_randi.hpp"
#include "armadillo_bits/fn_speye.hpp" #include "armadillo_bits/fn_speye.hpp"
#include "armadillo_bits/fn_spones.hpp" #include "armadillo_bits/fn_spones.hpp"
#include "armadillo_bits/fn_sprandn.hpp" #include "armadillo_bits/fn_sprandn.hpp"
#include "armadillo_bits/fn_sprandu.hpp" #include "armadillo_bits/fn_sprandu.hpp"
// misc stuff // misc stuff
#include "armadillo_bits/hdf5_misc.hpp" #include "armadillo_bits/hdf5_misc.hpp"
#include "armadillo_bits/fft_engine.hpp" #include "armadillo_bits/fft_engine.hpp"
skipping to change at line 449 skipping to change at line 468
#include "armadillo_bits/podarray_meat.hpp" #include "armadillo_bits/podarray_meat.hpp"
#include "armadillo_bits/auxlib_meat.hpp" #include "armadillo_bits/auxlib_meat.hpp"
#include "armadillo_bits/injector_meat.hpp" #include "armadillo_bits/injector_meat.hpp"
#include "armadillo_bits/Mat_meat.hpp" #include "armadillo_bits/Mat_meat.hpp"
#include "armadillo_bits/Col_meat.hpp" #include "armadillo_bits/Col_meat.hpp"
#include "armadillo_bits/Row_meat.hpp" #include "armadillo_bits/Row_meat.hpp"
#include "armadillo_bits/Cube_meat.hpp" #include "armadillo_bits/Cube_meat.hpp"
#include "armadillo_bits/xvec_htrans_meat.hpp" #include "armadillo_bits/xvec_htrans_meat.hpp"
#include "armadillo_bits/SizeMat_meat.hpp"
#include "armadillo_bits/SizeCube_meat.hpp"
#include "armadillo_bits/field_meat.hpp" #include "armadillo_bits/field_meat.hpp"
#include "armadillo_bits/subview_meat.hpp" #include "armadillo_bits/subview_meat.hpp"
#include "armadillo_bits/subview_elem1_meat.hpp" #include "armadillo_bits/subview_elem1_meat.hpp"
#include "armadillo_bits/subview_elem2_meat.hpp" #include "armadillo_bits/subview_elem2_meat.hpp"
#include "armadillo_bits/subview_field_meat.hpp" #include "armadillo_bits/subview_field_meat.hpp"
#include "armadillo_bits/subview_cube_meat.hpp" #include "armadillo_bits/subview_cube_meat.hpp"
#include "armadillo_bits/diagview_meat.hpp" #include "armadillo_bits/diagview_meat.hpp"
#include "armadillo_bits/subview_each_meat.hpp" #include "armadillo_bits/subview_each_meat.hpp"
skipping to change at line 526 skipping to change at line 547
#include "armadillo_bits/glue_cor_meat.hpp" #include "armadillo_bits/glue_cor_meat.hpp"
#include "armadillo_bits/glue_kron_meat.hpp" #include "armadillo_bits/glue_kron_meat.hpp"
#include "armadillo_bits/glue_cross_meat.hpp" #include "armadillo_bits/glue_cross_meat.hpp"
#include "armadillo_bits/glue_join_meat.hpp" #include "armadillo_bits/glue_join_meat.hpp"
#include "armadillo_bits/glue_relational_meat.hpp" #include "armadillo_bits/glue_relational_meat.hpp"
#include "armadillo_bits/glue_solve_meat.hpp" #include "armadillo_bits/glue_solve_meat.hpp"
#include "armadillo_bits/glue_conv_meat.hpp" #include "armadillo_bits/glue_conv_meat.hpp"
#include "armadillo_bits/glue_toeplitz_meat.hpp" #include "armadillo_bits/glue_toeplitz_meat.hpp"
#include "armadillo_bits/glue_hist_meat.hpp" #include "armadillo_bits/glue_hist_meat.hpp"
#include "armadillo_bits/glue_histc_meat.hpp" #include "armadillo_bits/glue_histc_meat.hpp"
#include "armadillo_bits/glue_max_meat.hpp"
#include "armadillo_bits/glue_min_meat.hpp"
#include "armadillo_bits/spop_max_meat.hpp" #include "armadillo_bits/spop_max_meat.hpp"
#include "armadillo_bits/spop_min_meat.hpp" #include "armadillo_bits/spop_min_meat.hpp"
#include "armadillo_bits/spop_sum_meat.hpp" #include "armadillo_bits/spop_sum_meat.hpp"
#include "armadillo_bits/spop_strans_meat.hpp" #include "armadillo_bits/spop_strans_meat.hpp"
#include "armadillo_bits/spop_htrans_meat.hpp" #include "armadillo_bits/spop_htrans_meat.hpp"
#include "armadillo_bits/spop_misc_meat.hpp" #include "armadillo_bits/spop_misc_meat.hpp"
#include "armadillo_bits/spop_mean_meat.hpp" #include "armadillo_bits/spop_mean_meat.hpp"
#include "armadillo_bits/spop_var_meat.hpp" #include "armadillo_bits/spop_var_meat.hpp"
 End of changes. 15 change blocks. 
9 lines changed or deleted 32 lines changed or added


 auxlib_bones.hpp   auxlib_bones.hpp 
skipping to change at line 168 skipping to change at line 168
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode); inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base< eT,T1>& X); inline static bool svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base< eT,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd_dc(Mat< std::complex<T> >& U, Col<T>& S, Mat< std: :complex<T> >& V, const Base< std::complex<T>, T1>& X); inline static bool svd_dc(Mat< std::complex<T> >& U, Col<T>& S, Mat< std: :complex<T> >& V, const Base< std::complex<T>, T1>& X);
template<typename eT, typename T1>
inline static bool svd_dc_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const
Base<eT,T1>& X);
template<typename T, typename T1>
inline static bool svd_dc_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat<
std::complex<T> >& V, const Base< std::complex<T>, T1>& X);
// //
// solve // solve
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool slow = false); inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool slow = false);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X); inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
 End of changes. 1 change blocks. 
0 lines changed or deleted 8 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
skipping to change at line 2100 skipping to change at line 2100
lwork = (lwork_proposed > lwork_min) ? lwork_proposed : lwork_min; lwork = (lwork_proposed > lwork_min) ? lwork_proposed : lwork_min;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
lapack::gesvd<eT> lapack::gesvd<eT>
( (
&jobu, &jobvt, &m, &n, A.memptr(), &lda, S.memptr(), U.memptr(), &l du, V.memptr(), &ldvt, work.memptr(), &lwork, &info &jobu, &jobvt, &m, &n, A.memptr(), &lda, S.memptr(), U.memptr(), &l du, V.memptr(), &ldvt, work.memptr(), &lwork, &info
); );
op_strans::apply(V,V); // op_strans will work out that an in-place t ranspose can be done op_strans::apply_mat_inplace(V);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
skipping to change at line 2196 skipping to change at line 2196
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork, work.memptr(), &lwork,
rwork.memptr(), rwork.memptr(),
&info &info
); );
op_htrans::apply(V,V); // op_htrans will work out that an in-place t ranspose can be done op_htrans::apply_mat_inplace(V);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
skipping to change at line 2331 skipping to change at line 2331
&jobu, &jobvt, &jobu, &jobvt,
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork, work.memptr(), &lwork,
&info &info
); );
op_strans::apply(V,V); // op_strans will work out that an in-place t ranspose can be done op_strans::apply_mat_inplace(V);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
skipping to change at line 2472 skipping to change at line 2472
&m, &n, &m, &n,
A.memptr(), &lda, A.memptr(), &lda,
S.memptr(), S.memptr(),
U.memptr(), &ldu, U.memptr(), &ldu,
V.memptr(), &ldvt, V.memptr(), &ldvt,
work.memptr(), &lwork, work.memptr(), &lwork,
rwork.memptr(), rwork.memptr(),
&info &info
); );
op_htrans::apply(V,V); // op_strans will work out that an in-place t ranspose can be done op_htrans::apply_mat_inplace(V);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
skipping to change at line 2535 skipping to change at line 2535
podarray<eT> work( static_cast<uword>(lwork ) ); podarray<eT> work( static_cast<uword>(lwork ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) ); podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::gesdd<eT> lapack::gesdd<eT>
( (
&jobz, &m, &n, &jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt, A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, iwork.memptr(), &info work.memptr(), &lwork, iwork.memptr(), &info
); );
op_strans::apply(V,V); // op_strans will work out that an in-place tra nspose can be done op_strans::apply_mat_inplace(V);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
skipping to change at line 2599 skipping to change at line 2599
podarray<T> rwork( static_cast<uword>(5*min_mn*min_mn + 7*min_mn ) ); podarray<T> rwork( static_cast<uword>(5*min_mn*min_mn + 7*min_mn ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn ) ); podarray<blas_int> iwork( static_cast<uword>(8*min_mn ) );
lapack::cx_gesdd<T> lapack::cx_gesdd<T>
( (
&jobz, &m, &n, &jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt, A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info
); );
op_htrans::apply(V,V); // op_htrans will work out that an in-place tra op_htrans::apply_mat_inplace(V);
nspose can be done
return (info == 0);
}
#else
{
arma_ignore(U);
arma_ignore(S);
arma_ignore(V);
arma_ignore(X);
arma_stop("svd(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
template<typename eT, typename T1>
inline
bool
auxlib::svd_dc_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>&
X)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
Mat<eT> A(X.get_ref());
char jobz = 'S';
blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
blas_int ldu = m;
blas_int ldvt = min_mn;
blas_int lwork = 3 * ( 3*min_mn + 4*min_mn*min_mn + 3*min_mn + std::ma
x(m,n) ); // based on lapack 3.4 docs, which have a slightly different fo
rmula to lapack 3.1 docs
blas_int info = 0;
if(A.is_empty())
{
U.eye();
S.reset();
V.eye( static_cast<uword>(n), static_cast<uword>(min_mn) );
return true;
}
S.set_size( static_cast<uword>(min_mn) );
U.set_size( static_cast<uword>(m), static_cast<uword>(min_mn) );
V.set_size( static_cast<uword>(min_mn), static_cast<uword>(n) );
podarray<eT> work( static_cast<uword>(lwork ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::gesdd<eT>
(
&jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, iwork.memptr(), &info
);
op_strans::apply_mat_inplace(V);
return (info == 0);
}
#else
{
arma_ignore(U);
arma_ignore(S);
arma_ignore(V);
arma_ignore(X);
arma_stop("svd(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
template<typename T, typename T1>
inline
bool
auxlib::svd_dc_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex
<T> >& V, const Base< std::complex<T>, T1>& X)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
typedef std::complex<T> eT;
Mat<eT> A(X.get_ref());
char jobz = 'S';
blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n);
blas_int max_mn = (std::max)(m,n);
blas_int lda = blas_int(A.n_rows);
blas_int ldu = m;
blas_int ldvt = min_mn;
blas_int lwork = 3 * (min_mn*min_mn + 2*min_mn + max_mn);
blas_int lrwork = min_mn * (std::max)( 5*min_mn+7, 2*max_mn + 2*min_mn+
1 ); // based on lapack 3.4 docs, which have a different formula to lapack
3.1 docs
blas_int info = 0;
if(A.is_empty())
{
U.eye();
S.reset();
V.eye( static_cast<uword>(n), static_cast<uword>(min_mn) );
return true;
}
S.set_size( static_cast<uword>(min_mn) );
U.set_size( static_cast<uword>(m), static_cast<uword>(min_mn) );
V.set_size( static_cast<uword>(min_mn), static_cast<uword>(n) );
podarray<eT> work( static_cast<uword>(lwork ) );
podarray<T> rwork( static_cast<uword>(lrwork ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::cx_gesdd<T>
(
&jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info
);
op_htrans::apply_mat_inplace(V);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(U); arma_ignore(U);
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
skipping to change at line 3097 skipping to change at line 3226
bool bool
auxlib::lyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q) auxlib::lyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (A.is_square() == false), "lyap(): matrix A is not squa re"); arma_debug_check( (A.is_square() == false), "lyap(): matrix A is not squa re");
arma_debug_check( (Q.is_square() == false), "lyap(): matrix Q is not squa re"); arma_debug_check( (Q.is_square() == false), "lyap(): matrix Q is not squa re");
arma_debug_check( (A.n_rows != Q.n_rows), "lyap(): matrices A and Q hav e different dimensions"); arma_debug_check( (A.n_rows != Q.n_rows), "lyap(): matrices A and Q hav e different dimensions");
Mat<eT> htransA; Mat<eT> htransA;
op_htrans::apply_noalias(htransA, A); op_htrans::apply_mat_noalias(htransA, A);
const Mat<eT> mQ = -Q; const Mat<eT> mQ = -Q;
return auxlib::syl(X, A, htransA, mQ); return auxlib::syl(X, A, htransA, mQ);
} }
// //
// dlyap (solution of the discrete Lyapunov equation AXA^H - X + Q = 0) // dlyap (solution of the discrete Lyapunov equation AXA^H - X + Q = 0)
template<typename eT> template<typename eT>
 End of changes. 7 change blocks. 
8 lines changed or deleted 142 lines changed or added


 compiler_setup.hpp   compiler_setup.hpp 
skipping to change at line 57 skipping to change at line 57
#define ARMA_BLAS_SDOT_BUG #define ARMA_BLAS_SDOT_BUG
#endif #endif
#if (__cplusplus >= 201103L) #if (__cplusplus >= 201103L)
#if !defined(ARMA_USE_CXX11) #if !defined(ARMA_USE_CXX11)
#define ARMA_USE_CXX11 #define ARMA_USE_CXX11
#endif #endif
#endif #endif
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
// TODO: enable in version 4.0
// #if defined(ARMA_USE_WRAPPER)
// #if !defined(ARMA_USE_CXX11_RNG)
// #define ARMA_USE_CXX11_RNG
// #endif
// #endif
#if !defined(ARMA_USE_U64S64) #if !defined(ARMA_USE_U64S64)
#define ARMA_USE_U64S64 #define ARMA_USE_U64S64
#endif #endif
#endif #endif
#if defined(ARMA_64BIT_WORD) #if defined(ARMA_64BIT_WORD)
#if !defined(ARMA_USE_U64S64) #if !defined(ARMA_USE_U64S64)
#define ARMA_USE_U64S64 #define ARMA_USE_U64S64
#endif #endif
#endif #endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 8 lines changed or added


 config.hpp   config.hpp 
skipping to change at line 142 skipping to change at line 142
#undef ARMA_USE_WRAPPER #undef ARMA_USE_WRAPPER
#endif #endif
#if defined(ARMA_DONT_USE_ATLAS) #if defined(ARMA_DONT_USE_ATLAS)
#undef ARMA_USE_ATLAS #undef ARMA_USE_ATLAS
#undef ARMA_ATLAS_INCLUDE_DIR #undef ARMA_ATLAS_INCLUDE_DIR
#endif #endif
#if defined(ARMA_DONT_USE_CXX11) #if defined(ARMA_DONT_USE_CXX11)
#undef ARMA_USE_CXX11 #undef ARMA_USE_CXX11
#undef ARMA_USE_CXX11_RNG
#endif #endif
#if defined(ARMA_DONT_USE_HDF5) #if defined(ARMA_DONT_USE_HDF5)
#undef ARMA_USE_HDF5 #undef ARMA_USE_HDF5
#endif #endif
#if defined(ARMA_DONT_USE_BOOST) #if defined(ARMA_DONT_USE_BOOST)
#undef ARMA_USE_BOOST #undef ARMA_USE_BOOST
#undef ARMA_USE_BOOST_DATE #undef ARMA_USE_BOOST_DATE
#undef ARMA_USE_BOOST_FORMAT
#endif #endif
#if defined(ARMA_DONT_PRINT_LOGIC_ERRORS) #if defined(ARMA_DONT_PRINT_LOGIC_ERRORS)
#undef ARMA_PRINT_LOGIC_ERRORS #undef ARMA_PRINT_LOGIC_ERRORS
#endif #endif
#if defined(ARMA_DONT_PRINT_RUNTIME_ERRORS) #if defined(ARMA_DONT_PRINT_RUNTIME_ERRORS)
#undef ARMA_PRINT_RUNTIME_ERRORS #undef ARMA_PRINT_RUNTIME_ERRORS
#endif #endif
 End of changes. 2 change blocks. 
0 lines changed or deleted 2 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 98 skipping to change at line 98
out << "error: " << x << '\n'; out << "error: " << x << '\n';
out << '\n'; out << '\n';
out.flush(); out.flush();
} }
#else #else
{ {
arma_ignore(x); arma_ignore(x);
} }
#endif #endif
throw std::logic_error(""); throw std::logic_error( std::string(x) );
} }
template<typename T1> template<typename T1>
arma_cold arma_cold
arma_noinline arma_noinline
static static
void void
arma_stop_bad_alloc(const T1& x) arma_stop_bad_alloc(const T1& x)
{ {
std::ostream& out = get_stream_err1(); std::ostream& out = get_stream_err1();
skipping to change at line 150 skipping to change at line 150
out.flush(); out.flush();
} }
#else #else
{ {
arma_ignore(x); arma_ignore(x);
} }
#endif #endif
if(hurl == true) if(hurl == true)
{ {
throw std::runtime_error(""); throw std::runtime_error( std::string(x) );
} }
} }
// //
// arma_print // arma_print
arma_cold arma_cold
inline inline
void void
arma_print() arma_print()
skipping to change at line 964 skipping to change at line 964
} }
} }
// //
// macros // macros
// #define ARMA_STRING1(x) #x // #define ARMA_STRING1(x) #x
// #define ARMA_STRING2(x) ARMA_STRING1(x) // #define ARMA_STRING2(x) ARMA_STRING1(x)
// #define ARMA_FILELINE __FILE__ ": " ARMA_STRING2(__LINE__) // #define ARMA_FILELINE __FILE__ ": " ARMA_STRING2(__LINE__)
#if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) #if defined(ARMA_NO_DEBUG)
#define arma_debug_print arma_print
#define arma_debug_warn arma_warn
#define arma_debug_check arma_check
#define arma_debug_set_error arma_set_error
#define arma_debug_assert_same_size arma_assert_same_size
#define arma_debug_assert_mul_size arma_assert_mul_size
#define arma_debug_assert_trans_mul_size arma_assert_trans_mul_size
#define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat
#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_sam e_size #define arma_debug_assert_same_size true ? (void)0 : arma_assert_sam e_size
#define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul _size #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul _size
#define arma_debug_assert_trans_mul_size true ? (void)0 : arma_assert_tra ns_mul_size #define arma_debug_assert_trans_mul_size true ? (void)0 : arma_assert_tra ns_mul_size
#define arma_debug_assert_cube_as_mat true ? (void)0 : arma_assert_cub e_as_mat #define arma_debug_assert_cube_as_mat true ? (void)0 : arma_assert_cub e_as_mat
#else
#define arma_debug_print arma_print
#define arma_debug_warn arma_warn
#define arma_debug_check arma_check
#define arma_debug_set_error arma_set_error
#define arma_debug_assert_same_size arma_assert_same_size
#define arma_debug_assert_mul_size arma_assert_mul_size
#define arma_debug_assert_trans_mul_size arma_assert_trans_mul_size
#define arma_debug_assert_cube_as_mat arma_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
skipping to change at line 1037 skipping to change at line 1037
const bool little_endian = (endian_test.b[0] == 1); const bool little_endian = (endian_test.b[0] == 1);
const char* nickname = ARMA_VERSION_NAME; const char* nickname = ARMA_VERSION_NAME;
std::ostream& out = get_stream_err1(); std::ostream& out = get_stream_err1();
out << "@ ---" << '\n'; out << "@ ---" << '\n';
out << "@ Armadillo " out << "@ Armadillo "
<< arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch << arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch
<< " (" << nickname << ")\n"; << " (" << nickname << ")\n";
out << "@ arma_config::mat_prealloc = " << arma_config::mat_preal out << "@ arma_config::use_wrapper = " << arma_config::use_wrapper
loc << " element(s)\n"; << '\n';
out << "@ arma_config::atlas = " << arma_config::atlas out << "@ arma_config::use_cxx11 = " << arma_config::use_cxx11
<< '\n'; << '\n';
out << "@ arma_config::lapack = " << arma_config::lapack out << "@ arma_config::lapack = " << arma_config::lapack
<< '\n'; << '\n';
out << "@ arma_config::blas = " << arma_config::blas out << "@ arma_config::blas = " << arma_config::blas
<< '\n'; << '\n';
out << "@ arma_config::boost = " << arma_config::boost out << "@ arma_config::atlas = " << arma_config::atlas
<< '\n'; << '\n';
out << "@ arma_config::boost_date = " << arma_config::boost_dat out << "@ arma_config::hdf5 = " << arma_config::hdf5
e << '\n'; << '\n';
out << "@ arma_config::good_comp = " << arma_config::good_comp out << "@ arma_config::boost = " << arma_config::boost
<< '\n'; << '\n';
out << "@ arma_config::extra_code = " << arma_config::extra_cod out << "@ arma_config::boost_date = " << arma_config::boost_date
e << '\n'; << '\n';
out << "@ arma_config::use_cxx11 = " << arma_config::use_cxx11 out << "@ arma_config::good_comp = " << arma_config::good_comp
<< '\n'; << '\n';
out << "@ arma_config::extra_code = " << arma_config::extra_code
<< '\n';
out << "@ arma_config::mat_prealloc = " << arma_config::mat_preallo
c << '\n';
out << "@ sizeof(void*) = " << sizeof(void*) << '\n'; out << "@ sizeof(void*) = " << sizeof(void*) << '\n';
out << "@ sizeof(uword) = " << sizeof(uword) << '\n'; out << "@ sizeof(uword) = " << sizeof(uword) << '\n';
out << "@ sizeof(int) = " << sizeof(int) << '\n'; out << "@ sizeof(int) = " << sizeof(int) << '\n';
out << "@ sizeof(long) = " << sizeof(long) << '\n'; out << "@ sizeof(long) = " << sizeof(long) << '\n';
out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n'; out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n';
out << "@ little_endian = " << little_endian << '\n'; out << "@ little_endian = " << little_endian << '\n';
out << "@ ---" << std::endl; out << "@ ---" << std::endl;
} }
}; };
 End of changes. 5 change blocks. 
32 lines changed or deleted 36 lines changed or added


 diagview_bones.hpp   diagview_bones.hpp 
skipping to change at line 78 skipping to change at line 78
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;
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 randu();
inline void randn();
inline static void extract(Mat<eT>& out, const diagview& in); inline static void extract(Mat<eT>& out, const diagview& in);
inline static void plus_inplace(Mat<eT>& out, const diagview& in); inline static void plus_inplace(Mat<eT>& out, const diagview& in);
inline static void minus_inplace(Mat<eT>& out, const diagview& in); inline static void minus_inplace(Mat<eT>& out, const diagview& in);
inline static void schur_inplace(Mat<eT>& out, const diagview& in); inline static void schur_inplace(Mat<eT>& out, const diagview& in);
inline static void div_inplace(Mat<eT>& out, const diagview& in); inline static void div_inplace(Mat<eT>& out, const diagview& in);
private: private:
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 diagview_meat.hpp   diagview_meat.hpp 
skipping to change at line 809 skipping to change at line 809
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 ii=0; ii < n_elem; ++ii) const uword local_n_elem = n_elem;
for(uword ii=0; ii < local_n_elem; ++ii)
{ {
x.at(ii+row_offset, ii+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()
{ {
skipping to change at line 835 skipping to change at line 837
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::ones() diagview<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
(*this).fill(eT(1)); (*this).fill(eT(1));
} }
template<typename eT>
inline
void
diagview<eT>::randu()
{
arma_extra_debug_sigprint();
Mat<eT>& x = const_cast< Mat<eT>& >(m);
const uword local_n_elem = n_elem;
for(uword ii=0; ii < local_n_elem; ++ii)
{
x.at(ii+row_offset, ii+col_offset) = eT(arma_rng::randu<eT>());
}
}
template<typename eT>
inline
void
diagview<eT>::randn()
{
arma_extra_debug_sigprint();
Mat<eT>& x = const_cast< Mat<eT>& >(m);
const uword local_n_elem = n_elem;
for(uword ii=0; ii < local_n_elem; ++ii)
{
x.at(ii+row_offset, ii+col_offset) = eT(arma_rng::randn<eT>());
}
}
//! @} //! @}
 End of changes. 2 change blocks. 
1 lines changed or deleted 37 lines changed or added


 eop_aux.hpp   eop_aux.hpp 
// Copyright (C) 2010-2013 Conrad Sanderson // Copyright (C) 2010-2013 Conrad Sanderson
// Copyright (C) 2010-2013 NICTA (www.nicta.com.au) // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup eop_aux //! \addtogroup eop_aux
//! @{ //! @{
template<typename eT>
struct eop_aux_randu
{
arma_inline
operator eT ()
{
// make sure we are internally using at least floats
typedef typename promote_type<eT,float>::result eTp;
return eT( eTp(std::rand()) * ( eTp(1) / eTp(RAND_MAX) ) );
}
inline
static
void
fill(eT* mem, const uword N)
{
uword i,j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
const eT tmp_i = eT(eop_aux_randu<eT>());
const eT tmp_j = eT(eop_aux_randu<eT>());
mem[i] = tmp_i;
mem[j] = tmp_j;
}
if(i < N)
{
mem[i] = eT(eop_aux_randu<eT>());
}
}
};
template<typename T>
struct eop_aux_randu< std::complex<T> >
{
arma_inline
operator std::complex<T> ()
{
return std::complex<T>( T(eop_aux_randu<T>()), T(eop_aux_randu<T>()) );
}
inline
static
void
fill(std::complex<T>* mem, const uword N)
{
for(uword i=0; i < N; ++i)
{
mem[i] = std::complex<T>( eop_aux_randu< std::complex<T> >() );
}
}
};
template<typename eT>
struct eop_aux_randn
{
// rudimentary method, based on the central limit theorem:
// http://en.wikipedia.org/wiki/Central_limit_theorem
// polar form of the Box-Muller transformation:
// http://en.wikipedia.org/wiki/Box-Muller_transformation
// http://en.wikipedia.org/wiki/Marsaglia_polar_method
// other methods:
// http://en.wikipedia.org/wiki/Ziggurat_algorithm
//
// Marsaglia and Tsang Ziggurat technique to transform from a uniform to
a normal distribution.
// G. Marsaglia, W.W. Tsang.
// "Ziggurat method for generating random variables",
// J. Statistical Software, vol 5, 2000.
// http://www.jstatsoft.org/v05/i08/
// currently using polar form of the Box-Muller transformation
inline
operator eT () const
{
// make sure we are internally using at least floats
typedef typename promote_type<eT,float>::result eTp;
eTp tmp1;
eTp tmp2;
eTp w;
do
{
tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
w = tmp1*tmp1 + tmp2*tmp2;
}
while ( w >= eTp(1) );
return eT( tmp1 * std::sqrt( (eTp(-2) * std::log(w)) / w) );
}
inline
static
void
generate(eT& out1, eT& out2)
{
// make sure we are internally using at least floats
typedef typename promote_type<eT,float>::result eTp;
eTp tmp1;
eTp tmp2;
eTp w;
do
{
tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
w = tmp1*tmp1 + tmp2*tmp2;
}
while ( w >= eTp(1) );
const eTp k = std::sqrt( (eTp(-2) * std::log(w)) / w);
out1 = eT(tmp1*k);
out2 = eT(tmp2*k);
}
inline
static
void
fill(eT* mem, const uword N)
{
uword i, j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
eop_aux_randn<eT>::generate( mem[i], mem[j] );
}
if(i < N)
{
mem[i] = eT(eop_aux_randn<eT>());
}
}
};
template<typename T>
struct eop_aux_randn< std::complex<T> >
{
inline
operator std::complex<T> () const
{
T a, b;
eop_aux_randn<T>::generate(a, b);
return std::complex<T>(a, b);
}
inline
static
void
fill(std::complex<T>* mem, const uword N)
{
for(uword i=0; i < N; ++i)
{
mem[i] = std::complex<T>( eop_aux_randn< std::complex<T> >() );
}
}
};
//! use of the SFINAE approach to work around compiler limitations //! use of the SFINAE approach to work around compiler limitations
//! http://en.wikipedia.org/wiki/SFINAE //! http://en.wikipedia.org/wiki/SFINAE
class eop_aux class eop_aux
{ {
public: public:
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result acos (const eT x) { return eT( std::acos(double(x)) ); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result acos (const eT x) { return eT( std::acos(double(x)) ); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result asin (const eT x) { return eT( std::asin(double(x)) ); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result asin (const eT x) { return eT( std::asin(double(x)) ); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result atan (const eT x) { return eT( std::atan(double(x)) ); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result atan (const eT x) { return eT( std::atan(double(x)) ); }
 End of changes. 1 change blocks. 
172 lines changed or deleted 0 lines changed or added


 field_bones.hpp   field_bones.hpp 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Ian Cullinan // Copyright (C) 2009-2010 Ian Cullinan
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup field //! \addtogroup field
//! @{ //! @{
struct field_prealloc_n_elem struct field_prealloc_n_elem
skipping to change at line 89 skipping to change at line 89
inline subview_field<oT> rows(const uword in_row1, const uword in_r ow2); inline subview_field<oT> rows(const uword in_row1, const uword in_r ow2);
inline const subview_field<oT> rows(const uword in_row1, const uword in_r ow2) const; inline const subview_field<oT> rows(const uword in_row1, const uword in_r ow2) const;
inline subview_field<oT> cols(const uword in_col1, const uword in_c ol2); inline subview_field<oT> cols(const uword in_col1, const uword in_c ol2);
inline const subview_field<oT> cols(const uword in_col1, const uword in_c ol2) const; inline const subview_field<oT> cols(const uword in_col1, const uword in_c ol2) const;
inline subview_field<oT> subfield(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2); inline subview_field<oT> subfield(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
inline const subview_field<oT> subfield(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const; inline const subview_field<oT> subfield(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
inline subview_field<oT> subfield(const uword in_row1, const uword
in_col1, const SizeMat& s);
inline const subview_field<oT> subfield(const uword in_row1, const uword
in_col1, const SizeMat& s) const;
inline subview_field<oT> subfield (const span& row_span, const spa n& col_span); inline subview_field<oT> subfield (const span& row_span, const spa n& col_span);
inline const subview_field<oT> subfield (const span& row_span, const spa n& col_span) const; inline const subview_field<oT> subfield (const span& row_span, const spa n& col_span) const;
inline subview_field<oT> operator()(const span& row_span, const spa n& col_span); inline subview_field<oT> operator()(const span& row_span, const spa n& col_span);
inline const subview_field<oT> operator()(const span& row_span, const spa n& col_span) const; inline const subview_field<oT> operator()(const span& row_span, const spa n& col_span) const;
inline subview_field<oT> operator()(const uword in_row1, const uwor
d in_col1, const SizeMat& s);
inline const subview_field<oT> operator()(const uword in_row1, const uwor
d in_col1, const SizeMat& s) const;
inline void print(const std::string extra_text = "") const; inline void print(const std::string extra_text = "") const;
inline void print(std::ostream& user_stream, const std::string extra_text = "") const; inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
inline void fill(const oT& x); inline void fill(const oT& x);
inline void reset(); inline void reset();
inline void reset_objects(); inline void reset_objects();
arma_inline bool is_empty() const; arma_inline bool is_empty() const;
arma_inline arma_warn_unused bool in_range(const uword i) const; arma_inline arma_warn_unused bool in_range(const uword i) 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 bool in_range(const uword in_row, const uwor
d in_col, const SizeMat& s) const;
inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save(const std::string name, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const; inline bool save( std::ostream& os, const file_type type = arma_bi nary, const bool print_status = true) const;
inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true); inline bool load(const std::string name, const file_type type = auto_de tect, const bool print_status = true);
inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true); inline bool load( std::istream& is, const file_type type = auto_de tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const; inline bool quiet_save(const std::string name, const file_type type = a rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const; inline bool quiet_save( std::ostream& os, const file_type type = a rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a uto_detect); inline bool quiet_load(const std::string name, const file_type type = a uto_detect);
 End of changes. 4 change blocks. 
1 lines changed or deleted 14 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 441 skipping to change at line 441
const uword sub_n_rows = in_row2 - in_row1 + 1; const uword sub_n_rows = in_row2 - in_row1 + 1;
const uword sub_n_cols = in_col2 - in_col1 + 1; const uword sub_n_cols = in_col2 - in_col1 + 1;
return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols) ; return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols) ;
} }
//! creation of subview_field (subfield with arbitrary dimensions) //! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::subfield(const uword in_row1, const uword in_col1, const SizeMat
& s)
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"field::subfield(): indices or size out of bounds"
);
return subview_field<oT>(*this, in_row1, in_col1, s_n_rows, s_n_cols);
}
//! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT>
inline
const subview_field<oT>
field<oT>::subfield(const uword in_row1, const uword in_col1, const SizeMat
& s) const
{
arma_extra_debug_sigprint();
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
const uword s_n_rows = s.n_rows;
const uword s_n_cols = s.n_cols;
arma_debug_check
(
((in_row1 >= l_n_rows) || (in_col1 >= l_n_cols) || ((in_row1 + s_n_rows
) > l_n_rows) || ((in_col1 + s_n_cols) > l_n_cols)),
"field::subfield(): indices or size out of bounds"
);
return subview_field<oT>(*this, in_row1, in_col1, s_n_rows, s_n_cols);
}
//! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT>
inline
subview_field<oT>
field<oT>::subfield(const span& row_span, const span& col_span) field<oT>::subfield(const span& row_span, const span& col_span)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
skipping to change at line 733 skipping to change at line 779
const uword in_col1 = col_span.a; const uword in_col1 = col_span.a;
const uword in_col2 = col_span.b; const uword in_col2 = col_span.b;
const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) ); const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (i n_row2 < n_rows) );
const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) ); const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (i n_col2 < n_cols) );
return ( (rows_ok == true) && (cols_ok == true) ); return ( (rows_ok == true) && (cols_ok == true) );
} }
template<typename oT> template<typename oT>
arma_inline
arma_warn_unused
bool
field<oT>::in_range(const uword in_row, const uword in_col, const SizeMat&
s) const
{
const uword l_n_rows = n_rows;
const uword l_n_cols = n_cols;
if( (in_row >= l_n_rows) || (in_col >= l_n_cols) || ((in_row + s.n_rows)
> l_n_rows) || ((in_col + s.n_cols) > l_n_cols) )
{
return false;
}
else
{
return true;
}
}
template<typename oT>
inline inline
bool bool
field<oT>::save(const std::string name, const file_type type, const bool pr int_status) const field<oT>::save(const std::string name, const file_type type, const bool pr int_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::string err_msg; std::string err_msg;
const bool save_okay = field_aux::save(*this, name, type, err_msg); const bool save_okay = field_aux::save(*this, name, type, err_msg);
if( (print_status == true) && (save_okay == false) ) if( (print_status == true) && (save_okay == false) )
 End of changes. 2 change blocks. 
0 lines changed or deleted 71 lines changed or added


 fn_det.hpp   fn_det.hpp 
skipping to change at line 29 skipping to change at line 29
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);
} }
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
det
(
const Base<typename T1::elem_type,T1>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "det(): unknown method
specified" );
const bool slow = (sig == 's');
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
det det
( (
const Op<T1, op_diagmat>& X, const Op<T1, op_diagmat>& X,
const bool slow = false const bool slow = false
) )
skipping to change at line 67 skipping to change at line 90
} }
if(i < N) if(i < N)
{ {
val1 *= A[i]; val1 *= A[i];
} }
return val1 * val2; return val1 * val2;
} }
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
det
(
const Op<T1, op_diagmat>& X,
const char* method
)
{
arma_extra_debug_sigprint();
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "det(): unknown method
specified" );
return det(X, false);
}
//! determinant of a triangular matrix //! determinant of a triangular matrix
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det det
( (
const Op<T1, op_trimat>& X, const Op<T1, op_trimat>& X,
const bool slow = false const bool slow = false
) )
skipping to change at line 107 skipping to change at line 149
} }
if(i < N) if(i < N)
{ {
val1 *= P.at(i,i); val1 *= P.at(i,i);
} }
return val1 * val2; return val1 * val2;
} }
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
det
(
const Op<T1, op_trimat>& X,
const char* method
)
{
arma_extra_debug_sigprint();
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "det(): unknown method
specified" );
return det(X, false);
}
//! determinant of inv(A), without doing the inverse operation //! determinant of inv(A), without doing the inverse operation
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det det
( (
const Op<T1,op_inv>& in, const Op<T1,op_inv>& 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);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT tmp = det(in.m, slow); const eT tmp = det(X.m, slow);
arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" ); arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" );
return eT(1) / tmp; return eT(1) / tmp;
} }
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
det
(
const Op<T1,op_inv>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "det(): unknown method
specified" );
const bool slow = (sig == 's');
return det(X, slow);
}
//! determinant of trans(A) //! determinant of trans(A)
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det det
( (
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);
return auxlib::det(in.m, slow); // bypass op_htrans return auxlib::det(in.m, slow); // bypass op_htrans
} }
template<typename T1>
inline
arma_warn_unused
typename T1::elem_type
det
(
const Op<T1,op_htrans>& in,
const char* method,
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
)
{
arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "det(): unknown method
specified" );
const bool slow = (sig == 's');
return auxlib::det(in.m, slow); // bypass op_htrans
}
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. 7 change blocks. 
2 lines changed or deleted 121 lines changed or added


 fn_eig.hpp   fn_eig.hpp 
skipping to change at line 79 skipping to change at line 79
//! 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 char* method = "standard",
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_ptr(&eigval) == void_ptr(&eigvec), "eig_sym(): eig val is an alias of eigvec" ); arma_debug_check( void_ptr(&eigval) == void_ptr(&eigvec), "eig_sym(): eig val is an alias of eigvec" );
bool use_divide_and_conquer = false;
const char sig = method[0]; const char sig = method[0];
switch(sig) arma_debug_check( ((sig != 's') && (sig != 'd')), "eig_sym(): unknown met
{ hod specified" );
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); const bool status = (sig == 'd') ? auxlib::eig_sym_dc(eigval, eigvec, X) : auxlib::eig_sym(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. 
20 lines changed or deleted 4 lines changed or added


 fn_elem.hpp   fn_elem.hpp 
skipping to change at line 462 skipping to change at line 462
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
conj(const eOpCube<T1, eop_conj>& A) conj(const eOpCube<T1, eop_conj>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return A.m; return A.m;
} }
// TODO: this needs a more elaborate template restriction mechanism to work
properly,
// i.e. an overloaded version of thus function should do nothing if t
he input type is non-complex
//
// //! the conjugate of the transpose of a complex matrix is the same as th
e hermitian transpose
// template<typename T1>
// arma_inline
// const Op<T1, op_htrans>
// conj(const Op<T1, op_strans>& A)
// {
// arma_extra_debug_sigprint();
//
// return Op<T1, op_htrans>(A.m);
// }
// pow // pow
template<typename T1> template<typename T1>
arma_inline arma_inline
const eOp<T1, eop_pow> const eOp<T1, eop_pow>
pow(const Base<typename T1::elem_type,T1>& A, const typename T1::elem_type exponent) pow(const Base<typename T1::elem_type,T1>& A, const typename T1::elem_type exponent)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<T1, eop_pow>(A.get_ref(), exponent); return eOp<T1, eop_pow>(A.get_ref(), exponent);
 End of changes. 1 change blocks. 
17 lines changed or deleted 0 lines changed or added


 fn_inv.hpp   fn_inv.hpp 
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_inv //! \addtogroup fn_inv
//! @{ //! @{
//! delayed matrix inverse (general matrices) //! delayed matrix inverse (general matrices)
template<typename T1> template<typename T1>
skipping to change at line 28 skipping to change at line 28
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 Op<T1, op_inv>(X.get_ref(), ((slow == false) ? 0 : 1), 0); return Op<T1, op_inv>(X.get_ref(), ((slow == false) ? 0 : 1), 0);
} }
//! remove the inverse operation if applied twice consecutively
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const Op<T1, op_inv>
inv(const Op<T1, op_inv>& X, const bool slow = false) inv
(
const Base<typename T1::elem_type,T1>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(slow); arma_ignore(junk);
const char sig = method[0];
return X.m; arma_debug_check( ((sig != 's') && (sig != 'f')), "inv(): unknown method
specified" );
return Op<T1, op_inv>(X.get_ref(), ((sig == 'f') ? 0 : 1), 0);
} }
//! delayed matrix inverse (triangular matrices) //! delayed matrix inverse (triangular matrices)
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_inv_tr> const Op<T1, op_inv_tr>
inv inv
( (
const Op<T1, op_trimat>& X, const Op<T1, op_trimat>& 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(slow); arma_ignore(slow);
arma_ignore(junk); arma_ignore(junk);
return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0); return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
} }
template<typename T1>
arma_inline
const Op<T1, op_inv_tr>
inv
(
const Op<T1, op_trimat>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "inv(): unknown method
specified" );
return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
}
//! delayed matrix inverse (symmetric positive definite matrices) //! delayed matrix inverse (symmetric positive definite matrices)
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_inv_sympd> const Op<T1, op_inv_sympd>
inv inv
( (
const Op<T1, op_sympd>& X, const Op<T1, op_sympd>& 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(slow); arma_ignore(slow);
arma_ignore(junk); arma_ignore(junk);
return Op<T1, op_inv_sympd>(X.m, 0, 0); return Op<T1, op_inv_sympd>(X.m, 0, 0);
} }
template<typename T1> template<typename T1>
arma_inline
const Op<T1, op_inv_sympd>
inv
(
const Op<T1, op_sympd>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "inv(): unknown method
specified" );
return Op<T1, op_inv_sympd>(X.m, 0, 0);
}
template<typename T1>
inline inline
bool bool
inv inv
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
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
) )
{ {
skipping to change at line 102 skipping to change at line 150
out = inv(X,slow); out = inv(X,slow);
} }
catch(std::runtime_error&) catch(std::runtime_error&)
{ {
return false; return false;
} }
return true; return true;
} }
template<typename T1>
inline
bool
inv
(
Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
try
{
out = inv(X,method);
}
catch(std::runtime_error&)
{
return false;
}
return true;
}
//! @} //! @}
 End of changes. 8 change blocks. 
7 lines changed or deleted 88 lines changed or added


 fn_max.hpp   fn_max.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_max //! \addtogroup fn_max
//! @{ //! @{
//! \brief //! \brief
//! Delayed 'maximum values' operation. //! Delayed 'maximum values' operation.
skipping to change at line 104 skipping to change at line 104
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
max(const T& x) max(const T& x)
{ {
return x; return x;
} }
//! element-wise maximum
template<typename T1, typename T2>
arma_inline
typename
enable_if2
<
( is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<type
name T1::elem_type, typename T2::elem_type>::value ),
const Glue<T1, T2, glue_max>
>::result
max
(
const T1& X,
const T2& Y
)
{
arma_extra_debug_sigprint();
return Glue<T1, T2, glue_max>(X, Y);
}
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename typename
enable_if2 enable_if2
< <
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1 >::value == true), (is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1 >::value == true),
typename T1::elem_type typename T1::elem_type
>::result >::result
max(const T1& x) max(const T1& x)
 End of changes. 2 change blocks. 
2 lines changed or deleted 23 lines changed or added


 fn_min.hpp   fn_min.hpp 
skipping to change at line 104 skipping to change at line 104
template<typename T> template<typename T>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
const typename arma_scalar_only<T>::result & const typename arma_scalar_only<T>::result &
min(const T& x) min(const T& x)
{ {
return x; return x;
} }
//! element-wise minimum
template<typename T1, typename T2>
arma_inline
typename
enable_if2
<
( is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<type
name T1::elem_type, typename T2::elem_type>::value ),
const Glue<T1, T2, glue_min>
>::result
min
(
const T1& X,
const T2& Y
)
{
arma_extra_debug_sigprint();
return Glue<T1, T2, glue_min>(X, Y);
}
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename typename
enable_if2 enable_if2
< <
(is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1 >::value == true), (is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1 >::value == true),
typename T1::elem_type typename T1::elem_type
>::result >::result
min(const T1& x) min(const T1& x)
 End of changes. 1 change blocks. 
0 lines changed or deleted 21 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_misc //! \addtogroup fn_misc
//! @{ //! @{
//! \brief //! \brief
//! Generate a vector with 'num' elements. //! Generate a vector with 'num' elements.
//! The values of the elements linearly increase from 'start' upto (and inc luding) 'end'. //! The values of the elements linearly increase from 'start' upto (and inc luding) 'end'.
template<typename vec_type> template<typename vec_type>
inline inline
vec_type typename
enable_if2
<
is_Mat<vec_type>::value,
vec_type
>::result
linspace linspace
( (
const typename vec_type::pod_type start, const typename vec_type::pod_type start,
const typename vec_type::pod_type end, const typename vec_type::pod_type end,
const uword num = 100u, const uword num = 100u
const typename arma_Mat_Col_Row_only<vec_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename vec_type::elem_type eT; typedef typename vec_type::elem_type eT;
typedef typename vec_type::pod_type T; typedef typename vec_type::pod_type T;
vec_type x; vec_type x;
if(num >= 2) if(num >= 2)
{ {
x.set_size(num); x.set_size(num);
skipping to change at line 183 skipping to change at line 186
return Op<T1, op_sympd>(X.get_ref()); return Op<T1, op_sympd>(X.get_ref());
} }
template<typename eT> template<typename eT>
inline inline
void void
swap(Mat<eT>& A, Mat<eT>& B) swap(Mat<eT>& A, Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword A_mem_state = A.mem_state; A.swap(B);
}
if( (A.vec_state == B.vec_state) && (A_mem_state == B.mem_state) && ((A_m
em_state == 0) || (A_mem_state == 3)) )
{
A.swap(B);
}
else
{
if(A.n_elem <= B.n_elem)
{
Mat<eT> C = A;
A.steal_mem(B); template<typename eT>
B.steal_mem(C); inline
} void
else swap(Cube<eT>& A, Cube<eT>& B)
{ {
Mat<eT> C = B; arma_extra_debug_sigprint();
B.steal_mem(A); A.swap(B);
A.steal_mem(C);
}
}
} }
//! @} //! @}
 End of changes. 7 change blocks. 
28 lines changed or deleted 18 lines changed or added


 fn_pinv.hpp   fn_pinv.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_pinv //! \addtogroup fn_pinv
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pinv> const Op<T1, op_pinv>
pinv pinv
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename T1::elem_type tol = 0.0, const typename T1::elem_type tol = 0.0,
const char* method = "standard",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Op<T1, op_pinv>(X.get_ref(), tol); const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'd')), "pinv(): unknown method
specified" );
return (sig == 'd') ? Op<T1, op_pinv>(X.get_ref(), tol, 1, 0) : Op<T1, op
_pinv>(X.get_ref(), tol, 0, 0);
} }
template<typename T1> template<typename T1>
inline inline
bool bool
pinv pinv
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename T1::elem_type tol = 0.0, const typename T1::elem_type tol = 0.0,
const char* method = "standard",
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);
try try
{ {
out = pinv(X,tol); out = pinv(X, tol, method);
} }
catch(std::runtime_error&) catch(std::runtime_error&)
{ {
return false; return false;
} }
return true; return true;
} }
//! @} //! @}
 End of changes. 5 change blocks. 
6 lines changed or deleted 14 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
skipping to change at line 15 skipping to change at line 15
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_randn //! \addtogroup fn_randn
//! @{ //! @{
inline inline
double double
randn() randn()
{ {
return double(eop_aux_randn<double>()); return double(arma_rng::randn<double>());
} }
template<typename eT> template<typename eT>
inline inline
typename arma_scalar_only<eT>::result typename arma_scalar_only<eT>::result
randn() randn()
{ {
return eT(eop_aux_randn<eT>()); return eT(arma_rng::randn<eT>());
} }
//! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance) //! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance)
arma_inline arma_inline
const Gen<vec, gen_randn> const Gen<vec, gen_randn>
randn(const uword n_elem) randn(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<vec, gen_randn>(n_elem, 1); return Gen<vec, gen_randn>(n_elem, 1);
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_randu.hpp   fn_randu.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_randu //! \addtogroup fn_randu
//! @{ //! @{
inline inline
double double
randu() randu()
{ {
return double(eop_aux_randu<double>()); return arma_rng::randu<double>();
} }
template<typename eT> template<typename eT>
inline inline
typename arma_scalar_only<eT>::result typename arma_scalar_only<eT>::result
randu() randu()
{ {
return eT(eop_aux_randu<eT>()); return eT(arma_rng::randu<eT>());
} }
//! Generate a vector with all elements set to random values in the [0,1] i nterval (uniform distribution) //! Generate a vector with all elements set to random values in the [0,1] i nterval (uniform distribution)
arma_inline arma_inline
const Gen<vec, gen_randu> const Gen<vec, gen_randu>
randu(const uword n_elem) randu(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<vec, gen_randu>(n_elem, 1); return Gen<vec, gen_randu>(n_elem, 1);
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added


 fn_solve.hpp   fn_solve.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_solve //! \addtogroup fn_solve
//! @{ //! @{
//! Solve a system of linear equations, i.e., A*X = B, where X is unknown. //! Solve a system of linear equations, i.e., A*X = B, where X is unknown.
//! For a square matrix A, this function is conceptually the same as X = in v(A)*B, //! For a square matrix A, this function is conceptually the same as X = in v(A)*B,
skipping to change at line 38 skipping to change at line 38
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Glue<T1, T2, glue_solve>(A.get_ref(), B.get_ref(), ((slow == false ) ? 0 : 1) ); return Glue<T1, T2, glue_solve>(A.get_ref(), B.get_ref(), ((slow == false ) ? 0 : 1) );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Glue<T1, T2, glue_solve>
solve
(
const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "solve(): unknown metho
d specified" );
return Glue<T1, T2, glue_solve>( A.get_ref(), B.get_ref(), ((sig == 'f')
? 0 : 1) );
}
template<typename T1, typename T2>
inline
const Glue<T1, T2, glue_solve_tr> const Glue<T1, T2, glue_solve_tr>
solve solve
( (
const Op<T1, op_trimat>& A, const Op<T1, op_trimat>& A,
const Base<typename T1::elem_type,T2>& B, const Base<typename T1::elem_type,T2>& B,
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(slow); arma_ignore(slow);
arma_ignore(junk); arma_ignore(junk);
return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_uword_a); return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_uword_a);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Glue<T1, T2, glue_solve_tr>
solve
(
const Op<T1, op_trimat>& A,
const Base<typename T1::elem_type,T2>& B,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "solve(): unknown metho
d specified" );
return Glue<T1, T2, glue_solve_tr>(A.m, B.get_ref(), A.aux_uword_a);
}
template<typename T1, typename T2>
inline
bool bool
solve solve
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B, const Base<typename T1::elem_type,T2>& B,
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
) )
{ {
skipping to change at line 81 skipping to change at line 123
out = solve( A.get_ref(), B.get_ref(), slow ); out = solve( A.get_ref(), B.get_ref(), slow );
} }
catch(std::runtime_error&) catch(std::runtime_error&)
{ {
return false; return false;
} }
return true; return true;
} }
template<typename T1, typename T2>
inline
bool
solve
(
Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
try
{
out = solve( A.get_ref(), B.get_ref(), method );
}
catch(std::runtime_error&)
{
return false;
}
return true;
}
//! @} //! @}
 End of changes. 4 change blocks. 
2 lines changed or deleted 77 lines changed or added


 fn_sort.hpp   fn_sort.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_sort //! \addtogroup fn_sort
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
skipping to change at line 31 skipping to change at line 31
const T1& X, const T1& X,
const uword sort_type = 0, const uword sort_type = 0,
const uword dim = 0 const uword dim = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_sort>(X, sort_type, dim); return Op<T1, op_sort>(X, sort_type, dim);
} }
template<typename T1, typename T2>
arma_inline
typename
enable_if2
<
( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value ==
false) && (is_same_type<T2, char>::value) ),
const Op<T1, op_sort>
>::result
sort
(
const T1& X,
const T2* sort_direction,
const uword dim = 0
)
{
arma_extra_debug_sigprint();
const char sig = sort_direction[0];
arma_debug_check( (sig != 'a') && (sig != 'd'), "sort(): unknown sort dir
ection");
const uword sort_type = (sig == 'a') ? 0 : 1;
return Op<T1, op_sort>(X, sort_type, dim);
}
template<typename T1> template<typename T1>
arma_inline arma_inline
typename typename
enable_if2 enable_if2
< <
( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value == true) ), ( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value == true) ),
const Op<T1, op_sort> const Op<T1, op_sort>
>::result >::result
sort sort
( (
skipping to change at line 52 skipping to change at line 78
const uword sort_type = 0 const uword sort_type = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword dim = (T1::is_col) ? 0 : 1; const uword dim = (T1::is_col) ? 0 : 1;
return Op<T1, op_sort>(X, sort_type, dim); return Op<T1, op_sort>(X, sort_type, dim);
} }
template<typename T1, typename T2>
arma_inline
typename
enable_if2
<
( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value ==
true) && (is_same_type<T2, char>::value) ),
const Op<T1, op_sort>
>::result
sort
(
const T1& X,
const T2* sort_direction
)
{
arma_extra_debug_sigprint();
const char sig = sort_direction[0];
arma_debug_check( (sig != 'a') && (sig != 'd'), "sort(): unknown sort dir
ection");
const uword sort_type = (sig == 'a') ? 0 : 1;
const uword dim = (T1::is_col) ? 0 : 1;
return Op<T1, op_sort>(X, sort_type, dim);
}
//! @} //! @}
 End of changes. 3 change blocks. 
2 lines changed or deleted 58 lines changed or added


 fn_sort_index.hpp   fn_sort_index.hpp 
// Copyright (C) 2009-2012 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2012 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_sort_index //! \addtogroup fn_sort_index
//! @{ //! @{
template<typename T1, typename T2> template<typename T1, typename T2>
struct arma_sort_index_packet struct arma_sort_index_packet
skipping to change at line 44 skipping to change at line 44
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_inline
bool bool
operator() (const arma_sort_index_packet<T1,T2>& A, const arma_sort_index _packet<T1,T2>& B) const operator() (const arma_sort_index_packet<T1,T2>& A, const arma_sort_index _packet<T1,T2>& B) const
{ {
return (A.val > B.val); return (A.val > B.val);
} }
}; };
template<typename umat_elem_type, typename eT, const uword sort_direction, const uword sort_type> template<typename umat_elem_type, typename eT, const uword sort_type, const uword sort_stable>
void void
inline inline
sort_index_helper(umat_elem_type* out_mem, const eT* in_mem, const uword n_ elem) sort_index_helper(umat_elem_type* out_mem, const eT* in_mem, const uword n_ elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::vector< arma_sort_index_packet<eT, umat_elem_type> > packet_vec(n_el em); std::vector< arma_sort_index_packet<eT, umat_elem_type> > packet_vec(n_el em);
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
packet_vec[i].val = in_mem[i]; packet_vec[i].val = in_mem[i];
packet_vec[i].index = i; packet_vec[i].index = i;
} }
if(sort_direction == 0) if(sort_type == 0)
{ {
// ascend // ascend
arma_sort_index_helper_ascend comparator; arma_sort_index_helper_ascend comparator;
if(sort_type == 0) if(sort_stable == 0)
{ {
std::sort( packet_vec.begin(), packet_vec.end(), comparator ); std::sort( packet_vec.begin(), packet_vec.end(), comparator );
} }
else else
{ {
std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator );
} }
} }
else else
{ {
// descend // descend
arma_sort_index_helper_descend comparator; arma_sort_index_helper_descend comparator;
if(sort_type == 0) if(sort_stable == 0)
{ {
std::sort( packet_vec.begin(), packet_vec.end(), comparator ); std::sort( packet_vec.begin(), packet_vec.end(), comparator );
} }
else else
{ {
std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator );
} }
} }
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
skipping to change at line 102 skipping to change at line 102
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 sort_index
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const uword sort_direction = 0, const uword sort_type = 0,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
skipping to change at line 125 skipping to change at line 125
{ {
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;
umat out(A.n_rows, A.n_cols); umat out(A.n_rows, A.n_cols);
if(sort_direction == 0) if(sort_type == 0)
{ {
sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele m); sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele m);
} }
else else
{ {
sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele m); sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele m);
} }
return out; return out;
} }
template<typename T1> template<typename T1>
inline inline
umat umat
stable_sort_index stable_sort_index
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const uword sort_direction = 0, const uword sort_type = 0,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
skipping to change at line 166 skipping to change at line 166
{ {
return umat(); return umat();
} }
arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currently only handles vectors"); arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currently only handles vectors");
typedef typename umat::elem_type out_elem_type; typedef typename umat::elem_type out_elem_type;
umat out(A.n_rows, A.n_cols); umat out(A.n_rows, A.n_cols);
if(sort_direction == 0) if(sort_type == 0)
{
sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_ele
m);
}
else
{
sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_ele
m);
}
return out;
}
template<typename T1, typename T2>
inline
typename
enable_if2
<
( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value ==
true) && (is_cx<typename T1::elem_type>::value == false) ),
umat
>::result
sort_index
(
const T1& X,
const T2* sort_direction
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X);
const Mat<eT>& A = tmp.M;
if(A.is_empty() == true)
{
return umat();
}
arma_debug_check( (A.is_vec() == false), "sort_index(): currently only ha
ndles vectors");
const char sig = sort_direction[0];
arma_debug_check( ((sig != 'a') && (sig != 'd')), "sort_index(): unknown
sort direction" );
typedef typename umat::elem_type out_elem_type;
umat out(A.n_rows, A.n_cols);
if(sig == 'a')
{
sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele
m);
}
else
{
sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele
m);
}
return out;
}
template<typename T1, typename T2>
inline
typename
enable_if2
<
( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value ==
true) && (is_cx<typename T1::elem_type>::value == false) ),
umat
>::result
stable_sort_index
(
const T1& X,
const T2* sort_direction
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X);
const Mat<eT>& A = tmp.M;
if(A.is_empty() == true)
{
return umat();
}
arma_debug_check( (A.is_vec() == false), "stable_sort_index(): currently
only handles vectors");
const char sig = sort_direction[0];
arma_debug_check( ((sig != 'a') && (sig != 'd')), "stable_sort_index(): u
nknown sort direction" );
typedef typename umat::elem_type out_elem_type;
umat out(A.n_rows, A.n_cols);
if(sig == 'a')
{ {
sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_ele m); sort_index_helper<out_elem_type, eT, 0, 1>(out.memptr(), A.mem, A.n_ele m);
} }
else else
{ {
sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_ele m); sort_index_helper<out_elem_type, eT, 1, 1>(out.memptr(), A.mem, A.n_ele m);
} }
return out; return out;
} }
 End of changes. 9 change blocks. 
10 lines changed or deleted 116 lines changed or added


 fn_sprandn.hpp   fn_sprandn.hpp 
skipping to change at line 69 skipping to change at line 69
inline inline
SpMat<typename T1::elem_type> SpMat<typename T1::elem_type>
sprandn(const SpBase<typename T1::elem_type, T1>& X) sprandn(const SpBase<typename T1::elem_type, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
SpMat<eT> out( X.get_ref() ); SpMat<eT> out( X.get_ref() );
eop_aux_randn<eT>::fill( access::rwp(out.values), out.n_nonzero ); arma_rng::randn<eT>::fill( access::rwp(out.values), out.n_nonzero );
return out; return out;
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_sprandu.hpp   fn_sprandu.hpp 
skipping to change at line 69 skipping to change at line 69
inline inline
SpMat<typename T1::elem_type> SpMat<typename T1::elem_type>
sprandu(const SpBase<typename T1::elem_type, T1>& X) sprandu(const SpBase<typename T1::elem_type, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
SpMat<eT> out( X.get_ref() ); SpMat<eT> out( X.get_ref() );
eop_aux_randu<eT>::fill( access::rwp(out.values), out.n_nonzero ); arma_rng::randu<eT>::fill( access::rwp(out.values), out.n_nonzero );
return out; return out;
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_svd.hpp   fn_svd.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_svd //! \addtogroup fn_svd
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
skipping to change at line 71 skipping to change at line 71
template<typename T1> template<typename T1>
inline inline
bool bool
svd svd
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char* method = "", const char* method = "standard",
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 arma_debug_check
( (
( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ), ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ),
"svd(): two or more output objects are the same object" "svd(): two or more output objects are the same object"
); );
bool use_divide_and_conquer = false;
const char sig = method[0]; const char sig = method[0];
switch(sig) arma_debug_check( ((sig != 's') && (sig != 'd')), "svd(): unknown method
{ specified" );
case '\0':
case 's':
break;
case 'd':
use_divide_and_conquer = true;
break;
default:
{
arma_stop("svd(): unknown method specified");
return false;
}
}
// auxlib::svd() makes an internal copy of X // auxlib::svd() makes an internal copy of X
const bool status = (use_divide_and_conquer == false) ? auxlib::svd(U, S, V, X) : auxlib::svd_dc(U, S, V, X); const bool status = (sig == 'd') ? auxlib::svd_dc(U, S, V, X) : auxlib::s vd(U, S, V, X);
if(status == false) if(status == false)
{ {
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
arma_bad("svd(): failed to converge", false); arma_bad("svd(): failed to converge", false);
} }
return status; return status;
skipping to change at line 128 skipping to change at line 111
template<typename T1> template<typename T1>
inline inline
bool bool
svd_econ svd_econ
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char mode = 'b', const char mode,
const char* method = "standard",
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 arma_debug_check
( (
( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ), ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ),
"svd_econ(): two or more output objects are the same object" "svd_econ(): two or more output objects are the same object"
); );
arma_debug_check arma_debug_check
( (
( (mode != 'l') && (mode != 'r') && (mode != 'b') ), ( (mode != 'l') && (mode != 'r') && (mode != 'b') ),
"svd_econ(): parameter 'mode' is incorrect" "svd_econ(): parameter 'mode' or 'side' is incorrect"
); );
// auxlib::svd_econ() makes an internal copy of X const char sig = method[0];
const bool status = auxlib::svd_econ(U, S, V, X, mode);
arma_debug_check( ((sig != 's') && (sig != 'd')), "svd_econ(): unknown me
thod specified" );
const bool status = ((mode == 'b') && (sig == 'd')) ? auxlib::svd_dc_econ
(U, S, V, X) : auxlib::svd_econ(U, S, V, X, mode);
if(status == false) if(status == false)
{ {
U.reset(); U.reset();
S.reset(); S.reset();
V.reset(); V.reset();
arma_bad("svd_econ(): failed to converge", false); arma_bad("svd_econ(): failed to converge", false);
} }
return status; return status;
} }
template<typename T1> template<typename T1>
inline
bool
svd_econ
(
Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X,
const char* side = "both",
const char* method = "standard",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return svd_econ(U,S,V,X,side[0],method);
}
// TODO: remove this function in version 4.0
template<typename T1>
arma_deprecated arma_deprecated
inline inline
bool bool
svd_thin svd_thin
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char mode = 'b', const char mode = 'b',
 End of changes. 9 change blocks. 
26 lines changed or deleted 38 lines changed or added


 format_wrap.hpp   format_wrap.hpp 
skipping to change at line 15 skipping to change at line 15
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup format_wrap //! \addtogroup format_wrap
//! @{ //! @{
//! \namespace arma_boost namespace for functions and classes which partial ly emulate Boost functionality //! \namespace arma_boost namespace for functions and classes which partial ly emulate Boost functionality
namespace arma_boost namespace arma_boost
{ {
// TODO: in version 4.0, remove use of boost::format
#if defined(ARMA_USE_BOOST_FORMAT) #if defined(ARMA_USE_BOOST_FORMAT)
using boost::format; using boost::format;
using boost::basic_format; using boost::basic_format;
using boost::str; using boost::str;
#else #else
#if defined(ARMA_HAVE_STD_SNPRINTF) #if defined(ARMA_HAVE_STD_SNPRINTF)
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 forward_bones.hpp   forward_bones.hpp 
skipping to change at line 45 skipping to change at line 45
template<typename eT> class SpSubview; template<typename eT> class SpSubview;
template<typename eT> class diagview; template<typename eT> class diagview;
template<typename eT, typename T1> class subview_elem1; template<typename eT, typename T1> class subview_elem1;
template<typename eT, typename T1, typename T2> class subview_elem2; template<typename eT, typename T1, typename T2> class subview_elem2;
template<typename parent, unsigned int mode> class subview_eac h1; template<typename parent, unsigned int mode> class subview_eac h1;
template<typename parent, unsigned int mode, typename TB> class subview_eac h2; template<typename parent, unsigned int mode, typename TB> class subview_eac h2;
class SizeMat;
class SizeCube;
class arma_empty_class {}; class arma_empty_class {};
class diskio; class diskio;
class op_min; class op_min;
class op_max; class op_max;
class op_strans; class op_strans;
class op_htrans; class op_htrans;
class op_htrans2; class op_htrans2;
 End of changes. 1 change blocks. 
0 lines changed or deleted 3 lines changed or added


 memory.hpp   memory.hpp 
skipping to change at line 17 skipping to change at line 17
//! \addtogroup memory //! \addtogroup memory
//! @{ //! @{
class memory class memory
{ {
public: public:
arma_inline static uword enlarge_to_mul t_of_chunksize(const uword n_elem); arma_inline static uword enlarge_to_mul t_of_chunksize(const uword n_elem);
template<typename eT> arma_inline arma_malloc static eT* acquire(const uword n_elem); template<typename eT> inline arma_malloc static eT* acquire(const uword n_elem);
template<typename eT> arma_inline arma_malloc static eT* acquire_chunke d(const uword n_elem); template<typename eT> inline arma_malloc static eT* acquire_chunke d(const uword n_elem);
template<typename eT> arma_inline static void release(eT* me m); template<typename eT> arma_inline static void release(eT* me m);
template<typename eT> arma_inline static bool is_aligned(const eT* mem); template<typename eT> arma_inline static bool is_aligned(const eT* mem);
template<typename eT> arma_inline static void mark_as_aligned( eT*& mem); template<typename eT> arma_inline static void mark_as_aligned( eT*& mem);
template<typename eT> arma_inline static void mark_as_aligned(const eT*& mem); template<typename eT> arma_inline static void mark_as_aligned(const eT*& mem);
}; };
arma_inline arma_inline
uword uword
skipping to change at line 41 skipping to change at line 41
{ {
const uword chunksize = arma_config::spmat_chunksize; const uword chunksize = arma_config::spmat_chunksize;
// this relies on integer division // this relies on integer division
const uword n_elem_mod = ((n_elem % chunksize) != 0) ? ((n_elem / chunksi ze) + 1) * chunksize : n_elem; const uword n_elem_mod = ((n_elem % chunksize) != 0) ? ((n_elem / chunksi ze) + 1) * chunksize : n_elem;
return n_elem_mod; return n_elem_mod;
} }
template<typename eT> template<typename eT>
arma_inline inline
arma_malloc arma_malloc
eT* eT*
memory::acquire(const uword n_elem) memory::acquire(const uword n_elem)
{ {
eT* out_memptr;
#if defined(ARMA_USE_TBB_ALLOC) #if defined(ARMA_USE_TBB_ALLOC)
{ {
return ( (eT *) scalable_malloc(sizeof(eT)*n_elem) ); out_memptr = (eT *) scalable_malloc(sizeof(eT)*n_elem);
} }
#elif defined(ARMA_USE_MKL_ALLOC) #elif defined(ARMA_USE_MKL_ALLOC)
{ {
return ( (eT *) mkl_malloc( sizeof(eT)*n_elem, 128 ) ); out_memptr = (eT *) mkl_malloc( sizeof(eT)*n_elem, 128 );
} }
#elif defined(ARMA_HAVE_POSIX_MEMALIGN) #elif defined(ARMA_HAVE_POSIX_MEMALIGN)
{ {
eT* memptr; eT* memptr;
const size_t alignment = 16; // change the 16 to 64 if you wish to ali gn to the cache line const size_t alignment = 16; // change the 16 to 64 if you wish to ali gn to the cache line
int status = posix_memalign((void **)&memptr, ( (alignment >= sizeof(vo id*)) ? alignment : sizeof(void*) ), sizeof(eT)*n_elem); int status = posix_memalign((void **)&memptr, ( (alignment >= sizeof(vo id*)) ? alignment : sizeof(void*) ), sizeof(eT)*n_elem);
return (status == 0) ? memptr : NULL; out_memptr = (status == 0) ? memptr : NULL;
} }
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
{ {
return ( (eT *) _aligned_malloc( sizeof(eT)*n_elem, 16 ) ); // lives i n malloc.h out_memptr = (eT *) _aligned_malloc( sizeof(eT)*n_elem, 16 ); // lives in malloc.h
} }
#else #else
{ {
//return ( new(std::nothrow) eT[n_elem] ); //return ( new(std::nothrow) eT[n_elem] );
return ( (eT *) malloc(sizeof(eT)*n_elem) ); out_memptr = (eT *) malloc(sizeof(eT)*n_elem);
} }
#endif #endif
// TODO: for mingw, use __mingw_aligned_malloc // TODO: for mingw, use __mingw_aligned_malloc
if(n_elem > 0)
{
arma_check_bad_alloc( (out_memptr == NULL), "arma::memory::acquire(): o
ut of memory" );
}
return out_memptr;
} }
//! get memory in multiples of chunks, holding at least n_elem //! get memory in multiples of chunks, holding at least n_elem
template<typename eT> template<typename eT>
arma_inline inline
arma_malloc arma_malloc
eT* eT*
memory::acquire_chunked(const uword n_elem) memory::acquire_chunked(const uword n_elem)
{ {
const uword n_elem_mod = memory::enlarge_to_mult_of_chunksize(n_elem); const uword n_elem_mod = memory::enlarge_to_mult_of_chunksize(n_elem);
return memory::acquire<eT>(n_elem_mod); return memory::acquire<eT>(n_elem_mod);
} }
template<typename eT> template<typename eT>
 End of changes. 11 change blocks. 
9 lines changed or deleted 19 lines changed or added


 mul_gemm.hpp   mul_gemm.hpp 
skipping to change at line 125 skipping to change at line 125
else if( (use_alpha == true ) && (use_beta == false) ) { C.at(co l_A,col_B) = alpha*acc; } else if( (use_alpha == true ) && (use_beta == false) ) { C.at(co l_A,col_B) = alpha*acc; }
else if( (use_alpha == false) && (use_beta == true ) ) { C.at(co l_A,col_B) = acc + beta*C.at(col_A,col_B); } else if( (use_alpha == false) && (use_beta == true ) ) { C.at(co l_A,col_B) = acc + beta*C.at(col_A,col_B); }
else if( (use_alpha == true ) && (use_beta == true ) ) { C.at(co l_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); } else if( (use_alpha == true ) && (use_beta == true ) ) { C.at(co l_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); }
} }
} }
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) ) if( (do_trans_A == false) && (do_trans_B == true) )
{ {
Mat<eT> BB; Mat<eT> BB;
op_strans::apply_noalias(BB, B); op_strans::apply_mat_noalias(BB, B);
gemm_emul_large<false, false, use_alpha, use_beta>::apply(C, A, BB, a lpha, beta); gemm_emul_large<false, false, use_alpha, use_beta>::apply(C, A, BB, a lpha, beta);
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) ) if( (do_trans_A == true) && (do_trans_B == true) )
{ {
// mat B_tmp = trans(B); // mat B_tmp = trans(B);
// dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta); // dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta);
// By using the trans(A)*trans(B) = trans(B*A) equivalency, // By using the trans(A)*trans(B) = trans(B*A) equivalency,
skipping to change at line 198 skipping to change at line 198
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) ) if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) )
{ {
if(do_trans_B == false) if(do_trans_B == false)
{ {
gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, B, a lpha, beta); gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, B, a lpha, beta);
} }
else else
{ {
Mat<eT> BB(A_n_rows, A_n_rows); Mat<eT> BB(A_n_rows, A_n_rows);
op_strans::apply_noalias_tinysq(BB, B); op_strans::apply_mat_noalias_tinysq(BB, B);
gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, BB, alpha, beta); gemm_emul_tinysq<do_trans_A, use_alpha, use_beta>::apply(C, A, BB, alpha, beta);
} }
} }
else else
{ {
gemm_emul_large<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C , A, B, alpha, beta); gemm_emul_large<do_trans_A, do_trans_B, use_alpha, use_beta>::apply(C , A, B, alpha, beta);
} }
} }
skipping to change at line 232 skipping to change at line 232
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
// "better than nothing" handling of hermitian transposes for complex n umber matrices // "better than nothing" handling of hermitian transposes for complex n umber matrices
Mat<eT> tmp_A; Mat<eT> tmp_A;
Mat<eT> tmp_B; Mat<eT> tmp_B;
if(do_trans_A) { op_htrans::apply_noalias(tmp_A, A); } if(do_trans_A) { op_htrans::apply_mat_noalias(tmp_A, A); }
if(do_trans_B) { op_htrans::apply_noalias(tmp_B, B); } if(do_trans_B) { op_htrans::apply_mat_noalias(tmp_B, B); }
const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A; const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A;
const Mat<eT>& BB = (do_trans_B == false) ? B : tmp_B; const Mat<eT>& BB = (do_trans_B == false) ? B : tmp_B;
const uword A_n_rows = AA.n_rows; const uword A_n_rows = AA.n_rows;
const uword A_n_cols = AA.n_cols; const uword A_n_cols = AA.n_cols;
const uword B_n_rows = BB.n_rows; const uword B_n_rows = BB.n_rows;
const uword B_n_cols = BB.n_cols; const uword B_n_cols = BB.n_cols;
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added


 mul_gemm_mixed.hpp   mul_gemm_mixed.hpp 
skipping to change at line 100 skipping to change at line 100
else if( (use_alpha == false) && (use_beta == true ) ) { C.at(co l_A,col_B) = acc + beta*C.at(col_A,col_B); } else if( (use_alpha == false) && (use_beta == true ) ) { C.at(co l_A,col_B) = acc + beta*C.at(col_A,col_B); }
else if( (use_alpha == true ) && (use_beta == true ) ) { C.at(co l_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); } else if( (use_alpha == true ) && (use_beta == true ) ) { C.at(co l_A,col_B) = alpha*acc + beta*C.at(col_A,col_B); }
} }
} }
} }
else else
if( (do_trans_A == false) && (do_trans_B == true) ) if( (do_trans_A == false) && (do_trans_B == true) )
{ {
Mat<in_eT2> B_tmp; Mat<in_eT2> B_tmp;
op_strans::apply_noalias(B_tmp, B); op_strans::apply_mat_noalias(B_tmp, B);
gemm_mixed_large<false, false, use_alpha, use_beta>::apply(C, A, B_tm p, alpha, beta); gemm_mixed_large<false, false, use_alpha, use_beta>::apply(C, A, B_tm p, alpha, beta);
} }
else else
if( (do_trans_A == true) && (do_trans_B == true) ) if( (do_trans_A == true) && (do_trans_B == true) )
{ {
// mat B_tmp = trans(B); // mat B_tmp = trans(B);
// dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta); // dgemm_arma<true, false, use_alpha, use_beta>::apply(C, A, B_tmp, alpha, beta);
// By using the trans(A)*trans(B) = trans(B*A) equivalency, // By using the trans(A)*trans(B) = trans(B*A) equivalency,
skipping to change at line 302 skipping to change at line 302
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<in_eT1> tmp_A; Mat<in_eT1> tmp_A;
Mat<in_eT2> tmp_B; Mat<in_eT2> tmp_B;
const bool predo_trans_A = ( (do_trans_A == true) && (is_cx<in_eT1>::ye s) ); const bool predo_trans_A = ( (do_trans_A == true) && (is_cx<in_eT1>::ye s) );
const bool predo_trans_B = ( (do_trans_B == true) && (is_cx<in_eT2>::ye s) ); const bool predo_trans_B = ( (do_trans_B == true) && (is_cx<in_eT2>::ye s) );
if(do_trans_A) if(do_trans_A)
{ {
op_htrans::apply_noalias(tmp_A, A); op_htrans::apply_mat_noalias(tmp_A, A);
} }
if(do_trans_B) if(do_trans_B)
{ {
op_htrans::apply_noalias(tmp_B, B); op_htrans::apply_mat_noalias(tmp_B, B);
} }
const Mat<in_eT1>& AA = (predo_trans_A == false) ? A : tmp_A; const Mat<in_eT1>& AA = (predo_trans_A == false) ? A : tmp_A;
const Mat<in_eT2>& BB = (predo_trans_B == false) ? B : tmp_B; const Mat<in_eT2>& BB = (predo_trans_B == false) ? B : tmp_B;
if( (AA.n_elem <= 64u) && (BB.n_elem <= 64u) ) if( (AA.n_elem <= 64u) && (BB.n_elem <= 64u) )
{ {
gemm_mixed_small<((predo_trans_A) ? false : do_trans_A), ((predo_tran s_B) ? false : do_trans_B), use_alpha, use_beta>::apply(C, AA, BB, alpha, b eta); gemm_mixed_small<((predo_trans_A) ? false : do_trans_A), ((predo_tran s_B) ? false : do_trans_B), use_alpha, use_beta>::apply(C, AA, BB, alpha, b eta);
} }
else else
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 mul_gemv.hpp   mul_gemv.hpp 
skipping to change at line 297 skipping to change at line 297
void void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0), const typename arma_cx_only<eT>::result* junk = 0 ) apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0), const typename arma_cx_only<eT>::result* junk = 0 )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
Mat<eT> tmp_A; Mat<eT> tmp_A;
if(do_trans_A) if(do_trans_A)
{ {
op_htrans::apply_noalias(tmp_A, A); op_htrans::apply_mat_noalias(tmp_A, A);
} }
const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A; const Mat<eT>& AA = (do_trans_A == false) ? A : tmp_A;
const uword AA_n_rows = AA.n_rows; const uword AA_n_rows = AA.n_rows;
const uword AA_n_cols = AA.n_cols; const uword AA_n_cols = AA.n_cols;
if( (AA_n_rows <= 4) && (AA_n_rows == AA_n_cols) ) if( (AA_n_rows <= 4) && (AA_n_rows == AA_n_cols) )
{ {
gemv_emul_tinysq<false, use_alpha, use_beta>::apply(y, AA, x, alpha, beta); gemv_emul_tinysq<false, use_alpha, use_beta>::apply(y, AA, x, alpha, beta);
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 mul_herk.hpp   mul_herk.hpp 
skipping to change at line 239 skipping to change at line 239
typedef std::complex<T> eT; typedef std::complex<T> eT;
// do_trans_A == false -> C = alpha * A * A^H + beta*C // do_trans_A == false -> C = alpha * A * A^H + beta*C
// do_trans_A == true -> C = alpha * A^H * A + beta*C // do_trans_A == true -> C = alpha * A^H * A + beta*C
if(do_trans_A == false) if(do_trans_A == false)
{ {
Mat<eT> AA; Mat<eT> AA;
op_htrans::apply_noalias(AA, A); op_htrans::apply_mat_noalias(AA, A);
herk_emul<true, use_alpha, use_beta>::apply(C, AA, alpha, beta); herk_emul<true, use_alpha, use_beta>::apply(C, AA, alpha, beta);
} }
else else
if(do_trans_A == true) if(do_trans_A == true)
{ {
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;
for(uword col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 mul_syrk.hpp   mul_syrk.hpp 
skipping to change at line 201 skipping to change at line 201
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// do_trans_A == false -> C = alpha * A * A^T + beta*C // do_trans_A == false -> C = alpha * A * A^T + beta*C
// do_trans_A == true -> C = alpha * A^T * A + beta*C // do_trans_A == true -> C = alpha * A^T * A + beta*C
if(do_trans_A == false) if(do_trans_A == false)
{ {
Mat<eT> AA; Mat<eT> AA;
op_strans::apply_noalias(AA, A); op_strans::apply_mat_noalias(AA, A);
syrk_emul<true, use_alpha, use_beta>::apply(C, AA, alpha, beta); syrk_emul<true, use_alpha, use_beta>::apply(C, AA, alpha, beta);
} }
else else
if(do_trans_A == true) if(do_trans_A == true)
{ {
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;
for(uword col_A=0; col_A < A_n_cols; ++col_A) for(uword col_A=0; col_A < A_n_cols; ++col_A)
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 op_cx_scalar_meat.hpp   op_cx_scalar_meat.hpp 
skipping to change at line 282 skipping to change at line 282
Cube< typename std::complex<typename T1::pod_type> >& out, Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_times>& X const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_times>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
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);
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
// TODO: implement handling for ProxyCube<T1>::prefer_at_accessor == true if(ProxyCube<T1>::prefer_at_accessor == false)
for(uword i=0; i<n_elem; ++i) {
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = A[i] * k;
}
}
else
{ {
out_mem[i] = A[i] * k; 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 = A.at(row,col,slice) * k; ++out_mem;
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_plus::apply op_cx_scalar_plus::apply
( (
Cube< typename std::complex<typename T1::pod_type> >& out, Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_plus>& X const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_plus>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
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);
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
out_mem[i] = A[i] + k; for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = A[i] + k;
}
}
else
{
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 = A.at(row,col,slice) + k; ++out_mem;
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_minus_pre::apply op_cx_scalar_minus_pre::apply
( (
Cube< typename std::complex<typename T1::pod_type> >& out, Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_minus_pre>& X const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_minus_pre>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
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);
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) if(ProxyCube<T1>::prefer_at_accessor == false)
{
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = k - A[i];
}
}
else
{ {
out_mem[i] = k - A[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 = k - A.at(row,col,slice); ++out_mem;
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_minus_post::apply op_cx_scalar_minus_post::apply
( (
Cube< typename std::complex<typename T1::pod_type> >& out, Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_minus_post>& X const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_minus_post>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
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);
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) if(ProxyCube<T1>::prefer_at_accessor == false)
{
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = A[i] - k;
}
}
else
{ {
out_mem[i] = A[i] - k; 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 = A.at(row,col,slice) - k; ++out_mem;
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_div_pre::apply op_cx_scalar_div_pre::apply
( (
Cube< typename std::complex<typename T1::pod_type> >& out, Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_div_pre>& X const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_div_pre>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
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);
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
out_mem[i] = k / A[i]; for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = k / A[i];
}
}
else
{
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 = k / A.at(row,col,slice); ++out_mem;
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_cx_scalar_div_post::apply op_cx_scalar_div_post::apply
( (
Cube< typename std::complex<typename T1::pod_type> >& out, Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_div_post>& X const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_sc alar_div_post>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT; typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m); const ProxyCube<T1> A(X.m);
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);
const eT k = X.aux_out_eT; const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) if(ProxyCube<T1>::prefer_at_accessor == false)
{
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = A[i] / k;
}
}
else
{ {
out_mem[i] = A[i] / k; 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 = A.at(row,col,slice) / k; ++out_mem;
}
} }
} }
//! @} //! @}
 End of changes. 18 change blocks. 
19 lines changed or deleted 114 lines changed or added


 op_diagmat_meat.hpp   op_diagmat_meat.hpp 
skipping to change at line 105 skipping to change at line 105
arma_debug_check( (n_rows != n_cols), "diagmat(): given matrix is not square" ); arma_debug_check( (n_rows != n_cols), "diagmat(): given matrix is not square" );
if( (Proxy<T1>::has_subview == false) && (Proxy<T1>::fake_mat == fals e) ) if( (Proxy<T1>::has_subview == false) && (Proxy<T1>::fake_mat == fals e) )
{ {
// NOTE: we have aliasing and it's not due to a subview, hence we'r e assuming that the output matrix already has the correct size // NOTE: we have aliasing and it's not due to a subview, hence we'r e assuming that the output matrix already has the correct size
for(uword i=0; i < n_rows; ++i) for(uword i=0; i < n_rows; ++i)
{ {
const eT val = P.at(i,i); const eT val = P.at(i,i);
arrayops::inplace_set(out.colptr(i), eT(0), n_rows); arrayops::fill_zeros(out.colptr(i), n_rows);
out.at(i,i) = val; out.at(i,i) = val;
} }
} }
else else
{ {
podarray<eT> tmp(n_rows); podarray<eT> tmp(n_rows);
eT* tmp_mem = tmp.memptr(); eT* tmp_mem = tmp.memptr();
for(uword i=0; i < n_rows; ++i) { tmp_mem[i] = P.at(i,i); } for(uword i=0; i < n_rows; ++i) { tmp_mem[i] = P.at(i,i); }
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 op_fft_meat.hpp   op_fft_meat.hpp 
skipping to change at line 59 skipping to change at line 59
if( (N_user == 1) && (N_orig >= 1) ) if( (N_user == 1) && (N_orig >= 1) )
{ {
out[0] = out_eT( P[0] ); out[0] = out_eT( P[0] );
return; return;
} }
podarray<out_eT> data(N_user); podarray<out_eT> data(N_user);
out_eT* data_mem = data.memptr(); out_eT* data_mem = data.memptr();
if(N_user > N_orig) { arrayops::inplace_set( &data_mem[N_orig], out_eT (0), (N_user - N_orig) ); } if(N_user > N_orig) { arrayops::fill_zeros( &data_mem[N_orig], (N_user - N_orig) ); }
const uword N = (std::min)(N_user, N_orig); const uword N = (std::min)(N_user, N_orig);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type X = P.get_ea(); typename Proxy<T1>::ea_type X = P.get_ea();
for(uword i=0; i < N; ++i) { data_mem[i] = out_eT( X[i], in_eT(0) ); } for(uword i=0; i < N; ++i) { data_mem[i] = out_eT( X[i], in_eT(0) ); }
} }
else else
skipping to change at line 106 skipping to change at line 106
{ {
for(uword col=0; col < n_cols; ++col) { out.at(0,col) = out_eT( P.at (0,col) ); } for(uword col=0; col < n_cols; ++col) { out.at(0,col) = out_eT( P.at (0,col) ); }
return; return;
} }
podarray<out_eT> data(N_user); podarray<out_eT> data(N_user);
out_eT* data_mem = data.memptr(); out_eT* data_mem = data.memptr();
if(N_user > N_orig) { arrayops::inplace_set( &data_mem[N_orig], out_eT (0), (N_user - N_orig) ); } if(N_user > N_orig) { arrayops::fill_zeros( &data_mem[N_orig], (N_user - N_orig) ); }
const uword N = (std::min)(N_user, N_orig); const uword N = (std::min)(N_user, N_orig);
for(uword col=0; col < n_cols; ++col) for(uword col=0; col < n_cols; ++col)
{ {
for(uword i=0; i < N; ++i) { data_mem[i] = P.at(i, col); } for(uword i=0; i < N; ++i) { data_mem[i] = P.at(i, col); }
worker.run( out.colptr(col), data_mem ); worker.run( out.colptr(col), data_mem );
} }
} }
skipping to change at line 189 skipping to change at line 189
out[0] = P[0]; out[0] = P[0];
return; return;
} }
if( (N_user > N_orig) || (is_Mat<typename Proxy<T1>::stored_type>::valu e == false) ) if( (N_user > N_orig) || (is_Mat<typename Proxy<T1>::stored_type>::valu e == false) )
{ {
podarray<eT> data(N_user); podarray<eT> data(N_user);
eT* data_mem = data.memptr(); eT* data_mem = data.memptr();
if(N_user > N_orig) { arrayops::inplace_set( &data_mem[N_orig], eT(0 ), (N_user - N_orig) ); } if(N_user > N_orig) { arrayops::fill_zeros( &data_mem[N_orig], (N_us er - N_orig) ); }
op_fft_cx::copy_vec( data_mem, P, (std::min)(N_user, N_orig) ); op_fft_cx::copy_vec( data_mem, P, (std::min)(N_user, N_orig) );
worker.run( out.memptr(), data_mem ); worker.run( out.memptr(), data_mem );
} }
else else
{ {
const unwrap< typename Proxy<T1>::stored_type > tmp(P.Q); const unwrap< typename Proxy<T1>::stored_type > tmp(P.Q);
worker.run( out.memptr(), tmp.M.memptr() ); worker.run( out.memptr(), tmp.M.memptr() );
skipping to change at line 227 skipping to change at line 227
return; return;
} }
if( (N_user > N_orig) || (is_Mat<typename Proxy<T1>::stored_type>::valu e == false) ) if( (N_user > N_orig) || (is_Mat<typename Proxy<T1>::stored_type>::valu e == false) )
{ {
podarray<eT> data(N_user); podarray<eT> data(N_user);
eT* data_mem = data.memptr(); eT* data_mem = data.memptr();
if(N_user > N_orig) { arrayops::inplace_set( &data_mem[N_orig], eT(0 ), (N_user - N_orig) ); } if(N_user > N_orig) { arrayops::fill_zeros( &data_mem[N_orig], (N_us er - N_orig) ); }
const uword N = (std::min)(N_user, N_orig); const uword N = (std::min)(N_user, N_orig);
for(uword col=0; col < n_cols; ++col) for(uword col=0; col < n_cols; ++col)
{ {
for(uword i=0; i < N; ++i) { data_mem[i] = P.at(i, col); } for(uword i=0; i < N; ++i) { data_mem[i] = P.at(i, col); }
worker.run( out.colptr(col), data_mem ); worker.run( out.colptr(col), data_mem );
} }
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 op_htrans_bones.hpp   op_htrans_bones.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \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_hot arma_inline static void apply_noalias(Mat<eT>& out, const Mat<eT >& A, const typename arma_not_cx<eT>::result* junk = 0); arma_hot arma_inline static void apply_mat_noalias(Mat<eT>& out, const Ma t<eT>& A, const typename arma_not_cx<eT>::result* junk = 0);
template<typename eT> template<typename eT>
arma_hot inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_only<eT>::result* junk = 0); arma_hot inline static void apply_mat_noalias(Mat<eT>& out, const Ma t<eT>& A, const typename arma_cx_only<eT>::result* junk = 0);
// //
template<typename eT> template<typename eT>
arma_hot arma_inline static void apply(Mat<eT>& out, const Mat<eT>& A, co nst typename arma_not_cx<eT>::result* junk = 0); arma_hot arma_inline static void apply_mat_inplace(Mat<eT>& out, const ty pename arma_not_cx<eT>::result* junk = 0);
template<typename eT> template<typename eT>
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const t arma_hot inline static void apply_mat_inplace(Mat<eT>& out, const ty
ypename arma_cx_only<eT>::result* junk = 0); pename arma_cx_only<eT>::result* junk = 0);
//
template<typename eT>
arma_hot arma_inline static void apply_mat(Mat<eT>& out, const Mat<eT>& A
, const typename arma_not_cx<eT>::result* junk = 0);
template<typename eT>
arma_hot inline static void apply_mat(Mat<eT>& out, const Mat<eT>& A
, const typename arma_cx_only<eT>::result* junk = 0);
// //
template<typename T1> template<typename T1>
arma_hot inline static void apply_proxy(Mat<typename T1::elem_type>& out, const T1& X); arma_hot inline static void apply_proxy(Mat<typename T1::elem_type>& out, const T1& X);
// //
template<typename T1> template<typename T1>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_not_cx<typename T1::elem_type>:: result* junk = 0); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_not_cx<typename T1::elem_type>:: result* junk = 0);
 End of changes. 5 change blocks. 
7 lines changed or deleted 17 lines changed or added


 op_htrans_meat.hpp   op_htrans_meat.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2012 Ryan Curtin // Copyright (C) 2012 Ryan Curtin
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_htrans //! \addtogroup op_htrans
//! @{ //! @{
template<typename eT> template<typename eT>
arma_hot 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_mat_noalias(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_noalias(out, A); op_strans::apply_mat_noalias(out, A);
} }
template<typename eT> template<typename eT>
arma_hot 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_mat_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_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;
out.set_size(A_n_cols, A_n_rows); out.set_size(A_n_cols, A_n_rows);
if( (A_n_cols == 1) || (A_n_rows == 1) ) if( (A_n_cols == 1) || (A_n_rows == 1) )
skipping to change at line 69 skipping to change at line 69
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_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_inplace(Mat<eT>& out, 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_mat_inplace(out);
} }
template<typename eT> template<typename eT>
arma_hot 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_inplace(Mat<eT>& out, const typename arma_cx_only<eT>: :result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
if(&out != &A) const uword n_rows = out.n_rows;
{ const uword n_cols = out.n_cols;
op_htrans::apply_noalias(out, A);
} if(n_rows == n_cols)
else
{ {
const uword n_rows = out.n_rows; arma_extra_debug_print("doing in-place hermitian transpose of a square
const uword n_cols = out.n_cols; matrix");
if(n_rows == n_cols) for(uword col=0; col < n_cols; ++col)
{ {
arma_extra_debug_print("doing in-place hermitian transpose of a squar e matrix"); eT* coldata = out.colptr(col);
for(uword col=0; col < n_cols; ++col) out.at(col,col) = std::conj( out.at(col,col) );
{
eT* coldata = out.colptr(col);
out.at(col,col) = std::conj( out.at(col,col) ); for(uword row=(col+1); row < n_rows; ++row)
{
const eT val1 = std::conj(coldata[row]);
const eT val2 = std::conj(out.at(col,row));
for(uword row=(col+1); row < n_rows; ++row) out.at(col,row) = val1;
{ coldata[row] = val2;
const eT val1 = std::conj(coldata[row]);
const eT val2 = std::conj(out.at(col,row));
out.at(col,row) = val1;
coldata[row] = val2;
}
} }
} }
else }
{ else
Mat<eT> tmp; {
op_htrans::apply_noalias(tmp, A); Mat<eT> tmp;
out.steal_mem(tmp); op_htrans::apply_mat_noalias(tmp, out);
}
out.steal_mem(tmp);
} }
}
template<typename eT>
arma_hot
arma_inline
void
op_htrans::apply_mat(Mat<eT>& out, const Mat<eT>& A, const typename arma_no
t_cx<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
op_strans::apply_mat(out, A);
}
template<typename eT>
arma_hot
inline
void
op_htrans::apply_mat(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx
_only<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
if(&out != &A)
{
op_htrans::apply_mat_noalias(out, A);
}
else
{
op_htrans::apply_mat_inplace(out);
}
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
op_htrans::apply_proxy(Mat<typename T1::elem_type>& out, const T1& X) op_htrans::apply_proxy(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 Proxy<T1> P(X); const Proxy<T1> P(X);
// allow detection of in-place transpose // allow detection of in-place transpose
if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) && (Proxy<T1 >::fake_mat == false) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) && (Proxy<T1 >::fake_mat == false) )
{ {
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
op_htrans::apply(out, tmp.M); op_htrans::apply_mat(out, tmp.M);
} }
else else
{ {
const uword n_rows = P.get_n_rows(); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols(); const uword n_cols = P.get_n_cols();
const bool is_alias = P.is_alias(out); const bool is_alias = P.is_alias(out);
if( (resolves_to_vector<T1>::value == true) && (Proxy<T1>::prefer_at_ac cessor == false) ) if( (resolves_to_vector<T1>::value == true) && (Proxy<T1>::prefer_at_ac cessor == false) )
{ {
 End of changes. 19 change blocks. 
36 lines changed or deleted 63 lines changed or added


 op_pinv_bones.hpp   op_pinv_bones.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_pinv //! \addtogroup op_pinv
//! @{ //! @{
class op_pinv class op_pinv
{ {
public: public:
template<typename eT> inline static void direct_pinv(Mat<eT>& out, const
Mat<eT>& A, const eT in_tol);
template<typename T1> inline static void apply(Mat<typename T1::elem_type >& out, const Op<T1,op_pinv>& in); template<typename T1> inline static void apply(Mat<typename T1::elem_type >& out, const Op<T1,op_pinv>& in);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
5 lines changed or deleted 2 lines changed or added


 op_pinv_meat.hpp   op_pinv_meat.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_pinv //! \addtogroup op_pinv
//! @{ //! @{
template<typename eT> template<typename T1>
inline inline
void void
op_pinv::direct_pinv(Mat<eT>& out, const Mat<eT>& A, const eT in_tol) op_pinv::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pinv>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename T1::elem_type eT;
typedef typename get_pod_type<eT>::result T;
T tol = access::tmp_real(in_tol); const bool use_divide_and_conquer = (in.aux_uword_a == 1);
T tol = access::tmp_real(in.aux);
arma_debug_check((tol < T(0)), "pinv(): tolerance must be >= 0"); arma_debug_check((tol < T(0)), "pinv(): tolerance must be >= 0");
const uword n_rows = A.n_rows; const Proxy<T1> P(in.m);
const uword n_cols = A.n_cols;
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if( (n_rows*n_cols) == 0 )
{
out.set_size(n_cols,n_rows);
return;
}
// economical SVD decomposition // economical SVD decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
Mat<eT> V; Mat<eT> V;
const bool status = (n_cols > n_rows) ? auxlib::svd_econ(U,s,V,trans(A),' bool status = false;
b') : auxlib::svd_econ(U,s,V,A,'b');
if(use_divide_and_conquer)
{
status = (n_cols > n_rows) ? auxlib::svd_dc_econ(U, s, V, trans(P.Q)) :
auxlib::svd_dc_econ(U, s, V, P.Q);
}
else
{
status = (n_cols > n_rows) ? auxlib::svd_econ(U, s, V, trans(P.Q), 'b')
: auxlib::svd_econ(U, s, V, P.Q, 'b');
}
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("pinv(): svd failed"); arma_bad("pinv(): svd failed");
return; return;
} }
const uword s_n_elem = s.n_elem; const uword s_n_elem = s.n_elem;
const T* s_mem = s.memptr(); const T* s_mem = s.memptr();
skipping to change at line 58 skipping to change at line 78
{ {
tol = (std::max)(n_rows, n_cols) * eop_aux::direct_eps( op_max::direct_ max(s_mem, s_n_elem) ); tol = (std::max)(n_rows, n_cols) * eop_aux::direct_eps( op_max::direct_ max(s_mem, s_n_elem) );
} }
// count non zero valued elements in s // count non zero valued elements in s
uword count = 0; uword count = 0;
for(uword i = 0; i < s_n_elem; ++i) for(uword i = 0; i < s_n_elem; ++i)
{ {
if(s_mem[i] > tol) if(s_mem[i] > tol) { ++count; }
{
++count;
}
} }
if(count != 0) if(count > 0)
{ {
Col<T> s2(count); Col<T> s2(count);
T* s2_mem = s2.memptr(); T* s2_mem = s2.memptr();
uword count2 = 0; uword count2 = 0;
for(uword i=0; i < s_n_elem; ++i) for(uword i=0; i < s_n_elem; ++i)
{ {
const T val = s_mem[i]; const T val = s_mem[i];
if(val > tol) if(val > tol) { s2_mem[count2] = T(1) / val; ++count2; }
{
s2_mem[count2] = T(1) / val;
++count2;
}
} }
if(n_rows >= n_cols) if(n_rows >= n_cols)
{ {
out = ( V.n_cols > count ? V.cols(0,count-1) : V ) * diagmat(s2) * tr ans( U.n_cols > count ? U.cols(0,count-1) : U ); out = ( (V.n_cols > count) ? V.cols(0,count-1) : V ) * diagmat(s2) * trans( (U.n_cols > count) ? U.cols(0,count-1) : U );
} }
else else
{ {
out = ( U.n_cols > count ? U.cols(0,count-1) : U ) * diagmat(s2) * tr ans( V.n_cols > count ? V.cols(0,count-1) : V ); out = ( (U.n_cols > count) ? U.cols(0,count-1) : U ) * diagmat(s2) * trans( (V.n_cols > count) ? V.cols(0,count-1) : V );
} }
} }
else else
{ {
out.zeros(n_cols, n_rows); out.zeros(n_cols, n_rows);
} }
} }
template<typename T1>
inline
void
op_pinv::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_pinv>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
op_pinv::direct_pinv(out, A, in.aux);
}
//! @} //! @}
 End of changes. 13 change blocks. 
37 lines changed or deleted 36 lines changed or added


 op_princomp_meat.hpp   op_princomp_meat.hpp 
// Copyright (C) 2010-2012 Conrad Sanderson // Copyright (C) 2010-2013 Conrad Sanderson
// Copyright (C) 2010-2012 NICTA (www.nicta.com.au) // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Dimitrios Bouzas // Copyright (C) 2010 Dimitrios Bouzas
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_princomp //! \addtogroup op_princomp
//! @{ //! @{
skipping to change at line 47 skipping to change at line 47
const unwrap_check<T1> Y( X.get_ref(), score_out ); const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M; 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; score_out.each_row() -= mean(in);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
const bool svd_ok = svd(U,s,coeff_out,score_out); const bool svd_ok = svd(U, s, coeff_out, score_out);
if(svd_ok == false) if(svd_ok == false) { return false; }
{
return false;
}
//U.reset(); // TODO: do we need this ? U will get automatically dele
ted anyway
// normalize the eigenvalues // normalize the eigenvalues
s /= std::sqrt( double(n_rows - 1) ); s /= std::sqrt( double(n_rows - 1) );
// project the samples to the principals // project the samples to the principals
score_out *= coeff_out; score_out *= coeff_out;
if(n_rows <= n_cols) // number of samples is less than their dimensiona lity if(n_rows <= n_cols) // number of samples is less than their dimensiona lity
{ {
score_out.cols(n_rows-1,n_cols-1).zeros(); score_out.cols(n_rows-1,n_cols-1).zeros();
skipping to change at line 144 skipping to change at line 139
const unwrap_check<T1> Y( X.get_ref(), score_out ); const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M; 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; score_out.each_row() -= mean(in);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
const bool svd_ok = svd(U,s,coeff_out,score_out); const bool svd_ok = svd(U, s, coeff_out, score_out);
if(svd_ok == false) if(svd_ok == false) { return false; }
{
return false;
}
// U.reset();
// normalize the eigenvalues // normalize the eigenvalues
s /= std::sqrt( double(n_rows - 1) ); s /= std::sqrt( double(n_rows - 1) );
// project the samples to the principals // project the samples to the principals
score_out *= coeff_out; score_out *= coeff_out;
if(n_rows <= n_cols) // number of samples is less than their dimensiona lity if(n_rows <= n_cols) // number of samples is less than their dimensiona lity
{ {
score_out.cols(n_rows-1,n_cols-1).zeros(); score_out.cols(n_rows-1,n_cols-1).zeros();
skipping to change at line 222 skipping to change at line 212
const unwrap_check<T1> Y( X.get_ref(), score_out ); const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M; 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; score_out.each_row() -= mean(in);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<eT> s; Col<eT> s;
const bool svd_ok = svd(U,s,coeff_out,score_out); const bool svd_ok = svd(U, s, coeff_out, score_out);
if(svd_ok == false)
{
return false;
}
// U.reset(); if(svd_ok == false) { return false; }
// normalize the eigenvalues // normalize the eigenvalues
s /= std::sqrt( double(n_rows - 1) ); s /= std::sqrt( double(n_rows - 1) );
// project the samples to the principals // project the samples to the principals
score_out *= coeff_out; score_out *= coeff_out;
if(n_rows <= n_cols) // number of samples is less than their dimensiona lity if(n_rows <= n_cols) // number of samples is less than their dimensiona lity
{ {
score_out.cols(n_rows-1,n_cols-1).zeros(); score_out.cols(n_rows-1,n_cols-1).zeros();
skipping to change at line 286 skipping to change at line 271
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> Y( X.get_ref() ); const unwrap<T1> Y( X.get_ref() );
const Mat<eT>& in = Y.M; const Mat<eT>& in = Y.M;
if(in.n_elem != 0) if(in.n_elem != 0)
{ {
Mat<eT> tmp = in; tmp.each_row() -= mean(in);
// 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 bool svd_ok = svd(U, s, coeff_out, tmp);
const bool svd_ok = svd(U,s,coeff_out, tmp);
if(svd_ok == false) if(svd_ok == false) { return false; }
{
return false;
}
} }
else else
{ {
coeff_out.eye(in.n_cols, in.n_cols); coeff_out.eye(in.n_cols, in.n_cols);
} }
return true; return true;
} }
//! \brief //! \brief
skipping to change at line 342 skipping to change at line 324
const unwrap_check<T1> Y( X.get_ref(), score_out ); const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M; 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; score_out.each_row() -= mean(in);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col<T> s; Col< T> s;
const bool svd_ok = svd(U,s,coeff_out,score_out);
if(svd_ok == false) const bool svd_ok = svd(U, s, coeff_out, score_out);
{
return false;
}
//U.reset(); if(svd_ok == false) { return false; }
// normalize the eigenvalues // normalize the eigenvalues
s /= std::sqrt( double(n_rows - 1) ); s /= std::sqrt( double(n_rows - 1) );
// project the samples to the principals // project the samples to the principals
score_out *= coeff_out; score_out *= coeff_out;
if(n_rows <= n_cols) // number of samples is less than their dimensiona lity if(n_rows <= n_cols) // number of samples is less than their dimensiona lity
{ {
score_out.cols(n_rows-1,n_cols-1).zeros(); score_out.cols(n_rows-1,n_cols-1).zeros();
skipping to change at line 437 skipping to change at line 414
const unwrap_check<T1> Y( X.get_ref(), score_out ); const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M; 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; score_out.each_row() -= mean(in);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
const bool svd_ok = svd(U,s,coeff_out,score_out); const bool svd_ok = svd(U, s, coeff_out, score_out);
if(svd_ok == false) if(svd_ok == false) { return false; }
{
return false;
}
// U.reset();
// normalize the eigenvalues // normalize the eigenvalues
s /= std::sqrt( double(n_rows - 1) ); s /= std::sqrt( double(n_rows - 1) );
// project the samples to the principals // project the samples to the principals
score_out *= coeff_out; score_out *= coeff_out;
if(n_rows <= n_cols) // number of samples is less than their dimensiona lity if(n_rows <= n_cols) // number of samples is less than their dimensiona lity
{ {
score_out.cols(n_rows-1,n_cols-1).zeros(); score_out.cols(n_rows-1,n_cols-1).zeros();
Col<T> s_tmp = zeros< Col<T> >(n_cols); Col<T> s_tmp = zeros< Col<T> >(n_cols);
s_tmp.rows(0,n_rows-2) = s.rows(0,n_rows-2); s_tmp.rows(0,n_rows-2) = s.rows(0,n_rows-2);
s = s_tmp; s = s_tmp;
} }
// compute the eigenvalues of the principal vectors // compute the eigenvalues of the principal vectors
latent_out = s%s; latent_out = s%s;
} }
else // 0 or 1 samples else // 0 or 1 samples
{ {
coeff_out.eye(n_cols, n_cols); coeff_out.eye(n_cols, n_cols);
score_out.copy_size(in); score_out.copy_size(in);
score_out.zeros(); score_out.zeros();
latent_out.set_size(n_cols); latent_out.set_size(n_cols);
latent_out.zeros(); latent_out.zeros();
skipping to change at line 516 skipping to change at line 487
const unwrap_check<T1> Y( X.get_ref(), score_out ); const unwrap_check<T1> Y( X.get_ref(), score_out );
const Mat<eT>& in = Y.M; 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; score_out.each_row() -= mean(in);
// singular value decomposition // singular value decomposition
Mat<eT> U; Mat<eT> U;
Col< T> s; Col< T> s;
const bool svd_ok = svd(U,s,coeff_out,score_out); const bool svd_ok = svd(U, s, coeff_out, score_out);
if(svd_ok == false) if(svd_ok == false) { return false; }
{
return false;
}
// U.reset();
// normalize the eigenvalues // normalize the eigenvalues
s /= std::sqrt( double(n_rows - 1) ); s /= std::sqrt( double(n_rows - 1) );
// project the samples to the principals // project the samples to the principals
score_out *= coeff_out; score_out *= coeff_out;
if(n_rows <= n_cols) // number of samples is less than their dimensiona lity if(n_rows <= n_cols) // number of samples is less than their dimensiona lity
{ {
score_out.cols(n_rows-1,n_cols-1).zeros(); score_out.cols(n_rows-1,n_cols-1).zeros();
skipping to change at line 579 skipping to change at line 545
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef std::complex<T> eT; typedef std::complex<T> eT;
const unwrap<T1> Y( X.get_ref() ); const unwrap<T1> Y( X.get_ref() );
const Mat<eT>& in = Y.M; 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); Mat<eT> tmp = in; tmp.each_row() -= mean(in);
const bool svd_ok = svd(U,s,coeff_out, tmp); const bool svd_ok = svd(U, s, coeff_out, tmp);
if(svd_ok == false) if(svd_ok == false) { return false; }
{
return false;
}
} }
else else
{ {
coeff_out.eye(in.n_cols, in.n_cols); coeff_out.eye(in.n_cols, in.n_cols);
} }
return true; return true;
} }
template<typename T1> template<typename T1>
 End of changes. 28 change blocks. 
68 lines changed or deleted 30 lines changed or added


 op_shuffle_meat.hpp   op_shuffle_meat.hpp 
skipping to change at line 38 skipping to change at line 38
arma_debug_check( (dim > 1), "shuffle(): dim must be 0 or 1" ); arma_debug_check( (dim > 1), "shuffle(): dim must be 0 or 1" );
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" // see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet"
// and the associated comparison functor // and the associated comparison functor
std::vector< arma_sort_index_packet<int,uword> > packet_vec(N); std::vector< arma_sort_index_packet<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 = int(arma_rng::randi<int>());
packet_vec[i].index = i; packet_vec[i].index = i;
} }
arma_sort_index_helper_ascend comparator; arma_sort_index_helper_ascend comparator;
std::sort( packet_vec.begin(), packet_vec.end(), comparator ); std::sort( packet_vec.begin(), packet_vec.end(), comparator );
const bool is_alias = (&out == &X); const bool is_alias = (&out == &X);
if(X.is_vec() == false) if(X.is_vec() == false)
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 op_strans_bones.hpp   op_strans_bones.hpp 
skipping to change at line 26 skipping to change at line 26
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, typename TA> template<typename eT, typename TA>
arma_hot inline static void apply_noalias_tinysq(Mat<eT>& out, const TA& A); arma_hot inline static void apply_mat_noalias_tinysq(Mat<eT>& out, const TA& A);
template<typename eT, typename TA> template<typename eT, typename TA>
arma_hot inline static void apply_noalias(Mat<eT>& out, const TA& A); arma_hot inline static void apply_mat_noalias(Mat<eT>& out, const TA& A);
template<typename eT>
arma_hot inline static void apply_mat_inplace(Mat<eT>& out);
template<typename eT, typename TA> template<typename eT, typename TA>
arma_hot inline static void apply(Mat<eT>& out, const TA& A); arma_hot inline static void apply_mat(Mat<eT>& out, const TA& A);
template<typename T1> template<typename T1>
arma_hot inline static void apply_proxy(Mat<typename T1::elem_type>& out, const T1& X); arma_hot inline static void apply_proxy(Mat<typename T1::elem_type>& out, const T1& X);
template<typename T1> template<typename T1>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_strans>& in); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_strans>& in);
}; };
class op_strans2 class op_strans2
{ {
 End of changes. 3 change blocks. 
3 lines changed or deleted 6 lines changed or added


 op_strans_meat.hpp   op_strans_meat.hpp 
skipping to change at line 17 skipping to change at line 17
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_strans //! \addtogroup op_strans
//! @{ //! @{
//! for tiny square matrices (size <= 4x4) //! for tiny square matrices (size <= 4x4)
template<typename eT, typename TA> template<typename eT, typename TA>
arma_hot arma_hot
inline inline
void void
op_strans::apply_noalias_tinysq(Mat<eT>& out, const TA& A) op_strans::apply_mat_noalias_tinysq(Mat<eT>& out, const TA& 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:
{ {
outm[0] = Am[0]; outm[0] = Am[0];
} }
skipping to change at line 91 skipping to change at line 91
; ;
} }
} }
//! Immediate transpose of a dense matrix //! Immediate transpose of a dense matrix
template<typename eT, typename TA> template<typename eT, typename TA>
arma_hot arma_hot
inline inline
void void
op_strans::apply_noalias(Mat<eT>& out, const TA& A) op_strans::apply_mat_noalias(Mat<eT>& out, const TA& 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);
if( (TA::is_row) || (TA::is_col) || (A_n_cols == 1) || (A_n_rows == 1) ) if( (TA::is_row) || (TA::is_col) || (A_n_cols == 1) || (A_n_rows == 1) )
{ {
arrayops::copy( out.memptr(), A.memptr(), A.n_elem ); arrayops::copy( out.memptr(), A.memptr(), A.n_elem );
} }
else else
{ {
if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) )
{ {
op_strans::apply_noalias_tinysq(out, A); op_strans::apply_mat_noalias_tinysq(out, A);
} }
else else
{ {
for(uword k=0; k < A_n_cols; ++k) for(uword k=0; k < A_n_cols; ++k)
{ {
uword i, j; uword i, j;
const eT* colptr = A.colptr(k); const eT* colptr = A.colptr(k);
for(i=0, j=1; j < A_n_rows; i+=2, j+=2) for(i=0, j=1; j < A_n_rows; i+=2, j+=2)
skipping to change at line 136 skipping to change at line 136
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, typename TA> template<typename eT>
arma_hot arma_hot
inline inline
void void
op_strans::apply(Mat<eT>& out, const TA& A) op_strans::apply_mat_inplace(Mat<eT>& out)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(&out != &A) const uword n_rows = out.n_rows;
{ const uword n_cols = out.n_cols;
op_strans::apply_noalias(out, A);
} if(n_rows == n_cols)
else
{ {
const uword n_rows = A.n_rows; arma_extra_debug_print("op_strans::apply(): doing in-place transpose of
const uword n_cols = A.n_cols; a square matrix");
const uword N = n_rows;
if(n_rows == n_cols) for(uword k=0; k < N; ++k)
{ {
arma_extra_debug_print("op_strans::apply(): doing in-place transpose of a square matrix"); eT* colptr = out.colptr(k);
const uword N = n_rows; uword i,j;
for(uword k=0; k < N; ++k) for(i=(k+1), j=(k+2); j < N; i+=2, j+=2)
{ {
eT* colptr = out.colptr(k); std::swap(out.at(k,i), colptr[i]);
std::swap(out.at(k,j), colptr[j]);
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) if(i < N)
{ {
std::swap(out.at(k,i), colptr[i]); std::swap(out.at(k,i), colptr[i]);
}
} }
} }
else }
{ else
Mat<eT> tmp; {
op_strans::apply_noalias(tmp, A); Mat<eT> tmp;
out.steal_mem(tmp); op_strans::apply_mat_noalias(tmp, out);
}
out.steal_mem(tmp);
}
}
template<typename eT, typename TA>
arma_hot
inline
void
op_strans::apply_mat(Mat<eT>& out, const TA& A)
{
arma_extra_debug_sigprint();
if(&out != &A)
{
op_strans::apply_mat_noalias(out, A);
}
else
{
op_strans::apply_mat_inplace(out);
} }
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
op_strans::apply_proxy(Mat<typename T1::elem_type>& out, const T1& X) op_strans::apply_proxy(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 Proxy<T1> P(X); const Proxy<T1> P(X);
// allow detection of in-place transpose // allow detection of in-place transpose
if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) && (Proxy<T1 >::fake_mat == false) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) && (Proxy<T1 >::fake_mat == false) )
{ {
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
op_strans::apply(out, tmp.M); op_strans::apply_mat(out, tmp.M);
} }
else else
{ {
const uword n_rows = P.get_n_rows(); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols(); const uword n_cols = P.get_n_cols();
const bool is_alias = P.is_alias(out); const bool is_alias = P.is_alias(out);
if( (resolves_to_vector<T1>::value == true) && (Proxy<T1>::prefer_at_ac cessor == false) ) if( (resolves_to_vector<T1>::value == true) && (Proxy<T1>::prefer_at_ac cessor == false) )
{ {
 End of changes. 16 change blocks. 
36 lines changed or deleted 49 lines changed or added


 podarray_meat.hpp   podarray_meat.hpp 
skipping to change at line 323 skipping to change at line 323
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(new_n_elem <= podarray_prealloc_n_elem::val ) if(new_n_elem <= podarray_prealloc_n_elem::val )
{ {
mem = mem_local; mem = mem_local;
} }
else else
{ {
mem = memory::acquire<eT>(new_n_elem); mem = memory::acquire<eT>(new_n_elem);
arma_check_bad_alloc( (mem == 0), "arma::podarray: out of memory" );
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::init_warm(const uword new_n_elem) podarray<eT>::init_warm(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 352 skipping to change at line 350
memory::release( mem ); memory::release( mem );
} }
if(new_n_elem <= podarray_prealloc_n_elem::val ) if(new_n_elem <= podarray_prealloc_n_elem::val )
{ {
mem = mem_local; mem = mem_local;
} }
else else
{ {
mem = memory::acquire<eT>(new_n_elem); mem = memory::acquire<eT>(new_n_elem);
arma_check_bad_alloc( (mem == 0), "arma::podarray: out of memory" );
} }
access::rw(n_elem) = new_n_elem; access::rw(n_elem) = new_n_elem;
} }
//! @} //! @}
 End of changes. 2 change blocks. 
4 lines changed or deleted 0 lines changed or added


 running_stat_bones.hpp   running_stat_bones.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup running_stat //! \addtogroup running_stat
//! @{ //! @{
template<typename eT> template<typename eT>
class arma_counter class arma_counter
skipping to change at line 86 skipping to change at line 86
arma_aligned T max_val_norm; arma_aligned T max_val_norm;
friend class running_stat_aux; friend class running_stat_aux;
}; };
class running_stat_aux class running_stat_aux
{ {
public: public:
template<typename eT> template<typename eT>
inline static void update_stats(running_stat<eT>& x, const eT sample); inline static void update_stats(running_stat<eT>& x, const eT sample, con st typename arma_not_cx<eT>::result* junk = 0);
template<typename T> template<typename eT>
inline static void update_stats(running_stat< std::complex<T> >& x, const inline static void update_stats(running_stat<eT>& x, const std::complex<e
T sample); T>& sample, const typename arma_not_cx<eT>::result* junk = 0);
template<typename T> template<typename eT>
inline static void update_stats(running_stat< std::complex<T> >& x, const inline static void update_stats(running_stat<eT>& x, const typename eT::v
std::complex<T>& sample); alue_type sample, const typename arma_cx_only<eT>::result* junk = 0);
template<typename eT>
inline static void update_stats(running_stat<eT>& x, const eT& sample, co
nst typename arma_cx_only<eT>::result* junk = 0);
}; };
//! @} //! @}
 End of changes. 5 change blocks. 
9 lines changed or deleted 12 lines changed or added


 running_stat_meat.hpp   running_stat_meat.hpp 
skipping to change at line 145 skipping to change at line 145
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for complex numbers)
template<typename eT> template<typename eT>
inline inline
void void
running_stat<eT>::operator() (const std::complex< typename running_stat<eT> ::T >& sample) running_stat<eT>::operator() (const std::complex< typename running_stat<eT> ::T >& sample)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type<eT, std::complex< typename running_stat<eT
>::T > >::no ));
if( arma_isfinite(sample) == false ) if( arma_isfinite(sample) == false )
{ {
arma_warn(true, "running_stat: sample ignored as it is non-finite" ); arma_warn(true, "running_stat: sample ignored as it is non-finite" );
return; return;
} }
running_stat_aux::update_stats(*this, sample); running_stat_aux::update_stats(*this, sample);
} }
//! set all statistics to zero //! set all statistics to zero
skipping to change at line 261 skipping to change at line 259
template<typename eT> template<typename eT>
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
running_stat<eT>::count() const running_stat<eT>::count() const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return counter.value(); return counter.value();
} }
//! update statistics to reflect new sample //! update statistics to reflect new sample (version for non-complex number s, non-complex sample)
template<typename eT> template<typename eT>
inline inline
void void
running_stat_aux::update_stats(running_stat<eT>& x, const eT sample) running_stat_aux::update_stats(running_stat<eT>& x, const eT sample, const typename arma_not_cx<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename running_stat<eT>::T T; typedef typename running_stat<eT>::T T;
const T N = x.counter.value(); const T N = x.counter.value();
if(N > T(0)) if(N > T(0))
{ {
if(sample < x.min_val) if(sample < x.min_val)
{ {
x.min_val = sample; x.min_val = sample;
skipping to change at line 311 skipping to change at line 310
x.min_val = sample; x.min_val = sample;
x.max_val = sample; x.max_val = sample;
// r_var is initialised to zero // r_var is initialised to zero
// in the constructor and reset() // in the constructor and reset()
} }
x.counter++; x.counter++;
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for non-complex number
template<typename T> s, complex sample)
template<typename eT>
inline
void
running_stat_aux::update_stats(running_stat<eT>& x, const std::complex<eT>&
sample, const typename arma_not_cx<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
running_stat_aux::update_stats(x, std::real(sample));
}
//! update statistics to reflect new sample (version for complex numbers, n
on-complex sample)
template<typename eT>
inline inline
void void
running_stat_aux::update_stats(running_stat< std::complex<T> >& x, const T sample) running_stat_aux::update_stats(running_stat<eT>& x, const typename eT::valu e_type sample, const typename arma_cx_only<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename eT::value_type T;
running_stat_aux::update_stats(x, std::complex<T>(sample)); running_stat_aux::update_stats(x, std::complex<T>(sample));
} }
//! alter statistics to reflect new sample (version for complex numbers) //! alter statistics to reflect new sample (version for complex numbers, co
template<typename T> mplex sample)
template<typename eT>
inline inline
void void
running_stat_aux::update_stats(running_stat< std::complex<T> >& x, const st d::complex<T>& sample) running_stat_aux::update_stats(running_stat<eT>& x, const eT& sample, const typename arma_cx_only<eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename eT::value_type T;
const T sample_norm = std::norm(sample); const T sample_norm = std::norm(sample);
const T N = x.counter.value(); const T N = x.counter.value();
if(N > T(0)) if(N > T(0))
{ {
if(sample_norm < x.min_val_norm) if(sample_norm < x.min_val_norm)
{ {
x.min_val_norm = sample_norm; x.min_val_norm = sample_norm;
x.min_val = sample; x.min_val = sample;
 End of changes. 10 change blocks. 
11 lines changed or deleted 31 lines changed or added


 running_stat_vec_bones.hpp   running_stat_vec_bones.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup running_stat_vec //! \addtogroup running_stat_vec
//! @{ //! @{
template<typename obj_type, bool> struct rsv_get_elem_type
{ };
template<typename obj_type> struct rsv_get_elem_type<obj_type, false>
{ typedef obj_type elem_type; };
template<typename obj_type> struct rsv_get_elem_type<obj_type, true>
{ typedef typename obj_type::elem_type elem_type; };
//! Class for keeping statistics of a continuously sampled process / signal . //! Class for keeping statistics of a continuously sampled process / signal .
//! Useful if the storage of individual samples is not necessary or desired . //! Useful if the storage of individual samples is not necessary or desired .
//! Also useful if the number of samples is not known beforehand or exceeds //! Also useful if the number of samples is not known beforehand or exceeds
//! available memory. //! available memory.
template<typename eT> template<typename obj_type>
class running_stat_vec class running_stat_vec
{ {
public: public:
// voodoo for compatibility with old user code
typedef typename rsv_get_elem_type<obj_type, is_Mat<obj_type>::value>::el
em_type eT;
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
inline ~running_stat_vec(); inline ~running_stat_vec();
inline running_stat_vec(const bool in_calc_cov = false); inline running_stat_vec(const bool in_calc_cov = false); // TODO: inves tigate char* overload, eg. "calc_cov", "no_calc_cov"
inline running_stat_vec(const running_stat_vec& in_rsv); inline running_stat_vec(const running_stat_vec& in_rsv);
inline const running_stat_vec& operator=(const running_stat_vec& in_rsv); inline const running_stat_vec& operator=(const running_stat_vec& in_rsv);
template<typename T1> arma_hot inline void operator() (const Base< template<typename T1> arma_hot inline void operator() (const Base<
T, T1>& X); T, T1>& X);
template<typename T1> arma_hot inline void operator() (const Base< std::c template<typename T1> arma_hot inline void operator() (const Base<std::co
omplex<T>, T1>& X); mplex<T>, T1>& X);
inline void reset(); inline void reset();
inline const Mat<eT>& mean() const; inline const Mat<eT>& mean() const;
inline const Mat< T>& var (const uword norm_type = 0); inline const Mat< T>& var (const uword norm_type = 0);
inline Mat< T> stddev(const uword norm_type = 0) const; inline Mat< T> stddev(const uword norm_type = 0) const;
inline const Mat<eT>& cov (const uword norm_type = 0); inline const Mat<eT>& cov (const uword norm_type = 0);
inline const Mat<eT>& min() const; inline const Mat<eT>& min() const;
skipping to change at line 77 skipping to change at line 84
arma_aligned Mat<eT> tmp1; arma_aligned Mat<eT> tmp1;
arma_aligned Mat<eT> tmp2; arma_aligned Mat<eT> tmp2;
friend class running_stat_vec_aux; friend class running_stat_vec_aux;
}; };
class running_stat_vec_aux class running_stat_vec_aux
{ {
public: public:
template<typename eT> template<typename obj_type>
inline static void update_stats(running_stat_vec< eT >& x, c inline static void
onst Mat<eT>& sample); update_stats
(
template<typename T> running_stat_vec<obj_type>& x,
inline static void update_stats(running_stat_vec< std::complex<T> >& x, c const Mat<typename running_stat_vec<obj_type>::eT>& sa
onst Mat< T>& sample); mple,
const typename arma_not_cx<typename running_stat_vec<obj_type>::eT>::re
template<typename T> sult* junk = 0
inline static void update_stats(running_stat_vec< std::complex<T> >& x, c );
onst Mat< std::complex<T> >& sample);
template<typename obj_type>
// inline static void
update_stats
template<typename eT> (
inline static Mat<eT> var(const running_stat_vec< eT >& x, c running_stat_vec<obj_type>& x,
onst uword norm_type = 0); const Mat<std::complex< typename running_stat_vec<obj_type>::T
> >& sample,
template<typename T> const typename arma_not_cx<typename running_stat_vec<obj_type>::e
inline static Mat< T> var(const running_stat_vec< std::complex<T> >& x, c T>::result* junk = 0
onst uword norm_type = 0); );
// template<typename obj_type>
inline static void
template<typename eT> update_stats
inline static Mat< eT > cov(const running_stat_vec< eT >& (
x, const uword norm_type = 0); running_stat_vec<obj_type>& x,
const Mat< typename running_stat_vec<obj_type>::T >& s
template<typename T> ample,
inline static Mat< std::complex<T> > cov(const running_stat_vec< std::com const typename arma_cx_only<typename running_stat_vec<obj_type>::eT>::r
plex<T> >& x, const uword norm_type = 0); esult* junk = 0
);
template<typename obj_type>
inline static void
update_stats
(
running_stat_vec<obj_type>& x,
const Mat<typename running_stat_vec<obj_type>::eT>& s
ample,
const typename arma_cx_only<typename running_stat_vec<obj_type>::eT>::r
esult* junk = 0
);
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
39 lines changed or deleted 62 lines changed or added


 running_stat_vec_meat.hpp   running_stat_vec_meat.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup running_stat_vec //! \addtogroup running_stat_vec
//! @{ //! @{
template<typename eT> template<typename obj_type>
running_stat_vec<eT>::~running_stat_vec() running_stat_vec<obj_type>::~running_stat_vec()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT> template<typename obj_type>
running_stat_vec<eT>::running_stat_vec(const bool in_calc_cov) running_stat_vec<obj_type>::running_stat_vec(const bool in_calc_cov)
: calc_cov(in_calc_cov) : calc_cov(in_calc_cov)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT> template<typename obj_type>
running_stat_vec<eT>::running_stat_vec(const running_stat_vec<eT>& in_rsv) running_stat_vec<obj_type>::running_stat_vec(const running_stat_vec<obj_typ
e>& in_rsv)
: calc_cov (in_rsv.calc_cov) : calc_cov (in_rsv.calc_cov)
, counter (in_rsv.counter) , counter (in_rsv.counter)
, r_mean (in_rsv.r_mean) , r_mean (in_rsv.r_mean)
, r_var (in_rsv.r_var) , r_var (in_rsv.r_var)
, r_cov (in_rsv.r_cov) , r_cov (in_rsv.r_cov)
, min_val (in_rsv.min_val) , min_val (in_rsv.min_val)
, max_val (in_rsv.max_val) , max_val (in_rsv.max_val)
, min_val_norm(in_rsv.min_val_norm) , min_val_norm(in_rsv.min_val_norm)
, max_val_norm(in_rsv.max_val_norm) , max_val_norm(in_rsv.max_val_norm)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT> template<typename obj_type>
const running_stat_vec<eT>& const running_stat_vec<obj_type>&
running_stat_vec<eT>::operator=(const running_stat_vec<eT>& in_rsv) running_stat_vec<obj_type>::operator=(const running_stat_vec<obj_type>& in_
rsv)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(calc_cov) = in_rsv.calc_cov; access::rw(calc_cov) = in_rsv.calc_cov;
counter = in_rsv.counter; counter = in_rsv.counter;
r_mean = in_rsv.r_mean; r_mean = in_rsv.r_mean;
r_var = in_rsv.r_var; r_var = in_rsv.r_var;
r_cov = in_rsv.r_cov; r_cov = in_rsv.r_cov;
min_val = in_rsv.min_val; min_val = in_rsv.min_val;
max_val = in_rsv.max_val; max_val = in_rsv.max_val;
min_val_norm = in_rsv.min_val_norm; min_val_norm = in_rsv.min_val_norm;
max_val_norm = in_rsv.max_val_norm; max_val_norm = in_rsv.max_val_norm;
return *this; return *this;
} }
//! update statistics to reflect new sample //! update statistics to reflect new sample
template<typename eT> template<typename obj_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
running_stat_vec<eT>::operator() (const Base<typename get_pod_type<eT>::res ult, T1>& X) running_stat_vec<obj_type>::operator() (const Base<typename running_stat_ve c<obj_type>::T, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//typedef typename get_pod_type<eT>::result T; const unwrap<T1> tmp(X.get_ref());
const Mat<T>& sample = tmp.M;
const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& sample = tmp.M;
if( sample.is_empty() ) if( sample.is_empty() )
{ {
return; return;
} }
if( sample.is_finite() == false ) if( sample.is_finite() == false )
{ {
arma_warn(true, "running_stat_vec: sample ignored as it has non-finite elements"); arma_warn(true, "running_stat_vec: sample ignored as it has non-finite elements");
return; return;
} }
running_stat_vec_aux::update_stats(*this, sample); running_stat_vec_aux::update_stats(*this, sample);
} }
//! update statistics to reflect new sample (version for complex numbers) template<typename obj_type>
template<typename eT>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
running_stat_vec<eT>::operator() (const Base<std::complex<typename get_pod_ type<eT>::result>, T1>& X) running_stat_vec<obj_type>::operator() (const Base< std::complex<typename r unning_stat_vec<obj_type>::T>, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//typedef typename std::complex<typename get_pod_type<eT>::result> eT; const unwrap<T1> tmp(X.get_ref());
const unwrap<T1> tmp(X.get_ref()); const Mat< std::complex<T> >& sample = tmp.M;
const Mat<eT>& sample = tmp.M;
if( sample.is_empty() ) if( sample.is_empty() )
{ {
return; return;
} }
if( sample.is_finite() == false ) if( sample.is_finite() == false )
{ {
arma_warn(true, "running_stat_vec: sample ignored as it has non-finite elements"); arma_warn(true, "running_stat_vec: sample ignored as it has non-finite elements");
return; return;
} }
running_stat_vec_aux::update_stats(*this, sample); running_stat_vec_aux::update_stats(*this, sample);
} }
//! set all statistics to zero //! set all statistics to zero
template<typename eT> template<typename obj_type>
inline inline
void void
running_stat_vec<eT>::reset() running_stat_vec<obj_type>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
counter.reset(); counter.reset();
r_mean.reset(); r_mean.reset();
r_var.reset(); r_var.reset();
r_cov.reset(); r_cov.reset();
min_val.reset(); min_val.reset();
skipping to change at line 145 skipping to change at line 141
max_val_norm.reset(); max_val_norm.reset();
r_var_dummy.reset(); r_var_dummy.reset();
r_cov_dummy.reset(); r_cov_dummy.reset();
tmp1.reset(); tmp1.reset();
tmp2.reset(); tmp2.reset();
} }
//! mean or average value //! mean or average value
template<typename eT> template<typename obj_type>
inline inline
const Mat<eT>& const Mat< typename running_stat_vec<obj_type>::eT >&
running_stat_vec<eT>::mean() const running_stat_vec<obj_type>::mean() const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return r_mean; return r_mean;
} }
//! variance //! variance
template<typename eT> template<typename obj_type>
inline inline
const Mat<typename get_pod_type<eT>::result>& const Mat< typename running_stat_vec<obj_type>::T >&
running_stat_vec<eT>::var(const uword norm_type) running_stat_vec<obj_type>::var(const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return r_var; return r_var;
skipping to change at line 190 skipping to change at line 186
else else
{ {
r_var_dummy.zeros(r_mean.n_rows, r_mean.n_cols); r_var_dummy.zeros(r_mean.n_rows, r_mean.n_cols);
return r_var_dummy; return r_var_dummy;
} }
} }
//! standard deviation //! standard deviation
template<typename eT> template<typename obj_type>
inline inline
Mat<typename get_pod_type<eT>::result> Mat< typename running_stat_vec<obj_type>::T >
running_stat_vec<eT>::stddev(const uword norm_type) const running_stat_vec<obj_type>::stddev(const uword norm_type) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return sqrt(r_var); return sqrt(r_var);
skipping to change at line 219 skipping to change at line 215
return sqrt( (N_minus_1/N) * r_var ); return sqrt( (N_minus_1/N) * r_var );
} }
} }
else else
{ {
return Mat<T>(); return Mat<T>();
} }
} }
//! covariance //! covariance
template<typename eT> template<typename obj_type>
inline inline
const Mat<eT>& const Mat< typename running_stat_vec<obj_type>::eT >&
running_stat_vec<eT>::cov(const uword norm_type) running_stat_vec<obj_type>::cov(const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(calc_cov == true) if(calc_cov == true)
{ {
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
skipping to change at line 262 skipping to change at line 258
else else
{ {
r_cov_dummy.reset(); r_cov_dummy.reset();
return r_cov_dummy; return r_cov_dummy;
} }
} }
//! vector with minimum values //! vector with minimum values
template<typename eT> template<typename obj_type>
inline inline
const Mat<eT>& const Mat< typename running_stat_vec<obj_type>::eT >&
running_stat_vec<eT>::min() const running_stat_vec<obj_type>::min() const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return min_val; return min_val;
} }
//! vector with maximum values //! vector with maximum values
template<typename eT> template<typename obj_type>
inline inline
const Mat<eT>& const Mat< typename running_stat_vec<obj_type>::eT >&
running_stat_vec<eT>::max() const running_stat_vec<obj_type>::max() const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return max_val; return max_val;
} }
//! number of samples so far //! number of samples so far
template<typename eT> template<typename obj_type>
inline inline
typename get_pod_type<eT>::result typename running_stat_vec<obj_type>::T
running_stat_vec<eT>::count() const running_stat_vec<obj_type>::count() const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return counter.value(); return counter.value();
} }
// //
//! update statistics to reflect new sample //! update statistics to reflect new sample (version for non-complex number
template<typename eT> s)
template<typename obj_type>
inline inline
void void
running_stat_vec_aux::update_stats(running_stat_vec<eT>& x, const Mat<eT>& running_stat_vec_aux::update_stats
sample) (
running_stat_vec<obj_type>& x,
const Mat<typename running_stat_vec<obj_type>::eT>& samp
le,
const typename arma_not_cx<typename running_stat_vec<obj_type>::eT>::resu
lt* junk
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename running_stat_vec<eT>::T T; typedef typename running_stat_vec<obj_type>::eT eT;
typedef typename running_stat_vec<obj_type>::T T;
const T N = x.counter.value(); const T N = x.counter.value();
if(N > T(0)) if(N > T(0))
{ {
arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch"); arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch");
const uword n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
skipping to change at line 390 skipping to change at line 393
const uword n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT val = sample_mem[i]; const eT val = sample_mem[i];
r_mean_mem[i] = val; r_mean_mem[i] = val;
min_val_mem[i] = val; min_val_mem[i] = val;
max_val_mem[i] = val; max_val_mem[i] = val;
} }
} }
x.counter++; x.counter++;
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for non-complex number
template<typename T> s, complex sample)
template<typename obj_type>
inline inline
void void
running_stat_vec_aux::update_stats(running_stat_vec< std::complex<T> >& x, running_stat_vec_aux::update_stats
const Mat<T>& sample) (
running_stat_vec<obj_type>& x,
const Mat<std::complex< typename running_stat_vec<obj_type>::T >
>& sample,
const typename arma_not_cx<typename running_stat_vec<obj_type>::eT>
::result* junk
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
const Mat< std::complex<T> > tmp = conv_to< Mat< std::complex<T> > >::fro m(sample); typedef typename running_stat_vec<obj_type>::eT eT;
running_stat_vec_aux::update_stats(x, tmp); running_stat_vec_aux::update_stats(x, conv_to< Mat<eT> >::from(sample));
} }
//! alter statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for complex numbers, n
template<typename T> on-complex sample)
template<typename obj_type>
inline inline
void void
running_stat_vec_aux::update_stats(running_stat_vec< std::complex<T> >& x, running_stat_vec_aux::update_stats
const Mat< std::complex<T> >& sample) (
running_stat_vec<obj_type>& x,
const Mat<typename running_stat_vec<obj_type>::T >& sam
ple,
const typename arma_cx_only<typename running_stat_vec<obj_type>::eT>::res
ult* junk
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename running_stat_vec<obj_type>::eT eT;
typedef typename std::complex<T> eT; running_stat_vec_aux::update_stats(x, conv_to< Mat<eT> >::from(sample));
}
//! alter statistics to reflect new sample (version for complex numbers, co
mplex sample)
template<typename obj_type>
inline
void
running_stat_vec_aux::update_stats
(
running_stat_vec<obj_type>& x,
const Mat<typename running_stat_vec<obj_type>::eT>& sam
ple,
const typename arma_cx_only<typename running_stat_vec<obj_type>::eT>::res
ult* junk
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename running_stat_vec<obj_type>::eT eT;
typedef typename running_stat_vec<obj_type>::T T;
const T N = x.counter.value(); const T N = x.counter.value();
if(N > T(0)) if(N > T(0))
{ {
arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch"); arma_debug_assert_same_size(x.r_mean, sample, "running_stat_vec(): dime nsionality mismatch");
const uword n_elem = sample.n_elem; const uword n_elem = sample.n_elem;
const eT* sample_mem = sample.memptr(); const eT* sample_mem = sample.memptr();
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
skipping to change at line 483 skipping to change at line 518
max_val_norm_mem[i] = val_norm; max_val_norm_mem[i] = val_norm;
max_val_mem[i] = val; max_val_mem[i] = val;
} }
const eT& r_mean_val = r_mean_mem[i]; const eT& r_mean_val = r_mean_mem[i];
r_var_mem[i] = N_minus_1/N * r_var_mem[i] + std::norm(val - r_mean_va l)/N_plus_1; r_var_mem[i] = N_minus_1/N * r_var_mem[i] + std::norm(val - r_mean_va l)/N_plus_1;
r_mean_mem[i] = r_mean_val + (val - r_mean_val)/N_plus_1; r_mean_mem[i] = r_mean_val + (val - r_mean_val)/N_plus_1;
} }
} }
else else
{ {
arma_debug_check( (sample.is_vec() == false), "running_stat_vec(): give n sample is not a vector"); arma_debug_check( (sample.is_vec() == false), "running_stat_vec(): give n sample is not a vector");
x.r_mean.set_size(sample.n_rows, sample.n_cols); x.r_mean.set_size(sample.n_rows, sample.n_cols);
x.r_var.zeros(sample.n_rows, sample.n_cols); x.r_var.zeros(sample.n_rows, sample.n_cols);
if(x.calc_cov == true) if(x.calc_cov == true)
skipping to change at line 517 skipping to change at line 551
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
T* min_val_norm_mem = x.min_val_norm.memptr(); T* min_val_norm_mem = x.min_val_norm.memptr();
T* max_val_norm_mem = x.max_val_norm.memptr(); T* max_val_norm_mem = x.max_val_norm.memptr();
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const eT& val = sample_mem[i]; const eT& val = sample_mem[i];
const T val_norm = std::norm(val); const T val_norm = std::norm(val);
r_mean_mem[i] = val; r_mean_mem[i] = val;
min_val_mem[i] = val; min_val_mem[i] = val;
max_val_mem[i] = val; max_val_mem[i] = val;
min_val_norm_mem[i] = val_norm; min_val_norm_mem[i] = val_norm;
max_val_norm_mem[i] = val_norm; max_val_norm_mem[i] = val_norm;
} }
} }
x.counter++; x.counter++;
} }
 End of changes. 44 change blocks. 
65 lines changed or deleted 110 lines changed or added


 subview_bones.hpp   subview_bones.hpp 
skipping to change at line 55 skipping to change at line 55
inline void operator*= (const eT val); inline void operator*= (const eT val);
inline void operator/= (const eT val); inline void operator/= (const eT val);
// deliberately returning void // deliberately returning void
template<typename T1> inline void operator= (const Base<eT,T1>& x); template<typename T1> inline void operator= (const Base<eT,T1>& x);
template<typename T1> inline void operator+= (const Base<eT,T1>& x); template<typename T1> inline void operator+= (const Base<eT,T1>& x);
template<typename T1> inline void operator-= (const Base<eT,T1>& x); template<typename T1> inline void operator-= (const Base<eT,T1>& x);
template<typename T1> inline void operator%= (const Base<eT,T1>& x); template<typename T1> inline void operator%= (const Base<eT,T1>& x);
template<typename T1> inline void operator/= (const Base<eT,T1>& x); template<typename T1> inline void operator/= (const Base<eT,T1>& x);
template<typename T1> inline void operator= (const SpBase<eT, T1>& x);
template<typename T1> inline void operator+=(const SpBase<eT, T1>& x);
template<typename T1> inline void operator-=(const SpBase<eT, T1>& x);
template<typename T1> inline void operator%=(const SpBase<eT, T1>& x);
template<typename T1> inline void operator/=(const SpBase<eT, T1>& x);
inline void operator= (const subview& x); inline void operator= (const subview& x);
inline void operator+= (const subview& x); inline void operator+= (const subview& x);
inline void operator-= (const subview& x); inline void operator-= (const subview& x);
inline void operator%= (const subview& x); inline void operator%= (const subview& x);
inline void operator/= (const subview& x); inline void operator/= (const subview& x);
inline static void extract(Mat<eT>& out, const subview& in); inline static void extract(Mat<eT>& out, const subview& in);
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);
template<typename functor> inline void transform(functor F); template<typename functor> inline void transform(functor F);
template<typename functor> inline void imbue(functor F); template<typename functor> inline void imbue(functor F);
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 void randu();
inline void randn();
inline eT at_alt (const uword ii) const; inline eT at_alt (const uword ii) const;
inline eT& operator[](const uword ii); inline eT& operator[](const uword ii);
inline eT operator[](const uword ii) const; inline eT operator[](const uword ii) const;
inline eT& operator()(const uword ii); inline eT& operator()(const uword ii);
inline eT operator()(const uword ii) 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);
 End of changes. 2 change blocks. 
0 lines changed or deleted 8 lines changed or added


 subview_cube_bones.hpp   subview_cube_bones.hpp 
skipping to change at line 84 skipping to change at line 84
inline static void minus_inplace(Mat<eT>& out, const subview_cube& in); inline static void minus_inplace(Mat<eT>& out, const subview_cube& in);
inline static void schur_inplace(Mat<eT>& out, const subview_cube& in); inline static void schur_inplace(Mat<eT>& out, const subview_cube& in);
inline static void div_inplace(Mat<eT>& out, const subview_cube& in); inline static void div_inplace(Mat<eT>& out, const subview_cube& in);
template<typename functor> inline void transform(functor F); template<typename functor> inline void transform(functor F);
template<typename functor> inline void imbue(functor F); template<typename functor> inline void imbue(functor F);
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 randu();
inline void randn();
inline eT at_alt (const uword i) const; inline eT at_alt (const uword i) const;
inline eT& operator[](const uword i); inline eT& operator[](const uword i);
inline eT operator[](const uword i) const; inline eT operator[](const uword i) const;
inline eT& operator()(const uword i); inline eT& operator()(const uword i);
inline eT operator()(const uword i) const; inline eT operator()(const uword i) const;
arma_inline eT& operator()(const uword in_row, const uword in_col, const uword in_slice); arma_inline eT& operator()(const uword in_row, const uword in_col, const uword in_slice);
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 subview_cube_meat.hpp   subview_cube_meat.hpp 
skipping to change at line 949 skipping to change at line 949
void void
subview_cube<eT>::ones() subview_cube<eT>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(1)); fill(eT(1));
} }
template<typename eT> template<typename eT>
inline inline
void
subview_cube<eT>::randu()
{
arma_extra_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
const uword local_n_slices = n_slices;
for(uword slice = 0; slice < local_n_slices; ++slice)
{
for(uword col = 0; col < local_n_cols; ++col)
{
arma_rng::randu<eT>::fill( slice_colptr(slice,col), local_n_rows );
}
}
}
template<typename eT>
inline
void
subview_cube<eT>::randn()
{
arma_extra_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
const uword local_n_slices = n_slices;
for(uword slice = 0; slice < local_n_slices; ++slice)
{
for(uword col = 0; col < local_n_cols; ++col)
{
arma_rng::randn<eT>::fill( slice_colptr(slice,col), local_n_rows );
}
}
}
template<typename eT>
inline
eT eT
subview_cube<eT>::at_alt(const uword i) const subview_cube<eT>::at_alt(const uword i) const
{ {
return operator[](i); return operator[](i);
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_cube<eT>::operator[](const uword i) subview_cube<eT>::operator[](const uword i)
 End of changes. 1 change blocks. 
0 lines changed or deleted 40 lines changed or added


 subview_elem1_bones.hpp   subview_elem1_bones.hpp 
// Copyright (C) 2010-2012 Conrad Sanderson // Copyright (C) 2010-2013 Conrad Sanderson
// Copyright (C) 2010-2012 NICTA (www.nicta.com.au) // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup subview_elem1 //! \addtogroup subview_elem1
//! @{ //! @{
template<typename eT, typename T1> template<typename eT, typename T1>
class subview_elem1 : public Base<eT, subview_elem1<eT,T1> > class subview_elem1 : public Base<eT, subview_elem1<eT,T1> >
skipping to change at line 44 skipping to change at line 44
template<typename op_type, typename T2> inline void inplace_op(const subv iew_elem1<eT,T2>& x ); template<typename op_type, typename T2> inline void inplace_op(const subv iew_elem1<eT,T2>& x );
template<typename op_type, typename T2> inline void inplace_op(const Base <eT,T2>& x ); template<typename op_type, typename T2> inline void inplace_op(const Base <eT,T2>& x );
arma_inline const Op<subview_elem1<eT,T1>,op_htrans> t() const; arma_inline const Op<subview_elem1<eT,T1>,op_htrans> t() const;
arma_inline const Op<subview_elem1<eT,T1>,op_htrans> ht() const; arma_inline const Op<subview_elem1<eT,T1>,op_htrans> ht() const;
arma_inline const Op<subview_elem1<eT,T1>,op_strans> st() const; arma_inline const Op<subview_elem1<eT,T1>,op_strans> st() const;
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 randu();
inline void randn();
inline void operator+= (const eT val); inline void operator+= (const eT val);
inline void operator-= (const eT val); inline void operator-= (const eT val);
inline void operator*= (const eT val); inline void operator*= (const eT val);
inline void operator/= (const eT val); inline void operator/= (const eT val);
// deliberately returning void // deliberately returning void
template<typename T2> inline void operator_equ(const subview_elem1<eT,T2> & x); template<typename T2> inline void operator_equ(const subview_elem1<eT,T2> & x);
template<typename T2> inline void operator= (const subview_elem1<eT,T2> & x); template<typename T2> inline void operator= (const subview_elem1<eT,T2> & x);
inline void operator= (const subview_elem1<eT,T1> & x); inline void operator= (const subview_elem1<eT,T1> & x);
 End of changes. 2 change blocks. 
2 lines changed or deleted 4 lines changed or added


 subview_elem1_meat.hpp   subview_elem1_meat.hpp 
skipping to change at line 337 skipping to change at line 337
subview_elem1<eT,T1>::ones() subview_elem1<eT,T1>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
inplace_op<op_subview_elem_equ>(eT(1)); inplace_op<op_subview_elem_equ>(eT(1));
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
subview_elem1<eT,T1>::randu()
{
arma_extra_debug_sigprint();
Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M;
arma_debug_check
(
( (aa.is_vec() == false) && (aa.is_empty() == false) ),
"Mat::elem(): given object is not a vector"
);
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
uword iq,jq;
for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{
const uword ii = aa_mem[iq];
const uword jj = aa_mem[jq];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(
): index out of bounds" );
const eT val1 = eT(arma_rng::randu<eT>());
const eT val2 = eT(arma_rng::randu<eT>());
m_mem[ii] = val1;
m_mem[jj] = val2;
}
if(iq < aa_n_elem)
{
const uword ii = aa_mem[iq];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds"
);
m_mem[ii] = eT(arma_rng::randu<eT>());
}
}
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::randn()
{
arma_extra_debug_sigprint();
Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M;
arma_debug_check
(
( (aa.is_vec() == false) && (aa.is_empty() == false) ),
"Mat::elem(): given object is not a vector"
);
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
uword iq,jq;
for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{
const uword ii = aa_mem[iq];
const uword jj = aa_mem[jq];
arma_debug_check( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(
): index out of bounds" );
arma_rng::randn<eT>::dual_val( m_mem[ii], m_mem[jj] );
}
if(iq < aa_n_elem)
{
const uword ii = aa_mem[iq];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds"
);
m_mem[ii] = eT(arma_rng::randn<eT>());
}
}
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::operator+= (const eT val) subview_elem1<eT,T1>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
inplace_op<op_subview_elem_inplace_plus>(val); inplace_op<op_subview_elem_inplace_plus>(val);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
 End of changes. 1 change blocks. 
0 lines changed or deleted 98 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2013 Ryan Curtin
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup subview //! \addtogroup subview
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
skipping to change at line 725 skipping to change at line 726
if(ii < s_n_rows) if(ii < s_n_rows)
{ {
s_col_data[ii] /= P.at(ii,ucol); s_col_data[ii] /= P.at(ii,ucol);
} }
} }
} }
} }
} }
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(x.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "copy into submatrix");
// Clear the subview.
zeros();
// Iterate through the sparse subview and set the nonzero values appropri
ately.
typename SpProxy<T1>::const_iterator_type cit = p.begin();
while (cit != p.end())
{
at(cit.row(), cit.col()) = *cit;
++cit;
}
}
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator+=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(x.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "addition");
// Iterate through the sparse subview and add its values.
typename SpProxy<T1>::const_iterator_type cit = p.begin();
while (cit != p.end())
{
at(cit.row(), cit.col()) += *cit;
++cit;
}
}
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator-=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(x.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "subtraction");
// Iterate through the sparse subview and subtract its values.
typename SpProxy<T1>::const_iterator_type cit = p.begin();
while (cit != p.end())
{
at(cit.row(), cit.col()) -= *cit;
++cit;
}
}
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator%=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
// Temporary sparse matrix to hold the values we need.
SpMat<eT> tmp = x.get_ref();
arma_debug_assert_same_size(n_rows, n_cols, tmp.n_rows, tmp.n_cols, "elem
ent-wise multiplication");
// Iterate over nonzero values.
// Any zero values in the sparse expression will result in a zero in our
subview.
typename SpMat<eT>::const_iterator cit = tmp.begin();
while (cit != tmp.end())
{
// Set elements before this one to zero.
tmp.at(cit.row(), cit.col()) *= at(cit.row(), cit.col());
++cit;
}
// Now set the subview equal to that.
*this = tmp;
}
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator/=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
const SpProxy<T1> p(x.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(
), "element-wise division");
// This is probably going to fill your subview with a bunch of NaNs,
// so I'm not going to bother to implement it fast.
// You can have slow NaNs. They're fine too.
for (uword c = 0; c < n_cols; ++c)
for (uword r = 0; r < n_rows; ++r)
{
at(r, c) /= p.at(r, c);
}
}
//! 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);
skipping to change at line 1208 skipping to change at line 1328
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword ii=0; ii < N; ++ii) for(uword ii=0; ii < N; ++ii)
{ {
at(ii,ii) = eT(1); at(ii,ii) = eT(1);
} }
} }
template<typename eT> template<typename eT>
inline inline
void
subview<eT>::randu()
{
arma_extra_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
if(local_n_rows == 1)
{
for(uword ii=0; ii < local_n_cols; ++ii)
{
at(0,ii) = eT(arma_rng::randu<eT>());
}
}
else
{
for(uword ii=0; ii < local_n_cols; ++ii)
{
arma_rng::randu<eT>::fill( colptr(ii), local_n_rows );
}
}
}
template<typename eT>
inline
void
subview<eT>::randn()
{
arma_extra_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
if(local_n_rows == 1)
{
for(uword ii=0; ii < local_n_cols; ++ii)
{
at(0,ii) = eT(arma_rng::randn<eT>());
}
}
else
{
for(uword ii=0; ii < local_n_cols; ++ii)
{
arma_rng::randn<eT>::fill( colptr(ii), local_n_rows );
}
}
}
template<typename eT>
inline
eT eT
subview<eT>::at_alt(const uword ii) const subview<eT>::at_alt(const uword ii) const
{ {
return operator[](ii); return operator[](ii);
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator[](const uword ii) subview<eT>::operator[](const uword ii)
 End of changes. 3 change blocks. 
1 lines changed or deleted 180 lines changed or added


 wall_clock_bones.hpp   wall_clock_bones.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup wall_clock //! \addtogroup wall_clock
//! @{ //! @{
//! Class for measuring time intervals //! Class for measuring time intervals
class wall_clock class wall_clock
skipping to change at line 26 skipping to change at line 26
inline wall_clock(); inline wall_clock();
inline ~wall_clock(); inline ~wall_clock();
inline void tic(); //!< start the timer inline void tic(); //!< start the timer
inline double toc(); //!< return the number of seconds since the last ca ll to tic() inline double toc(); //!< return the number of seconds since the last ca ll to tic()
private: private:
bool valid; bool valid;
#if defined(ARMA_USE_BOOST_DATE) #if defined(ARMA_USE_CXX11)
std::chrono::steady_clock::time_point chrono_time1;
#elif defined(ARMA_USE_BOOST_DATE)
boost::posix_time::ptime boost_time1; boost::posix_time::ptime boost_time1;
boost::posix_time::time_duration boost_duration; boost::posix_time::time_duration boost_duration;
#elif defined(ARMA_HAVE_GETTIMEOFDAY) #elif defined(ARMA_HAVE_GETTIMEOFDAY)
struct timeval posix_time1; struct timeval posix_time1;
struct timeval posix_time2; struct timeval posix_time2;
#else #else
clock_t time1; clock_t time1;
#endif #endif
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
4 lines changed or deleted 5 lines changed or added


 wall_clock_meat.hpp   wall_clock_meat.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup wall_clock //! \addtogroup wall_clock
//! @{ //! @{
inline inline
wall_clock::wall_clock() wall_clock::wall_clock()
skipping to change at line 30 skipping to change at line 30
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
void void
wall_clock::tic() wall_clock::tic()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_BOOST_DATE) #if defined(ARMA_USE_CXX11)
{
chrono_time1 = std::chrono::steady_clock::now();
valid = true;
}
#elif defined(ARMA_USE_BOOST_DATE)
{ {
boost_time1 = boost::posix_time::microsec_clock::local_time(); boost_time1 = boost::posix_time::microsec_clock::local_time();
valid = true; valid = true;
} }
#elif defined(ARMA_HAVE_GETTIMEOFDAY) #elif defined(ARMA_HAVE_GETTIMEOFDAY)
{ {
gettimeofday(&posix_time1, 0); gettimeofday(&posix_time1, 0);
valid = true; valid = true;
} }
#else #else
skipping to change at line 56 skipping to change at line 61
} }
inline inline
double double
wall_clock::toc() wall_clock::toc()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(valid) if(valid)
{ {
#if defined(ARMA_USE_BOOST_DATE) #if defined(ARMA_USE_CXX11)
{
const std::chrono::steady_clock::time_point chrono_time2 = std::chron
o::steady_clock::now();
typedef std::chrono::duration<double> duration_type;
const duration_type chrono_span = std::chrono::duration_cast< duratio
n_type >(chrono_time2 - chrono_time1);
return chrono_span.count();
}
#elif defined(ARMA_USE_BOOST_DATE)
{ {
boost_duration = boost::posix_time::microsec_clock::local_time() - bo ost_time1; boost_duration = boost::posix_time::microsec_clock::local_time() - bo ost_time1;
return boost_duration.total_microseconds() * 1e-6; return boost_duration.total_microseconds() * 1e-6;
} }
#elif defined(ARMA_HAVE_GETTIMEOFDAY) #elif defined(ARMA_HAVE_GETTIMEOFDAY)
{ {
gettimeofday(&posix_time2, 0); gettimeofday(&posix_time2, 0);
const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1 .0e-6; const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1 .0e-6;
const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1 .0e-6; const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1 .0e-6;
 End of changes. 3 change blocks. 
4 lines changed or deleted 21 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/