Base_bones.hpp   Base_bones.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 35 skipping to change at line 35
arma_inline const Op<derived,op_htrans> t() const; arma_inline const Op<derived,op_htrans> t() const;
arma_inline const Op<derived,op_htrans> ht() const; arma_inline const Op<derived,op_htrans> ht() const;
arma_inline const Op<derived,op_strans> st() const; arma_inline const Op<derived,op_strans> st() const;
inline void print(const std::string extra_text = "") const; inline void print(const std::string extra_text = "") const;
inline void print(std::ostream& user_stream, const std::string extra_text = "") const; inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
inline void raw_print(const std::string extra_text = "") const; inline void raw_print(const std::string extra_text = "") const;
inline void raw_print(std::ostream& user_stream, const std::string extra_ text = "") const; inline void raw_print(std::ostream& user_stream, const std::string extra_ text = "") const;
arma_deprecated inline void print_trans(const std::string extra_text = ""
) const;
arma_deprecated inline void print_trans(std::ostream& user_stream, const
std::string extra_text = "") const;
arma_deprecated inline void raw_print_trans(const std::string extra_text
= "") const;
arma_deprecated inline void raw_print_trans(std::ostream& user_stream, co
nst std::string extra_text = "") const;
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
12 lines changed or deleted 2 lines changed or added


 Base_meat.hpp   Base_meat.hpp 
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2011 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 71 skipping to change at line 71
Base<elem_type,derived>::print(std::ostream& user_stream, const std::string extra_text) const Base<elem_type,derived>::print(std::ostream& user_stream, const std::string extra_text) const
{ {
const unwrap<derived> tmp( (*this).get_ref() ); const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_print(user_stream, extra_text); tmp.M.impl_print(user_stream, extra_text);
} }
template<typename elem_type, typename derived> template<typename elem_type, typename derived>
inline inline
void void
Base<elem_type,derived>::print_trans(const std::string extra_text) const
{
const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_print_trans(extra_text);
}
template<typename elem_type, typename derived>
inline
void
Base<elem_type,derived>::print_trans(std::ostream& user_stream, const std::
string extra_text) const
{
const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_print_trans(user_stream, extra_text);
}
template<typename elem_type, typename derived>
inline
void
Base<elem_type,derived>::raw_print(const std::string extra_text) const Base<elem_type,derived>::raw_print(const std::string extra_text) const
{ {
const unwrap<derived> tmp( (*this).get_ref() ); const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_raw_print(extra_text); tmp.M.impl_raw_print(extra_text);
} }
template<typename elem_type, typename derived> template<typename elem_type, typename derived>
inline inline
void void
Base<elem_type,derived>::raw_print(std::ostream& user_stream, const std::st ring extra_text) const Base<elem_type,derived>::raw_print(std::ostream& user_stream, const std::st ring extra_text) const
{ {
const unwrap<derived> tmp( (*this).get_ref() ); const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_raw_print(user_stream, extra_text); tmp.M.impl_raw_print(user_stream, extra_text);
} }
template<typename elem_type, typename derived>
inline
void
Base<elem_type,derived>::raw_print_trans(const std::string extra_text) cons
t
{
const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_raw_print_trans(extra_text);
}
template<typename elem_type, typename derived>
inline
void
Base<elem_type,derived>::raw_print_trans(std::ostream& user_stream, const s
td::string extra_text) const
{
const unwrap<derived> tmp( (*this).get_ref() );
tmp.M.impl_raw_print_trans(user_stream, extra_text);
}
//! @} //! @}
 End of changes. 3 change blocks. 
45 lines changed or deleted 2 lines changed or added


 Col_bones.hpp   Col_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 26 skipping to change at line 26
//! Class for column vectors (matrices with only one column) //! Class for column vectors (matrices with only one column)
template<typename eT> template<typename eT>
class Col : public Mat<eT> class Col : public Mat<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
static const bool is_col = true;
static const bool is_row = false;
inline Col(); inline Col();
inline Col(const Col<eT>& X); inline Col(const Col<eT>& X);
inline explicit Col(const uword n_elem); inline explicit Col(const uword n_elem);
inline Col(const uword in_rows, const uword in_cols); inline Col(const uword in_rows, const uword in_cols);
inline Col(const char* text); inline Col(const char* text);
inline const Col& operator=(const char* text); inline const Col& operator=(const char* text);
inline Col(const std::string& text); inline Col(const std::string& text);
inline const Col& operator=(const std::string& text); inline const Col& operator=(const std::string& text);
skipping to change at line 61 skipping to change at line 64
inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
template<typename T1> inline Col(const BaseCube<eT,T1>& X); template<typename T1> inline Col(const BaseCube<eT,T1>& X);
template<typename T1> inline const Col& operator=(const BaseCube<eT,T1>& X); template<typename T1> inline const Col& operator=(const BaseCube<eT,T1>& X);
inline Col(const subview_cube<eT>& X); inline Col(const subview_cube<eT>& X);
inline const Col& operator=(const subview_cube<eT>& X); inline const Col& operator=(const subview_cube<eT>& X);
inline mat_injector<Col> operator<<(const eT val); inline mat_injector<Col> operator<<(const eT val);
arma_inline const Op<Col<eT>,op_htrans> t() const;
arma_inline const Op<Col<eT>,op_htrans> ht() const;
arma_inline const Op<Col<eT>,op_strans> st() const;
arma_inline eT& row(const uword row_num); arma_inline eT& row(const uword row_num);
arma_inline eT row(const uword row_num) const; arma_inline eT row(const uword row_num) const;
arma_inline subview_col<eT> rows(const uword in_row1, const uword i n_row2); arma_inline subview_col<eT> rows(const uword in_row1, const uword i n_row2);
arma_inline const subview_col<eT> rows(const uword in_row1, const uword i n_row2) const; arma_inline const subview_col<eT> rows(const uword in_row1, const uword i n_row2) const;
arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2); arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2);
arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const; arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const;
arma_inline subview_col<eT> subvec(const span& row_span); arma_inline subview_col<eT> subvec(const span& row_span);
skipping to change at line 116 skipping to change at line 123
static const uword n_cols = 1; static const uword n_cols = 1;
static const uword n_elem = fixed_n_elem; static const uword n_elem = fixed_n_elem;
arma_inline fixed(); arma_inline fixed();
arma_inline fixed(const fixed<fixed_n_elem>& X); arma_inline fixed(const fixed<fixed_n_elem>& X);
inline fixed(const subview_cube<eT>& X); inline fixed(const subview_cube<eT>& X);
template<typename T1> inline fixed(const Base<eT,T1>& A); template<typename T1> inline fixed(const Base<eT,T1>& A);
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B); template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B);
inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
inline fixed(const eT* aux_mem); inline fixed(const eT* aux_mem);
inline fixed(const char* text); inline fixed(const char* text);
inline fixed(const std::string& text); inline fixed(const std::string& text);
template<typename T1> inline const Col& operator=(const Base<eT,T1>& A) ; template<typename T1> inline const Col& operator=(const Base<eT,T1>& A) ;
inline const Col& operator=(const eT val); inline const Col& operator=(const eT val);
inline const Col& operator=(const char* text); inline const Col& operator=(const char* text);
inline const Col& operator=(const std::string& text); inline const Col& operator=(const std::string& text);
 End of changes. 4 change blocks. 
3 lines changed or deleted 9 lines changed or added


 Col_meat.hpp   Col_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Col //! \addtogroup Col
//! @{ //! @{
//! construct an empty column vector //! construct an empty column vector
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col() Col<eT>::Col()
: Mat<eT>(0, 1) : Mat<eT>(arma_vec_indicator(), 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
} }
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const Col<eT>& X) Col<eT>::Col(const Col<eT>& X)
: Mat<eT>(X.n_elem, 1) : Mat<eT>(arma_vec_indicator(), X.n_elem, 1, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
arrayops::copy((*this).memptr(), X.memptr(), X.n_elem); arrayops::copy((*this).memptr(), X.memptr(), X.n_elem);
} }
//! construct a column vector with the specified number of n_elem //! construct a column vector with the specified number of n_elem
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const uword in_n_elem) Col<eT>::Col(const uword in_n_elem)
: Mat<eT>(in_n_elem, 1) : Mat<eT>(arma_vec_indicator(), in_n_elem, 1, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
} }
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const uword in_n_rows, const uword in_n_cols) Col<eT>::Col(const uword in_n_rows, const uword in_n_cols)
: Mat<eT>(arma_vec_indicator(), 0, 0, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
Mat<eT>::init_warm(in_n_rows, in_n_cols); Mat<eT>::init_warm(in_n_rows, in_n_cols);
} }
//! construct a column vector from specified text //! construct a column vector from specified text
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const char* text) Col<eT>::Col(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 184 skipping to change at line 177
Mat<eT>::operator=(val); Mat<eT>::operator=(val);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
Col<eT>::Col(const Base<eT,T1>& X) Col<eT>::Col(const Base<eT,T1>& X)
: Mat<eT>(arma_vec_indicator(), 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 1;
Mat<eT>::operator=(X.get_ref()); Mat<eT>::operator=(X.get_ref());
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(const Base<eT,T1>& X) Col<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 301 skipping to change at line 293
template<typename eT> template<typename eT>
inline inline
mat_injector< Col<eT> > mat_injector< Col<eT> >
Col<eT>::operator<<(const eT val) Col<eT>::operator<<(const eT val)
{ {
return mat_injector< Col<eT> >(*this, val); return mat_injector< Col<eT> >(*this, val);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Col<eT>,op_htrans>
Col<eT>::t() const
{
return Op<Col<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<Col<eT>,op_htrans>
Col<eT>::ht() const
{
return Op<Col<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<Col<eT>,op_strans>
Col<eT>::st() const
{
return Op<Col<eT>,op_strans>(*this);
}
template<typename eT>
arma_inline
eT& eT&
Col<eT>::row(const uword row_num) Col<eT>::row(const uword row_num)
{ {
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound s" ); arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bound s" );
return access::rw(Mat<eT>::mem[row_num]); return access::rw(Mat<eT>::mem[row_num]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
skipping to change at line 682 skipping to change at line 698
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Col<eT>::init(A,B); Col<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
{
arma_extra_debug_sigprint_this(this);
access::rw(Mat<eT>::n_rows) = fixed_n_elem;
access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 1;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true)
{
eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
access::rw(Mat<eT>::mem) = dest;
arrayops::copy( dest, aux_mem, fixed_n_elem );
}
else
{
access::rw(Mat<eT>::mem) = aux_mem;
}
}
template<typename eT>
template<uword fixed_n_elem>
inline
Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
//! NOTE: this function relies on //! NOTE: this function relies on
skipping to change at line 890 skipping to change at line 879
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator[] (const uword i) Col<eT>::fixed<fixed_n_elem>::operator[] (const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const Col<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::at(const uword i) Col<eT>::fixed<fixed_n_elem>::at(const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::at(const uword i) const Col<eT>::fixed<fixed_n_elem>::at(const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator() (const uword i) Col<eT>::fixed<fixed_n_elem>::operator() (const uword i)
{ {
arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Col::operator(): out of bounds");
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::operator() (const uword i) const Col<eT>::fixed<fixed_n_elem>::operator() (const uword i) const
{ {
arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Col::operator(): out of bounds");
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col)
{ {
return access::rw( Mat<eT>::mem[in_row] ); return (use_extra) ? mem_local_extra[in_row] : Mat<eT>::mem_local[in_row] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) co nst Col<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) co nst
{ {
return ( Mat<eT>::mem[in_row] ); return (use_extra) ? mem_local_extra[in_row] : Mat<eT>::mem_local[in_row] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Col<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) Col<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col)
{ {
arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row >= fixed_n_elem) || (in_col > 0)), "Col::opera tor(): out of bounds" );
return access::rw( Mat<eT>::mem[in_row] ); return (use_extra) ? mem_local_extra[in_row] : Mat<eT>::mem_local[in_row] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Col<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) const Col<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) const
{ {
arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row >= fixed_n_elem) || (in_col > 0)), "Col::opera tor(): out of bounds" );
return ( Mat<eT>::mem[in_row] ); return (use_extra) ? mem_local_extra[in_row] : Mat<eT>::mem_local[in_row] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::fill(const eT val) Col<eT>::fixed<fixed_n_elem>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[
; 0]);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::zeros() Col<eT>::fixed<fixed_n_elem>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[
); 0]);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(0) );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::fixed<fixed_n_elem>::ones() Col<eT>::fixed<fixed_n_elem>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[
); 0]);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(1) );
return *this; return *this;
} }
#ifdef ARMA_EXTRA_COL_MEAT #ifdef ARMA_EXTRA_COL_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT)
#endif #endif
//! @} //! @}
 End of changes. 30 change blocks. 
62 lines changed or deleted 57 lines changed or added


 Gen_bones.hpp   Gen_bones.hpp 
// Copyright (C) 2011 NICTA (www.nicta.com.au) // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Conrad Sanderson // Copyright (C) 2011-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Gen //! \addtogroup Gen
//! @{ //! @{
//! support class for generator functions (eg. zeros, randu, randn, ...) //! support class for generator functions (eg. zeros, randu, randn, ...)
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
class Gen : public Base<eT, Gen<eT, gen_type> > class Gen : public Base<typename T1::elem_type, Gen<T1, gen_type> >
{ {
public: public:
typedef eT elem_type; typedef typename T1::elem_type eT;
typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool prefer_at_accessor = (is_same_type<gen_type, gen_ones_d iag>::value) ? true : false; static const bool prefer_at_accessor = (is_same_type<gen_type, gen_ones_d iag>::value) ? true : false;
static const bool is_row = T1::is_row;
static const bool is_col = T1::is_col;
arma_aligned const uword n_rows; arma_aligned const uword n_rows;
arma_aligned const uword n_cols; arma_aligned const uword n_cols;
arma_inline Gen(const uword in_n_rows, const uword in_n_cols); arma_inline Gen(const uword in_n_rows, const uword in_n_cols);
arma_inline ~Gen(); arma_inline ~Gen();
arma_inline static eT generate(); arma_inline static eT generate();
arma_inline eT operator[] (const uword i) const; arma_inline eT operator[] (const uword i) const;
arma_inline eT at (const uword row, const uword col) const; arma_inline eT at (const uword row, const uword col) const;
 End of changes. 4 change blocks. 
5 lines changed or deleted 9 lines changed or added


 Gen_meat.hpp   Gen_meat.hpp 
// Copyright (C) 2011 NICTA (www.nicta.com.au) // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Conrad Sanderson // Copyright (C) 2011-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Gen //! \addtogroup Gen
//! @{ //! @{
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
Gen<eT, gen_type>::Gen(const uword in_n_rows, const uword in_n_cols) Gen<T1, gen_type>::Gen(const uword in_n_rows, const uword in_n_cols)
: n_rows(in_n_rows) : n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
Gen<eT, gen_type>::~Gen() Gen<T1, gen_type>::~Gen()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
eT typename T1::elem_type
Gen<eT, gen_type>::generate() Gen<T1, gen_type>::generate()
{ {
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_full>::value == true) { return eT (1); } if(is_same_type<gen_type, gen_ones_full>::value == true) { return eT (1); }
else if(is_same_type<gen_type, gen_zeros >::value == true) { return eT (0); } else if(is_same_type<gen_type, gen_zeros >::value == true) { return eT (0); }
else if(is_same_type<gen_type, gen_randu >::value == true) { return eT (eop_aux_randu<eT>()); } else if(is_same_type<gen_type, gen_randu >::value == true) { return eT (eop_aux_randu<eT>()); }
else if(is_same_type<gen_type, gen_randn >::value == true) { return eT (eop_aux_randn<eT>()); } else if(is_same_type<gen_type, gen_randn >::value == true) { return eT (eop_aux_randn<eT>()); }
else { return eT (); } else { return eT (); }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
eT typename T1::elem_type
Gen<eT, gen_type>::operator[](const uword i) const Gen<T1, gen_type>::operator[](const uword i) const
{ {
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
return ((i % n_rows) == (i / n_rows)) ? eT(1) : eT(0); return ((i % n_rows) == (i / n_rows)) ? eT(1) : eT(0);
} }
else else
{ {
return Gen<eT, gen_type>::generate(); return Gen<T1, gen_type>::generate();
} }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
arma_inline arma_inline
eT typename T1::elem_type
Gen<eT, gen_type>::at(const uword row, const uword col) const Gen<T1, gen_type>::at(const uword row, const uword col) const
{ {
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
return (row == col) ? eT(1) : eT(0); return (row == col) ? eT(1) : eT(0);
} }
else else
{ {
return Gen<eT, gen_type>::generate(); return Gen<T1, gen_type>::generate();
} }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<eT, gen_type>::apply(Mat<eT>& out) const Gen<T1, gen_type>::apply(Mat<typename T1::elem_type>& out) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// NOTE: we're assuming that the matrix has already been set to the corre ct size; // NOTE: we're assuming that the matrix has already been set to the corre ct size;
// this is done by either the Mat contructor or operator=() // this is done by either the Mat contructor or operator=()
if(is_same_type<gen_type, gen_ones_diag>::value == true) { out.eye() ; } if(is_same_type<gen_type, gen_ones_diag>::value == true) { out.eye() ; }
else if(is_same_type<gen_type, gen_ones_full>::value == true) { out.ones( ); } else if(is_same_type<gen_type, gen_ones_full>::value == true) { out.ones( ); }
else if(is_same_type<gen_type, gen_zeros >::value == true) { out.zeros (); } else if(is_same_type<gen_type, gen_zeros >::value == true) { out.zeros (); }
else if(is_same_type<gen_type, gen_randu >::value == true) { out.randu (); } else if(is_same_type<gen_type, gen_randu >::value == true) { out.randu (); }
else if(is_same_type<gen_type, gen_randn >::value == true) { out.randn (); } else if(is_same_type<gen_type, gen_randn >::value == true) { out.randn (); }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<eT, gen_type>::apply_inplace_plus(Mat<eT>& out) const Gen<T1, gen_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out) con st
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi tion");
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.at(i,i) += eT(1); out.at(i,i) += eT(1);
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<eT, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<eT, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] += tmp_i; out_mem[i] += tmp_i;
out_mem[j] += tmp_j; out_mem[j] += tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] += Gen<eT, gen_type>::generate(); out_mem[i] += Gen<T1, gen_type>::generate();
} }
} }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<eT, gen_type>::apply_inplace_minus(Mat<eT>& out) const Gen<T1, gen_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out) co nst
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt raction");
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
out.at(i,i) -= eT(1); out.at(i,i) -= eT(1);
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<eT, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<eT, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] -= tmp_i; out_mem[i] -= tmp_i;
out_mem[j] -= tmp_j; out_mem[j] -= tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] -= Gen<eT, gen_type>::generate(); out_mem[i] -= Gen<T1, gen_type>::generate();
} }
} }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<eT, gen_type>::apply_inplace_schur(Mat<eT>& out) const Gen<T1, gen_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out) co nst
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise multiplication");
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
for(uword row=0; row<i; ++row) { out.at(row,i) = eT(0); } for(uword row=0; row<i; ++row) { out.at(row,i) = eT(0); }
for(uword row=i+1; row<n_rows; ++row) { out.at(row,i) = eT(0); } for(uword row=i+1; row<n_rows; ++row) { out.at(row,i) = eT(0); }
} }
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<eT, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<eT, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] *= tmp_i; out_mem[i] *= tmp_i;
out_mem[j] *= tmp_j; out_mem[j] *= tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] *= Gen<eT, gen_type>::generate(); out_mem[i] *= Gen<T1, gen_type>::generate();
} }
} }
} }
template<typename eT, typename gen_type> template<typename T1, typename gen_type>
inline inline
void void
Gen<eT, gen_type>::apply_inplace_div(Mat<eT>& out) const Gen<T1, gen_type>::apply_inplace_div(Mat<typename T1::elem_type>& out) cons t
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division"); arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem ent-wise division");
typedef typename T1::elem_type eT;
if(is_same_type<gen_type, gen_ones_diag>::value == true) if(is_same_type<gen_type, gen_ones_diag>::value == true)
{ {
const uword N = (std::min)(n_rows, n_cols); const uword N = (std::min)(n_rows, n_cols);
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const eT zero = eT(0); const eT zero = eT(0);
for(uword row=0; row<i; ++row) { out.at(row,i) /= zero; } for(uword row=0; row<i; ++row) { out.at(row,i) /= zero; }
for(uword row=i+1; row<n_rows; ++row) { out.at(row,i) /= zero; } for(uword row=i+1; row<n_rows; ++row) { out.at(row,i) /= zero; }
skipping to change at line 248 skipping to change at line 262
} }
else else
{ {
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT tmp_i = Gen<eT, gen_type>::generate(); const eT tmp_i = Gen<T1, gen_type>::generate();
const eT tmp_j = Gen<eT, gen_type>::generate(); const eT tmp_j = Gen<T1, gen_type>::generate();
out_mem[i] /= tmp_i; out_mem[i] /= tmp_i;
out_mem[j] /= tmp_j; out_mem[j] /= tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
out_mem[i] /= Gen<eT, gen_type>::generate(); out_mem[i] /= Gen<T1, gen_type>::generate();
} }
} }
} }
//! @} //! @}
 End of changes. 38 change blocks. 
39 lines changed or deleted 53 lines changed or added


 Glue_bones.hpp   Glue_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 35 skipping to change at line 35
//! Another example is: Glue< Op<Mat, op_htrans>, Op<Mat, op_inv>, glue_tim es > //! Another example is: Glue< Op<Mat, op_htrans>, Op<Mat, op_inv>, glue_tim es >
template<typename T1, typename T2, typename glue_type> template<typename T1, typename T2, typename glue_type>
class Glue : public Base<typename T1::elem_type, Glue<T1, T2, glue_type> > class Glue : public Base<typename T1::elem_type, Glue<T1, T2, glue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool is_row = (is_same_type<glue_type, glue_times>::value) ?
T1::is_row : false;
static const bool is_col = (is_same_type<glue_type, glue_times>::value) ?
T2::is_col : false;
arma_inline Glue(const T1& in_A, const T2& in_B); arma_inline Glue(const T1& in_A, const T2& in_B);
arma_inline Glue(const T1& in_A, const T2& in_B, const uword in_aux_uwor d); arma_inline Glue(const T1& in_A, const T2& in_B, const uword in_aux_uwor d);
arma_inline ~Glue(); arma_inline ~Glue();
const T1& A; //!< first operand const T1& A; //!< first operand
const T2& B; //!< second operand const T2& B; //!< second operand
uword aux_uword; //!< storage of auxiliary data, uword format uword aux_uword; //!< storage of auxiliary data, uword format
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 7 lines changed or added


 Mat_bones.hpp   Mat_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 26 skipping to change at line 26
//! Dense matrix class //! Dense matrix class
template<typename eT> template<typename eT>
class Mat : public Base< eT, Mat<eT> > class Mat : public Base< eT, Mat<eT> >
{ {
public: public:
typedef eT elem_type; //!< the type of el ements stored in the matrix typedef eT elem_type; //!< the type of el ements stored in the matrix
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-c omplex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-c omplex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex
static const bool is_col = false;
static const bool is_row = false;
const uword n_rows; //!< number of rows in the matrix (read-only) const uword n_rows; //!< number of rows in the matrix (read-only)
const uword n_cols; //!< number of columns in the matrix (read-only) const uword n_cols; //!< number of columns in the matrix (read-only)
const uword n_elem; //!< number of elements in the matrix (read-only) const uword n_elem; //!< number of elements in the matrix (read-only)
const uhword vec_state; //!< 0: matrix layout; 1: column vector layout; 2 : row vector layout const uhword vec_state; //!< 0: matrix layout; 1: column vector layout; 2 : row vector layout
const uhword mem_state; const uhword mem_state;
// mem_state = 0: normal matrix that can be resized; // mem_state = 0: normal matrix that can be resized;
// mem_state = 1: use auxiliary memory until change in the number of elem ents is requested; // mem_state = 1: use auxiliary memory until change in the number of elem ents is requested;
// mem_state = 2: use auxiliary memory and don't allow the number of elem ents to be changed; // mem_state = 2: use auxiliary memory and don't allow the number of elem ents to be changed;
// mem_state = 3: fixed size (e.g. via template based size specification) . // mem_state = 3: fixed size (e.g. via template based size specification) .
skipping to change at line 122 skipping to change at line 125
inline const Mat& operator/=(const diagview<eT>& X); inline const Mat& operator/=(const diagview<eT>& X);
template<typename T1> inline Mat(const subview_elem1<eT ,T1>& X); template<typename T1> inline Mat(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator= (const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator= (const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator+=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator+=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator-=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator-=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator*=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator*=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator%=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator%=(const subview_elem1<eT ,T1>& X);
template<typename T1> inline const Mat& operator/=(const subview_elem1<eT ,T1>& X); template<typename T1> inline const Mat& operator/=(const subview_elem1<eT ,T1>& X);
template<typename T1, typename T2> inline Mat(const sub
view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator= (const sub
view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator+=(const sub
view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator-=(const sub
view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator*=(const sub
view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator%=(const sub
view_elem2<eT,T1,T2>& X);
template<typename T1, typename T2> inline const Mat& operator/=(const sub
view_elem2<eT,T1,T2>& X);
inline mat_injector<Mat> operator<<(const eT val); inline mat_injector<Mat> operator<<(const eT val);
inline mat_injector<Mat> operator<<(const injector_end_of_row& x); inline mat_injector<Mat> operator<<(const injector_end_of_row<>&amp; x);
arma_inline subview_row<eT> row(const uword row_num); arma_inline subview_row<eT> row(const uword row_num);
arma_inline const subview_row<eT> row(const uword row_num) const; arma_inline const subview_row<eT> row(const uword row_num) const;
inline subview_row<eT> operator()(const uword row_num, const s pan& col_span); inline subview_row<eT> operator()(const uword row_num, const s pan& col_span);
inline const subview_row<eT> operator()(const uword row_num, const s pan& col_span) const; inline const subview_row<eT> operator()(const uword row_num, const s pan& col_span) const;
arma_inline subview_col<eT> col(const uword col_num); arma_inline subview_col<eT> col(const uword col_num);
arma_inline const subview_col<eT> col(const uword col_num) const; arma_inline const subview_col<eT> col(const uword col_num) const;
skipping to change at line 158 skipping to change at line 169
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;
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, typename T2> arma_inline subview_elem2<eT, template<typename T1, typename T2> arma_inline subview_elem2<eT,T1,
T1,T2> submat(const Base<uword,T1>& a, const Base<uword,T2>& b); T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci);
// template<typename T1, typename T2> arma_inline const subview_elem2<eT, template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1,
T1,T2> submat(const Base<uword,T1>& a, const Base<uword,T2>& b) const; 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 const subview_elem2<eT,T1,
T2> submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const;
template<typename T1, typename T2> arma_inline subview_elem2<eT,T1,
T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci);
template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1,
T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const;
template<typename T1> arma_inline subview_elem2<eT,T1,T1> rows(cons
t Base<uword,T1>& ri);
template<typename T1> arma_inline const subview_elem2<eT,T1,T1> rows(cons
t Base<uword,T1>& ri) const;
template<typename T2> arma_inline subview_elem2<eT,T2,T2> cols(cons
t Base<uword,T2>& ci);
template<typename T2> arma_inline const subview_elem2<eT,T2,T2> cols(cons
t Base<uword,T2>& ci) const;
arma_inline diagview<eT> diag(const sword in_id = 0); arma_inline diagview<eT> diag(const sword in_id = 0);
arma_inline const diagview<eT> diag(const sword in_id = 0) const; arma_inline const diagview<eT> diag(const sword in_id = 0) const;
inline void swap_rows(const uword in_row1, const uword in_row2); inline void swap_rows(const uword in_row1, const uword in_row2);
inline void swap_cols(const uword in_col1, const uword in_col2); inline void swap_cols(const uword in_col1, const uword in_col2);
inline void shed_row(const uword row_num); inline void shed_row(const uword row_num);
inline void shed_col(const uword col_num); inline void shed_col(const uword col_num);
inline void shed_rows(const uword in_row1, const uword in_row2); inline void shed_rows(const uword in_row1, const uword in_row2);
inline void shed_cols(const uword in_col1, const uword in_col2); inline void shed_cols(const uword in_col1, const uword in_col2);
inline void insert_rows(const uword row_num, const uword N, const bool se t_to_zero = true); inline void insert_rows(const uword row_num, const uword N, const bool se t_to_zero = true);
inline void insert_cols(const uword col_num, const uword N, const bool se t_to_zero = true); inline void insert_cols(const uword col_num, const uword N, const bool se t_to_zero = true);
template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X); template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X);
template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X); template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X);
template<typename gen_type> inline Mat(const Gen<eT, ge template<typename T1, typename gen_type> inline Mat(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename gen_type> inline const Mat& operator=(const Gen<eT, ge template<typename T1, typename gen_type> inline const Mat& operator=(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename gen_type> inline const Mat& operator+=(const Gen<eT, ge template<typename T1, typename gen_type> inline const Mat& operator+=(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename gen_type> inline const Mat& operator-=(const Gen<eT, ge template<typename T1, typename gen_type> inline const Mat& operator-=(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename gen_type> inline const Mat& operator*=(const Gen<eT, ge template<typename T1, typename gen_type> inline const Mat& operator*=(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename gen_type> inline const Mat& operator%=(const Gen<eT, ge template<typename T1, typename gen_type> inline const Mat& operator%=(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename gen_type> inline const Mat& operator/=(const Gen<eT, ge template<typename T1, typename gen_type> inline const Mat& operator/=(con
n_type>& X); st Gen<T1, gen_type>& X);
template<typename T1, typename op_type> inline Mat(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline Mat(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator+=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator+=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator-=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator-=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator*=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator*=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator%=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator%=(cons t Op<T1, op_type>& X);
template<typename T1, typename op_type> inline const Mat& operator/=(cons t Op<T1, op_type>& X); template<typename T1, typename op_type> inline const Mat& operator/=(cons t Op<T1, op_type>& X);
template<typename T1, typename eop_type> inline Mat(con st eOp<T1, eop_type>& X); template<typename T1, typename eop_type> inline Mat(con st eOp<T1, eop_type>& X);
skipping to change at line 289 skipping to change at line 312
inline void impl_print_trans(const std::string& extra_text) const; inline void impl_print_trans(const std::string& extra_text) const;
inline void impl_print_trans(std::ostream& user_stream, const std::string & extra_text) const; inline void impl_print_trans(std::ostream& user_stream, const std::string & extra_text) const;
inline void impl_raw_print(const std::string& extra_text) const; inline void impl_raw_print(const std::string& extra_text) const;
inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const; inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const;
inline void impl_raw_print_trans(const std::string& extra_text) const; inline void impl_raw_print_trans(const std::string& extra_text) const;
inline void impl_raw_print_trans(std::ostream& user_stream, const std::st ring& extra_text) const; inline void impl_raw_print_trans(std::ostream& user_stream, const std::st ring& extra_text) const;
template<typename eT2> template<typename eT2, typename expr>
inline void copy_size(const Mat<eT2>& m); 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);
arma_hot inline const Mat& fill(const eT val); arma_hot inline const Mat& fill(const eT val);
skipping to change at line 448 skipping to change at line 471
static const uword n_rows = fixed_n_rows; static const uword n_rows = fixed_n_rows;
static const uword n_cols = fixed_n_cols; static const uword n_cols = fixed_n_cols;
static const uword n_elem = fixed_n_elem; static const uword n_elem = fixed_n_elem;
arma_inline fixed(); arma_inline fixed();
arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X); arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X);
template<typename T1> inline fixed(const Base<eT,T1>& A); template<typename T1> inline fixed(const Base<eT,T1>& A);
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B); template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B);
inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
inline fixed(const eT* aux_mem); inline fixed(const eT* aux_mem);
inline fixed(const char* text); inline fixed(const char* text);
inline fixed(const std::string& text); inline fixed(const std::string& text);
// TODO: handling of initializer_list ? // TODO: handling of initializer_list ?
template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A) ; template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A) ;
inline const Mat& operator=(const eT val); inline const Mat& operator=(const eT val);
skipping to change at line 488 skipping to change at line 510
arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col);
arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const; arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const;
arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col);
arma_inline arma_warn_unused eT operator() (const uword in_row, const uword in_col) const; arma_inline arma_warn_unused eT operator() (const uword in_row, const uword in_col) const;
arma_hot inline const Mat<eT>& fill(const eT val); arma_hot inline const Mat<eT>& fill(const eT val);
arma_hot inline const Mat<eT>& zeros(); arma_hot inline const Mat<eT>& zeros();
arma_hot inline const Mat<eT>& ones(); arma_hot inline const Mat<eT>& ones();
}; };
inline void steal_mem(Mat& X); //!< don't use this unless you're writing
code internal to Armadillo
protected: protected:
inline void init_cold(); inline void init_cold();
inline void init_warm(uword in_rows, uword in_cols); inline void init_warm(uword in_rows, uword in_cols);
inline void init(const std::string& text); inline void init(const std::string& text);
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
inline void init(const std::initializer_list<eT>& list); inline void init(const std::initializer_list<eT>& list);
#endif #endif
template<typename T1, typename T2> template<typename T1, typename T2>
inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
inline void steal_mem(Mat& X);
inline Mat(const char junk, const eT* aux_mem, const uword aux_n_rows, co nst uword aux_n_cols); inline Mat(const char junk, const eT* aux_mem, const uword aux_n_rows, co nst uword aux_n_cols);
inline Mat(const arma_vec_indicator&, const uhword in_vec_state);
inline Mat(const arma_vec_indicator&, const uword in_n_rows, const uword
in_n_cols, const uhword in_vec_state);
friend class Cube<eT>; friend class Cube<eT>;
friend class glue_join; friend class glue_join;
friend class op_strans; friend class op_strans;
friend class op_htrans; friend class op_htrans;
friend class op_resize; friend class op_resize;
public: public:
#ifdef ARMA_EXTRA_MAT_PROTO #ifdef ARMA_EXTRA_MAT_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO)
 End of changes. 11 change blocks. 
26 lines changed or deleted 68 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 75 skipping to change at line 75
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
, mem() , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init_cold(); init_cold();
} }
//! constructor used by Row and Col classes
template<typename eT>
inline
Mat<eT>::Mat(const arma_vec_indicator&, const uhword in_vec_state)
: n_rows( (in_vec_state == 2) ? 1 : 0 )
, n_cols( (in_vec_state == 1) ? 1 : 0 )
, n_elem(0)
, vec_state(in_vec_state)
, mem_state(0)
, mem()
{
arma_extra_debug_sigprint_this(this);
}
//! constructor used by Row and Col classes
template<typename eT>
inline
Mat<eT>::Mat(const arma_vec_indicator&, const uword in_n_rows, const uword
in_n_cols, const uhword in_vec_state)
: n_rows(in_n_rows)
, n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols)
, vec_state(in_vec_state)
, mem_state(0)
, mem()
{
arma_extra_debug_sigprint_this(this);
init_cold();
}
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::init_cold() Mat<eT>::init_cold()
{ {
arma_extra_debug_sigprint( arma_boost::format("n_rows = %d, n_cols = %d") % n_rows % n_cols ); arma_extra_debug_sigprint( arma_boost::format("n_rows = %d, n_cols = %d") % n_rows % n_cols );
// 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_check arma_debug_check
skipping to change at line 545 skipping to change at line 575
#endif #endif
//! for constructing a complex matrix out of two non-complex matrices //! for constructing a complex matrix out of two non-complex matrices
template<typename eT> template<typename eT>
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
Mat<eT>::init Mat<eT>::init
( (
const Base<typename Mat<eT>::pod_type, T1>& A, const Base<typename Mat<eT>::pod_type, T1>& X,
const Base<typename Mat<eT>::pod_type, T2>& B const Base<typename Mat<eT>::pod_type, T2>& Y
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type T; typedef typename T1::elem_type T;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2;
arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex
arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex
arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible
const Proxy<T1> X(A.get_ref()); const Proxy<T1> PX(X.get_ref());
const Proxy<T2> Y(B.get_ref()); const Proxy<T2> PY(Y.get_ref());
arma_assert_same_size(X, Y, "Mat()"); arma_assert_same_size(PX, PY, "Mat()");
init_warm(X.get_n_rows(), X.get_n_cols()); const uword local_n_rows = PX.get_n_rows();
const uword local_n_cols = PX.get_n_cols();
const uword N = n_elem; init_warm(local_n_rows, local_n_cols);
eT* out_mem = memptr();
ea_type1 PX = X.get_ea();
ea_type2 PY = Y.get_ea();
for(uword i=0; i<N; ++i) eT* out_mem = (*this).memptr();
const bool prefer_at_accessor = ( Proxy<T1>::prefer_at_accessor || Proxy<
T2>::prefer_at_accessor );
if(prefer_at_accessor == false)
{ {
out_mem[i] = std::complex<T>(PX[i], PY[i]); typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2;
const uword N = n_elem;
ea_type1 A = PX.get_ea();
ea_type2 B = PY.get_ea();
for(uword i=0; i<N; ++i)
{
out_mem[i] = std::complex<T>(A[i], B[i]);
}
}
else
{
uword i = 0;
for(uword col=0; col < local_n_cols; ++col)
for(uword row=0; row < local_n_rows; ++row, ++i)
{
out_mem[i] = std::complex<T>(PX.at(row,col), PY.at(row,col));
}
} }
} }
//! 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 1634 skipping to change at line 1685
Mat<eT>::operator/=(const subview_elem1<eT,T1>& X) Mat<eT>::operator/=(const subview_elem1<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview_elem1<eT,T1>::div_inplace(*this, X); subview_elem1<eT,T1>::div_inplace(*this, X);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1, typename T2>
inline
Mat<eT>::Mat(const subview_elem2<eT,T1,T2>& X)
: n_rows(0)
, n_cols(0)
, n_elem(0)
, vec_state(0)
, mem_state(0)
, mem()
{
arma_extra_debug_sigprint_this(this);
this->operator=(X);
}
template<typename eT>
template<typename T1, typename T2>
inline
const Mat<eT>&
Mat<eT>::operator=(const subview_elem2<eT,T1,T2>& X)
{
arma_extra_debug_sigprint();
subview_elem2<eT,T1,T2>::extract(*this, X);
return *this;
}
template<typename eT>
template<typename T1, typename T2>
inline
const Mat<eT>&
Mat<eT>::operator+=(const subview_elem2<eT,T1,T2>& X)
{
arma_extra_debug_sigprint();
subview_elem2<eT,T1,T2>::plus_inplace(*this, X);
return *this;
}
template<typename eT>
template<typename T1, typename T2>
inline
const Mat<eT>&
Mat<eT>::operator-=(const subview_elem2<eT,T1,T2>& X)
{
arma_extra_debug_sigprint();
subview_elem2<eT,T1,T2>::minus_inplace(*this, X);
return *this;
}
template<typename eT>
template<typename T1, typename T2>
inline
const Mat<eT>&
Mat<eT>::operator*=(const subview_elem2<eT,T1,T2>& X)
{
arma_extra_debug_sigprint();
glue_times::apply_inplace(*this, X);
return *this;
}
template<typename eT>
template<typename T1, typename T2>
inline
const Mat<eT>&
Mat<eT>::operator%=(const subview_elem2<eT,T1,T2>& X)
{
arma_extra_debug_sigprint();
subview_elem2<eT,T1,T2>::schur_inplace(*this, X);
return *this;
}
template<typename eT>
template<typename T1, typename T2>
inline
const Mat<eT>&
Mat<eT>::operator/=(const subview_elem2<eT,T1,T2>& X)
{
arma_extra_debug_sigprint();
subview_elem2<eT,T1,T2>::div_inplace(*this, X);
return *this;
}
template<typename eT>
inline inline
mat_injector< Mat<eT> > mat_injector< Mat<eT> >
Mat<eT>::operator<<(const eT val) Mat<eT>::operator<<(const eT val)
{ {
return mat_injector< Mat<eT> >(*this, val); return mat_injector< Mat<eT> >(*this, val);
} }
template<typename eT> template<typename eT>
inline inline
mat_injector< Mat<eT> > mat_injector< Mat<eT> >
Mat<eT>::operator<<(const injector_end_of_row& x) Mat<eT>::operator<<(const injector_end_of_row<>&amp; x)
{ {
return mat_injector< Mat<eT> >(*this, x); return mat_injector< Mat<eT> >(*this, x);
} }
//! creation of subview (row vector) //! creation of subview (row vector)
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT> subview_row<eT>
Mat<eT>::row(const uword row_num) Mat<eT>::row(const uword row_num)
{ {
skipping to change at line 2071 skipping to change at line 2216
template<typename T1> template<typename T1>
arma_inline arma_inline
const subview_elem1<eT,T1> const subview_elem1<eT,T1>
Mat<eT>::elem(const Base<uword,T1>& a) const Mat<eT>::elem(const Base<uword,T1>& a) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a); return subview_elem1<eT,T1>(*this, a);
} }
// template<typename eT> template<typename eT>
// template<typename T1, typename T2> template<typename T1, typename T2>
// arma_inline arma_inline
// subview_elem2<eT,T1,T2> subview_elem2<eT,T1,T2>
// Mat<eT>::elem(const Base<uword,T1>& a, const Base<uword,T2>& b) Mat<eT>::elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci)
// { {
// arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//
// return subview_elem2<eT,T1,T2>(*this, a, b); return subview_elem2<eT,T1,T2>(*this, ri, ci, false, false);
// } }
//
// template<typename eT>
// template<typename T1, typename T2>
// template<typename eT> arma_inline
// template<typename T1, typename T2> const subview_elem2<eT,T1,T2>
// arma_inline Mat<eT>::elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const
// const subview_elem2<eT,T1,T2> {
// Mat<eT>::elem(const Base<uword,T1>& a, const Base<uword,T2>& b) const arma_extra_debug_sigprint();
// {
// arma_extra_debug_sigprint(); return subview_elem2<eT,T1,T2>(*this, ri, ci, false, false);
// }
// return subview_elem2<eT,T1,T2>(*this, a, b);
// } template<typename eT>
template<typename T1, typename T2>
arma_inline
subview_elem2<eT,T1,T2>
Mat<eT>::submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci)
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T1,T2>(*this, ri, ci, false, false);
}
template<typename eT>
template<typename T1, typename T2>
arma_inline
const subview_elem2<eT,T1,T2>
Mat<eT>::submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T1,T2>(*this, ri, ci, false, false);
}
template<typename eT>
template<typename T1, typename T2>
arma_inline
subview_elem2<eT,T1,T2>
Mat<eT>::operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci)
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T1,T2>(*this, ri, ci, false, false);
}
template<typename eT>
template<typename T1, typename T2>
arma_inline
const subview_elem2<eT,T1,T2>
Mat<eT>::operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci) con
st
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T1,T2>(*this, ri, ci, false, false);
}
template<typename eT>
template<typename T1>
arma_inline
subview_elem2<eT,T1,T1>
Mat<eT>::rows(const Base<uword,T1>& ri)
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T1,T1>(*this, ri, ri, false, true);
}
template<typename eT>
template<typename T1>
arma_inline
const subview_elem2<eT,T1,T1>
Mat<eT>::rows(const Base<uword,T1>& ri) const
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T1,T1>(*this, ri, ri, false, true);
}
template<typename eT>
template<typename T2>
arma_inline
subview_elem2<eT,T2,T2>
Mat<eT>::cols(const Base<uword,T2>& ci)
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T2,T2>(*this, ci, ci, true, false);
}
template<typename eT>
template<typename T2>
arma_inline
const subview_elem2<eT,T2,T2>
Mat<eT>::cols(const Base<uword,T2>& ci) const
{
arma_extra_debug_sigprint();
return subview_elem2<eT,T2,T2>(*this, ci, ci, true, false);
}
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT> diagview<eT>
Mat<eT>::diag(const sword in_id) Mat<eT>::diag(const sword in_id)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword row_offset = (in_id < 0) ? uword(-in_id) : 0; const uword row_offset = (in_id < 0) ? uword(-in_id) : 0;
skipping to change at line 2507 skipping to change at line 2738
if(C_n_rows > 0) if(C_n_rows > 0)
{ {
out.cols(col_num, col_num + C_n_cols - 1) = C; out.cols(col_num, col_num + C_n_cols - 1) = C;
} }
steal_mem(out); steal_mem(out);
} }
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
Mat<eT>::Mat(const Gen<eT, gen_type>& X) Mat<eT>::Mat(const Gen<T1, gen_type>& X)
: n_rows(X.n_rows) : n_rows(X.n_rows)
, n_cols(X.n_cols) , n_cols(X.n_cols)
, n_elem(n_rows*n_cols) , n_elem(n_rows*n_cols)
, vec_state(0) , vec_state(0)
, mem_state(0) , mem_state(0)
, mem() , mem()
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
init_cold(); init_cold();
X.apply(*this); X.apply(*this);
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const Gen<eT, gen_type>& X) Mat<eT>::operator=(const Gen<T1, gen_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
init_warm(X.n_rows, X.n_cols); init_warm(X.n_rows, X.n_cols);
X.apply(*this); X.apply(*this);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator+=(const Gen<eT, gen_type>& X) Mat<eT>::operator+=(const Gen<T1, gen_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
X.apply_inplace_plus(*this); X.apply_inplace_plus(*this);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator-=(const Gen<eT, gen_type>& X) Mat<eT>::operator-=(const Gen<T1, gen_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
X.apply_inplace_minus(*this); X.apply_inplace_minus(*this);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator*=(const Gen<eT, gen_type>& X) Mat<eT>::operator*=(const Gen<T1, gen_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
const Mat<eT> tmp(X); const Mat<eT> tmp(X);
return (*this).operator*=(tmp); return (*this).operator*=(tmp);
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator%=(const Gen<eT, gen_type>& X) Mat<eT>::operator%=(const Gen<T1, gen_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
X.apply_inplace_schur(*this); X.apply_inplace_schur(*this);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename gen_type> template<typename T1, typename gen_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator/=(const Gen<eT, gen_type>& X) Mat<eT>::operator/=(const Gen<T1, gen_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa
lse ));
X.apply_inplace_div(*this); X.apply_inplace_div(*this);
return *this; return *this;
} }
//! create a matrix from Op, i.e. run the previously delayed unary operatio ns //! create a matrix from Op, i.e. run the previously delayed unary operatio ns
template<typename eT> template<typename eT>
template<typename T1, typename op_type> template<typename T1, typename op_type>
inline inline
Mat<eT>::Mat(const Op<T1, op_type>& X) Mat<eT>::Mat(const Op<T1, op_type>& X)
skipping to change at line 2751 skipping to change at line 2996
template<typename eT> template<typename eT>
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eOp<T1, eop_type>& X) Mat<eT>::operator=(const eOp<T1, eop_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse )); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
const bool bad_alias = (X.P.has_subview && X.P.is_alias(*this)); const bool bad_alias = (eOp<T1, eop_type>::proxy_type::has_subview && X .P.is_alias(*this));
if(bad_alias == false) if(bad_alias == false)
{ {
init_warm(X.get_n_rows(), X.get_n_cols()); init_warm(X.get_n_rows(), X.get_n_cols());
eop_type::apply(*this, X); eop_type::apply(*this, X);
} }
else else
{ {
Mat<eT> tmp(X); Mat<eT> tmp(X);
skipping to change at line 3127 skipping to change at line 3372
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(const eGlue<T1, T2, eglue_type>& X) Mat<eT>::operator=(const eGlue<T1, T2, eglue_type>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse )); arma_type_check(( is_same_type< eT, typename T1::elem_type >::value == fa lse ));
arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa lse )); arma_type_check(( is_same_type< eT, typename T2::elem_type >::value == fa lse ));
const bool bad_alias = ( (X.P1.has_subview && X.P1.is_alias(*this)) || const bool bad_alias =
( X.P2.has_subview && X.P2.is_alias(*this)) ); (
(eGlue<T1, T2, eglue_type>::proxy1_type::has_subview && X.P1.is_alias
(*this))
||
(eGlue<T1, T2, eglue_type>::proxy2_type::has_subview && X.P2.is_alias
(*this))
);
if(bad_alias == false) if(bad_alias == false)
{ {
init_warm(X.get_n_rows(), X.get_n_cols()); init_warm(X.get_n_rows(), X.get_n_cols());
eglue_type::apply(*this, X); eglue_type::apply(*this, X);
} }
else else
{ {
Mat<eT> tmp(X); Mat<eT> tmp(X);
skipping to change at line 3902 skipping to change at line 4152
template<typename eT> template<typename eT>
inline inline
void void
Mat<eT>::reshape(const uword in_rows, const uword in_cols, const uword dim) Mat<eT>::reshape(const uword in_rows, const uword in_cols, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
*this = arma::reshape(*this, in_rows, in_cols, dim); *this = arma::reshape(*this, in_rows, in_cols, dim);
} }
//! change the matrix (without preserving data) to have the same dimensions as the given matrix //! change the matrix (without preserving data) to have the same dimensions as the given expression
template<typename eT> template<typename eT>
template<typename eT2> template<typename eT2, typename expr>
inline inline
void void
Mat<eT>::copy_size(const Mat<eT2>& m) Mat<eT>::copy_size(const Base<eT2, expr>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init_warm(m.n_rows, m.n_cols); const Proxy<expr> P(X.get_ref());
const uword X_n_rows = P.get_n_rows();
const uword X_n_cols = P.get_n_cols();
init_warm(X_n_rows, X_n_cols);
} }
//! fill the matrix with the specified value //! fill the matrix with the specified value
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fill(const eT val) Mat<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 4939 skipping to change at line 5194
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Mat<eT>::init(A,B); Mat<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
inline inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(eT* aux_mem, const bool c
opy_aux_mem)
{
arma_extra_debug_sigprint_this(this);
access::rw(Mat<eT>::n_rows) = fixed_n_rows;
access::rw(Mat<eT>::n_cols) = fixed_n_cols;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 0;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true)
{
eT* dest = (use_extra) ? mem_local_extra : mem_local;
access::rw(Mat<eT>::mem) = dest;
arrayops::copy( dest, aux_mem, fixed_n_elem );
}
else
{
access::rw(Mat<eT>::mem) = aux_mem;
}
}
template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols>
inline
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const eT* aux_mem) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
skipping to change at line 5123 skipping to change at line 5351
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword i) cons t Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator[] (const uword i) cons t
{ {
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword i) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword i) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword i)
{ {
arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Mat::operator(): out of bounds");
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword i) cons t Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword i) cons t
{ {
arma_debug_check( (i >= fixed_n_elem), "Mat::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Mat::operator(): out of bounds");
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col)
{ {
const uword i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::at(const uword in_row, const uw ord in_col) const
{ {
const uword i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::fixed::operator(): out of bounds"); arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::operator(): out of bounds");
const uword i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col) const Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator() (const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::fixed::operator(): out of bounds"); arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)), "Mat::operator(): out of bounds");
const uword i = in_row + in_col*fixed_n_rows; const uword i = in_row + in_col*fixed_n_rows;
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_hot arma_hot
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fill(const eT val) Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(mem_local[0]);
;
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_hot arma_hot
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::zeros() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(mem_local[0]);
);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(0) );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_rows, uword fixed_n_cols> template<uword fixed_n_rows, uword fixed_n_cols>
arma_hot arma_hot
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::ones() Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(mem_local[0]);
);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(1) );
return *this; return *this;
} }
//! prefix ++ //! prefix ++
template<typename eT> template<typename eT>
arma_inline arma_inline
void void
Mat_aux::prefix_pp(Mat<eT>& x) Mat_aux::prefix_pp(Mat<eT>& x)
{ {
skipping to change at line 5432 skipping to change at line 5666
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
Mat_aux::set_real(Mat< std::complex<T> >& out, const Base<T,T1>& X) Mat_aux::set_real(Mat< std::complex<T> >& out, const Base<T,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> P(X.get_ref());
arma_debug_assert_same_size( out, A, "Mat::set_real()" ); const uword local_n_rows = P.get_n_rows();
const uword local_n_cols = P.get_n_cols();
const uword n_elem = out.n_elem; arma_debug_assert_same_size( out.n_rows, out.n_cols, local_n_rows, local_
eT* out_mem = out.memptr(); n_cols, "Mat::set_real()" );
ea_type PA = A.get_ea();
for(uword i=0; i<n_elem; ++i) eT* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
//out_mem[i].real() = PA[i]; typedef typename Proxy<T1>::ea_type ea_type;
out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() );
ea_type A = P.get_ea();
const uword N = out.n_elem;
for(uword i=0; i<N; ++i)
{
out_mem[i] = std::complex<T>( A[i], out_mem[i].imag() );
}
}
else
{
uword i = 0;
for(uword col=0; col < local_n_cols; ++col)
for(uword row=0; row < local_n_rows; ++row, ++i)
{
out_mem[i] = std::complex<T>( P.at(row,col), out_mem[i].imag());
}
} }
} }
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
Mat_aux::set_imag(Mat< std::complex<T> >& out, const Base<T,T1>& X) Mat_aux::set_imag(Mat< std::complex<T> >& out, const Base<T,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> P(X.get_ref());
const uword local_n_rows = P.get_n_rows();
const uword local_n_cols = P.get_n_cols();
arma_debug_assert_same_size( out.n_rows, out.n_cols, local_n_rows, local_
n_cols, "Mat::set_imag()" );
eT* out_mem = out.memptr();
const Proxy<T1> A(X.get_ref()); if(Proxy<T1>::prefer_at_accessor == false)
{
typedef typename Proxy<T1>::ea_type ea_type;
arma_debug_assert_same_size( out, A, "Mat::set_imag()" ); ea_type A = P.get_ea();
const uword n_elem = out.n_elem; const uword N = out.n_elem;
eT* out_mem = out.memptr();
ea_type PA = A.get_ea();
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<N; ++i)
{
out_mem[i] = std::complex<T>( out_mem[i].real(), A[i] );
}
}
else
{ {
//out_mem[i].imag() = PA[i]; uword i = 0;
out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] );
for(uword col=0; col < local_n_cols; ++col)
for(uword row=0; row < local_n_rows; ++row, ++i)
{
out_mem[i] = std::complex<T>( out_mem[i].real(), P.at(row,col) );
}
} }
} }
#ifdef ARMA_EXTRA_MAT_MEAT #ifdef ARMA_EXTRA_MAT_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_MEAT)
#endif #endif
//! @} //! @}
 End of changes. 70 change blocks. 
130 lines changed or deleted 409 lines changed or added


 Op_bones.hpp   Op_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 34 skipping to change at line 34
//! Op< Glue< Mat, Mat, glue_times >, op_htrans > //! Op< Glue< Mat, Mat, glue_times >, op_htrans >
template<typename T1, typename op_type> template<typename T1, typename op_type>
class Op : public Base<typename T1::elem_type, Op<T1, op_type> > class Op : public Base<typename T1::elem_type, Op<T1, op_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool is_row = ( T1::is_col && (is_same_type<op_type, op_stra
ns>::value || is_same_type<op_type, op_htrans>::value || is_same_type<op_ty
pe, op_htrans2>::value) );
static const bool is_col = ( T1::is_row && (is_same_type<op_type, op_stra
ns>::value || is_same_type<op_type, op_htrans>::value || is_same_type<op_ty
pe, op_htrans2>::value) );
inline explicit Op(const T1& in_m); inline explicit Op(const T1& in_m);
inline Op(const T1& in_m, const elem_type in_aux); inline Op(const T1& in_m, const elem_type in_aux);
inline Op(const T1& in_m, const elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b); inline Op(const T1& in_m, const elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b);
inline Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b); inline Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b);
inline Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c, const char junk); inline Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c, const char junk);
inline ~Op(); inline ~Op();
arma_aligned const T1& m; //!< storage of reference to t he operand (eg. a matrix) arma_aligned const T1& m; //!< storage of reference to t he operand (eg. a matrix)
arma_aligned elem_type aux; //!< storage of auxiliary data , user defined format arma_aligned elem_type aux; //!< storage of auxiliary data , user defined format
arma_aligned uword aux_uword_a; //!< storage of auxiliary data , uword format arma_aligned uword aux_uword_a; //!< storage of auxiliary data , uword format
 End of changes. 2 change blocks. 
2 lines changed or deleted 9 lines changed or added


 Proxy.hpp   Proxy.hpp 
skipping to change at line 42 skipping to change at line 42
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = false;
static const bool is_col = false;
arma_aligned const Mat<eT>& Q; arma_aligned const Mat<eT>& Q;
inline explicit Proxy(const Mat<eT>& A) inline explicit Proxy(const Mat<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
skipping to change at line 76 skipping to change at line 79
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Col<eT> stored_type; typedef Col<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = false;
static const bool is_col = true;
arma_aligned const Col<eT>& Q; arma_aligned const Col<eT>& Q;
inline explicit Proxy(const Col<eT>& A) inline explicit Proxy(const Col<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return 1; } arma_inline uword get_n_cols() const { return 1; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const arma_inline elem_type operator[] (const uword i) const { r
{ return Q[i]; } eturn Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const arma_inline elem_type at (const uword row, const uword) const { r
{ return Q.at(row, col); } eturn Q[row]; }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); }
}; };
template<typename eT> template<typename eT>
class Proxy< Row<eT> > class Proxy< Row<eT> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Row<eT> stored_type; typedef Row<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = true;
static const bool is_col = false;
arma_aligned const Row<eT>& Q; arma_aligned const Row<eT>& Q;
inline explicit Proxy(const Row<eT>& A) inline explicit Proxy(const Row<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return 1; } arma_inline uword get_n_rows() const { return 1; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const arma_inline elem_type operator[] (const uword i) const { r
{ return Q[i]; } eturn Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const arma_inline elem_type at (const uword, const uword col) const { r
{ return Q.at(row, col); } eturn Q[col]; }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); }
}; };
template<typename eT, typename gen_type> // // TODO: how to allow general Mat<eT> instead of specific Mat<double> ?
class Proxy< Gen<eT, gen_type > > // template<uword fixed_n_rows, uword fixed_n_cols>
// class Proxy< Mat<double>::fixed<fixed_n_rows,fixed_n_cols> >
// {
// public:
//
// typedef double eT;
//
// typedef eT elem_type;
// typedef typename get_pod_type<elem_type>::result pod_type;
// typedef Mat<eT>::fixed<fixed_n_rows,fixed_n_cols> stored_type;
// typedef const eT* ea_type;
//
// static const bool prefer_at_accessor = false;
// static const bool has_subview = false;
//
// static const bool is_row = false;
// static const bool is_col = false;
//
// arma_aligned const Mat<eT>::fixed<fixed_n_rows,fixed_n_cols>& Q;
//
// inline explicit Proxy(const Mat<eT>::fixed<fixed_n_rows,fixed_n_cols>&
A)
// : Q(A)
// {
// arma_extra_debug_sigprint();
// }
//
// arma_inline uword get_n_rows() const { return fixed_n_rows;
}
// arma_inline uword get_n_cols() const { return fixed_n_cols;
}
// arma_inline uword get_n_elem() const { return fixed_n_rows*fixed_n_col
s; }
//
// arma_inline elem_type operator[] (const uword i) co
nst { return Q[i]; }
// arma_inline elem_type at (const uword row, const uword col) co
nst { return Q.at(row, col); }
//
// arma_inline ea_type get_ea() const { return Q.memptr
(); }
// arma_inline bool is_alias(const Mat<eT>& X) const { return (&Q == &
X); }
// };
template<typename T1, typename gen_type>
class Proxy< Gen<T1, gen_type > >
{ {
public: public:
typedef eT elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Gen<eT, gen_type> stored_type; typedef Gen<T1, gen_type> stored_type;
typedef const Gen<eT, gen_type>& ea_type; typedef const Gen<T1, gen_type>& ea_type;
static const bool prefer_at_accessor = Gen<eT, gen_type>::prefer_at_acces sor; static const bool prefer_at_accessor = Gen<T1, gen_type>::prefer_at_acces sor;
static const bool has_subview = false; static const bool has_subview = false;
arma_aligned const Gen<eT, gen_type>& Q; static const bool is_row = Gen<T1, gen_type>::is_row;
static const bool is_col = Gen<T1, gen_type>::is_col;
arma_aligned const Gen<T1, gen_type>& Q;
inline explicit Proxy(const Gen<eT, gen_type>& A) inline explicit Proxy(const Gen<T1, gen_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols; } arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
skipping to change at line 178 skipping to change at line 228
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = Op<T1, op_type>::is_row;
static const bool is_col = Op<T1, op_type>::is_col;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Op<T1, op_type>& A) inline explicit Proxy(const Op<T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
skipping to change at line 212 skipping to change at line 265
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<elem_type> stored_type; typedef Mat<elem_type> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = Glue<T1, T2, glue_type>::is_row;
static const bool is_col = Glue<T1, T2, glue_type>::is_col;
arma_aligned const Mat<elem_type> Q; arma_aligned const Mat<elem_type> Q;
inline explicit Proxy(const Glue<T1, T2, glue_type>& A) inline explicit Proxy(const Glue<T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
skipping to change at line 246 skipping to change at line 302
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview<eT> stored_type; typedef subview<eT> stored_type;
typedef const subview<eT>& ea_type; typedef const subview<eT>& ea_type;
static const bool prefer_at_accessor = true; static const bool prefer_at_accessor = true;
static const bool has_subview = true; static const bool has_subview = true;
static const bool is_row = false;
static const bool is_col = false;
arma_aligned const subview<eT>& Q; arma_aligned const subview<eT>& Q;
inline explicit Proxy(const subview<eT>& A) inline explicit Proxy(const subview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return Q.n_cols; }
skipping to change at line 267 skipping to change at line 326
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q .m)) == void_ptr(&X)); } arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q .m)) == void_ptr(&X)); }
}; };
template<typename eT>
class Proxy< subview_col<eT> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview_col<eT> stored_type;
typedef const subview_col<eT>& ea_type;
static const bool prefer_at_accessor = true;
static const bool has_subview = true;
static const bool is_row = false;
static const bool is_col = true;
arma_aligned const subview_col<eT>& Q;
inline explicit Proxy(const subview_col<eT>& A)
: Q(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return 1; }
arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { r
eturn Q[i]; }
arma_inline elem_type at (const uword row, const uword) const { r
eturn Q.at(row, 0); }
arma_inline ea_type get_ea() const { return Q; }
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q
.m)) == void_ptr(&X)); }
};
template<typename eT>
class Proxy< subview_row<eT> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef subview_row<eT> stored_type;
typedef const subview_row<eT>& ea_type;
static const bool prefer_at_accessor = true;
static const bool has_subview = true;
static const bool is_row = true;
static const bool is_col = false;
arma_aligned const subview_row<eT>& Q;
inline explicit Proxy(const subview_row<eT>& A)
: Q(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return 1; }
arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { r
eturn Q[i]; }
arma_inline elem_type at (const uword, const uword col) const { r
eturn Q.at(0, col); }
arma_inline ea_type get_ea() const { return Q; }
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q
.m)) == void_ptr(&X)); }
};
template<typename eT, typename T1> template<typename eT, typename T1>
class Proxy< subview_elem1<eT,T1> > class Proxy< subview_elem1<eT,T1> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type; typedef Mat<eT> stored_type;
typedef const eT* ea_type; typedef const eT* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = false;
static const bool is_col = true;
arma_aligned const Mat<eT> Q; arma_aligned const Mat<eT> Q;
inline explicit Proxy(const subview_elem1<eT,T1>& A) inline explicit Proxy(const subview_elem1<eT,T1>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return 1; } arma_inline uword get_n_cols() const { return 1; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { r
eturn Q[i]; }
arma_inline elem_type at (const uword row, const uword) const { r
eturn Q[row]; }
arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
};
template<typename eT, typename T1, typename T2>
class Proxy< subview_elem2<eT,T1,T2> >
{
public:
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
typedef Mat<eT> stored_type;
typedef const eT* ea_type;
static const bool prefer_at_accessor = false;
static const bool has_subview = false;
static const bool is_row = false;
static const bool is_col = false;
arma_aligned const Mat<eT> Q;
inline explicit Proxy(const subview_elem2<eT,T1,T2>& A)
: Q(A)
{
arma_extra_debug_sigprint();
}
arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
template<typename eT> template<typename eT>
skipping to change at line 314 skipping to change at line 487
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef diagview<eT> stored_type; typedef diagview<eT> stored_type;
typedef const diagview<eT>& ea_type; typedef const diagview<eT>& ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = true; static const bool has_subview = true;
static const bool is_row = false;
static const bool is_col = true;
arma_aligned const diagview<eT>& Q; arma_aligned const diagview<eT>& Q;
inline explicit Proxy(const diagview<eT>& A) inline explicit Proxy(const diagview<eT>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return Q.n_rows; }
arma_inline uword get_n_cols() const { return 1; } arma_inline uword get_n_cols() const { return 1; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const arma_inline elem_type operator[] (const uword i) const { r
{ return Q[i]; } eturn Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const arma_inline elem_type at (const uword row, const uword) const { r
{ return Q.at(row, col); } eturn Q.at(row, 0); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q .m)) == void_ptr(&X)); } arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&(Q .m)) == void_ptr(&X)); }
}; };
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
class Proxy< eOp<T1, eop_type > > class Proxy< eOp<T1, eop_type > >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eOp<T1, eop_type> stored_type; typedef eOp<T1, eop_type> stored_type;
typedef const eOp<T1, eop_type>& ea_type; typedef const eOp<T1, eop_type>& ea_type;
static const bool prefer_at_accessor = eOp<T1, eop_type>::prefer_at_acces sor; static const bool prefer_at_accessor = eOp<T1, eop_type>::prefer_at_acces sor;
static const bool has_subview = eOp<T1, eop_type>::has_subview; static const bool has_subview = eOp<T1, eop_type>::has_subview;
static const bool is_row = eOp<T1, eop_type>::is_row;
static const bool is_col = eOp<T1, eop_type>::is_col;
arma_aligned const eOp<T1, eop_type>& Q; arma_aligned const eOp<T1, eop_type>& Q;
inline explicit Proxy(const eOp<T1, eop_type>& A) inline explicit Proxy(const eOp<T1, eop_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.get_n_rows(); } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.get_n_rows()
arma_inline uword get_n_cols() const { return Q.get_n_cols(); } ; }
arma_inline uword get_n_elem() const { return Q.get_n_elem(); } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.get_n_cols()
; }
arma_inline uword get_n_elem() const { return Q.get_n_elem();
}
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return Q.P.is_alias( X); } arma_inline bool is_alias(const Mat<eT2>& X) const { return Q.P.is_alias( X); }
}; };
skipping to change at line 382 skipping to change at line 561
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef eGlue<T1, T2, eglue_type> stored_type; typedef eGlue<T1, T2, eglue_type> stored_type;
typedef const eGlue<T1, T2, eglue_type>& ea_type; typedef const eGlue<T1, T2, eglue_type>& ea_type;
static const bool prefer_at_accessor = eGlue<T1, T2, eglue_type>::prefer_ at_accessor; static const bool prefer_at_accessor = eGlue<T1, T2, eglue_type>::prefer_ at_accessor;
static const bool has_subview = eGlue<T1, T2, eglue_type>::has_sub view; static const bool has_subview = eGlue<T1, T2, eglue_type>::has_sub view;
static const bool is_row = eGlue<T1, T2, eglue_type>::is_row;
static const bool is_col = eGlue<T1, T2, eglue_type>::is_col;
arma_aligned const eGlue<T1, T2, eglue_type>& Q; arma_aligned const eGlue<T1, T2, eglue_type>& Q;
inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A) inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.get_n_rows(); } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.get_n_rows()
arma_inline uword get_n_cols() const { return Q.get_n_cols(); } ; }
arma_inline uword get_n_elem() const { return Q.get_n_elem(); } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.get_n_cols()
; }
arma_inline uword get_n_elem() const { return Q.get_n_elem();
}
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); }
arma_inline ea_type get_ea() const { return Q; } arma_inline ea_type get_ea() const { return Q; }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (Q.P1.is_alia s(X) || Q.P2.is_alias(X)); } arma_inline bool is_alias(const Mat<eT2>& X) const { return (Q.P1.is_alia s(X) || Q.P2.is_alias(X)); }
}; };
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class Proxy< mtOp<out_eT, T1, op_type> > class Proxy< mtOp<out_eT, T1, op_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Mat<out_eT> stored_type; typedef Mat<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = mtOp<out_eT, T1, op_type>::is_row;
static const bool is_col = mtOp<out_eT, T1, op_type>::is_col;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A) inline explicit Proxy(const mtOp<out_eT, T1, op_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row,col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row,col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
skipping to change at line 450 skipping to change at line 635
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef Mat<out_eT> stored_type; typedef Mat<out_eT> stored_type;
typedef const elem_type* ea_type; typedef const elem_type* ea_type;
static const bool prefer_at_accessor = false; static const bool prefer_at_accessor = false;
static const bool has_subview = false; static const bool has_subview = false;
static const bool is_row = mtGlue<out_eT, T1, T2, glue_type>::is_row;
static const bool is_col = mtGlue<out_eT, T1, T2, glue_type>::is_col;
arma_aligned const Mat<out_eT> Q; arma_aligned const Mat<out_eT> Q;
inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A) inline explicit Proxy(const mtGlue<out_eT, T1, T2, glue_type>& A)
: Q(A) : Q(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
arma_inline uword get_n_rows() const { return Q.n_rows; } arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; }
arma_inline uword get_n_cols() const { return Q.n_cols; } arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; }
arma_inline uword get_n_elem() const { return Q.n_elem; } arma_inline uword get_n_elem() const { return Q.n_elem; }
arma_inline elem_type operator[] (const uword i) const { return Q[i]; } arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row,col); } arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row,col); }
arma_inline ea_type get_ea() const { return Q.memptr(); } arma_inline ea_type get_ea() const { return Q.memptr(); }
template<typename eT2> template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>&) const { return false; } arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
}; };
 End of changes. 31 change blocks. 
42 lines changed or deleted 252 lines changed or added


 Row_bones.hpp   Row_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 26 skipping to change at line 26
//! Class for row vectors (matrices with only one row) //! Class for row vectors (matrices with only one row)
template<typename eT> template<typename eT>
class Row : public Mat<eT> class Row : public Mat<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
static const bool is_col = false;
static const bool is_row = true;
inline Row(); inline Row();
inline Row(const Row<eT>& X); inline Row(const Row<eT>& X);
inline explicit Row(const uword N); inline explicit Row(const uword N);
inline Row(const uword in_rows, const uword in_cols); inline Row(const uword in_rows, const uword in_cols);
inline Row(const char* text); inline Row(const char* text);
inline const Row& operator=(const char* text); inline const Row& operator=(const char* text);
inline Row(const std::string& text); inline Row(const std::string& text);
inline const Row& operator=(const std::string& text); inline const Row& operator=(const std::string& text);
skipping to change at line 61 skipping to change at line 64
inline explicit Row(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); inline explicit Row(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
template<typename T1> inline Row(const BaseCube<eT,T1>& X); template<typename T1> inline Row(const BaseCube<eT,T1>& X);
template<typename T1> inline const Row& operator=(const BaseCube<eT,T1>& X); template<typename T1> inline const Row& operator=(const BaseCube<eT,T1>& X);
inline Row(const subview_cube<eT>& X); inline Row(const subview_cube<eT>& X);
inline const Row& operator=(const subview_cube<eT>& X); inline const Row& operator=(const subview_cube<eT>& X);
inline mat_injector<Row> operator<<(const eT val); inline mat_injector<Row> operator<<(const eT val);
arma_inline const Op<Row<eT>,op_htrans> t() const;
arma_inline const Op<Row<eT>,op_htrans> ht() const;
arma_inline const Op<Row<eT>,op_strans> st() const;
arma_inline eT& col(const uword col_num); arma_inline eT& col(const uword col_num);
arma_inline eT col(const uword col_num) const; arma_inline eT col(const uword col_num) const;
arma_inline subview_row<eT> cols(const uword in_col1, const uword i n_col2); arma_inline subview_row<eT> cols(const uword in_col1, const uword i n_col2);
arma_inline const subview_row<eT> cols(const uword in_col1, const uword i n_col2) const; arma_inline const subview_row<eT> cols(const uword in_col1, const uword i n_col2) const;
arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2); arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2);
arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const; arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
arma_inline subview_row<eT> subvec(const span& col_span); arma_inline subview_row<eT> subvec(const span& col_span);
skipping to change at line 115 skipping to change at line 122
static const uword n_cols = fixed_n_elem; static const uword n_cols = fixed_n_elem;
static const uword n_elem = fixed_n_elem; static const uword n_elem = fixed_n_elem;
arma_inline fixed(); arma_inline fixed();
arma_inline fixed(const fixed<fixed_n_elem>& X); arma_inline fixed(const fixed<fixed_n_elem>& X);
inline fixed(const subview_cube<eT>& X); inline fixed(const subview_cube<eT>& X);
template<typename T1> inline fixed(const Base<eT,T1>& A); template<typename T1> inline fixed(const Base<eT,T1>& A);
template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B); template<typename T1, typename T2> inline fixed(const Base<pod_type,T1> & A, const Base<pod_type,T2>& B);
inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
inline fixed(const eT* aux_mem); inline fixed(const eT* aux_mem);
inline fixed(const char* text); inline fixed(const char* text);
inline fixed(const std::string& text); inline fixed(const std::string& text);
template<typename T1> inline const Row& operator=(const Base<eT,T1>& A) ; template<typename T1> inline const Row& operator=(const Base<eT,T1>& A) ;
inline const Row& operator=(const eT val); inline const Row& operator=(const eT val);
inline const Row& operator=(const char* text); inline const Row& operator=(const char* text);
inline const Row& operator=(const std::string& text); inline const Row& operator=(const std::string& text);
 End of changes. 4 change blocks. 
3 lines changed or deleted 9 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup Row //! \addtogroup Row
//! @{ //! @{
//! construct an empty row vector //! construct an empty row vector
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row() Row<eT>::Row()
: Mat<eT>(1, 0) : Mat<eT>(arma_vec_indicator(), 2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const Row<eT>& X) Row<eT>::Row(const Row<eT>& X)
: Mat<eT>(1, X.n_elem) : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
arrayops::copy((*this).memptr(), X.memptr(), X.n_elem); arrayops::copy((*this).memptr(), X.memptr(), X.n_elem);
} }
//! construct a row vector with the specified number of n_elem //! construct a row vector with the specified number of n_elem
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const uword in_n_elem) Row<eT>::Row(const uword in_n_elem)
: Mat<eT>(1, in_n_elem) : Mat<eT>(arma_vec_indicator(), 1, in_n_elem, 2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const uword in_n_rows, const uword in_n_cols) Row<eT>::Row(const uword in_n_rows, const uword in_n_cols)
: Mat<eT>(arma_vec_indicator(), 2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::init_warm(in_n_rows, in_n_cols); Mat<eT>::init_warm(in_n_rows, in_n_cols);
} }
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const char* text) Row<eT>::Row(const char* text)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2; access::rw(Mat<eT>::vec_state) = 2;
skipping to change at line 150 skipping to change at line 143
Mat<eT>::operator=(val); Mat<eT>::operator=(val);
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
Row<eT>::Row(const Base<eT,T1>& X) Row<eT>::Row(const Base<eT,T1>& X)
: Mat<eT>(arma_vec_indicator(), 2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
access::rw(Mat<eT>::vec_state) = 2;
Mat<eT>::operator=(X.get_ref()); Mat<eT>::operator=(X.get_ref());
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(const Base<eT,T1>& X) Row<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 267 skipping to change at line 259
template<typename eT> template<typename eT>
inline inline
mat_injector< Row<eT> > mat_injector< Row<eT> >
Row<eT>::operator<<(const eT val) Row<eT>::operator<<(const eT val)
{ {
return mat_injector< Row<eT> >(*this, val); return mat_injector< Row<eT> >(*this, val);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Row<eT>,op_htrans>
Row<eT>::t() const
{
return Op<Row<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<Row<eT>,op_htrans>
Row<eT>::ht() const
{
return Op<Row<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<Row<eT>,op_strans>
Row<eT>::st() const
{
return Op<Row<eT>,op_strans>(*this);
}
template<typename eT>
arma_inline
eT& eT&
Row<eT>::col(const uword col_num) Row<eT>::col(const uword col_num)
{ {
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound s" ); arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bound s" );
return access::rw(Mat<eT>::mem[col_num]); return access::rw(Mat<eT>::mem[col_num]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
skipping to change at line 636 skipping to change at line 652
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
Row<eT>::init(A,B); Row<eT>::init(A,B);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
inline inline
Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
{
arma_extra_debug_sigprint_this(this);
access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = fixed_n_elem;
access::rw(Mat<eT>::n_elem) = fixed_n_elem;
access::rw(Mat<eT>::vec_state) = 2;
access::rw(Mat<eT>::mem_state) = 3;
if(copy_aux_mem == true)
{
eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
access::rw(Mat<eT>::mem) = dest;
arrayops::copy( dest, aux_mem, fixed_n_elem );
}
else
{
access::rw(Mat<eT>::mem) = aux_mem;
}
}
template<typename eT>
template<uword fixed_n_elem>
inline
Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
mem_setup(); mem_setup();
arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem ); arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
} }
template<typename eT> template<typename eT>
skipping to change at line 830 skipping to change at line 819
return Mat<eT>::operator()(row_span, col_span); return Mat<eT>::operator()(row_span, col_span);
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i) Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::at(const uword i) Row<eT>::fixed<fixed_n_elem>::at(const uword i)
{ {
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::at(const uword i) const Row<eT>::fixed<fixed_n_elem>::at(const uword i) const
{ {
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator() (const uword i) Row<eT>::fixed<fixed_n_elem>::operator() (const uword i)
{ {
arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Row::operator(): out of bounds");
return access::rw( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::operator() (const uword i) const Row<eT>::fixed<fixed_n_elem>::operator() (const uword i) const
{ {
arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bo unds"); arma_debug_check( (i >= fixed_n_elem), "Row::operator(): out of bounds");
return ( Mat<eT>::mem[i] ); return (use_extra) ? mem_local_extra[i] : Mat<eT>::mem_local[i];
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col)
{ {
return access::rw( Mat<eT>::mem[in_col] ); return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) co nst Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) co nst
{ {
return ( Mat<eT>::mem[in_col] ); return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT& eT&
Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col)
{ {
arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row > 0) || (in_col >= fixed_n_elem)), "Row::opera tor(): out of bounds" );
return access::rw( Mat<eT>::mem[in_col] ); return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
eT eT
Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) const Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword i n_col) const
{ {
arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixe d::operator(): out of bounds" ); arma_debug_check( ((in_row > 0) || (in_col >= fixed_n_elem)), "Row::opera tor(): out of bounds" );
return ( Mat<eT>::mem[in_col] ); return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col] ;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::fill(const eT val) Row<eT>::fixed<fixed_n_elem>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem ) eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[
; 0]);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::zeros() Row<eT>::fixed<fixed_n_elem>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[
); 0]);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(0) );
return *this; return *this;
} }
template<typename eT> template<typename eT>
template<uword fixed_n_elem> template<uword fixed_n_elem>
arma_hot arma_hot
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::fixed<fixed_n_elem>::ones() Row<eT>::fixed<fixed_n_elem>::ones()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[
); 0]);
arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(1) );
return *this; return *this;
} }
#ifdef ARMA_EXTRA_ROW_MEAT #ifdef ARMA_EXTRA_ROW_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT) #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT)
#endif #endif
//! @} //! @}
 End of changes. 30 change blocks. 
62 lines changed or deleted 57 lines changed or added


 arma_version.hpp   arma_version.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 2 #define ARMA_VERSION_MAJOR 2
#define ARMA_VERSION_MINOR 4 #define ARMA_VERSION_MINOR 99
#define ARMA_VERSION_PATCH 6 #define ARMA_VERSION_PATCH 1
#define ARMA_VERSION_NAME "Loco Lounge Lizard" #define ARMA_VERSION_NAME "Antarctic Chilli Ranch (Beta 1)"
struct arma_version struct arma_version
{ {
static const unsigned int major = ARMA_VERSION_MAJOR; static const unsigned int major = ARMA_VERSION_MAJOR;
static const unsigned int minor = ARMA_VERSION_MINOR; static const unsigned int minor = ARMA_VERSION_MINOR;
static const unsigned int patch = ARMA_VERSION_PATCH; static const unsigned int patch = ARMA_VERSION_PATCH;
static static
inline inline
std::string std::string
 End of changes. 2 change blocks. 
5 lines changed or deleted 5 lines changed or added


 armadillo   armadillo 
skipping to change at line 71 skipping to change at line 71
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST)
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/current_function.hpp> #include <boost/current_function.hpp>
#define ARMA_USE_BOOST_FORMAT #define ARMA_USE_BOOST_FORMAT
#endif #endif
#endif #endif
#include "armadillo_bits/include_atlas.hpp" #include "armadillo_bits/include_atlas.hpp"
#include "armadillo_bits/itpp_wrap.hpp"
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
// preliminaries // preliminaries
#include "armadillo_bits/forward_bones.hpp" #include "armadillo_bits/forward_bones.hpp"
#include "armadillo_bits/arma_static_check.hpp" #include "armadillo_bits/arma_static_check.hpp"
#include "armadillo_bits/typedef.hpp" #include "armadillo_bits/typedef.hpp"
skipping to change at line 93 skipping to change at line 92
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/format_wrap.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
#include "armadillo_bits/span.hpp" #include "armadillo_bits/span.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
#include "armadillo_bits/constants_compat.hpp"
// //
// class prototypes // class prototypes
#include "armadillo_bits/Base_bones.hpp" #include "armadillo_bits/Base_bones.hpp"
#include "armadillo_bits/BaseCube_bones.hpp" #include "armadillo_bits/BaseCube_bones.hpp"
#include "armadillo_bits/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 124 skipping to change at line 124
#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/typedef_fixed.hpp" #include "armadillo_bits/typedef_fixed.hpp"
#include "armadillo_bits/field_bones.hpp" #include "armadillo_bits/field_bones.hpp"
#include "armadillo_bits/subview_bones.hpp" #include "armadillo_bits/subview_bones.hpp"
#include "armadillo_bits/subview_elem1_bones.hpp" #include "armadillo_bits/subview_elem1_bones.hpp"
#include "armadillo_bits/subview_elem2_bones.hpp"
#include "armadillo_bits/subview_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/diskio_bones.hpp" #include "armadillo_bits/diskio_bones.hpp"
#include "armadillo_bits/wall_clock_bones.hpp" #include "armadillo_bits/wall_clock_bones.hpp"
#include "armadillo_bits/running_stat_bones.hpp" #include "armadillo_bits/running_stat_bones.hpp"
#include "armadillo_bits/running_stat_vec_bones.hpp" #include "armadillo_bits/running_stat_vec_bones.hpp"
#include "armadillo_bits/Op_bones.hpp" #include "armadillo_bits/Op_bones.hpp"
skipping to change at line 189 skipping to change at line 190
#include "armadillo_bits/op_flip_bones.hpp" #include "armadillo_bits/op_flip_bones.hpp"
#include "armadillo_bits/op_princomp_bones.hpp" #include "armadillo_bits/op_princomp_bones.hpp"
#include "armadillo_bits/op_misc_bones.hpp" #include "armadillo_bits/op_misc_bones.hpp"
#include "armadillo_bits/op_relational_bones.hpp" #include "armadillo_bits/op_relational_bones.hpp"
#include "armadillo_bits/op_find_bones.hpp" #include "armadillo_bits/op_find_bones.hpp"
#include "armadillo_bits/op_chol_bones.hpp" #include "armadillo_bits/op_chol_bones.hpp"
#include "armadillo_bits/op_cx_scalar_bones.hpp" #include "armadillo_bits/op_cx_scalar_bones.hpp"
#include "armadillo_bits/op_trimat_bones.hpp" #include "armadillo_bits/op_trimat_bones.hpp"
#include "armadillo_bits/op_cumsum_bones.hpp" #include "armadillo_bits/op_cumsum_bones.hpp"
#include "armadillo_bits/op_symmat_bones.hpp" #include "armadillo_bits/op_symmat_bones.hpp"
#include "armadillo_bits/op_hist_bones.hpp"
#include "armadillo_bits/glue_times_bones.hpp" #include "armadillo_bits/glue_times_bones.hpp"
#include "armadillo_bits/glue_mixed_bones.hpp" #include "armadillo_bits/glue_mixed_bones.hpp"
#include "armadillo_bits/glue_cov_bones.hpp" #include "armadillo_bits/glue_cov_bones.hpp"
#include "armadillo_bits/glue_cor_bones.hpp" #include "armadillo_bits/glue_cor_bones.hpp"
#include "armadillo_bits/glue_kron_bones.hpp" #include "armadillo_bits/glue_kron_bones.hpp"
#include "armadillo_bits/glue_cross_bones.hpp" #include "armadillo_bits/glue_cross_bones.hpp"
#include "armadillo_bits/glue_join_bones.hpp" #include "armadillo_bits/glue_join_bones.hpp"
#include "armadillo_bits/glue_relational_bones.hpp" #include "armadillo_bits/glue_relational_bones.hpp"
#include "armadillo_bits/glue_solve_bones.hpp" #include "armadillo_bits/glue_solve_bones.hpp"
#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_histc_bones.hpp"
// //
// debugging functions // debugging functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
// //
// //
#include "armadillo_bits/cmath_wrap.hpp" #include "armadillo_bits/cmath_wrap.hpp"
skipping to change at line 341 skipping to change at line 345
#include "armadillo_bits/fn_cross.hpp" #include "armadillo_bits/fn_cross.hpp"
#include "armadillo_bits/fn_join.hpp" #include "armadillo_bits/fn_join.hpp"
#include "armadillo_bits/fn_conv.hpp" #include "armadillo_bits/fn_conv.hpp"
#include "armadillo_bits/fn_trunc_exp.hpp" #include "armadillo_bits/fn_trunc_exp.hpp"
#include "armadillo_bits/fn_trunc_log.hpp" #include "armadillo_bits/fn_trunc_log.hpp"
#include "armadillo_bits/fn_toeplitz.hpp" #include "armadillo_bits/fn_toeplitz.hpp"
#include "armadillo_bits/fn_trimat.hpp" #include "armadillo_bits/fn_trimat.hpp"
#include "armadillo_bits/fn_cumsum.hpp" #include "armadillo_bits/fn_cumsum.hpp"
#include "armadillo_bits/fn_symmat.hpp" #include "armadillo_bits/fn_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_histc.hpp"
// //
// class meat // class meat
#include "armadillo_bits/gemv.hpp" #include "armadillo_bits/gemv.hpp"
#include "armadillo_bits/gemm.hpp" #include "armadillo_bits/gemm.hpp"
#include "armadillo_bits/gemm_mixed.hpp" #include "armadillo_bits/gemm_mixed.hpp"
#include "armadillo_bits/eop_core_meat.hpp" #include "armadillo_bits/eop_core_meat.hpp"
#include "armadillo_bits/eglue_core_meat.hpp" #include "armadillo_bits/eglue_core_meat.hpp"
skipping to change at line 365 skipping to change at line 371
#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/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_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/diskio_meat.hpp" #include "armadillo_bits/diskio_meat.hpp"
#include "armadillo_bits/wall_clock_meat.hpp" #include "armadillo_bits/wall_clock_meat.hpp"
#include "armadillo_bits/running_stat_meat.hpp" #include "armadillo_bits/running_stat_meat.hpp"
#include "armadillo_bits/running_stat_vec_meat.hpp" #include "armadillo_bits/running_stat_vec_meat.hpp"
#include "armadillo_bits/op_diagmat_meat.hpp" #include "armadillo_bits/op_diagmat_meat.hpp"
skipping to change at line 407 skipping to change at line 414
#include "armadillo_bits/op_flip_meat.hpp" #include "armadillo_bits/op_flip_meat.hpp"
#include "armadillo_bits/op_princomp_meat.hpp" #include "armadillo_bits/op_princomp_meat.hpp"
#include "armadillo_bits/op_misc_meat.hpp" #include "armadillo_bits/op_misc_meat.hpp"
#include "armadillo_bits/op_relational_meat.hpp" #include "armadillo_bits/op_relational_meat.hpp"
#include "armadillo_bits/op_find_meat.hpp" #include "armadillo_bits/op_find_meat.hpp"
#include "armadillo_bits/op_chol_meat.hpp" #include "armadillo_bits/op_chol_meat.hpp"
#include "armadillo_bits/op_cx_scalar_meat.hpp" #include "armadillo_bits/op_cx_scalar_meat.hpp"
#include "armadillo_bits/op_trimat_meat.hpp" #include "armadillo_bits/op_trimat_meat.hpp"
#include "armadillo_bits/op_cumsum_meat.hpp" #include "armadillo_bits/op_cumsum_meat.hpp"
#include "armadillo_bits/op_symmat_meat.hpp" #include "armadillo_bits/op_symmat_meat.hpp"
#include "armadillo_bits/op_hist_meat.hpp"
#include "armadillo_bits/glue_times_meat.hpp" #include "armadillo_bits/glue_times_meat.hpp"
#include "armadillo_bits/glue_mixed_meat.hpp" #include "armadillo_bits/glue_mixed_meat.hpp"
#include "armadillo_bits/glue_cov_meat.hpp" #include "armadillo_bits/glue_cov_meat.hpp"
#include "armadillo_bits/glue_cor_meat.hpp" #include "armadillo_bits/glue_cor_meat.hpp"
#include "armadillo_bits/glue_kron_meat.hpp" #include "armadillo_bits/glue_kron_meat.hpp"
#include "armadillo_bits/glue_cross_meat.hpp" #include "armadillo_bits/glue_cross_meat.hpp"
#include "armadillo_bits/glue_join_meat.hpp" #include "armadillo_bits/glue_join_meat.hpp"
#include "armadillo_bits/glue_relational_meat.hpp" #include "armadillo_bits/glue_relational_meat.hpp"
#include "armadillo_bits/glue_solve_meat.hpp" #include "armadillo_bits/glue_solve_meat.hpp"
#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_histc_meat.hpp"
} }
#endif #endif
 End of changes. 9 change blocks. 
1 lines changed or deleted 11 lines changed or added


 arrayops_bones.hpp   arrayops_bones.hpp 
// Copyright (C) 2011 NICTA (www.nicta.com.au) // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Conrad Sanderson // Copyright (C) 2011-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 82 skipping to change at line 82
inplace_div(eT* dest, const eT* src, const uword n_elem); inplace_div(eT* dest, const eT* src, const uword n_elem);
// //
// array op= scalar // array op= scalar
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_set(eT* dest, const eT val, const uword n_elem); inplace_set(eT* dest, const eT val, const uword n_elem);
template<typename eT, const uword n_elem>
arma_hot inline static
void
inplace_set_fixed(eT* dest, const eT val);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_plus(eT* dest, const eT val, const uword n_elem); inplace_plus(eT* dest, const eT val, const uword n_elem);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_minus(eT* dest, const eT val, const uword n_elem); inplace_minus(eT* dest, const eT val, const uword n_elem);
 End of changes. 2 change blocks. 
2 lines changed or deleted 7 lines changed or added


 arrayops_meat.hpp   arrayops_meat.hpp 
// Copyright (C) 2011 NICTA (www.nicta.com.au) // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Conrad Sanderson // Copyright (C) 2011-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 182 skipping to change at line 182
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_hot
inline inline
void void
arrayops::convert(out_eT* dest, const in_eT* src, const uword n_elem) arrayops::convert(out_eT* dest, const in_eT* src, const uword n_elem)
{ {
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] = out_eT( src[i] ); const in_eT tmp_i = src[i];
dest[j] = out_eT( src[j] ); const in_eT tmp_j = src[j];
dest[i] = out_eT( tmp_i );
dest[j] = out_eT( tmp_j );
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] = out_eT( src[i] ); dest[i] = out_eT( src[i] );
} }
} }
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
arma_hot arma_hot
skipping to change at line 222 skipping to change at line 225
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_plus(eT* dest, const eT* src, const uword n_elem) arrayops::inplace_plus(eT* dest, const eT* src, const uword n_elem)
{ {
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] += src[i]; const eT tmp_i = src[i];
dest[j] += src[j]; const eT tmp_j = src[j];
dest[i] += tmp_i;
dest[j] += tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] += src[i]; dest[i] += src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_minus(eT* dest, const eT* src, const uword n_elem) arrayops::inplace_minus(eT* dest, const eT* src, const uword n_elem)
{ {
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] -= src[i]; const eT tmp_i = src[i];
dest[j] -= src[j]; const eT tmp_j = src[j];
dest[i] -= tmp_i;
dest[j] -= tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] -= src[i]; dest[i] -= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_mul(eT* dest, const eT* src, const uword n_elem) arrayops::inplace_mul(eT* dest, const eT* src, const uword n_elem)
{ {
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] *= src[i]; const eT tmp_i = src[i];
dest[j] *= src[j]; const eT tmp_j = src[j];
dest[i] *= tmp_i;
dest[j] *= tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] *= src[i]; dest[i] *= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_div(eT* dest, const eT* src, const uword n_elem) arrayops::inplace_div(eT* dest, const eT* src, const uword n_elem)
{ {
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] /= src[i]; const eT tmp_i = src[i];
dest[j] /= src[j]; const eT tmp_j = src[j];
dest[i] /= tmp_i;
dest[j] /= tmp_j;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] /= src[i]; dest[i] /= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
skipping to change at line 312 skipping to change at line 327
dest[i] = val; dest[i] = val;
dest[j] = val; dest[j] = val;
} }
if(i < n_elem) if(i < n_elem)
{ {
dest[i] = val; dest[i] = val;
} }
} }
template<typename eT, const uword n_elem>
arma_hot
inline
void
arrayops::inplace_set_fixed(eT* dest, const eT val)
{
for(uword i=0; i<n_elem; ++i)
{
dest[i] = val;
}
}
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_plus(eT* dest, const eT val, const uword n_elem) arrayops::inplace_plus(eT* dest, const eT val, const uword n_elem)
{ {
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
 End of changes. 7 change blocks. 
12 lines changed or deleted 39 lines changed or added


 compiler_setup.hpp   compiler_setup.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 98 skipping to change at line 98
#if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__GXX_EXPERIMENTAL_CXX0X__)
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#if !defined(ARMA_USE_CXX11) #if !defined(ARMA_USE_CXX11)
#define ARMA_USE_CXX11 #define ARMA_USE_CXX11
#endif #endif
#endif #endif
#if defined(__clang__) #if defined(__clang__)
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_STD_TR1
#undef ARMA_GOOD_COMPILER
#endif #endif
#if (ARMA_GCC_VERSION >= 40300) #if (ARMA_GCC_VERSION >= 40300)
#undef arma_hot #undef arma_hot
#undef arma_cold #undef arma_cold
#define arma_hot __attribute__((hot)) #define arma_hot __attribute__((hot))
#define arma_cold __attribute__((cold)) #define arma_cold __attribute__((cold))
#endif #endif
 End of changes. 2 change blocks. 
2 lines changed or deleted 3 lines changed or added


 constants.hpp   constants.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup constants //! \addtogroup constants
//! @{ //! @{
namespace priv namespace priv
{ {
class Math_helper class Datum_helper
{ {
public: public:
template<typename eT> template<typename eT>
static static
typename arma_float_only<eT>::result typename arma_float_only<eT>::result
nan(typename arma_float_only<eT>::result* junk = 0) nan(typename arma_float_only<eT>::result* junk = 0)
{ {
arma_ignore(junk); arma_ignore(junk);
skipping to change at line 48 skipping to change at line 48
template<typename eT> template<typename eT>
static static
typename arma_cx_only<eT>::result typename arma_cx_only<eT>::result
nan(typename arma_cx_only<eT>::result* junk = 0) nan(typename arma_cx_only<eT>::result* junk = 0)
{ {
arma_ignore(junk); arma_ignore(junk);
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
return eT( Math_helper::nan<T>(), Math_helper::nan<T>() ); return eT( Datum_helper::nan<T>(), Datum_helper::nan<T>() );
} }
template<typename eT> template<typename eT>
static static
typename arma_integral_only<eT>::result typename arma_integral_only<eT>::result
nan(typename arma_integral_only<eT>::result* junk = 0) nan(typename arma_integral_only<eT>::result* junk = 0)
{ {
arma_ignore(junk); arma_ignore(junk);
return eT(0); return eT(0);
skipping to change at line 87 skipping to change at line 87
template<typename eT> template<typename eT>
static static
typename arma_cx_only<eT>::result typename arma_cx_only<eT>::result
inf(typename arma_cx_only<eT>::result* junk = 0) inf(typename arma_cx_only<eT>::result* junk = 0)
{ {
arma_ignore(junk); arma_ignore(junk);
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
return eT( Math_helper::inf<T>(), Math_helper::inf<T>() ); return eT( Datum_helper::inf<T>(), Datum_helper::inf<T>() );
} }
template<typename eT> template<typename eT>
static static
typename arma_integral_only<eT>::result typename arma_integral_only<eT>::result
inf(typename arma_integral_only<eT>::result* junk = 0) inf(typename arma_integral_only<eT>::result* junk = 0)
{ {
arma_ignore(junk); arma_ignore(junk);
return std::numeric_limits<eT>::max(); return std::numeric_limits<eT>::max();
} }
}; };
} }
template<typename eT> //! various constants.
class Math
{
public:
// the long lengths of the constants are for future support of "long doub
le"
// and any smart compiler that does high-precision computation at compile
-time
//! ratio of any circle's circumference to its diameter
static eT pi() { return eT(3.1415926535897932384626433832795028841
971693993751058209749445923078164062862089986280348253421170679); }
//! base of the natural logarithm
static eT e() { return eT(2.7182818284590452353602874713526624977
572470936999595749669676277240766303535475945713821785251664274); }
//! Euler's constant, aka Euler-Mascheroni constant
static eT euler() { return eT(0.5772156649015328606065120900824024310
421593359399235988057672348848677267776646709369470632917467495); }
//! golden ratio
static eT gratio() { return eT(1.6180339887498948482045868343656381177
203091798057628621354486227052604628189024497072072041893911374); }
//! square root of 2
static eT sqrt2() { return eT(1.4142135623730950488016887242096980785
696718753769480731766797379907324784621070388503875343276415727); }
//! the difference between 1 and the least value greater than 1 that is r
epresentable
static eT eps() { return std::numeric_limits<eT>::epsilon(); }
//! log of the minimum representable value
static eT log_min() { static const eT out = std::log(std::numeric_limit
s<eT>::min()); return out; }
//! log of the maximum representable value
static eT log_max() { static const eT out = std::log(std::numeric_limit
s<eT>::max()); return out; }
//! "not a number"
static eT nan() { return priv::Math_helper::nan<eT>(); }
//! infinity
static eT inf() { return priv::Math_helper::inf<eT>(); }
};
//! Physical constants taken from NIST and WolframAlpha on 2009-06-23 //! Physical constants taken from NIST and WolframAlpha on 2009-06-23
//! http://physics.nist.gov/cuu/Constants //! http://physics.nist.gov/cuu/Constants
//! http://www.wolframalpha.com //! http://www.wolframalpha.com
//! See also http://en.wikipedia.org/wiki/Physical_constant //! See also http://en.wikipedia.org/wiki/Physical_constant
template<typename eT> template<typename eT>
class Phy class Datum
{ {
public: public:
//! atomic mass constant (in kg) static const eT pi; //!< ratio of any circle's circumference to its
static eT m_u() { return eT(1.660538782e-27); } diameter
static const eT e; //!< base of the natural logarithm
//! Avogadro constant static const eT euler; //!< Euler's constant, aka Euler-Mascheroni con
static eT N_A() { return eT(6.02214179e23); } stant
static const eT gratio; //!< golden ratio
//! Boltzmann constant (in joules per kelvin) static const eT sqrt2; //!< square root of 2
static eT k() { return eT(1.3806504e-23); } static const eT eps; //!< the difference between 1 and the least val
ue greater than 1 that is representable
//! Boltzmann constant (in eV/K) static const eT log_min; //!< log of the minimum representable value
static eT k_evk() { return eT(8.617343e-5); } static const eT log_max; //!< log of the maximum representable value
static const eT nan; //!< "not a number"
//! Bohr radius (in meters) static const eT inf; //!< infinity
static eT a_0() { return eT(0.52917720859e-10); }
//
//! Bohr magneton
static eT mu_B() { return eT(927.400915e-26); } static const eT m_u; //!< atomic mass constant (in kg)
static const eT N_A; //!< Avogadro constant
//! characteristic impedance of vacuum (in ohms) static const eT k; //!< Boltzmann constant (in joules per kelvin)
static eT Z_0() { return eT(3.76730313461771e-2); } static const eT k_evk; //!< Boltzmann constant (in eV/K)
static const eT a_0; //!< Bohr radius (in meters)
//! conductance quantum (in siemens) static const eT mu_B; //!< Bohr magneton
static eT G_0() { return eT(7.7480917004e-5); } static const eT Z_0; //!< characteristic impedance of vacuum (in oh
ms)
//! Coulomb's constant (in meters per farad) static const eT G_0; //!< conductance quantum (in siemens)
static eT k_e() { return eT(8.9875517873681764e9); } static const eT k_e; //!< Coulomb's constant (in meters per farad)
static const eT eps_0; //!< electric constant (in farads per meter)
//! electric constant (in farads per meter) static const eT m_e; //!< electron mass (in kg)
static eT eps_0() { return eT(8.85418781762039e-12); } static const eT eV; //!< electron volt (in joules)
static const eT ec; //!< elementary charge (in coulombs)
//! electron mass (in kg) static const eT F; //!< Faraday constant (in coulombs)
static eT m_e() { return eT(9.10938215e-31); } static const eT alpha; //!< fine-structure constant
static const eT alpha_inv; //!< inverse fine-structure constant
//! electron volt (in joules) static const eT K_J; //!< Josephson constant
static eT eV() { return eT(1.602176487e-19); } static const eT mu_0; //!< magnetic constant (in henries per meter)
static const eT phi_0; //!< magnetic flux quantum (in webers)
//! elementary charge (in coulombs) static const eT R; //!< molar gas constant (in joules per mole ke
static eT e() { return eT(1.602176487e-19); } lvin)
static const eT G; //!< Newtonian constant of gravitation (in new
//! Faraday constant (in coulombs) ton square meters per kilogram squared)
static eT F() { return eT(96485.3399); } static const eT h; //!< Planck constant (in joule seconds)
static const eT h_bar; //!< Planck constant over 2 pi, aka reduced Pl
//! fine-structure constant anck constant (in joule seconds)
static eT alpha() { return eT(7.2973525376e-3); } static const eT m_p; //!< proton mass (in kg)
static const eT R_inf; //!< Rydberg constant (in reciprocal meters)
//! inverse fine-structure constant static const eT c_0; //!< speed of light in vacuum (in meters per s
static eT alpha_inv() { return eT(137.035999679); } econd)
static const eT sigma; //!< Stefan-Boltzmann constant
//! Josephson constant static const eT R_k; //!< von Klitzing constant (in ohms)
static eT K_J() { return eT(483597.891e9); } static const eT b; //!< Wien wavelength displacement law constant
//! magnetic constant (in henries per meter)
static eT mu_0() { return eT(1.25663706143592e-06); }
//! magnetic flux quantum (in webers)
static eT phi_0() { return eT(2.067833667e-15); }
//! molar gas constant (in joules per mole kelvin)
static eT R() { return eT(8.314472); }
//! Newtonian constant of gravitation (in newton square meters per kilogr
am squared)
static eT G() { return eT(6.67428e-11); }
//! Planck constant (in joule seconds)
static eT h() { return eT(6.62606896e-34); }
//! Planck constant over 2 pi, aka reduced Planck constant (in joule seco
nds)
static eT h_bar() { return eT(1.054571628e-34); }
//! proton mass (in kg)
static eT m_p() { return eT(1.672621637e-27); }
//! Rydberg constant (in reciprocal meters)
static eT R_inf() { return eT(10973731.568527); }
//! speed of light in vacuum (in meters per second)
static eT c_0() { return eT(299792458.0); }
//! Stefan-Boltzmann constant
static eT sigma() { return eT(5.670400e-8); }
//! von Klitzing constant (in ohms)
static eT R_k() { return eT(25812.807557); }
//! Wien wavelength displacement law constant
static eT b() { return eT(2.8977685e-3); }
}; };
typedef Math<float> fmath; // the long lengths of the constants are for future support of "long double
typedef Math<double> math; "
// and any smart compiler that does high-precision computation at compile-t
ime
template<typename eT> const eT Datum<eT>::pi = eT(3.1415926535897932
384626433832795028841971693993751058209749445923078164062862089986280348253
421170679);
template<typename eT> const eT Datum<eT>::e = eT(2.7182818284590452
353602874713526624977572470936999595749669676277240766303535475945713821785
251664274);
template<typename eT> const eT Datum<eT>::euler = eT(0.5772156649015328
606065120900824024310421593359399235988057672348848677267776646709369470632
917467495);
template<typename eT> const eT Datum<eT>::gratio = eT(1.6180339887498948
482045868343656381177203091798057628621354486227052604628189024497072072041
893911374);
template<typename eT> const eT Datum<eT>::sqrt2 = eT(1.4142135623730950
488016887242096980785696718753769480731766797379907324784621070388503875343
276415727);
template<typename eT> const eT Datum<eT>::eps = std::numeric_limits<e
T>::epsilon();
template<typename eT> const eT Datum<eT>::log_min = std::log(std::numeric
_limits<eT>::min());
template<typename eT> const eT Datum<eT>::log_max = std::log(std::numeric
_limits<eT>::max());
template<typename eT> const eT Datum<eT>::nan = priv::Datum_helper::n
an<eT>();
template<typename eT> const eT Datum<eT>::inf = priv::Datum_helper::i
nf<eT>();
template<typename eT> const eT Datum<eT>::m_u = eT(1.660538782e-27);
template<typename eT> const eT Datum<eT>::N_A = eT(6.02214179e23);
template<typename eT> const eT Datum<eT>::k = eT(1.3806504e-23);
template<typename eT> const eT Datum<eT>::k_evk = eT(8.617343e-5);
template<typename eT> const eT Datum<eT>::a_0 = eT(0.52917720859e-10)
;
template<typename eT> const eT Datum<eT>::mu_B = eT(927.400915e-26);
template<typename eT> const eT Datum<eT>::Z_0 = eT(3.76730313461771e-
2);
template<typename eT> const eT Datum<eT>::G_0 = eT(7.7480917004e-5);
template<typename eT> const eT Datum<eT>::k_e = eT(8.9875517873681764
e9);
template<typename eT> const eT Datum<eT>::eps_0 = eT(8.85418781762039e-
12);
template<typename eT> const eT Datum<eT>::m_e = eT(9.10938215e-31);
template<typename eT> const eT Datum<eT>::eV = eT(1.602176487e-19);
template<typename eT> const eT Datum<eT>::ec = eT(1.602176487e-19);
template<typename eT> const eT Datum<eT>::F = eT(96485.3399);
template<typename eT> const eT Datum<eT>::alpha = eT(7.2973525376e-3);
template<typename eT> const eT Datum<eT>::alpha_inv = eT(137.035999679);
template<typename eT> const eT Datum<eT>::K_J = eT(483597.891e9);
template<typename eT> const eT Datum<eT>::mu_0 = eT(1.25663706143592e-
06);
template<typename eT> const eT Datum<eT>::phi_0 = eT(2.067833667e-15);
template<typename eT> const eT Datum<eT>::R = eT(8.314472);
template<typename eT> const eT Datum<eT>::G = eT(6.67428e-11);
template<typename eT> const eT Datum<eT>::h = eT(6.62606896e-34);
template<typename eT> const eT Datum<eT>::h_bar = eT(1.054571628e-34);
template<typename eT> const eT Datum<eT>::m_p = eT(1.672621637e-27);
template<typename eT> const eT Datum<eT>::R_inf = eT(10973731.568527);
template<typename eT> const eT Datum<eT>::c_0 = eT(299792458.0);
template<typename eT> const eT Datum<eT>::sigma = eT(5.670400e-8);
template<typename eT> const eT Datum<eT>::R_k = eT(25812.807557);
template<typename eT> const eT Datum<eT>::b = eT(2.8977685e-3);
typedef Phy<float> fphy; typedef Datum<float> fdatum;
typedef Phy<double> phy; typedef Datum<double> datum;
namespace priv namespace priv
{ {
template<typename eT> template<typename eT>
static static
arma_inline arma_inline
arma_hot arma_hot
typename arma_float_only<eT>::result typename arma_float_only<eT>::result
most_neg(typename arma_float_only<eT>::result* junk = 0) most_neg(typename arma_float_only<eT>::result* junk = 0)
 End of changes. 10 change blocks. 
147 lines changed or deleted 125 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 945 skipping to change at line 945
#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 (__GNUG__) #if defined (__GNUG__)
#define ARMA_FNSIG __PRETTY_FUNCTION__ #define ARMA_FNSIG __PRETTY_FUNCTION__
#elif defined (_MSC_VER) #elif defined (_MSC_VER)
#define ARMA_FNSIG __FUNCSIG__ #define ARMA_FNSIG __FUNCSIG__
#elif defined (ARMA_USE_BOOST) #elif defined (ARMA_USE_BOOST)
#define ARMA_FNSIG BOOST_CURRENT_FUNCTION #define ARMA_FNSIG BOOST_CURRENT_FUNCTION
#elif defined (ARMA_USE_CXX11)
#define ARMA_FNSIG __func__
#else #else
#define ARMA_FNSIG "(unknown)" #define ARMA_FNSIG "(unknown)"
#endif #endif
#if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) #if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG)
#define arma_debug_print arma_print #define arma_debug_print arma_print
#define arma_debug_warn arma_warn #define arma_debug_warn arma_warn
#define arma_debug_check arma_check #define arma_debug_check arma_check
#define arma_debug_set_error arma_set_error #define arma_debug_set_error arma_set_error
skipping to change at line 969 skipping to change at line 971
#else #else
#undef ARMA_EXTRA_DEBUG #undef ARMA_EXTRA_DEBUG
#define arma_debug_print true ? (void)0 : arma_print #define arma_debug_print true ? (void)0 : arma_print
#define arma_debug_warn true ? (void)0 : arma_warn #define arma_debug_warn true ? (void)0 : arma_warn
#define arma_debug_check true ? (void)0 : arma_check #define arma_debug_check true ? (void)0 : arma_check
#define arma_debug_set_error true ? (void)0 : arma_set_error #define arma_debug_set_error true ? (void)0 : arma_set_error
#define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s ize #define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_s ize
#define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si ze #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_si ze
#define arma_debug_assert_cube_as_mat true ? (void)0 : arma_assert_cube_a s_mat #define arma_debug_assert_cube_as_mat true ? (void)0 : arma_debug_assert_ cube_as_mat
#endif #endif
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint #define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_b ktprint
#define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint #define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_t hisprint
#define arma_extra_debug_print arma_print #define arma_extra_debug_print arma_print
#define arma_extra_debug_warn arma_warn #define arma_extra_debug_warn arma_warn
#define arma_extra_debug_check arma_check #define arma_extra_debug_check arma_check
 End of changes. 2 change blocks. 
1 lines changed or deleted 3 lines changed or added


 diagview_bones.hpp   diagview_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup diagview //! \addtogroup diagview
//! @{ //! @{
//! Class for storing data required to extract and set the diagonals of a m atrix //! Class for storing data required to extract and set the diagonals of a m atrix
template<typename eT> template<typename eT>
class diagview : public Base<eT, diagview<eT> > class diagview : public Base<eT, diagview<eT> >
{ {
public: arma_aligned const Mat<eT>& m;
protected: arma_aligned Mat<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
arma_aligned const Mat<eT>& m;
static const bool is_row = false;
static const bool is_col = true;
const uword row_offset; const uword row_offset;
const uword col_offset; const uword col_offset;
const uword n_rows; // equal to n_elem const uword n_rows; // equal to n_elem
const uword n_elem; const uword n_elem;
static const uword n_cols = 1; static const uword n_cols = 1;
protected: protected:
arma_inline diagview(const Mat<eT>& in_m, const uword in_row_offset, cons t uword in_col_offset, const uword len); arma_inline diagview(const Mat<eT>& in_m, const uword in_row_offset, cons t uword in_col_offset, const uword len);
arma_inline diagview( Mat<eT>& in_m, const uword in_row_offset, cons t uword in_col_offset, const uword len);
public: public:
inline ~diagview(); inline ~diagview();
inline void operator=(const diagview& x); inline void operator=(const diagview& x);
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);
skipping to change at line 67 skipping to change at line 68
arma_inline eT& operator[](const uword i); arma_inline eT& operator[](const uword i);
arma_inline eT operator[](const uword i) const; arma_inline eT operator[](const uword i) const;
arma_inline eT& at(const uword i); arma_inline eT& at(const uword i);
arma_inline eT at(const uword i) const; arma_inline eT at(const uword i) const;
arma_inline eT& operator()(const uword i); arma_inline eT& operator()(const uword i);
arma_inline eT operator()(const uword i) const; arma_inline eT operator()(const uword i) const;
arma_inline eT& at(const uword in_n_row, const uword in_n_col); arma_inline eT& at(const uword in_n_row, const uword);
arma_inline eT at(const uword in_n_row, const uword in_n_col) co arma_inline eT at(const uword in_n_row, const uword) const;
nst;
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> ht() 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 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);
 End of changes. 6 change blocks. 
9 lines changed or deleted 13 lines changed or added


 diagview_meat.hpp   diagview_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 27 skipping to change at line 27
inline inline
diagview<eT>::~diagview() diagview<eT>::~diagview()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
diagview<eT>::diagview(const Mat<eT>& in_m, const uword in_row_offset, cons t uword in_col_offset, const uword in_len) diagview<eT>::diagview(const Mat<eT>& in_m, const uword in_row_offset, cons t uword in_col_offset, const uword in_len)
: m(in_m) : m(in_m)
, m_ptr(0)
, row_offset(in_row_offset)
, col_offset(in_col_offset)
, n_rows(in_len)
, n_elem(in_len)
{
arma_extra_debug_sigprint();
}
template<typename eT>
arma_inline
diagview<eT>::diagview(Mat<eT>& in_m, const uword in_row_offset, const uwor
d in_col_offset, const uword in_len)
: m(in_m)
, m_ptr(&in_m)
, row_offset(in_row_offset) , row_offset(in_row_offset)
, col_offset(in_col_offset) , col_offset(in_col_offset)
, n_rows(in_len) , n_rows(in_len)
, n_elem(in_len) , n_elem(in_len)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
//! set a diagonal of our matrix using a diagonal from a foreign matrix //! set a diagonal of our matrix using a diagonal from a foreign matrix
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator= (const diagview<eT>& x) diagview<eT>::operator= (const diagview<eT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check( (t.n_elem != x.n_elem), "diagview: diagonals have incom patible lengths"); arma_debug_check( (t.n_elem != x.n_elem), "diagview: diagonals have incom patible lengths");
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& x_m = x.m; const Mat<eT>& x_m = x.m;
if(&t_m != &x_m) if(&t_m != &x_m)
{ {
const uword t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const uword x_row_offset = x.row_offset; const uword x_row_offset = x.row_offset;
const uword x_col_offset = x.col_offset; const uword x_col_offset = x.col_offset;
skipping to change at line 103 skipping to change at line 89
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator+=(const eT val) diagview<eT>::operator+=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) += val; t_m.at( i + t_row_offset, i + t_col_offset) += val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator-=(const eT val) diagview<eT>::operator-=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) -= val; t_m.at( i + t_row_offset, i + t_col_offset) -= val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator*=(const eT val) diagview<eT>::operator*=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) *= val; t_m.at( i + t_row_offset, i + t_col_offset) *= val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
diagview<eT>::operator/=(const eT val) diagview<eT>::operator/=(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& t_m = (*m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
const uword t_n_elem = n_elem; const uword t_n_elem = n_elem;
const uword t_row_offset = row_offset; const uword t_row_offset = row_offset;
const uword t_col_offset = col_offset; const uword t_col_offset = col_offset;
for(uword i=0; i<t_n_elem; ++i) for(uword i=0; i<t_n_elem; ++i)
{ {
t_m.at( i + t_row_offset, i + t_col_offset) /= val; t_m.at( i + t_row_offset, i + t_col_offset) /= val;
} }
} }
skipping to change at line 192 skipping to change at line 178
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m);
const uword t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
skipping to change at line 235 skipping to change at line 221
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m);
const uword t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
skipping to change at line 278 skipping to change at line 264
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m);
const uword t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
skipping to change at line 321 skipping to change at line 307
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m);
const uword t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
skipping to change at line 364 skipping to change at line 350
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
diagview<eT>& t = *this; diagview<eT>& t = *this;
arma_debug_check arma_debug_check
( (
( (t.n_elem != x.n_elem) || (x.is_vec() == false) ), ( (t.n_elem != x.n_elem) || (x.is_vec() == false) ),
"diagview: given object has incompatible size" "diagview: given object has incompatible size"
); );
Mat<eT>& t_m = *(t.m_ptr); Mat<eT>& t_m = const_cast< Mat<eT>& >(t.m);
const uword t_n_elem = t.n_elem; const uword t_n_elem = t.n_elem;
const uword t_row_offset = t.row_offset; const uword t_row_offset = t.row_offset;
const uword t_col_offset = t.col_offset; const uword t_col_offset = t.col_offset;
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_elem; i+=2, j+=2) for(i=0, j=1; j < t_n_elem; i+=2, j+=2)
{ {
skipping to change at line 564 skipping to change at line 550
{ {
out_mem[i] /= in_m.at( i + in_row_offset, i + in_col_offset ); out_mem[i] /= in_m.at( i + in_row_offset, i + in_col_offset );
} }
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator[](const uword i) diagview<eT>::operator[](const uword i)
{ {
return (*m_ptr).at(i+row_offset, i+col_offset); return (const_cast< Mat<eT>& >(m)).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator[](const uword i) const diagview<eT>::operator[](const uword i) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const uword i) diagview<eT>::at(const uword i)
{ {
return (*m_ptr).at(i+row_offset, i+col_offset); return (const_cast< Mat<eT>& >(m)).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::at(const uword i) const diagview<eT>::at(const uword i) const
{ {
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator()(const uword i) diagview<eT>::operator()(const uword i)
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" );
return (*m_ptr).at(i+row_offset, i+col_offset); return (const_cast< Mat<eT>& >(m)).at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator()(const uword i) const diagview<eT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" ); arma_debug_check( (i >= n_elem), "diagview::operator(): out of bounds" );
return m.at(i+row_offset, i+col_offset); return m.at(i+row_offset, i+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::at(const uword row, const uword col) diagview<eT>::at(const uword row, const uword)
{ {
return (*m_ptr).at(row+row_offset, row+col_offset); return (const_cast< Mat<eT>& >(m)).at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::at(const uword row, const uword col) const diagview<eT>::at(const uword row, const uword) const
{ {
return m.at(row+row_offset, row+col_offset); return m.at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
diagview<eT>::operator()(const uword row, const uword col) diagview<eT>::operator()(const uword row, const uword col)
{ {
arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" ); arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" );
return (*m_ptr).at(row+row_offset, row+col_offset); return (const_cast< Mat<eT>& >(m)).at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
diagview<eT>::operator()(const uword row, const uword col) const diagview<eT>::operator()(const uword row, const uword col) const
{ {
arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" ); arma_debug_check( ((row >= n_elem) || (col > 0)), "diagview::operator(): out of bounds" );
return m.at(row+row_offset, row+col_offset); return m.at(row+row_offset, row+col_offset);
} }
template<typename eT> template<typename eT>
arma_inline
const Op<diagview<eT>,op_htrans>
diagview<eT>::t() const
{
return Op<diagview<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<diagview<eT>,op_htrans>
diagview<eT>::ht() const
{
return Op<diagview<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<diagview<eT>,op_strans>
diagview<eT>::st() const
{
return Op<diagview<eT>,op_strans>(*this);
}
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 = (*m_ptr); Mat<eT>& x = const_cast< Mat<eT>& >(m);
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
x.at(i+row_offset, i+col_offset) = val; x.at(i+row_offset, i+col_offset) = val;
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
 End of changes. 21 change blocks. 
35 lines changed or deleted 44 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 1225 skipping to change at line 1225
f.close(); f.close();
} }
return load_okay; return load_okay;
} }
//! Load a matrix in CSV text format (human readable) //! Load a matrix in CSV text format (human readable)
template<typename eT> template<typename eT>
inline inline
bool bool
diskio::load_csv_ascii(Mat<eT>& x, std::istream& f, std::string&) diskio::load_csv_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = f.good(); bool load_okay = f.good();
f.clear(); f.clear();
const std::fstream::pos_type pos1 = f.tellg(); const std::fstream::pos_type pos1 = f.tellg();
// //
// work out the size // work out the size
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 eGlue_bones.hpp   eGlue_bones.hpp 
skipping to change at line 23 skipping to change at line 23
//! \addtogroup eGlue //! \addtogroup eGlue
//! @{ //! @{
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
class eGlue : public Base<typename T1::elem_type, eGlue<T1, T2, eglue_type> > class eGlue : public Base<typename T1::elem_type, eGlue<T1, T2, eglue_type> >
{ {
public: public:
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
typedef Proxy<T1> proxy1_type;
typedef Proxy<T2> proxy2_type;
static const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor); static const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
static const bool has_subview = (Proxy<T1>::has_subview || Proxy<T2>::has_subview ); static const bool has_subview = (Proxy<T1>::has_subview || Proxy<T2>::has_subview );
static const bool is_col = (Proxy<T1>::is_col || Proxy<T2>::is_col);
static const bool is_row = (Proxy<T1>::is_row || Proxy<T2>::is_row);
arma_aligned const Proxy<T1> P1; arma_aligned const Proxy<T1> P1;
arma_aligned const Proxy<T2> P2; arma_aligned const Proxy<T2> P2;
arma_inline ~eGlue(); arma_inline ~eGlue();
arma_inline eGlue(const T1& in_A, const T2& in_B); arma_inline eGlue(const T1& in_A, const T2& in_B);
arma_inline uword get_n_rows() const; arma_inline uword get_n_rows() const;
arma_inline uword get_n_cols() const; arma_inline uword get_n_cols() const;
arma_inline uword get_n_elem() const; arma_inline uword get_n_elem() const;
arma_inline elem_type operator[] (const uword i) const; arma_inline elem_type operator[] (const uword i) const ;
arma_inline elem_type at (const uword row, const uword col) const ; arma_inline elem_type at (const uword row, const uword col) const ;
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
1 lines changed or deleted 6 lines changed or added


 eGlue_meat.hpp   eGlue_meat.hpp 
skipping to change at line 45 skipping to change at line 45
P2.get_n_rows(), P2.get_n_cols(), P2.get_n_rows(), P2.get_n_cols(),
eglue_type::text() eglue_type::text()
); );
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
uword uword
eGlue<T1,T2,eglue_type>::get_n_rows() const eGlue<T1,T2,eglue_type>::get_n_rows() const
{ {
return P1.get_n_rows(); return is_row ? 1 : P1.get_n_rows();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
uword uword
eGlue<T1,T2,eglue_type>::get_n_cols() const eGlue<T1,T2,eglue_type>::get_n_cols() const
{ {
return P1.get_n_cols(); return is_col ? 1 : P1.get_n_cols();
} }
template<typename T1, typename T2, typename eglue_type> template<typename T1, typename T2, typename eglue_type>
arma_inline arma_inline
uword uword
eGlue<T1,T2,eglue_type>::get_n_elem() const eGlue<T1,T2,eglue_type>::get_n_elem() const
{ {
return P1.get_n_elem(); return P1.get_n_elem();
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


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


 eOp_meat.hpp   eOp_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup eOp //! \addtogroup eOp
//! @{ //! @{
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m) eOp<T1, eop_type>::eOp(const T1& in_m)
: P(in_m.get_ref()) : P(in_m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const eOp<T1, eop_type>::eOp(const T1& in_m, const typename T1::elem_type in_aux)
typename T1::elem_type in_aux) : P(in_m)
: P(in_m.get_ref())
, aux(in_aux) , aux(in_aux)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const eOp<T1, eop_type>::eOp(const T1& in_m, const uword in_aux_uword_a, const uw
uword in_aux_uword_a, const uword in_aux_uword_b) ord in_aux_uword_b)
: P(in_m.get_ref()) : P(in_m)
, aux_uword_a(in_aux_uword_a) , aux_uword_a(in_aux_uword_a)
, aux_uword_b(in_aux_uword_b) , aux_uword_b(in_aux_uword_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const eOp<T1, eop_type>::eOp(const T1& in_m, const typename T1::elem_type in_aux,
typename T1::elem_type in_aux, const uword in_aux_uword_a, const uword in_a const uword in_aux_uword_a, const uword in_aux_uword_b)
ux_uword_b) : P(in_m)
: P(in_m.get_ref())
, aux(in_aux) , aux(in_aux)
, aux_uword_a(in_aux_uword_a) , aux_uword_a(in_aux_uword_a)
, aux_uword_b(in_aux_uword_b) , aux_uword_b(in_aux_uword_b)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
eOp<T1, eop_type>::~eOp() eOp<T1, eop_type>::~eOp()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
uword uword
eOp<T1, eop_type>::get_n_rows() const eOp<T1, eop_type>::get_n_rows() const
{ {
return P.get_n_rows(); return is_row ? 1 : P.get_n_rows();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
uword uword
eOp<T1, eop_type>::get_n_cols() const eOp<T1, eop_type>::get_n_cols() const
{ {
return P.get_n_cols(); return is_col ? 1 : P.get_n_cols();
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
uword uword
eOp<T1, eop_type>::get_n_elem() const eOp<T1, eop_type>::get_n_elem() const
{ {
return P.get_n_elem(); return P.get_n_elem();
} }
skipping to change at line 93 skipping to change at line 93
eOp<T1, eop_type>::operator[] (const uword i) const eOp<T1, eop_type>::operator[] (const uword i) const
{ {
return eop_core<eop_type>::process(P[i], aux); return eop_core<eop_type>::process(P[i], aux);
} }
template<typename T1, typename eop_type> template<typename T1, typename eop_type>
arma_inline arma_inline
typename T1::elem_type typename T1::elem_type
eOp<T1, eop_type>::at(const uword row, const uword col) const eOp<T1, eop_type>::at(const uword row, const uword col) const
{ {
return eop_core<eop_type>::process(P.at(row, col), aux); if(is_row)
{
return eop_core<eop_type>::process(P.at(0, col), aux);
}
else
if(is_col)
{
return eop_core<eop_type>::process(P.at(row, 0), aux);
}
else
{
return eop_core<eop_type>::process(P.at(row, col), aux);
}
} }
//! @} //! @}
 End of changes. 8 change blocks. 
17 lines changed or deleted 27 lines changed or added


 eglue_core_meat.hpp   eglue_core_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 74 skipping to change at line 74
}\ }\
\ \
if(i < n_elem)\ if(i < n_elem)\
{\ {\
out_mem[i] operatorA P1[i] operatorB P2[i];\ out_mem[i] operatorA P1[i] operatorB P2[i];\
}\ }\
} }
#define arma_applier_2(operatorA, operatorB) \ #define arma_applier_2(operatorA, operatorB) \
{\ {\
uword count = 0;\ if(n_rows != 1)\
\
for(uword col=0; col<n_cols; ++col)\
{\ {\
uword i,j;\ uword count = 0;\
\ \
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
eT tmp_i = P1.at(i,col);\ uword i,j;\
eT tmp_j = P1.at(j,col);\
\ \
tmp_i operatorB##= P2.at(i,col);\ for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
tmp_j operatorB##= P2.at(j,col);\ {\
eT tmp_i = P1.at(i,col);\
eT tmp_j = P1.at(j,col);\
\
tmp_i operatorB##= P2.at(i,col);\
tmp_j operatorB##= P2.at(j,col);\
\
out_mem[count ] operatorA tmp_i;\
out_mem[count+1] operatorA tmp_j;\
}\
\ \
out_mem[count ] operatorA tmp_i;\ if(i < n_rows)\
out_mem[count+1] operatorA tmp_j;\ {\
out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\
++count;\
}\
}\
}\
else\
{\
uword i,j;\
for(i=0, j=1; j < n_cols; i+=2, j+=2)\
{\
eT tmp_i = P1.at(0,i);\
eT tmp_j = P1.at(0,j);\
\
tmp_i operatorB##= P2.at(0,i);\
tmp_j operatorB##= P2.at(0,j);\
\
out_mem[i] operatorA tmp_i;\
out_mem[j] operatorA tmp_j;\
}\ }\
\ \
if(i < n_rows)\ if(i < n_cols)\
{\ {\
out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\ out_mem[i] operatorA P1.at(0,i) operatorB P2.at(0,i);\
++count;\
}\ }\
}\ }\
} }
#define arma_applier_3(operatorA, operatorB) \ #define arma_applier_3(operatorA, operatorB) \
{\ {\
uword count = 0;\ uword count = 0;\
\ \
for(uword slice=0; slice<n_slices; ++slice)\ for(uword slice=0; slice<n_slices; ++slice)\
{\ {\
skipping to change at line 166 skipping to change at line 189
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(=, *); }
} }
else else
{ {
const uword n_rows = out.n_rows; const uword n_rows = x.get_n_rows();
const uword n_cols = out.n_cols; const uword n_cols = x.get_n_cols();
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out , const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out , const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "addition"); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addi
tion");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
skipping to change at line 210 skipping to change at line 236
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(+=, *); }
} }
else else
{ {
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(+=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(+=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(+=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(+=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(+=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(+=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(+=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(+=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "subtraction"); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subt
raction");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
skipping to change at line 254 skipping to change at line 280
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(-=, *); }
} }
else else
{ {
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(-=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(-=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(-=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(-=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(-=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(-=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(-=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(-=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& ou t, const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "element-wise multiplication"); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem
ent-wise multiplication");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
skipping to change at line 298 skipping to change at line 324
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(*=, *); }
} }
else else
{ {
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); }
} }
} }
template<typename eglue_type> template<typename eglue_type>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x) eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_same_size(out, x.P1, "element-wise division"); const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "elem
ent-wise division");
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor); const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T 2>::prefer_at_accessor);
if(prefer_at_accessor == false) if(prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
skipping to change at line 342 skipping to change at line 368
typename Proxy<T1>::ea_type P1 = x.P1.get_ea(); typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
typename Proxy<T2>::ea_type P2 = x.P2.get_ea(); typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_1(/=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_1(/=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_1(/=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_1(/=, *); }
} }
else else
{ {
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const Proxy<T1>& P1 = x.P1; const Proxy<T1>& P1 = x.P1;
const Proxy<T2>& P2 = x.P2; const Proxy<T2>& P2 = x.P2;
if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); } if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_ap plier_2(*=, +); }
else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); } else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_ap plier_2(*=, -); }
else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); } else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_ap plier_2(*=, /); }
else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); } else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_ap plier_2(*=, *); }
} }
} }
 End of changes. 18 change blocks. 
34 lines changed or deleted 61 lines changed or added


 eop_aux.hpp   eop_aux.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup eop_aux //! \addtogroup eop_aux
//! @{ //! @{
template<typename eT> template<typename eT>
struct eop_aux_randu struct eop_aux_randu
{ {
arma_inline arma_inline
operator eT () operator eT ()
{ {
return eT(std::rand()) / eT(RAND_MAX); //return eT(std::rand()) / eT(RAND_MAX);
return eT(std::rand()) * ( eT(1) / eT(RAND_MAX) );
} }
}; };
template<typename T> template<typename T>
struct eop_aux_randu< std::complex<T> > struct eop_aux_randu< std::complex<T> >
{ {
arma_inline arma_inline
operator std::complex<T> () operator std::complex<T> ()
{ {
return std::complex<T>( T(eop_aux_randu<T>()), T(eop_aux_randu<T>()) ); return std::complex<T>( T(eop_aux_randu<T>()), T(eop_aux_randu<T>()) );
skipping to change at line 74 skipping to change at line 75
{ {
// make sure we are internally using at least floats // make sure we are internally using at least floats
typedef typename promote_type<eT,float>::result eTp; typedef typename promote_type<eT,float>::result eTp;
eTp tmp1; eTp tmp1;
eTp tmp2; eTp tmp2;
eTp w; eTp w;
do do
{ {
tmp1 = eTp(2) * eTp(std::rand()) / eTp(RAND_MAX) - eTp(1); // tmp1 = eTp(2) * eTp(std::rand()) / eTp(RAND_MAX) - eTp(1);
tmp2 = eTp(2) * eTp(std::rand()) / eTp(RAND_MAX) - eTp(1); // tmp2 = eTp(2) * eTp(std::rand()) / eTp(RAND_MAX) - eTp(1);
tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1);
w = tmp1*tmp1 + tmp2*tmp2; w = tmp1*tmp1 + tmp2*tmp2;
} }
while ( w >= eTp(1) ); while ( w >= eTp(1) );
return eT( tmp1 * std::sqrt( (eTp(-2) * std::log(w)) / w) ); return eT( tmp1 * std::sqrt( (eTp(-2) * std::log(w)) / w) );
} }
// other methods: // other methods:
// http://en.wikipedia.org/wiki/Ziggurat_algorithm // http://en.wikipedia.org/wiki/Ziggurat_algorithm
// //
 End of changes. 3 change blocks. 
5 lines changed or deleted 10 lines changed or added


 eop_core_meat.hpp   eop_core_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 45 skipping to change at line 45
}\ }\
\ \
if(i < n_elem)\ if(i < n_elem)\
{\ {\
out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\ out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\
}\ }\
} }
#define arma_applier_2(operatorA) \ #define arma_applier_2(operatorA) \
{\ {\
uword count = 0;\ if(n_rows != 1)\
\
for(uword col=0; col<n_cols; ++col)\
{\ {\
uword i,j;\ uword count = 0;\
\ \
for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\ for(uword col=0; col<n_cols; ++col)\
{\ {\
eT tmp_i = P.at(i,col);\ uword i,j;\
eT tmp_j = P.at(j,col);\
\ \
tmp_i = eop_core<eop_type>::process(tmp_i, k);\ for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\ {\
eT tmp_i = P.at(i,col);\
eT tmp_j = P.at(j,col);\
\
tmp_i = eop_core<eop_type>::process(tmp_i, k);\
tmp_j = eop_core<eop_type>::process(tmp_j, k);\
\
out_mem[count ] operatorA tmp_i;\
out_mem[count+1] operatorA tmp_j;\
}\
\ \
out_mem[count ] operatorA tmp_i;\ if(i < n_rows)\
out_mem[count+1] operatorA tmp_j;\ {\
out_mem[count] operatorA eop_core<eop_type>::process(P.at(i,col), k
);\
++count;\
}\
}\ }\
\ }\
if(i < n_rows)\ else\
{\
for(uword count=0; count < n_cols; ++count)\
{\ {\
out_mem[count] operatorA eop_core<eop_type>::process(P.at(i,col), k); out_mem[count] operatorA eop_core<eop_type>::process(P.at(0,count), k
\ );\
++count;\
}\ }\
}\ }\
} }
#define arma_applier_3(operatorA) \ #define arma_applier_3(operatorA) \
{\ {\
uword count = 0;\ uword count = 0;\
\ \
for(uword slice=0; slice<n_slices; ++slice)\ for(uword slice=0; slice<n_slices; ++slice)\
{\ {\
skipping to change at line 116 skipping to change at line 126
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
void void
eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, e op_type>& x) eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, e op_type>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const uword n_rows = out.n_rows;
const uword n_cols = out.n_cols;
const uword n_elem = out.n_elem;
// NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing; // NOTE: we're assuming that the matrix has already been set to the corre ct size and there is no aliasing;
// size setting and alias checking is done by either the Mat contructor o r operator=() // size setting and alias checking is done by either the Mat contructor o r operator=()
const eT k = x.aux; const eT k = x.aux;
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
const uword n_elem = out.n_elem;
typename Proxy<T1>::ea_type P = x.P.get_ea(); typename Proxy<T1>::ea_type P = x.P.get_ea();
arma_applier_1(=); arma_applier_1(=);
} }
else else
{ {
const uword n_rows = x.get_n_rows();
const uword n_cols = x.get_n_cols();
const Proxy<T1>& P = x.P; const Proxy<T1>& P = x.P;
arma_applier_2(=); arma_applier_2(=);
} }
} }
template<typename eop_type> template<typename eop_type>
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
 End of changes. 12 change blocks. 
22 lines changed or deleted 34 lines changed or added


 field_bones.hpp   field_bones.hpp 
skipping to change at line 38 skipping to change at line 38
public: public:
typedef oT object_type; typedef oT object_type;
const uword n_rows; //!< number of rows in the field (read-only) const uword n_rows; //!< number of rows in the field (read-only)
const uword n_cols; //!< number of columns in the field (read-only) const uword n_cols; //!< number of columns in the field (read-only)
const uword n_elem; //!< number of elements in the field (read-only) const uword n_elem; //!< number of elements in the field (read-only)
private: private:
arma_aligned oT** mem; //!< pointer to memory used by the obj arma_aligned oT** mem; //!< pointer t
ect o memory used by the object
arma_aligned oT* mem_local[ field_prealloc_n_elem::val ]; arma_aligned oT* mem_local[ field_prealloc_n_elem::val ]; //!< Internal
//!< Internal memory, to avoid calling the 'new' operator for small amoun memory, to avoid calling the 'new' operator for small amounts of memory
ts of memory
public: public:
inline ~field(); inline ~field();
inline field(); inline field();
inline field(const field& x); inline field(const field& x);
inline const field& operator=(const field& x); inline const field& operator=(const field& x);
inline field(const subview_field<oT>& x); inline field(const subview_field<oT>& x);
skipping to change at line 78 skipping to change at line 77
arma_inline oT& operator()(const uword i); arma_inline oT& operator()(const uword i);
arma_inline const oT& operator()(const uword i) const; arma_inline const oT& operator()(const uword i) const;
arma_inline oT& at(const uword row, const uword col); arma_inline oT& at(const uword row, const uword col);
arma_inline const oT& at(const uword row, const uword col) const; arma_inline const oT& at(const uword row, const uword col) const;
arma_inline oT& operator()(const uword row, const uword col); arma_inline oT& operator()(const uword row, const uword col);
arma_inline const oT& operator()(const uword row, const uword col) const; arma_inline const oT& operator()(const uword row, const uword col) const;
inline field_injector<field> operator<<(const oT& val); inline field_injector<field> operator<<(const oT& val);
inline field_injector<field> operator<<(const injector_end_of_row& x); inline field_injector<field> operator<<(const injector_end_of_row<>&amp; x);
inline subview_field<oT> row(const uword row_num); inline subview_field<oT> row(const uword row_num);
inline const subview_field<oT> row(const uword row_num) const; inline const subview_field<oT> row(const uword row_num) const;
inline subview_field<oT> col(const uword col_num); inline subview_field<oT> col(const uword col_num);
inline const subview_field<oT> col(const uword col_num) const; inline const subview_field<oT> col(const uword col_num) const;
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;
 End of changes. 2 change blocks. 
6 lines changed or deleted 5 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 272 skipping to change at line 272
inline inline
field_injector< field<oT> > field_injector< field<oT> >
field<oT>::operator<<(const oT& val) field<oT>::operator<<(const oT& val)
{ {
return field_injector< field<oT> >(*this, val); return field_injector< field<oT> >(*this, val);
} }
template<typename oT> template<typename oT>
inline inline
field_injector< field<oT> > field_injector< field<oT> >
field<oT>::operator<<(const injector_end_of_row& x) field<oT>::operator<<(const injector_end_of_row<>&amp; x)
{ {
return field_injector< field<oT> >(*this, x); return field_injector< field<oT> >(*this, x);
} }
//! creation of subview_field (row of a field) //! creation of subview_field (row of a field)
template<typename oT> template<typename oT>
inline inline
subview_field<oT> subview_field<oT>
field<oT>::row(const uword row_num) field<oT>::row(const uword row_num)
{ {
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_accu.hpp   fn_accu.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_accu //! \addtogroup fn_accu
//! @{ //! @{
//! accumulate the elements of a matrix
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::elem_type typename T1::elem_type
accu(const Base<typename T1::elem_type,T1>& X) accu_proxy_linear(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type; typedef typename Proxy<T1>::ea_type ea_type;
const Proxy<T1> A(X.get_ref()); ea_type A = P.get_ea();
const uword n_elem = P.get_n_elem();
if(Proxy<T1>::prefer_at_accessor == false) eT val1 = eT(0);
eT val2 = eT(0);
uword i,j;
for(i=0, j=1; j < n_elem; i+=2, j+=2)
{ {
ea_type P = A.get_ea(); val1 += A[i];
const uword n_elem = A.get_n_elem(); val2 += A[j];
}
eT val1 = eT(0); if(i < n_elem)
eT val2 = eT(0); {
val1 += A[i];
}
uword i,j; return (val1 + val2);
}
for(i=0, j=1; j<n_elem; i+=2, j+=2) #if defined(ARMA_GOOD_COMPILER)
{ template<typename T1>
val1 += P[i]; arma_hot
val2 += P[j]; inline
} typename T1::elem_type
accu_proxy_at(const Proxy<T1>& P)
{
typedef typename T1::elem_type eT;
if(i < n_elem) const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(n_rows != 1)
{ {
val1 += P[i]; eT val1 = eT(0);
eT val2 = eT(0);
for(uword col=0; col < n_cols; ++col)
{
uword i,j;
for(i=0, j=1; j < n_rows; i+=2, j+=2)
{
val1 += P.at(i,col);
val2 += P.at(j,col);
}
if(i < n_rows)
{
val1 += P.at(i,col);
}
}
return (val1 + val2);
} }
else
{
eT val1 = eT(0);
eT val2 = eT(0);
return val1 + val2; uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
val1 += P.at(0,i);
val2 += P.at(0,j);
}
if(i < n_cols)
{
val1 += P.at(0,i);
}
return (val1 + val2);
}
} }
else #else
template<typename T1>
arma_hot
inline
typename T1::elem_type
accu_proxy_at(const Proxy<T1>& P)
{ {
const uword n_rows = A.get_n_rows(); typedef typename T1::elem_type eT;
const uword n_cols = A.get_n_cols();
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
eT val = eT(0); eT val = eT(0);
for(uword col=0; col<n_cols; ++col) if(n_rows != 1)
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
val += P.at(row,col);
}
}
else
{ {
for(uword row=0; row<n_rows; ++row) for(uword col=0; col < n_cols; ++col)
{ {
val += A.at(row,col); val += P.at(0,col);
} }
} }
return val; return val;
} }
} #endif
//! explicit handling of Hamming norm (also known as zero norm) //! accumulate the elements of a matrix
template<typename T1> template<typename T1>
arma_inline arma_hot
arma_warn_unused inline
uword typename T1::elem_type
accu(const mtOp<uword,T1,op_rel_noteq>& X) accu(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; const Proxy<T1> P(X.get_ref());
const Proxy<T1> A(X.m);
const uword n_elem = A.get_n_elem();
const eT val = X.aux;
uword n_nonzero = 0; return (Proxy<T1>::prefer_at_accessor == false) ? accu_proxy_linear(P) :
for(uword i=0; i<n_elem; ++i) accu_proxy_at(P);
{
if(A[i] != val)
{
++n_nonzero;
}
}
return n_nonzero;
} }
//! accumulate the elements of a cube //! explicit handling of Hamming norm (also known as zero norm)
template<typename T1> template<typename T1>
arma_hot
arma_warn_unused
inline inline
typename T1::elem_type arma_warn_unused
accu(const BaseCube<typename T1::elem_type,T1>& X) uword
accu(const mtOp<uword,T1,op_rel_noteq>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> A(X.get_ref());
if(ProxyCube<T1>::prefer_at_accessor == false) const eT val = X.aux;
{
ea_type P = A.get_ea(); const Proxy<T1> P(X.m);
const uword n_elem = A.get_n_elem();
eT val1 = eT(0); uword n_nonzero = 0;
eT val2 = eT(0);
uword i,j; if(Proxy<T1>::prefer_at_accessor == false)
{
typedef typename Proxy<T1>::ea_type ea_type;
for(i=0, j=1; j<n_elem; i+=2, j+=2) ea_type A = P.get_ea();
{ const uword n_elem = P.get_n_elem();
val1 += P[i];
val2 += P[j];
}
if(i < n_elem) for(uword i=0; i<n_elem; ++i)
{ {
val1 += P[i]; if(A[i] != val) { ++n_nonzero; }
} }
return val1 + val2;
} }
else else
{ {
const uword n_rows = A.get_n_rows(); const uword P_n_cols = P.get_n_cols();
const uword n_cols = A.get_n_cols(); const uword P_n_rows = P.get_n_rows();
const uword n_slices = A.get_n_slices();
eT val = eT(0); if(P_n_rows == 1)
for(uword slice=0; slice<n_slices; ++slice)
{ {
for(uword col=0; col<n_cols; ++col) for(uword col=0; col < P_n_cols; ++col)
{ {
for(uword row=0; row<n_rows; ++row) if(P.at(0,col) != val) { ++n_nonzero; }
{ }
val += A.at(row,col,slice); }
} else
{
for(uword col=0; col < P_n_cols; ++col)
for(uword row=0; row < P_n_rows; ++row)
{
if(P.at(row,col) != val) { ++n_nonzero; }
} }
} }
return val;
} }
return n_nonzero;
} }
//! accumulate the elements of a diagview //! accumulate the elements of a subview (submatrix)
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const diagview<eT>& X) accu(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword n_elem = X.n_elem; const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
eT val = eT(0); eT val = eT(0);
for(uword i=0; i<n_elem; ++i) if(X_n_rows == 1)
{ {
val += X[i]; const Mat<eT>& A = X.m;
}
return val;
}
//! accumulate the elements of a subview (submatrix) const uword start_row = X.aux_row1;
template<typename eT> const uword start_col = X.aux_col1;
arma_pure
arma_warn_unused
inline
eT
accu(const subview<eT>& S)
{
arma_extra_debug_sigprint();
const uword S_n_rows = S.n_rows; const uword end_col_p1 = start_col + X_n_cols;
const uword S_n_cols = S.n_cols;
const uword S_n_elem = S.n_elem;
eT val = eT(0); uword i,j;
for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
{
val += A.at(start_row, i);
val += A.at(start_row, j);
}
if(S_n_elem > 0) if(i < end_col_p1)
{
val += A.at(start_row, i);
}
}
else
if(X_n_cols == 1)
{
val = arrayops::accumulate( X.colptr(0), X_n_rows );
}
else
{ {
for(uword col=0; col<S_n_cols; ++col) for(uword col=0; col < X_n_cols; ++col)
{ {
val += arrayops::accumulate( S.colptr(col), S_n_rows ); val += arrayops::accumulate( X.colptr(col), X_n_rows );
} }
} }
return val; return val;
} }
//! accumulate the elements of a subview_row
template<typename eT> template<typename eT>
arma_pure arma_pure
arma_warn_unused arma_warn_unused
inline inline
eT eT
accu(const subview_row<eT>& S) accu(const subview_col<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Mat<eT>& X = S.m; return arrayops::accumulate( X.colptr(0), X.n_rows );
}
const uword n_elem = S.n_elem; //! accumulate the elements of a cube
const uword row = S.aux_row1; template<typename T1>
const uword start_col = S.aux_col1; arma_hot
const uword end_col_p1 = start_col + S.n_cols; arma_warn_unused
inline
typename T1::elem_type
accu(const BaseCube<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
eT val = eT(0); typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> A(X.get_ref());
if(n_elem > 0) if(ProxyCube<T1>::prefer_at_accessor == false)
{ {
ea_type P = A.get_ea();
const uword n_elem = A.get_n_elem();
eT val1 = eT(0);
eT val2 = eT(0);
uword i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val += X.at(row,i); val1 += P[i];
val += X.at(row,j); val2 += P[j];
} }
if(i < end_col_p1) if(i < n_elem)
{ {
val += X.at(row,i); val1 += P[i];
} }
return val1 + val2;
} }
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
return val; eT val = eT(0);
for(uword slice=0; slice<n_slices; ++slice)
for(uword col=0; col<n_cols; ++col)
for(uword row=0; row<n_rows; ++row)
{
val += A.at(row,col,slice);
}
return val;
}
} }
//! accumulate the elements of a subview_col template<typename T>
template<typename eT> arma_inline
arma_pure
arma_warn_unused arma_warn_unused
inline const typename arma_scalar_only<T>::result &
eT accu(const T& x)
accu(const subview_col<eT>& S)
{ {
arma_extra_debug_sigprint(); return x;
return (S.n_elem > 0) ? arrayops::accumulate( S.colptr(0), S.n_rows ) : e
T(0);
} }
//! @} //! @}
 End of changes. 70 change blocks. 
137 lines changed or deleted 207 lines changed or added


 fn_conv_to.hpp   fn_conv_to.hpp 
skipping to change at line 124 skipping to change at line 124
arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
out_eT out; out_eT out;
arrayops::convert_cx_scalar(out, X.mem[0]); arrayops::convert_cx_scalar(out, X.mem[0]);
return out; return out;
} }
//! conversion to Armadillo matrices from Armadillo Base objects, //! conversion to Armadillo matrices from Armadillo Base objects, as well a
//! as well as from std::vector, itpp::Mat and itpp::Vec s from std::vector
template<typename out_eT> template<typename out_eT>
class conv_to< Mat<out_eT> > class conv_to< Mat<out_eT> >
{ {
public: public:
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0); inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0); inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Mat<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Mat<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Mat<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Mat<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
Mat<out_eT> Mat<out_eT>
conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk) conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 257 skipping to change at line 244
{ {
out_eT& out_elem = (*out_it); out_eT& out_elem = (*out_it);
const in_eT& in_elem = (*in_it); const in_eT& in_elem = (*in_it);
arrayops::convert_cx_scalar(out_elem, in_elem); arrayops::convert_cx_scalar(out_elem, in_elem);
} }
return out; return out;
} }
template<typename out_eT> //! conversion to Armadillo row vectors from Armadillo Base objects, as wel
template<typename in_eT> l as from std::vector
inline
Mat<out_eT>
conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Mat<out_eT> out(in.rows(), in.cols());
arrayops::convert( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Mat<out_eT>
conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Mat<out_eT> out(in.rows(), in.cols());
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Mat<out_eT>
conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Mat<out_eT> out(in.length(), 1);
arrayops::convert( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Mat<out_eT>
conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Mat<out_eT> out(in.length(), 1);
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out;
}
//! conversion to Armadillo row vectors from Armadillo Base objects,
//! as well as from std::vector, itpp::Mat and itpp::Vec
template<typename out_eT> template<typename out_eT>
class conv_to< Row<out_eT> > class conv_to< Row<out_eT> >
{ {
public: public:
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Row<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0); inline static Row<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Row<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0); inline static Row<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Row<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Row<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Row<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Row<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
Row<out_eT> Row<out_eT>
conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk) conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 462 skipping to change at line 368
{ {
out_eT& out_elem = (*out_it); out_eT& out_elem = (*out_it);
const in_eT& in_elem = (*in_it); const in_eT& in_elem = (*in_it);
arrayops::convert_cx_scalar(out_elem, in_elem); arrayops::convert_cx_scalar(out_elem, in_elem);
} }
return out; return out;
} }
template<typename out_eT> //! conversion to Armadillo column vectors from Armadillo Base objects, as
template<typename in_eT> well as from std::vector
inline
Row<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
arma_debug_check( (is_vec == false), "conv_to(): given object can't be in
terpreted as a vector" );
Row<out_eT> out(in.rows() * in.cols());
arrayops::convert( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Row<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
//const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
Row<out_eT> out(in.rows() * in.cols());
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Row<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Row<out_eT> out(in.length());
arrayops::convert( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Row<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Row<out_eT> out(in.length());
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out;
}
//! conversion to Armadillo column vectors from Armadillo Base objects,
//! as well as from std::vector, itpp::Mat and itpp::Vec
template<typename out_eT> template<typename out_eT>
class conv_to< Col<out_eT> > class conv_to< Col<out_eT> >
{ {
public: public:
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Col<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0); inline static Col<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Col<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0); inline static Col<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Col<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Col<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Col<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Col<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
Col<out_eT> Col<out_eT>
conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk) conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 673 skipping to change at line 492
{ {
out_eT& out_elem = (*out_it); out_eT& out_elem = (*out_it);
const in_eT& in_elem = (*in_it); const in_eT& in_elem = (*in_it);
arrayops::convert_cx_scalar(out_elem, in_elem); arrayops::convert_cx_scalar(out_elem, in_elem);
} }
return out; return out;
} }
template<typename out_eT>
template<typename in_eT>
inline
Col<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
arma_debug_check( (is_vec == false), "conv_to(): given object can't be in
terpreted as a vector" );
Col<out_eT> out(in.rows() * in.cols());
arrayops::convert( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Col<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
//const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
Col<out_eT> out(in.rows() * in.cols());
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Col<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Col<out_eT> out( in.length() );
arrayops::convert( out.memptr(), in._data(), out.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT>
inline
Col<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
Col<out_eT> out( in.length() );
arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
return out;
}
//! conversion to Armadillo cubes from Armadillo BaseCube objects //! conversion to Armadillo cubes from Armadillo BaseCube objects
template<typename out_eT> template<typename out_eT>
class conv_to< Cube<out_eT> > class conv_to< Cube<out_eT> >
{ {
public: public:
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const type name arma_not_cx<in_eT>::result* junk = 0); inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const type name arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
skipping to change at line 884 skipping to change at line 629
{ {
out_eT& out_elem = (*out_it); out_eT& out_elem = (*out_it);
const in_eT& X_elem = (*X_it); const in_eT& X_elem = (*X_it);
arrayops::convert_cx_scalar(out_elem, X_elem); arrayops::convert_cx_scalar(out_elem, X_elem);
} }
return out; return out;
} }
//! conversion to itpp::Mat from Armadillo Base objects
template<typename out_eT>
class conv_to< itpp::Mat<out_eT> >
{
public:
template<typename in_eT, typename T1>
inline static itpp::Mat<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1>
inline static itpp::Mat<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_cx_only<in_eT>::result* junk = 0);
};
template<typename out_eT>
template<typename in_eT, typename T1>
inline
itpp::Mat<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
itpp::Mat<out_eT> out(X.n_rows, X.n_cols);
arrayops::convert( out._data(), X.memptr(), X.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT, typename T1>
inline
itpp::Mat<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
itpp::Mat<out_eT> out(X.n_rows, X.n_cols);
arrayops::convert_cx( out._data(), X.memptr(), X.n_elem );
return out;
}
//! conversion to itpp::Vec from Armadillo Base objects
template<typename out_eT>
class conv_to< itpp::Vec<out_eT> >
{
public:
template<typename in_eT, typename T1>
inline static itpp::Vec<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1>
inline static itpp::Vec<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_cx_only<in_eT>::result* junk = 0);
};
template<typename out_eT>
template<typename in_eT, typename T1>
inline
itpp::Vec<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_not_cx<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" );
itpp::Vec<out_eT> out(X.n_elem);
arrayops::convert( out._data(), X.memptr(), X.n_elem );
return out;
}
template<typename out_eT>
template<typename in_eT, typename T1>
inline
itpp::Vec<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
itpp::Vec<out_eT> out(X.n_elem);
arrayops::convert_cx( out._data(), X.memptr(), X.n_elem );
return out;
}
//! @} //! @}
 End of changes. 8 change blocks. 
401 lines changed or deleted 6 lines changed or added


 fn_cumsum.hpp   fn_cumsum.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_cumsum //! \addtogroup fn_cumsum
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_cumsum_mat> const Op<T1, op_cumsum_mat>
cumsum(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) cumsum
(
const Base<typename T1::elem_type,T1>& X,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_cumsum_mat>(X.get_ref(), dim, 0); return Op<T1, op_cumsum_mat>(X.get_ref(), dim, 0);
} }
template<typename eT> template<typename T1>
arma_inline
const Op<Row<eT>, op_cumsum_vec>
cumsum(const Row<eT>& A)
{
arma_extra_debug_sigprint();
return Op<Row<eT>, op_cumsum_vec>(A);
}
template<typename eT>
arma_inline
const Op<Col<eT>, op_cumsum_vec>
cumsum(const Col<eT>& A)
{
arma_extra_debug_sigprint();
return Op<Col<eT>, op_cumsum_vec>(A);
}
template<typename eT>
arma_inline arma_inline
const Op<subview_row<eT>, op_cumsum_vec> const Op<T1, op_cumsum_mat>
cumsum(const subview_row<eT>& A) cumsum
(
const Base<typename T1::elem_type,T1>& X,
const uword dim,
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
return Op<subview_row<eT>, op_cumsum_vec>(A); return Op<T1, op_cumsum_mat>(X.get_ref(), dim, 0);
} }
template<typename eT> template<typename T1>
arma_inline arma_inline
const Op<subview_col<eT>, op_cumsum_vec> const Op<T1, op_cumsum_vec>
cumsum(const subview_col<eT>& A) cumsum
(
const Base<typename T1::elem_type,T1>& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<subview_col<eT>, op_cumsum_vec>(A); return Op<T1, op_cumsum_vec>(X.get_ref());
} }
template<typename eT> template<typename T1>
arma_inline arma_inline
const Op<diagview<eT>, op_cumsum_vec> const Op<T1, op_cumsum_vec>
cumsum(const diagview<eT>& A) cumsum
(
const T1& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<diagview<eT>, op_cumsum_vec>(A); return Op<T1, op_cumsum_vec>(X);
} }
template<typename eT, typename T1> template<typename T>
arma_inline arma_inline
const Op<subview_elem1<eT,T1>, op_cumsum_vec> arma_warn_unused
cumsum(const subview_elem1<eT,T1>& A) const typename arma_scalar_only<T>::result &
cumsum(const T& x)
{ {
arma_extra_debug_sigprint(); return x;
return Op<subview_elem1<eT,T1>, op_cumsum_vec>(A);
} }
//! @} //! @}
 End of changes. 18 change blocks. 
41 lines changed or deleted 53 lines changed or added


 fn_det.hpp   fn_det.hpp 
skipping to change at line 113 skipping to change at line 113
arma_ignore(junk2); arma_ignore(junk2);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
return det(X, slow); return det(X, slow);
} }
template<typename T>
arma_inline
arma_warn_unused
const typename arma_scalar_only<T>::result &
det(const T& x)
{
return x;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 9 lines changed or added


 fn_eye.hpp   fn_eye.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_eye //! \addtogroup fn_eye
//! @{ //! @{
arma_inline arma_inline
const Gen<mat::elem_type, gen_ones_diag> const Gen<mat, gen_ones_diag>
eye(const uword n_rows, const uword n_cols) eye(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<mat::elem_type, gen_ones_diag>(n_rows, n_cols); return Gen<mat, gen_ones_diag>(n_rows, n_cols);
} }
template<typename mat_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename mat_type::elem_type, gen_ones_diag> const Gen<obj_type, gen_ones_diag>
eye(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row eye(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row
_only<mat_type>::result* junk = 0) _only<obj_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Gen<typename mat_type::elem_type, gen_ones_diag>(n_rows, n_cols); if(is_Col<obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "eye(): incompatible size" );
}
else
if(is_Row<obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "eye(): incompatible size" );
}
return Gen<obj_type, gen_ones_diag>(n_rows, n_cols);
} }
//! @} //! @}
 End of changes. 6 change blocks. 
9 lines changed or deleted 19 lines changed or added


 fn_max.hpp   fn_max.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 26 skipping to change at line 26
//! \brief //! \brief
//! Delayed 'maximum values' operation. //! Delayed 'maximum values' operation.
//! The dimension, along which the maxima are found, is set via 'dim'. //! The dimension, along which the maxima are found, is set via 'dim'.
//! For dim = 0, the maximum value of each column is found (i.e. searches b y traversing across rows). //! For dim = 0, the maximum value of each column is found (i.e. searches b y traversing across rows).
//! For dim = 1, the maximum value of each row is found (i.e. searches by t raversing across columns). //! For dim = 1, the maximum value of each row is found (i.e. searches by t raversing across columns).
//! The default is dim = 0. //! The default is dim = 0.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_max> const Op<T1, op_max>
max(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) max
(
const Base<typename T1::elem_type,T1>& X,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_max>(X.get_ref(), dim, 0); return Op<T1, op_max>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the maximum value in a row vector' operation template<typename T1>
template<typename eT> arma_inline
inline const Op<T1, op_max>
arma_warn_unused max
eT (
max(const Row<eT>& A) const Base<typename T1::elem_type,T1>& X,
{ const uword dim,
arma_extra_debug_sigprint(); const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk = 0
const uword A_n_elem = A.n_elem; )
arma_debug_check( (A_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(A.mem, A_n_elem);
}
//! Immediate 'find the maximum value in a column vector' operation
template<typename eT>
inline
arma_warn_unused
eT
max(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
const uword A_n_elem = A.n_elem; return Op<T1, op_max>(X.get_ref(), dim, 0);
arma_debug_check( (A_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find maximum value' operation, //! Immediate 'find maximum value' operation,
//! invoked, for example, by: max(max(A)) //! invoked, for example, by: max(max(A))
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
max(const Op<T1, op_max>& in) max(const Op<T1, op_max>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("max(): two consecutive max() calls detected"); arma_extra_debug_print("max(): two consecutive max() calls detected");
typedef typename T1::elem_type eT; return op_max::max(in.m);
const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M;
const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op< Op<T1, op_max>, op_max> const Op< Op<T1, op_max>, op_max>
max(const Op<T1, op_max>& in, const uword dim) max(const Op<T1, op_max>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_max>, op_max>(in, dim, 0); return Op< Op<T1, op_max>, op_max>(in, dim, 0);
} }
template<typename eT> template<typename T1>
inline
arma_warn_unused
eT
max(const subview_row<eT>& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(A);
}
template<typename eT>
inline
arma_warn_unused
eT
max(const subview_col<eT>& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(A.colptr(0), A.n_rows);
}
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
max(const Op<subview<eT>, op_max>& in) max
(
const Base<typename T1::elem_type,T1>& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("max(): two consecutive max() calls detected"); arma_ignore(junk1);
arma_ignore(junk2);
const subview<eT>& X = in.m;
arma_debug_check( (X.n_elem == 0), "max(): given object has no elements" return op_max::max(X);
);
return op_max::direct_max(X);
} }
template<typename eT> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
max(const diagview<eT>& A) max
(
const T1& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" return op_max::max(X);
);
return op_max::direct_max(A);
} }
template<typename eT, typename T1> template<typename T>
inline arma_inline
arma_warn_unused arma_warn_unused
eT const typename arma_scalar_only<T>::result &
max(const subview_elem1<eT,T1>& A) max(const T& x)
{ {
arma_extra_debug_sigprint(); return x;
const Mat<eT> X(A);
const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "max(): given object has no elements"
);
return op_max::direct_max(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 18 change blocks. 
102 lines changed or deleted 55 lines changed or added


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


 fn_median.hpp   fn_median.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_median //! \addtogroup fn_median
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_median> const Op<T1, op_median>
median(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) median
(
const Base<typename T1::elem_type,T1>& X,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_median>(X.get_ref(), dim, 0); return Op<T1, op_median>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the median value of a row vector' operation template<typename T1>
template<typename eT> arma_inline
inline const Op<T1, op_median>
arma_warn_unused median
eT (
median(const Row<eT>& A) const Base<typename T1::elem_type,T1>& X,
{ const uword dim,
arma_extra_debug_sigprint(); const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk = 0
const uword A_n_elem = A.n_elem; )
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
return op_median::direct_median(A.mem, A_n_elem);
}
//! Immediate 'find the median value of a column vector' operation
template<typename eT>
inline
arma_warn_unused
eT
median(const Col<eT>& A)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
return op_median::direct_median(A.mem, A_n_elem);
}
//! Immediate 'find the median value of a row vector' operation (complex nu
mber version)
template<typename T>
inline
arma_warn_unused
std::complex<T>
median(const Row< std::complex<T> >& A)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem);
return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem
[index1], A.mem[index2] );
}
//! Immediate 'find the median value of a column vector' operation (complex
number version)
template<typename T>
inline
arma_warn_unused
std::complex<T>
median(const Col< std::complex<T> >& A)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "median(): given object has no element
s" );
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, A.mem, A_n_elem);
return (index1 == index2) ? A.mem[index1] : op_median::robust_mean( A.mem
[index1], A.mem[index2] );
}
//! find the median value of a subview_row
template<typename eT>
inline
arma_warn_unused
eT
median(const subview_row<eT>& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given object has no element
s" );
return op_median::direct_median(A);
}
//! find the median value of a subview_col
template<typename eT>
inline
arma_warn_unused
eT
median(const subview_col<eT>& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given object has no element
s" );
return op_median::direct_median(A.colptr(0), A.n_rows);
}
//! find the median value of a subview_row (complex number version)
template<typename T>
inline
arma_warn_unused
std::complex<T>
median(const subview_row< std::complex<T> >& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
arma_debug_check( (A.n_elem == 0), "median(): given object has no element return Op<T1, op_median>(X.get_ref(), dim, 0);
s" );
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, A);
return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1],
A[index2]);
} }
//! find the median value of a subview_col (complex number version) template<typename T1>
template<typename T>
inline inline
arma_warn_unused arma_warn_unused
std::complex<T> typename T1::elem_type
median(const subview_col< std::complex<T> >& A) median
(
const Base<typename T1::elem_type,T1>& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_debug_check( (A.n_elem == 0), "median(): given object has no element return op_median::median_vec(X.get_ref());
s" );
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, A);
return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1],
A[index2]);
} }
template<typename eT> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
median(const diagview<eT>& A) median
(
const T1& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_debug_check( (A.n_elem == 0), "median(): given object has no element return op_median::median_vec(X);
s" );
return op_median::direct_median(A);
} }
template<typename T> template<typename T>
inline arma_inline
arma_warn_unused
std::complex<T>
median(const diagview< std::complex<T> >& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "median(): given object has no element
s" );
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, A);
return (index1 == index2) ? A[index1] : op_median::robust_mean(A[index1],
A[index2]);
}
template<typename eT, typename T1>
inline
arma_warn_unused arma_warn_unused
eT const typename arma_scalar_only<T>::result &
median(const subview_elem1<eT,T1>& A) median(const T& x)
{ {
arma_extra_debug_sigprint(); return x;
const Col<eT> X(A);
return median(X);
} }
//! @} //! @}
 End of changes. 17 change blocks. 
175 lines changed or deleted 53 lines changed or added


 fn_min.hpp   fn_min.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 26 skipping to change at line 26
//! \brief //! \brief
//! Delayed 'minimum values' operation. //! Delayed 'minimum values' operation.
//! The dimension, along which the minima are found, is set via 'dim'. //! The dimension, along which the minima are found, is set via 'dim'.
//! For dim = 0, the minimum value of each column is found (i.e. searches b y traversing across rows). //! For dim = 0, the minimum value of each column is found (i.e. searches b y traversing across rows).
//! For dim = 1, the minimum value of each row is found (i.e. searches by t raversing across columns). //! For dim = 1, the minimum value of each row is found (i.e. searches by t raversing across columns).
//! The default is dim = 0. //! The default is dim = 0.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_min> const Op<T1, op_min>
min(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) min
(
const Base<typename T1::elem_type,T1>& X,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_min>(X.get_ref(), dim, 0); return Op<T1, op_min>(X.get_ref(), dim, 0);
} }
//! Immediate 'find the minimum value in a row vector' operation template<typename T1>
template<typename eT> arma_inline
inline const Op<T1, op_min>
arma_warn_unused min
eT (
min(const Row<eT>& A) const Base<typename T1::elem_type,T1>& X,
{ const uword dim,
arma_extra_debug_sigprint(); const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk = 0
const uword A_n_elem = A.n_elem; )
arma_debug_check( (A_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(A.mem, A_n_elem);
}
//! Immediate 'find the minimum value in a column vector'
template<typename eT>
inline
arma_warn_unused
eT
min(const Col<eT>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
const uword A_n_elem = A.n_elem; return Op<T1, op_min>(X.get_ref(), dim, 0);
arma_debug_check( (A_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(A.mem, A_n_elem);
} }
//! \brief //! \brief
//! Immediate 'find minimum value' operation, //! Immediate 'find minimum value' operation,
//! invoked, for example, by: min(min(A)) //! invoked, for example, by: min(min(A))
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
min(const Op<T1, op_min>& in) min(const Op<T1, op_min>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("min(): two consecutive min() calls detected"); arma_extra_debug_print("min(): two consecutive min() calls detected");
typedef typename T1::elem_type eT; return op_min::min(in.m);
const unwrap<T1> tmp1(in.m);
const Mat<eT>& X = tmp1.M;
const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(X.mem, X_n_elem);
} }
template<typename T1> template<typename T1>
inline arma_inline
const Op< Op<T1, op_min>, op_min> const Op< Op<T1, op_min>, op_min>
min(const Op<T1, op_min>& in, const uword dim) min(const Op<T1, op_min>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op< Op<T1, op_min>, op_min>(in, dim, 0); return Op< Op<T1, op_min>, op_min>(in, dim, 0);
} }
template<typename eT> template<typename T1>
inline
arma_warn_unused
eT
min(const subview_row<eT>& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(A);
}
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
min(const subview_col<eT>& A) min
(
const Base<typename T1::elem_type,T1>& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" return op_min::min(X);
);
return op_min::direct_min(A.colptr(0), A.n_rows);
} }
template<typename eT> template<typename T1>
inline
arma_warn_unused
eT
min(const diagview<eT>& A)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(A);
}
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
min(const Op<subview<eT>, op_min>& in) min
(
const T1& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("min(): two consecutive min() calls detected"); arma_ignore(junk1);
arma_ignore(junk2);
const subview<eT>& X = in.m; return op_min::min(X);
arma_debug_check( (X.n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(X);
} }
template<typename eT, typename T1> template<typename T>
inline arma_inline
arma_warn_unused arma_warn_unused
eT const typename arma_scalar_only<T>::result &
min(const subview_elem1<eT,T1>& A) min(const T& x)
{ {
arma_extra_debug_sigprint(); return x;
const Mat<eT> X(A);
const uword X_n_elem = X.n_elem;
arma_debug_check( (X_n_elem == 0), "min(): given object has no elements"
);
return op_min::direct_min(X.mem, X_n_elem);
} }
//! @} //! @}
 End of changes. 19 change blocks. 
103 lines changed or deleted 56 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 105 skipping to change at line 105
typename arma_float_only<eT>::result typename arma_float_only<eT>::result
log_add(eT log_a, eT log_b) log_add(eT log_a, eT log_b)
{ {
if(log_a < log_b) if(log_a < log_b)
{ {
std::swap(log_a, log_b); std::swap(log_a, log_b);
} }
const eT negdelta = log_b - log_a; const eT negdelta = log_b - log_a;
if( (negdelta < Math<eT>::log_min()) || (arma_isfinite(negdelta) == false ) ) if( (negdelta < Datum<eT>::log_min) || (arma_isfinite(negdelta) == false) )
{ {
return log_a; return log_a;
} }
else else
{ {
#if defined(ARMA_HAVE_LOG1P) #if defined(ARMA_HAVE_LOG1P)
return (log_a + log1p(std::exp(negdelta))); return (log_a + log1p(std::exp(negdelta)));
#else #else
return (log_a + std::log(1.0 + std::exp(negdelta))); return (log_a + std::log(1.0 + std::exp(negdelta)));
#endif #endif
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_norm.hpp   fn_norm.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_norm //! \addtogroup fn_norm
//! @{ //! @{
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_1(const Proxy<T1>& A) arma_vec_norm_1(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type A = P.get_ea();
const uword N = A.get_n_elem(); const uword N = P.get_n_elem();
uword i,j; T acc1 = T(0);
T acc2 = T(0);
uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2) for(i=0, j=1; j<N; i+=2, j+=2)
{ {
acc += std::abs(P[i]); acc1 += std::abs(A[i]);
acc += std::abs(P[j]); acc2 += std::abs(A[j]);
} }
if(i < N) if(i < N)
{ {
acc += std::abs(P[i]); acc1 += std::abs(A[i]);
} }
acc = acc1 + acc2;
} }
else else
{ {
const uword n_rows = A.get_n_rows(); const uword n_rows = P.get_n_rows();
const uword n_cols = A.get_n_cols(); const uword n_cols = P.get_n_cols();
for(uword col=0; col<n_cols; ++col) if(n_rows == 1)
{ {
uword i,j; for(uword col=0; col<n_cols; ++col)
for(i=0, j=1; j<n_rows; i+=2, j+=2)
{ {
acc += std::abs(A.at(i,col)); acc += std::abs(P.at(0,col));
acc += std::abs(A.at(j,col));
} }
}
if(i < n_rows) else
{
for(uword col=0; col<n_cols; ++col)
{ {
acc += std::abs(A.at(i,col)); uword i,j;
for(i=0, j=1; j<n_rows; i+=2, j+=2)
{
acc += std::abs(P.at(i,col));
acc += std::abs(P.at(j,col));
}
if(i < n_rows)
{
acc += std::abs(P.at(i,col));
}
} }
} }
} }
return acc; return acc;
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_2(const Proxy<T1>& A, const typename arma_not_cx<typename T1: arma_vec_norm_2
:elem_type>::result* junk = 0) (
const Proxy<T1>& P,
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::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type A = P.get_ea();
const uword N = P.get_n_elem();
const uword N = A.get_n_elem(); T acc1 = T(0);
T acc2 = T(0);
uword i,j; uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2) for(i=0, j=1; j<N; i+=2, j+=2)
{ {
const T tmp_i = P[i]; const T tmp_i = A[i];
const T tmp_j = P[j]; const T tmp_j = A[j];
acc += tmp_i * tmp_i; acc1 += tmp_i * tmp_i;
acc += tmp_j * tmp_j; acc2 += tmp_j * tmp_j;
} }
if(i < N) if(i < N)
{ {
const T tmp_i = P[i]; const T tmp_i = A[i];
acc += tmp_i * tmp_i; acc1 += tmp_i * tmp_i;
} }
acc = acc1 + acc2;
} }
else else
{ {
const uword n_rows = A.get_n_rows(); const uword n_rows = P.get_n_rows();
const uword n_cols = A.get_n_cols(); const uword n_cols = P.get_n_cols();
for(uword col=0; col<n_cols; ++col) if(n_rows == 1)
{ {
uword i,j; for(uword col=0; col<n_cols; ++col)
for(i=0, j=1; j<n_rows; i+=2, j+=2)
{ {
const T tmp_i = A.at(i,col); const T tmp = P.at(0,col);
const T tmp_j = A.at(j,col);
acc += tmp_i * tmp_i; acc += tmp * tmp;
acc += tmp_j * tmp_j;
} }
}
if(i < n_rows) else
{
for(uword col=0; col<n_cols; ++col)
{ {
const T tmp_i = A.at(i,col); uword i,j;
for(i=0, j=1; j<n_rows; i+=2, j+=2)
{
const T tmp_i = P.at(i,col);
const T tmp_j = P.at(j,col);
acc += tmp_i * tmp_i;
acc += tmp_j * tmp_j;
}
if(i < n_rows)
{
const T tmp_i = P.at(i,col);
acc += tmp_i * tmp_i; acc += tmp_i * tmp_i;
}
} }
} }
} }
return std::sqrt(acc); return std::sqrt(acc);
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_2(const Proxy<T1>& A, const typename arma_cx_only<typename T1 arma_vec_norm_2
::elem_type>::result* junk = 0) (
const Proxy<T1>& P,
const typename arma_cx_only<typename T1::elem_type>::result* junk = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type A = P.get_ea();
const uword N = A.get_n_elem(); const uword N = P.get_n_elem();
for(uword i=0; i<N; ++i) for(uword i=0; i<N; ++i)
{ {
const T tmp = std::abs(P[i]); const T tmp = std::abs(A[i]);
acc += tmp*tmp; acc += tmp*tmp;
} }
} }
else else
{ {
const uword n_rows = A.get_n_rows(); const uword n_rows = P.get_n_rows();
const uword n_cols = A.get_n_cols(); const uword n_cols = P.get_n_cols();
for(uword col=0; col<n_cols; ++col) if(n_rows == 1)
for(uword row=0; row<n_rows; ++row)
{ {
const T tmp = std::abs(A.at(row,col)); for(uword col=0; col<n_cols; ++col)
acc += tmp*tmp; {
const T tmp = std::abs(P.at(0,col));
acc += tmp*tmp;
}
}
else
{
for(uword col=0; col<n_cols; ++col)
for(uword row=0; row<n_rows; ++row)
{
const T tmp = std::abs(P.at(row,col));
acc += tmp*tmp;
}
} }
} }
return std::sqrt(acc); return std::sqrt(acc);
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_k(const Proxy<T1>& A, const int k) arma_vec_norm_k
(
const Proxy<T1>& P,
const int k
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
T acc = T(0); T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false) if(Proxy<T1>::prefer_at_accessor == false)
{ {
typename Proxy<T1>::ea_type P = A.get_ea(); typename Proxy<T1>::ea_type A = P.get_ea();
const uword N = A.get_n_elem(); const uword N = P.get_n_elem();
uword i,j; uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2) for(i=0, j=1; j<N; i+=2, j+=2)
{ {
acc += std::pow(std::abs(P[i]), k); acc += std::pow(std::abs(A[i]), k);
acc += std::pow(std::abs(P[j]), k); acc += std::pow(std::abs(A[j]), k);
} }
if(i < N) if(i < N)
{ {
acc += std::pow(std::abs(P[i]), k); acc += std::pow(std::abs(A[i]), k);
} }
} }
else else
{ {
const uword n_rows = A.get_n_rows(); const uword n_rows = P.get_n_rows();
const uword n_cols = A.get_n_cols(); const uword n_cols = P.get_n_cols();
for(uword col=0; col<n_cols; ++col) if(n_rows != 1)
for(uword row=0; row<n_rows; ++row) {
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
acc += std::pow(std::abs(P.at(row,col)), k);
}
}
else
{ {
acc += std::pow(std::abs(A.at(row,col)), k); for(uword col=0; col < n_cols; ++col)
{
acc += std::pow(std::abs(P.at(0,col)), k);
}
} }
} }
return std::pow(acc, T(1)/T(k)); return std::pow(acc, T(1)/T(k));
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_max(const Proxy<T1>& A) arma_vec_norm_max(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef typename Proxy<T1>::ea_type ea_type;
ea_type P = A.get_ea(); const uword N = P.get_n_elem();
const uword N = A.get_n_elem();
T max_val = (N != 1) ? priv::most_neg<T>() : std::abs(P[0]); T max_val = (N != 1) ? priv::most_neg<T>() : std::abs(P[0]);
uword i,j; if(Proxy<T1>::prefer_at_accessor == false)
for(i=0, j=1; j<N; i+=2, j+=2)
{ {
const T tmp_i = std::abs(P[i]); typename Proxy<T1>::ea_type A = P.get_ea();
const T tmp_j = std::abs(P[j]);
if(max_val < tmp_i) { max_val = tmp_i; } uword i,j;
if(max_val < tmp_j) { max_val = tmp_j; } for(i=0, j=1; j<N; i+=2, j+=2)
} {
const T tmp_i = std::abs(A[i]);
const T tmp_j = std::abs(A[j]);
if(i < N) if(max_val < tmp_i) { max_val = tmp_i; }
if(max_val < tmp_j) { max_val = tmp_j; }
}
if(i < N)
{
const T tmp_i = std::abs(A[i]);
if(max_val < tmp_i) { max_val = tmp_i; }
}
}
else
{ {
const T tmp_i = std::abs(P[i]); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(n_rows != 1)
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const T tmp = std::abs(P.at(row,col));
if(max_val < tmp) { max_val = tmp; }
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
const T tmp = std::abs(P.at(0,col));
if(max_val < tmp_i) { max_val = tmp_i; } if(max_val < tmp) { max_val = tmp; }
}
}
} }
return max_val; return max_val;
} }
template<typename T1> template<typename T1>
arma_hot arma_hot
inline inline
typename T1::pod_type typename T1::pod_type
arma_vec_norm_min(const Proxy<T1>& A) arma_vec_norm_min(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef typename Proxy<T1>::ea_type ea_type;
ea_type P = A.get_ea(); const uword N = P.get_n_elem();
const uword N = A.get_n_elem();
T min_val = (N != 1) ? priv::most_pos<T>() : std::abs(P[0]); T min_val = (N != 1) ? priv::most_pos<T>() : std::abs(P[0]);
uword i,j; if(Proxy<T1>::prefer_at_accessor == false)
for(i=0, j=1; j<N; i+=2, j+=2)
{ {
const T tmp_i = std::abs(P[i]); typename Proxy<T1>::ea_type A = P.get_ea();
const T tmp_j = std::abs(P[j]);
if(min_val > tmp_i) { min_val = tmp_i; } uword i,j;
if(min_val > tmp_j) { min_val = tmp_j; } for(i=0, j=1; j<N; i+=2, j+=2)
} {
const T tmp_i = std::abs(A[i]);
const T tmp_j = std::abs(A[j]);
if(i < N) if(min_val > tmp_i) { min_val = tmp_i; }
if(min_val > tmp_j) { min_val = tmp_j; }
}
if(i < N)
{
const T tmp_i = std::abs(A[i]);
if(min_val > tmp_i) { min_val = tmp_i; }
}
}
else
{ {
const T tmp_i = std::abs(P[i]); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(min_val > tmp_i) { min_val = tmp_i; } if(n_rows != 1)
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const T tmp = std::abs(P.at(row,col));
if(min_val > tmp) { min_val = tmp; }
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
const T tmp = std::abs(P.at(0,col));
if(min_val > tmp) { min_val = tmp; }
}
}
} }
return min_val; return min_val;
} }
template<typename T1> template<typename T1>
inline inline
typename T1::pod_type typename T1::pod_type
arma_mat_norm_1(const Proxy<T1>& A) arma_mat_norm_1(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const unwrap<typename Proxy<T1>::stored_type> tmp(A.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// TODO: this can be sped up with a dedicated implementation // TODO: this can be sped up with a dedicated implementation
return as_scalar( max( sum(abs(X)), 1) ); return as_scalar( max( sum(abs(X)), 1) );
} }
template<typename T1> template<typename T1>
inline inline
typename T1::pod_type typename T1::pod_type
arma_mat_norm_2(const Proxy<T1>& A) arma_mat_norm_2(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const unwrap<typename Proxy<T1>::stored_type> tmp(A.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
Col<T> S; Col<T> S;
svd(S, X); svd(S, X);
return (S.n_elem > 0) ? max(S) : T(0); return (S.n_elem > 0) ? max(S) : T(0);
} }
template<typename T1> template<typename T1>
inline inline
typename T1::pod_type typename T1::pod_type
arma_mat_norm_inf(const Proxy<T1>& A) arma_mat_norm_inf(const Proxy<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const unwrap<typename Proxy<T1>::stored_type> tmp(A.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
// TODO: this can be sped up with a dedicated implementation // TODO: this can be sped up with a dedicated implementation
return as_scalar( max( sum(abs(X),1) ) ); return as_scalar( max( sum(abs(X),1) ) );
} }
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::pod_type typename T1::pod_type
skipping to change at line 370 skipping to change at line 487
const uword k, const uword k,
const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun k = 0 const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun k = 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;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> P(X.get_ref());
if(A.get_n_elem() == 0) if(P.get_n_elem() == 0)
{ {
return T(0); return T(0);
} }
const bool is_vec = (A.get_n_rows() == 1) || (A.get_n_cols() == 1); const bool is_vec = (P.get_n_rows() == 1) || (P.get_n_cols() == 1);
if(is_vec == true) if(is_vec == true)
{ {
switch(k) switch(k)
{ {
case 1: case 1:
return arma_vec_norm_1(A); return arma_vec_norm_1(P);
break; break;
case 2: case 2:
return arma_vec_norm_2(A); return arma_vec_norm_2(P);
break; break;
default: default:
{ {
arma_debug_check( (k == 0), "norm(): k must be greater than zero" ); arma_debug_check( (k == 0), "norm(): k must be greater than zero" );
return arma_vec_norm_k(A, int(k)); return arma_vec_norm_k(P, int(k));
} }
} }
} }
else else
{ {
switch(k) switch(k)
{ {
case 1: case 1:
return arma_mat_norm_1(A); return arma_mat_norm_1(P);
break; break;
case 2: case 2:
return arma_mat_norm_2(A); return arma_mat_norm_2(P);
break; break;
default: default:
arma_stop("norm(): unsupported matrix norm type"); arma_stop("norm(): unsupported matrix norm type");
return T(0); return T(0);
} }
} }
} }
template<typename T1> template<typename T1>
skipping to change at line 434 skipping to change at line 551
const char* method, const char* method,
const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun k = 0 const typename arma_float_or_cx_only<typename T1::elem_type>::result* jun k = 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;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> P(X.get_ref());
if(A.get_n_elem() == 0) if(P.get_n_elem() == 0)
{ {
return T(0); return T(0);
} }
const char sig = method[0]; const char sig = method[0];
const bool is_vec = (A.get_n_rows() == 1) || (A.get_n_cols() == 1); const bool is_vec = (P.get_n_rows() == 1) || (P.get_n_cols() == 1);
if(is_vec == true) if(is_vec == true)
{ {
if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm
{ {
return arma_vec_norm_max(A); return arma_vec_norm_max(P);
} }
else else
if(sig == '-') // min norm if(sig == '-') // min norm
{ {
return arma_vec_norm_min(A); return arma_vec_norm_min(P);
} }
else else
if( (sig == 'f') || (sig == 'F') ) if( (sig == 'f') || (sig == 'F') )
{ {
return arma_vec_norm_2(A); return arma_vec_norm_2(P);
} }
else else
{ {
arma_stop("norm(): unsupported vector norm type"); arma_stop("norm(): unsupported vector norm type");
return T(0); return T(0);
} }
} }
else else
{ {
if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // inf norm if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // inf norm
{ {
return arma_mat_norm_inf(A); return arma_mat_norm_inf(P);
} }
else else
if( (sig == 'f') || (sig == 'F') ) if( (sig == 'f') || (sig == 'F') )
{ {
return arma_vec_norm_2(A); return arma_vec_norm_2(P);
} }
else else
{ {
arma_stop("norm(): unsupported matrix norm type"); arma_stop("norm(): unsupported matrix norm type");
return T(0); return T(0);
} }
} }
} }
//! @} //! @}
 End of changes. 86 change blocks. 
120 lines changed or deleted 235 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_ones //! \addtogroup fn_ones
//! @{ //! @{
arma_inline arma_inline
const Gen<vec::elem_type, gen_ones_full> const Gen<vec, gen_ones_full>
ones(const uword n_elem) ones(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<vec::elem_type, gen_ones_full>(n_elem, 1); return Gen<vec, gen_ones_full>(n_elem, 1);
} }
template<typename vec_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename vec_type::elem_type, gen_ones_full> const Gen<obj_type, gen_ones_full>
ones(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), ones(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(),
const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<obj_type>::value == true)
{ {
return Gen<typename vec_type::elem_type, gen_ones_full>(1, n_elem); return Gen<obj_type, gen_ones_full>(1, n_elem);
} }
else else
{ {
return Gen<typename vec_type::elem_type, gen_ones_full>(n_elem, 1); return Gen<obj_type, gen_ones_full>(n_elem, 1);
} }
} }
arma_inline arma_inline
const Gen<mat::elem_type, gen_ones_full> const Gen<mat, gen_ones_full>
ones(const uword n_rows, const uword n_cols) ones(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<mat::elem_type, gen_ones_full>(n_rows, n_cols); return Gen<mat, gen_ones_full>(n_rows, n_cols);
} }
template<typename mat_type> template<typename obj_type>
arma_inline inline
const Gen<typename mat_type::elem_type, gen_ones_full> const Gen<obj_type, gen_ones_full>
ones(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Ro ones(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Ro
w_only<mat_type>::result* junk = 0) w_only<obj_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Gen<typename mat_type::elem_type, gen_ones_full>(n_rows, n_cols); if(is_Col<obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "ones(): incompatible size" );
}
else
if(is_Row<obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "ones(): incompatible size" );
}
return Gen<obj_type, gen_ones_full>(n_rows, n_cols);
} }
arma_inline arma_inline
const GenCube<cube::elem_type, gen_ones_full> const GenCube<cube::elem_type, gen_ones_full>
ones(const uword n_rows, const uword n_cols, const uword n_slices) ones(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return GenCube<cube::elem_type, gen_ones_full>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_ones_full>(n_rows, n_cols, n_slices);
} }
 End of changes. 12 change blocks. 
19 lines changed or deleted 29 lines changed or added


 fn_prod.hpp   fn_prod.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 27 skipping to change at line 27
//! Delayed product of elements of a matrix along a specified dimension (ei ther rows or columns). //! Delayed product of elements of a matrix along a specified dimension (ei ther rows or columns).
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! For dim = 0, find the sum of each column (i.e. traverse across rows) //! For dim = 0, find the sum of each column (i.e. traverse across rows)
//! For dim = 1, find the sum of each row (i.e. traverse across columns) //! For dim = 1, find the sum of each row (i.e. traverse across columns)
//! The default is dim = 0. //! The default is dim = 0.
//! NOTE: this function works differently than in Matlab/Octave. //! NOTE: this function works differently than in Matlab/Octave.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_prod> const Op<T1, op_prod>
prod(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) prod
(
const Base<typename T1::elem_type,T1>& X,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_prod>(X.get_ref(), dim, 0); return Op<T1, op_prod>(X.get_ref(), dim, 0);
} }
//! \brief template<typename T1>
//! Immediate 'product of all values' operation for a row vector arma_inline
template<typename eT> const Op<T1, op_prod>
inline prod
arma_warn_unused (
eT const Base<typename T1::elem_type,T1>& X,
prod(const Row<eT>& X) const uword dim,
{ const typename enable_if<resolves_to_vector<T1>::value == true>::result*
arma_extra_debug_sigprint(); junk = 0
)
return arrayops::product(X.memptr(), X.n_elem);
}
//! \brief
//! Immediate 'product of all values' operation for a column vector
template<typename eT>
inline
arma_warn_unused
eT
prod(const Col<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
return arrayops::product(X.memptr(), X.n_elem); return Op<T1, op_prod>(X.get_ref(), dim, 0);
} }
//! \brief //! \brief
//! Immediate 'product of all values' operation, //! Immediate 'product of all values' operation,
//! invoked, for example, by: prod(prod(A)) //! invoked, for example, by: prod(prod(A))
template<typename T1> template<typename T1>
inline inline
typename T1::elem_type typename T1::elem_type
prod(const Op<T1, op_prod>& in) prod(const Op<T1, op_prod>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("prod(): two consecutive prod() calls detected"); arma_extra_debug_print("prod(): two consecutive prod() calls detected");
typedef typename T1::elem_type eT; return op_prod::prod( in.m );
const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M;
return arrayops::product( X.memptr(), X.n_elem );
} }
template<typename T1> template<typename T1>
inline inline
const Op<Op<T1, op_prod>, op_prod> const Op<Op<T1, op_prod>, op_prod>
prod(const Op<T1, op_prod>& in, const uword dim) prod(const Op<T1, op_prod>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<Op<T1, op_prod>, op_prod>(in, dim, 0); return Op<Op<T1, op_prod>, op_prod>(in, dim, 0);
} }
//! product of all values of a subview_row template<typename T1>
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
prod(const subview_row<eT>& S) prod
(
const Base<typename T1::elem_type,T1>& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
const Mat<eT>& X = S.m; return op_prod::prod( X.get_ref() );
const uword n_elem = S.n_elem;
const uword row = S.aux_row1;
const uword start_col = S.aux_col1;
const uword end_col_plus_1 = start_col + S.n_cols;
eT val = eT(1);
if(n_elem > 0)
{
for(uword col=start_col; col<end_col_plus_1; ++col)
{
val *= X.at(row,col);
}
}
return val;
} }
//! product of all values of a subview_col template<typename T1>
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
prod(const subview_col<eT>& S) prod
{ (
arma_extra_debug_sigprint(); const T1& X,
const arma_empty_class junk1 = arma_empty_class(),
return (S.n_elem > 0) ? arrayops::product( S.colptr(0), S.n_rows ) : eT(1 const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
); 0
} )
//! product of all values of a diagview
template<typename eT>
arma_warn_unused
inline
eT
prod(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
const uword X_n_elem = X.n_elem; return op_prod::prod(X);
eT val = eT(1);
for(uword i=0; i<X_n_elem; ++i)
{
val *= X[i];
}
return val;
} }
template<typename eT, typename T1> template<typename T>
inline arma_inline
arma_warn_unused arma_warn_unused
eT const typename arma_scalar_only<T>::result &
prod(const subview_elem1<eT,T1>& A) prod(const T& x)
{ {
arma_extra_debug_sigprint(); return x;
const Col<eT> X(A);
return prod(X);
} }
//! @} //! @}
 End of changes. 18 change blocks. 
88 lines changed or deleted 55 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 33 skipping to change at line 33
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(eop_aux_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::elem_type, 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::elem_type, gen_randn>(n_elem, 1); return Gen<vec, gen_randn>(n_elem, 1);
} }
template<typename vec_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename vec_type::elem_type, gen_randn> const Gen<obj_type, gen_randn>
randn(const uword n_elem, const arma_empty_class junk1 = arma_empty_class() randn(const uword n_elem, const arma_empty_class junk1 = arma_empty_class()
, const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) , const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<obj_type>::value == true)
{ {
return Gen<typename vec_type::elem_type, gen_randn>(1, n_elem); return Gen<obj_type, gen_randn>(1, n_elem);
} }
else else
{ {
return Gen<typename vec_type::elem_type, gen_randn>(n_elem, 1); return Gen<obj_type, gen_randn>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance) //! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance)
arma_inline arma_inline
const Gen<mat::elem_type, gen_randn> const Gen<mat, gen_randn>
randn(const uword n_rows, const uword n_cols) randn(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<mat::elem_type, gen_randn>(n_rows, n_cols); return Gen<mat, gen_randn>(n_rows, n_cols);
} }
template<typename mat_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename mat_type::elem_type, gen_randn> const Gen<obj_type, gen_randn>
randn(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R randn(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R
ow_only<mat_type>::result* junk = 0) ow_only<obj_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Gen<typename mat_type::elem_type, gen_randn>(n_rows, n_cols); if(is_Col<obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "randn(): incompatible size" );
}
else
if(is_Row<obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "randn(): incompatible size" );
}
return Gen<obj_type, gen_randn>(n_rows, n_cols);
} }
arma_inline arma_inline
const GenCube<cube::elem_type, gen_randn> const GenCube<cube::elem_type, gen_randn>
randn(const uword n_rows, const uword n_cols, const uword n_slices) randn(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return GenCube<cube::elem_type, gen_randn>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_randn>(n_rows, n_cols, n_slices);
} }
template<typename cube_type> template<typename cube_type>
arma_inline arma_inline
const GenCube<typename cube_type::elem_type, gen_randn> const GenCube<typename cube_type::elem_type, gen_randn>
randn(const uword n_rows, const uword n_cols, const uword n_slices, const t ypename arma_Cube_only<cube_type>::result* junk = 0) randn(const uword n_rows, const uword n_cols, const uword n_slices, const t ypename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return GenCube<typename cube_type::elem_type, gen_randn>(n_rows, n_cols, n_slices); return GenCube<typename cube_type::elem_type, gen_randn>(n_rows, n_cols, n_slices);
} }
//! @} //! @}
 End of changes. 14 change blocks. 
19 lines changed or deleted 28 lines changed or added


 fn_randu.hpp   fn_randu.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 33 skipping to change at line 33
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(eop_aux_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::elem_type, 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::elem_type, gen_randu>(n_elem, 1); return Gen<vec, gen_randu>(n_elem, 1);
} }
template<typename vec_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename vec_type::elem_type, gen_randu> const Gen<obj_type, gen_randu>
randu(const uword n_elem, const arma_empty_class junk1 = arma_empty_class() randu(const uword n_elem, const arma_empty_class junk1 = arma_empty_class()
, const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) , const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<obj_type>::value == true)
{ {
return Gen<typename vec_type::elem_type, gen_randu>(1, n_elem); return Gen<obj_type, gen_randu>(1, n_elem);
} }
else else
{ {
return Gen<typename vec_type::elem_type, gen_randu>(n_elem, 1); return Gen<obj_type, gen_randu>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to random values in the [ 0,1] interval (uniform distribution) //! Generate a dense matrix with all elements set to random values in the [ 0,1] interval (uniform distribution)
arma_inline arma_inline
const Gen<mat::elem_type, gen_randu> const Gen<mat, gen_randu>
randu(const uword n_rows, const uword n_cols) randu(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<mat::elem_type, gen_randu>(n_rows, n_cols); return Gen<mat, gen_randu>(n_rows, n_cols);
} }
template<typename mat_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename mat_type::elem_type, gen_randu> const Gen<obj_type, gen_randu>
randu(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R randu(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R
ow_only<mat_type>::result* junk = 0) ow_only<obj_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Gen<typename mat_type::elem_type, gen_randu>(n_rows, n_cols); if(is_Col<obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "randu(): incompatible size" );
}
else
if(is_Row<obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "randu(): incompatible size" );
}
return Gen<obj_type, gen_randu>(n_rows, n_cols);
} }
arma_inline arma_inline
const GenCube<cube::elem_type, gen_randu> const GenCube<cube::elem_type, gen_randu>
randu(const uword n_rows, const uword n_cols, const uword n_slices) randu(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return GenCube<cube::elem_type, gen_randu>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_randu>(n_rows, n_cols, n_slices);
} }
 End of changes. 13 change blocks. 
18 lines changed or deleted 28 lines changed or added


 fn_stddev.hpp   fn_stddev.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_stddev //! \addtogroup fn_stddev
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const mtOp<typename T1::pod_type, T1, op_stddev> const mtOp<typename T1::pod_type, T1, op_stddev>
stddev(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, stddev
const uword dim = 0) (
const Base<typename T1::elem_type,T1>& X,
const uword norm_type = 0,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type, dim); return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type, dim);
} }
//! Immediate 'find the standard deviation of a row vector' operation template<typename T1>
template<typename eT>
inline
arma_warn_unused
typename get_pod_type<eT>::result
stddev(const Row<eT>& A, const uword norm_type = 0)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element
s" );
return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) );
}
//! Immediate 'find the standard deviation of a column vector' operation
template<typename eT>
inline
arma_warn_unused
typename get_pod_type<eT>::result
stddev(const Col<eT>& A, const uword norm_type = 0)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "stddev(): given object has no element
s" );
return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) );
}
//! find the standard deviation of a subview_row
template<typename eT>
inline
arma_warn_unused
typename get_pod_type<eT>::result
stddev(const subview_row<eT>& A, const uword norm_type = 0)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element
s" );
return std::sqrt( op_var::direct_var(A, norm_type) );
}
//! find the standard deviation of a subview_col
template<typename eT>
inline inline
arma_warn_unused const mtOp<typename T1::pod_type, T1, op_stddev>
typename get_pod_type<eT>::result stddev
stddev(const subview_col<eT>& A, const uword norm_type = 0) (
const Base<typename T1::elem_type,T1>& X,
const uword norm_type,
const uword dim,
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type,
s" ); dim);
return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) );
} }
//! find the standard deviation of a diagview template<typename T1>
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename T1::pod_type
stddev(const diagview<eT>& A, const uword norm_type = 0) stddev
(
const Base<typename T1::elem_type,T1>& X,
const uword norm_type = 0,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_debug_check( (A.n_elem == 0), "stddev(): given object has no element return std::sqrt( op_var::var_vec(X.get_ref(), norm_type) );
s" );
return std::sqrt( op_var::direct_var(A, norm_type) );
} }
template<typename eT, typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename T1::pod_type
stddev(const subview_elem1<eT,T1>& A, const uword norm_type = 0) stddev
(
const T1& X,
const uword norm_type = 0,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
const Col<eT> X(A); return std::sqrt( op_var::var_vec(X, norm_type) );
return stddev(X, norm_type);
} }
//! @} //! @}
 End of changes. 15 change blocks. 
76 lines changed or deleted 53 lines changed or added


 fn_strans.hpp   fn_strans.hpp 
// Copyright (C) 2011 NICTA (www.nicta.com.au) // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Conrad Sanderson // Copyright (C) 2011-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_strans //! \addtogroup fn_strans
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_strans> const Op<T1, op_strans>
strans(const Base<typename T1::elem_type,T1>& X, const typename arma_cx_onl strans
y<typename T1::elem_type>::result* junk = 0) (
const Base<typename T1::elem_type,T1>& X,
const typename enable_if<is_basevec<T1>::value == false>::result* junk1 =
0,
const typename arma_cx_only<typename T1::elem_type>::result* junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_strans>(X.get_ref()); return Op<T1, op_strans>(X.get_ref());
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_htrans> const Op<T1, op_htrans>
strans(const Base<typename T1::elem_type,T1>& X, const typename arma_not_cx strans
<typename T1::elem_type>::result* junk = 0) (
const Base<typename T1::elem_type,T1>& X,
const typename enable_if<is_basevec<T1>::value == false>::result* junk1 =
0,
const typename arma_not_cx<typename T1::elem_type>::result* junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_htrans>(X.get_ref()); return Op<T1, op_htrans>(X.get_ref());
} }
template<typename T1>
arma_inline
const Op<T1, op_strans>
strans
(
const T1& X,
const typename enable_if<is_basevec<T1>::value == true>::result* junk1 =
0,
const typename arma_cx_only<typename T1::elem_type>::result* junk2 = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_strans>(X);
}
template<typename T1>
arma_inline
const Op<T1, op_htrans>
strans
(
const T1& X,
const typename enable_if<is_basevec<T1>::value == true>::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);
return Op<T1, op_htrans>(X);
}
//! two consecutive transpose operations cancel each other //! two consecutive transpose operations cancel each other
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
strans(const Op<T1, op_strans>& X) strans(const Op<T1, op_strans>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("strans(): removing op_strans"); arma_extra_debug_print("strans(): removing op_strans");
return X.m; return X.m;
 End of changes. 6 change blocks. 
8 lines changed or deleted 56 lines changed or added


 fn_sum.hpp   fn_sum.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 27 skipping to change at line 27
//! Delayed sum of elements of a matrix along a specified dimension (either rows or columns). //! Delayed sum of elements of a matrix along a specified dimension (either rows or columns).
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! For dim = 0, find the sum of each column. //! For dim = 0, find the sum of each column.
//! For dim = 1, find the sum of each row. //! For dim = 1, find the sum of each row.
//! The default is dim = 0. //! The default is dim = 0.
//! NOTE: this function works differently than in Matlab/Octave. //! NOTE: this function works differently than in Matlab/Octave.
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_sum> const Op<T1, op_sum>
sum(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) sum
(
const Base<typename T1::elem_type,T1>& X,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return Op<T1, op_sum>(X.get_ref(), dim, 0); return Op<T1, op_sum>(X.get_ref(), dim, 0);
} }
//! \brief template<typename T1>
//! Immediate 'sum all values' operation for a row vector arma_inline
template<typename eT> const Op<T1, op_sum>
inline sum
arma_warn_unused (
eT const Base<typename T1::elem_type,T1>& X,
sum(const Row<eT>& X) const uword dim,
{ const typename enable_if<resolves_to_vector<T1>::value == true>::result*
arma_extra_debug_sigprint(); junk = 0
)
return accu(X);
}
//! \brief
//! Immediate 'sum all values' operation for a column vector
template<typename eT>
inline
arma_warn_unused
eT
sum(const Col<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
return accu(X); return Op<T1, op_sum>(X.get_ref(), dim, 0);
} }
//! \brief //! \brief
//! Immediate 'sum all values' operation, //! Immediate 'sum all values' operation,
//! invoked, for example, by: sum(sum(A)) //! invoked, for example, by: sum(sum(A))
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
skipping to change at line 86 skipping to change at line 84
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<Op<T1, op_sum>, op_sum> const Op<Op<T1, op_sum>, op_sum>
sum(const Op<T1, op_sum>& in, const uword dim) sum(const Op<T1, op_sum>& in, const uword dim)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<Op<T1, op_sum>, op_sum>(in, dim, 0); return Op<Op<T1, op_sum>, op_sum>(in, dim, 0);
} }
//! sum all values of a subview_row //! \brief
template<typename eT> //! Immediate 'sum all values' operation for expressions which resolve to a
inline vector
arma_warn_unused template<typename T1>
eT
sum(const subview_row<eT>& X)
{
arma_extra_debug_sigprint();
return accu(X);
}
//! sum all values of a subview_col
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
sum(const subview_col<eT>& X) sum
(
const Base<typename T1::elem_type,T1>& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return accu(X); return accu(X.get_ref());
} }
//! sum all values of a diagview template<typename T1>
template<typename eT>
inline inline
arma_warn_unused arma_warn_unused
eT typename T1::elem_type
sum(const diagview<eT>& X) sum
(
const T1& X,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return accu(X); return accu(X);
} }
template<typename eT, typename T1> template<typename T>
inline arma_inline
arma_warn_unused arma_warn_unused
eT const typename arma_scalar_only<T>::result &
sum(const subview_elem1<eT,T1>& A) sum(const T& x)
{ {
arma_extra_debug_sigprint(); return x;
return accu(A);
} }
//! @} //! @}
 End of changes. 16 change blocks. 
52 lines changed or deleted 56 lines changed or added


 fn_trans.hpp   fn_trans.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_trans //! \addtogroup fn_trans
//! @{ //! @{
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_htrans> const Op<T1, op_htrans>
trans(const Base<typename T1::elem_type,T1>& X) trans
(
const Base<typename T1::elem_type,T1>& X,
const typename enable_if<is_basevec<T1>::value == false>::result* junk =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
return Op<T1, op_htrans>(X.get_ref()); return Op<T1, op_htrans>(X.get_ref());
} }
//! two consecutive transpose operations cancel each other
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& arma_warn_unused
trans(const Op<T1, op_htrans>& X) const Op<T1, op_htrans>
trans
(
const T1& X,
const typename enable_if<is_basevec<T1>::value == true>::result* junk = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("trans(): removing op_htrans"); arma_ignore(junk);
return X.m; return Op<T1, op_htrans>(X);
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_htrans> const Op<T1, op_htrans>
htrans(const Base<typename T1::elem_type,T1>& X) htrans
(
const Base<typename T1::elem_type,T1>& X,
const typename enable_if<is_basevec<T1>::value == false>::result* junk =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
return Op<T1, op_htrans>(X.get_ref()); return Op<T1, op_htrans>(X.get_ref());
} }
//! two consecutive hermitian transpose operations cancel each other template<typename T1>
arma_inline
arma_warn_unused
const Op<T1, op_htrans>
htrans
(
const T1& X,
const typename enable_if<is_basevec<T1>::value == true>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
return Op<T1, op_htrans>(X);
}
//! two consecutive transpose operations cancel each other
template<typename T1>
arma_inline
const T1&
trans(const Op<T1, op_htrans>& X)
{
arma_extra_debug_sigprint();
arma_extra_debug_print("trans(): removing op_htrans");
return X.m;
}
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
htrans(const Op<T1, op_htrans>& X) htrans(const Op<T1, op_htrans>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_extra_debug_print("htrans(): removing op_htrans"); arma_extra_debug_print("htrans(): removing op_htrans");
return X.m; return X.m;
} }
 End of changes. 10 change blocks. 
10 lines changed or deleted 53 lines changed or added


 fn_var.hpp   fn_var.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_var //! \addtogroup fn_var
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const mtOp<typename T1::pod_type, T1, op_var> const mtOp<typename T1::pod_type, T1, op_var>
var(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, co var
nst uword dim = 0) (
const Base<typename T1::elem_type,T1>& X,
const uword norm_type = 0,
const uword dim = 0,
const typename enable_if<resolves_to_vector<T1>::value == false>::result*
junk1 = 0,
const typename enable_if<is_basevec<T1>::value == false>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
return mtOp<typename T1::pod_type, T1, op_var>(X.get_ref(), norm_type, di m); return mtOp<typename T1::pod_type, T1, op_var>(X.get_ref(), norm_type, di m);
} }
//! Immediate 'find the variance of a row vector' operation template<typename T1>
template<typename eT>
inline
arma_warn_unused
typename get_pod_type<eT>::result
var(const Row<eT>& A, const uword norm_type = 0)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "var(): given object has no elements"
);
return op_var::direct_var(A.mem, A_n_elem, norm_type);
}
//! Immediate 'find the variance of a column vector' operation
template<typename eT>
inline
arma_warn_unused
typename get_pod_type<eT>::result
var(const Col<eT>& A, const uword norm_type = 0)
{
arma_extra_debug_sigprint();
const uword A_n_elem = A.n_elem;
arma_debug_check( (A_n_elem == 0), "var(): given object has no elements"
);
return op_var::direct_var(A.mem, A_n_elem, norm_type);
}
template<typename eT>
inline
arma_warn_unused
typename get_pod_type<eT>::result
var(const subview_row<eT>& A, const uword norm_type = 0)
{
arma_extra_debug_sigprint();
arma_debug_check( (A.n_elem == 0), "var(): given object has no elements"
);
return op_var::direct_var(A, norm_type);
}
template<typename eT>
inline inline
arma_warn_unused const mtOp<typename T1::pod_type, T1, op_var>
typename get_pod_type<eT>::result var
var(const subview_col<eT>& A, const uword norm_type = 0) (
const Base<typename T1::elem_type,T1>& X,
const uword norm_type,
const uword dim,
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk);
arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" return mtOp<typename T1::pod_type, T1, op_var>(X.get_ref(), norm_type, di
); m);
return op_var::direct_var(A.colptr(0), A.n_rows, norm_type);
} }
template<typename eT> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename T1::pod_type
var(const diagview<eT>& A, const uword norm_type = 0) var
(
const Base<typename T1::elem_type,T1>& X,
const uword norm_type = 0,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<resolves_to_vector<T1>::value == true>::result*
junk2 = 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" return op_var::var_vec( X.get_ref(), norm_type );
);
return op_var::direct_var(A, norm_type);
} }
template<typename eT, typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename get_pod_type<eT>::result typename T1::pod_type
var(const subview_elem1<eT,T1>& A, const uword norm_type = 0) var
(
const T1& X,
const uword norm_type = 0,
const arma_empty_class junk1 = arma_empty_class(),
const typename enable_if<is_basevec<T1>::value == true>::result* junk2 =
0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
const Col<eT> X(A); return op_var::var_vec( X, norm_type );
return var(X, norm_type);
} }
//! @} //! @}
 End of changes. 15 change blocks. 
73 lines changed or deleted 53 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_zeros //! \addtogroup fn_zeros
//! @{ //! @{
//! Generate a vector with all elements set to zero //! Generate a vector with all elements set to zero
arma_inline arma_inline
const Gen<vec::elem_type, gen_zeros> const Gen<vec, gen_zeros>
zeros(const uword n_elem) zeros(const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<vec::elem_type, gen_zeros>(n_elem, 1); return Gen<vec, gen_zeros>(n_elem, 1);
} }
template<typename vec_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename vec_type::elem_type, gen_zeros> const Gen<obj_type, gen_zeros>
zeros(const uword n_elem, const arma_empty_class junk1 = arma_empty_class() zeros(const uword n_elem, const arma_empty_class junk1 = arma_empty_class()
, const typename arma_Mat_Col_Row_only<vec_type>::result* junk2 = 0) , const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk1); arma_ignore(junk1);
arma_ignore(junk2); arma_ignore(junk2);
if(is_Row<vec_type>::value == true) if(is_Row<obj_type>::value == true)
{ {
return Gen<typename vec_type::elem_type, gen_zeros>(1, n_elem); return Gen<obj_type, gen_zeros>(1, n_elem);
} }
else else
{ {
return Gen<typename vec_type::elem_type, gen_zeros>(n_elem, 1); return Gen<obj_type, gen_zeros>(n_elem, 1);
} }
} }
//! Generate a dense matrix with all elements set to zero //! Generate a dense matrix with all elements set to zero
arma_inline arma_inline
const Gen<mat::elem_type, gen_zeros> const Gen<mat, gen_zeros>
zeros(const uword n_rows, const uword n_cols) zeros(const uword n_rows, const uword n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Gen<mat::elem_type, gen_zeros>(n_rows, n_cols); return Gen<mat, gen_zeros>(n_rows, n_cols);
} }
template<typename mat_type> template<typename obj_type>
arma_inline arma_inline
const Gen<typename mat_type::elem_type, gen_zeros> const Gen<obj_type, gen_zeros>
zeros(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R zeros(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_R
ow_only<mat_type>::result* junk = 0) ow_only<obj_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return Gen<typename mat_type::elem_type, gen_zeros>(n_rows, n_cols); if(is_Col<obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "zeros(): incompatible size" );
}
else
if(is_Row<obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "zeros(): incompatible size" );
}
return Gen<obj_type, gen_zeros>(n_rows, n_cols);
} }
arma_inline arma_inline
const GenCube<cube::elem_type, gen_zeros> const GenCube<cube::elem_type, gen_zeros>
zeros(const uword n_rows, const uword n_cols, const uword n_slices) zeros(const uword n_rows, const uword n_cols, const uword n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return GenCube<cube::elem_type, gen_zeros>(n_rows, n_cols, n_slices); return GenCube<cube::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
} }
 End of changes. 13 change blocks. 
18 lines changed or deleted 28 lines changed or added


 forward_bones.hpp   forward_bones.hpp 
skipping to change at line 44 skipping to change at line 44
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_inv; class op_inv;
class op_sum; class op_sum;
class op_abs; class op_abs;
class op_diagmat; class op_diagmat;
class op_trimat; class op_trimat;
class eop_conj; class eop_conj;
class glue_times; class glue_times;
class glue_times_diag; class glue_times_diag;
skipping to change at line 79 skipping to change at line 80
class op_rel_gteq_post; class op_rel_gteq_post;
class op_rel_eq; class op_rel_eq;
class op_rel_noteq; class op_rel_noteq;
class gen_ones_diag; class gen_ones_diag;
class gen_ones_full; class gen_ones_full;
class gen_zeros; class gen_zeros;
class gen_randu; class gen_randu;
class gen_randn; class gen_randn;
class glue_mixed_plus;
class glue_mixed_minus;
class glue_mixed_div;
class glue_mixed_schur;
class glue_mixed_times;
class op_cx_scalar_times;
class op_cx_scalar_plus;
class op_cx_scalar_minus_pre;
class op_cx_scalar_minus_post;
class op_cx_scalar_div_pre;
class op_cx_scalar_div_post;
class op_subview_elem_equ;
class op_subview_elem_inplace_plus;
class op_subview_elem_inplace_minus;
class op_subview_elem_inplace_schur;
class op_subview_elem_inplace_div;
template<const bool, const bool, const bool, const bool> class gemm; template<const bool, const bool, const bool, const bool> class gemm;
template<const bool, const bool, const bool> class gemv; template<const bool, const bool, const bool> class gemv;
template< typename eT, typename gen_type> class Gen; template< typename eT, typename gen_type> class Gen;
template< typename T1, typename op_type> class Op; template< typename T1, typename op_type> class Op;
template< typename T1, typename eop_type> class eOp; template< typename T1, typename eop_type> class eOp;
template<typename out_eT, typename T1, typename op_type> class mtOp; template<typename out_eT, typename T1, typename op_type> class mtOp;
template< typename T1, typename T2, typename glue_type> cl ass Glue; template< typename T1, typename T2, typename glue_type> cl ass Glue;
skipping to change at line 105 skipping to change at line 125
template< typename T1, typename eop_type> class eOpCube; template< typename T1, typename eop_type> class eOpCube;
template<typename out_eT, typename T1, typename op_type> class mtOpCube; template<typename out_eT, typename T1, typename op_type> class mtOpCube;
template< typename T1, typename T2, typename glue_type> cl ass GlueCube; template< typename T1, typename T2, typename glue_type> cl ass GlueCube;
template< typename T1, typename T2, typename eglue_type> cl ass eGlueCube; template< typename T1, typename T2, typename eglue_type> cl ass eGlueCube;
template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlueCube; template<typename out_eT, typename T1, typename T2, typename glue_type> cl ass mtGlueCube;
template<typename T1> class Proxy; template<typename T1> class Proxy;
template<typename T1> class ProxyCube; template<typename T1> class ProxyCube;
struct arma_vec_indicator {};
//! \addtogroup injector //! \addtogroup injector
//! @{ //! @{
struct injector_end_of_row {}; template<typename Dummy = int> struct injector_end_of_row {};
static const injector_end_of_row endr = injector_end_of_row(); static const injector_end_of_row<> endr = injector_end_of_row<>();
//!< endr indicates "end of row" when using the << operator; //!< endr indicates "end of row" when using the << operator;
//!< similar conceptual meaning to std::endl //!< similar conceptual meaning to std::endl
//! @} //! @}
//! \addtogroup diskio //! \addtogroup diskio
//! @{ //! @{
enum file_type enum file_type
{ {
 End of changes. 5 change blocks. 
2 lines changed or deleted 24 lines changed or added


 gemv.hpp   gemv.hpp 
skipping to change at line 282 skipping to change at line 282
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
apply( eT* y, const Mat<eT>& A, const eT* x, const eT alpha = eT(1), cons t eT beta = eT(0), 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);
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_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;
 End of changes. 1 change blocks. 
1 lines changed or deleted 0 lines changed or added


 glue_mixed_meat.hpp   glue_mixed_meat.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 81 skipping to change at line 81
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "addition"); arma_debug_assert_same_size(A, B, "addition");
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
out.set_size(n_rows, n_cols);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(uword i=0; i<n_elem; ++i) const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
2>::prefer_at_accessor);
if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: typename Proxy<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename Proxy<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) + upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col)) + upgrade_val
<eT1,eT2>::apply(B.at(row,col));
++i;
}
} }
} }
//! matrix subtraction with different element types //! matrix subtraction with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_minus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X) glue_mixed_minus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_minus>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 112 skipping to change at line 134
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "subtraction"); arma_debug_assert_same_size(A, B, "subtraction");
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
out.set_size(n_rows, n_cols);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(uword i=0; i<n_elem; ++i) const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
2>::prefer_at_accessor);
if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: typename Proxy<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename Proxy<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) - upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col)) - upgrade_val
<eT1,eT2>::apply(B.at(row,col));
++i;
}
} }
} }
//! element-wise matrix division with different element types //! element-wise matrix division with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_div::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtGl ue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X) glue_mixed_div::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtGl ue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 143 skipping to change at line 187
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise division"); arma_debug_assert_same_size(A, B, "element-wise division");
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
out.set_size(n_rows, n_cols);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(uword i=0; i<n_elem; ++i) const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
2>::prefer_at_accessor);
if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: typename Proxy<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename Proxy<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) / upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col)) / upgrade_val
<eT1,eT2>::apply(B.at(row,col));
++i;
}
} }
} }
//! element-wise matrix multiplication with different element types //! element-wise matrix multiplication with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_mixed_schur::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X) glue_mixed_schur::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mt Glue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 174 skipping to change at line 240
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
const Proxy<T1> A(X.A); const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B); const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise multiplication"); arma_debug_assert_same_size(A, B, "element-wise multiplication");
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
out.set_size(n_rows, n_cols);
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
for(uword i=0; i<n_elem; ++i) const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T
2>::prefer_at_accessor);
if(prefer_at_accessor == false)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: typename Proxy<T1>::ea_type AA = A.get_ea();
apply(B[i]); typename Proxy<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) * upgrade_val<eT1,eT2
>::apply(BB[i]);
}
}
else
{
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col)) * upgrade_val
<eT1,eT2>::apply(B.at(row,col));
++i;
}
} }
} }
// //
// //
// //
//! cube addition with different element types //! cube addition with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
skipping to change at line 214 skipping to change at line 302
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "addition"); arma_debug_assert_same_size(A, B, "addition");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! cube subtraction with different element types //! cube subtraction with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
skipping to change at line 245 skipping to change at line 335
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "subtraction"); arma_debug_assert_same_size(A, B, "subtraction");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! element-wise cube division with different element types //! element-wise cube division with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
skipping to change at line 276 skipping to change at line 368
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise division"); arma_debug_assert_same_size(A, B, "element-wise division");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! element-wise cube multiplication with different element types //! element-wise cube multiplication with different element types
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
skipping to change at line 307 skipping to change at line 401
const ProxyCube<T1> A(X.A); const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B); const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise multiplication"); arma_debug_assert_same_size(A, B, "element-wise multiplication");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices()); out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr(); out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem; const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: apply(B[i]); out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>:: apply(B[i]);
} }
} }
//! @} //! @}
 End of changes. 21 change blocks. 
22 lines changed or deleted 126 lines changed or added


 glue_relational_meat.hpp   glue_relational_meat.hpp 
skipping to change at line 57 skipping to change at line 57
\ \
const uword n_elem = out.n_elem;\ const uword n_elem = out.n_elem;\
\ \
for(uword i=0; i<n_elem; ++i)\ for(uword i=0; i<n_elem; ++i)\
{\ {\
out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\ out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
}\ }\
}\ }\
else\ else\
{\ {\
uword count = 0;\ if(n_rows == 1)\
\ {\
for(uword col=0; col<n_cols; ++col)\ for(uword count=0; count < n_cols; ++count)\
for(uword row=0; row<n_rows; ++row, ++count)\ {\
out_mem[count] = (P1.at(0,count) operator_rel P2.at(0,count)) ? u
word(1) : uword(0);\
}\
}\
else\
{\ {\
out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? uwo uword count = 0;\
rd(1) : uword(0);\ \
for(uword col=0; col<n_cols; ++col)\
for(uword row=0; row<n_rows; ++row, ++count)\
{\
out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? u
word(1) : uword(0);\
}\
}\ }\
}\ }\
}\ }\
else\ else\
{\ {\
const unwrap<typename Proxy<T1>::stored_type> tmp1(P1.Q);\ const unwrap<typename Proxy<T1>::stored_type> tmp1(P1.Q);\
const unwrap<typename Proxy<T2>::stored_type> tmp2(P2.Q);\ const unwrap<typename Proxy<T2>::stored_type> tmp2(P2.Q);\
\ \
out = (tmp1.M) operator_rel (tmp2.M);\ out = (tmp1.M) operator_rel (tmp2.M);\
}\ }\
 End of changes. 2 change blocks. 
6 lines changed or deleted 17 lines changed or added


 glue_times_bones.hpp   glue_times_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 37 skipping to change at line 37
template<typename glue_type, typename T1, typename T2> template<typename glue_type, typename T1, typename T2>
struct depth_lhs< glue_type, Glue<T1,T2,glue_type> > struct depth_lhs< glue_type, Glue<T1,T2,glue_type> >
{ {
static const uword num = 1 + depth_lhs<glue_type, T1>::num; static const uword num = 1 + depth_lhs<glue_type, T1>::num;
}; };
template<uword N> template<uword N>
struct glue_times_redirect struct glue_times_redirect
{ {
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
}; };
template<> template<>
struct glue_times_redirect<3> struct glue_times_redirect<3>
{ {
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl ue<T1,T2,glue_times>,T3,glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
}; };
template<> template<>
struct glue_times_redirect<4> struct glue_times_redirect<4>
{ {
template<typename T1, typename T2, typename T3, typename T4> template<typename T1, typename T2, typename T3, typename T4>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl ue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X);
}; };
//! Class which implements the immediate multiplication of two or more matr ices //! Class which implements the immediate multiplication of two or more matr ices
class glue_times class glue_times
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2,glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
template<typename T1> template<typename T1>
inline static void apply_inplace(Mat<typename T1::elem_type>& out, const T1& X); arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& ou t, const T1& X);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type >& out, const Glue<T1, T2, glue_times>& X, const sword sign); arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type >& out, const Glue<T1, T2, glue_times>& X, const sword sign);
template<typename eT1, typename eT2> template<typename eT1, typename eT2>
inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result >& out, const Mat<eT1>& X, const Mat<eT2>& Y); inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result >& out, const Mat<eT1>& X, const Mat<eT2>& Y);
template<typename eT> template<typename eT, const bool do_trans_A, const bool do_trans_B>
arma_inline static uword mul_storage_cost(const Mat<eT>& A, const Mat<eT arma_inline static uword mul_storage_cost(const Mat<eT>& A, const Mat<eT
>& B, const bool do_trans_A, const bool do_trans_B); >& B);
template<typename eT> template<typename eT, const bool do_trans_A, const bool do_trans_B, const
arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M bool do_scalar_times>
at<eT>& B, const eT val, const bool do_trans_A, const bool do_trans_B, cons arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M
t bool do_scalar_times); at<eT>& B, const eT val);
template<typename eT> template<typename eT, const bool do_trans_A, const bool do_trans_B, const
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B bool do_trans_C, const bool do_scalar_times>
, const Mat<eT>& C, const eT val, const bool do_trans_A, const bool do_tran arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M
s_B, const bool do_trans_C, const bool do_scalar_times); at<eT>& B, const Mat<eT>& C, const eT val);
template<typename eT> template<typename eT, const bool do_trans_A, const bool do_trans_B, const
inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B bool do_trans_C, const bool do_trans_D, const bool do_scalar_times>
, const Mat<eT>& C, const Mat<eT>& D, const eT val, const bool do_trans_A, arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const M
const bool do_trans_B, const bool do_trans_C, const bool do_trans_D, const at<eT>& B, const Mat<eT>& C, const Mat<eT>& D, const eT val);
bool do_scalar_times);
}; };
class glue_times_diag class glue_times_diag
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times_diag>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times_diag>& X);
 End of changes. 10 change blocks. 
23 lines changed or deleted 22 lines changed or added


 glue_times_meat.hpp   glue_times_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup glue_times //! \addtogroup glue_times
//! @{ //! @{
template<uword N> template<uword N>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot
inline inline
void void
glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue< T1,T2,glue_times>& X) glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue< T1,T2,glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const partial_unwrap_check<T1> tmp1(X.A, out); const partial_unwrap_check<T1> tmp1(X.A, out);
const partial_unwrap_check<T2> tmp2(X.B, out); const partial_unwrap_check<T2> tmp2(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const bool do_trans_A = tmp1.do_trans; const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
const bool do_trans_B = tmp2.do_trans; ap_check<T2>::do_times;
const bool use_alpha = tmp1.do_times || tmp2.do_times;
const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) : eT (0); const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val()) : eT (0);
glue_times::apply(out, A, B, alpha, do_trans_A, do_trans_B, use_alpha); glue_times::apply
<
eT,
partial_unwrap_check<T1>::do_trans,
partial_unwrap_check<T2>::do_trans,
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim
es)
>
(out, A, B, alpha);
} }
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
arma_hot
inline inline
void void
glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// there is exactly 3 objects // there is exactly 3 objects
// hence we can safely expand X as X.A.A, X.A.B and X.B // hence we can safely expand X as X.A.A, X.A.B and X.B
const partial_unwrap_check<T1> tmp1(X.A.A, out); const partial_unwrap_check<T1> tmp1(X.A.A, out);
const partial_unwrap_check<T2> tmp2(X.A.B, out); const partial_unwrap_check<T2> tmp2(X.A.B, out);
const partial_unwrap_check<T3> tmp3(X.B, out); const partial_unwrap_check<T3> tmp3(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
const bool do_trans_A = tmp1.do_trans; const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
const bool do_trans_B = tmp2.do_trans; ap_check<T2>::do_times || partial_unwrap_check<T3>::do_times;
const bool do_trans_C = tmp3.do_trans;
const bool use_alpha = tmp1.do_times || tmp2.do_times || tmp3.do_times;
const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp 3.get_val()) : eT(0); const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp 3.get_val()) : eT(0);
glue_times::apply(out, A, B, C, alpha, do_trans_A, do_trans_B, do_trans_C glue_times::apply
, use_alpha); <
eT,
partial_unwrap_check<T1>::do_trans,
partial_unwrap_check<T2>::do_trans,
partial_unwrap_check<T3>::do_trans,
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim
es || partial_unwrap_check<T3>::do_times)
>
(out, A, B, C, alpha);
} }
template<typename T1, typename T2, typename T3, typename T4> template<typename T1, typename T2, typename T3, typename T4>
arma_hot
inline inline
void void
glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X) glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// there is exactly 4 objects // there is exactly 4 objects
// hence we can safely expand X as X.A.A.A, X.A.A.B, X.A.B and X.B // hence we can safely expand X as X.A.A.A, X.A.A.B, X.A.B and X.B
skipping to change at line 93 skipping to change at line 104
const partial_unwrap_check<T1> tmp1(X.A.A.A, out); const partial_unwrap_check<T1> tmp1(X.A.A.A, out);
const partial_unwrap_check<T2> tmp2(X.A.A.B, out); const partial_unwrap_check<T2> tmp2(X.A.A.B, out);
const partial_unwrap_check<T3> tmp3(X.A.B, out); const partial_unwrap_check<T3> tmp3(X.A.B, out);
const partial_unwrap_check<T4> tmp4(X.B, out); const partial_unwrap_check<T4> tmp4(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const Mat<eT>& C = tmp3.M; const Mat<eT>& C = tmp3.M;
const Mat<eT>& D = tmp4.M; const Mat<eT>& D = tmp4.M;
const bool do_trans_A = tmp1.do_trans; const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
const bool do_trans_B = tmp2.do_trans; ap_check<T2>::do_times || partial_unwrap_check<T3>::do_times || partial_unw
const bool do_trans_C = tmp3.do_trans; rap_check<T4>::do_times;
const bool do_trans_D = tmp4.do_trans;
const bool use_alpha = tmp1.do_times || tmp2.do_times || tmp3.do_times ||
tmp4.do_times;
const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp 3.get_val() * tmp4.get_val()) : eT(0); const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp 3.get_val() * tmp4.get_val()) : eT(0);
glue_times::apply(out, A, B, C, D, alpha, do_trans_A, do_trans_B, do_tran glue_times::apply
s_C, do_trans_D, use_alpha); <
eT,
partial_unwrap_check<T1>::do_trans,
partial_unwrap_check<T2>::do_trans,
partial_unwrap_check<T3>::do_trans,
partial_unwrap_check<T4>::do_trans,
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim
es || partial_unwrap_check<T3>::do_times || partial_unwrap_check<T4>::do_ti
mes)
>
(out, A, B, C, D, alpha);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot
inline inline
void void
glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t imes>& X) glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t imes>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const sword N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >:: num; const sword N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >:: num;
arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat); arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat);
glue_times_redirect<N_mat>::apply(out, X); glue_times_redirect<N_mat>::apply(out, X);
} }
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X) glue_times::apply_inplace(Mat<typename T1::elem_type>& out, const T1& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(X, out); const unwrap_check<T1> tmp(X, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
skipping to change at line 159 skipping to change at line 176
for(uword col=0; col < out_n_cols; ++col) for(uword col=0; col < out_n_cols; ++col)
{ {
out.at(row,col) = op_dot::direct_dot( out_n_cols, tmp_rowdata, B.co lptr(col) ); out.at(row,col) = op_dot::direct_dot( out_n_cols, tmp_rowdata, B.co lptr(col) );
} }
} }
} }
else else
{ {
const Mat<eT> tmp(out); const Mat<eT> tmp(out);
glue_times::apply(out, tmp, B, eT(1), false, false, false);
glue_times::apply<eT, false, false, false>(out, tmp, B, eT(1));
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
glue_times::apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue <T1, T2, glue_times>& X, const sword sign) glue_times::apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue <T1, T2, glue_times>& X, const sword sign)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const partial_unwrap_check<T1> tmp1(X.A, out); const partial_unwrap_check<T1> tmp1(X.A, out);
const partial_unwrap_check<T2> tmp2(X.B, out); const partial_unwrap_check<T2> tmp2(X.B, out);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
const eT alpha = tmp1.get_val() * tmp2.get_val() * ( (sign > sword( 0)) ? eT(1) : eT(-1) );
const bool do_trans_A = tmp1.do_trans; const bool do_trans_A = partial_unwrap_check<T1>::do_trans;
const bool do_trans_B = tmp2.do_trans; const bool do_trans_B = partial_unwrap_check<T2>::do_trans;
const bool use_alpha = tmp1.do_times || tmp2.do_times || (sign < sword(0
)); const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || (sign < sword(0));
const eT alpha = use_alpha ? ( tmp1.get_val() * tmp2.get_val() * (
(sign > sword(0)) ? eT(1) : eT(-1) ) ) : eT(0);
arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli cation"); arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli cation");
const uword result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const uword result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const uword result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "addition"); arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col s, "addition");
if(out.n_elem > 0) if(out.n_elem > 0)
{ {
skipping to change at line 333 skipping to change at line 352
} }
else else
{ {
gemm<true, true, true, true>::apply(out, A, B, alpha, eT(1)); gemm<true, true, true, true>::apply(out, A, B, alpha, eT(1));
} }
} }
} }
} }
template<typename eT> template<typename eT, const bool do_trans_A, const bool do_trans_B>
arma_inline arma_inline
uword uword
glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, const bool do_trans_A, const bool do_trans_B) glue_times::mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B)
{ {
const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
return final_A_n_rows * final_B_n_cols; return final_A_n_rows * final_B_n_cols;
} }
template<typename eT> template
<
typename eT,
const bool do_trans_A,
const bool do_trans_B,
const bool use_alpha
>
arma_hot arma_hot
inline inline
void void
glue_times::apply glue_times::apply
( (
Mat<eT>& out, Mat<eT>& out,
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& B,
const eT alpha, const eT alpha
const bool do_trans_A,
const bool do_trans_B,
const bool use_alpha
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli cation"); arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli cation");
const uword final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; const uword final_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
const uword final_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; const uword final_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
out.set_size(final_n_rows, final_n_cols); out.set_size(final_n_rows, final_n_cols);
skipping to change at line 512 skipping to change at line 534
gemm<true, true, true, false>::apply(out, A, B, alpha); gemm<true, true, true, false>::apply(out, A, B, alpha);
} }
} }
} }
else else
{ {
out.zeros(); out.zeros();
} }
} }
template<typename eT> template
<
typename eT,
const bool do_trans_A,
const bool do_trans_B,
const bool do_trans_C,
const bool use_alpha
>
arma_hot
inline inline
void void
glue_times::apply glue_times::apply
( (
Mat<eT>& out, Mat<eT>& out,
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& B,
const Mat<eT>& C, const Mat<eT>& C,
const eT alpha, const eT alpha
const bool do_trans_A,
const bool do_trans_B,
const bool do_trans_C,
const bool use_alpha
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
if( glue_times::mul_storage_cost(A, B, do_trans_A, do_trans_B) <= glue_ti mes::mul_storage_cost(B, C, do_trans_B, do_trans_C) ) if( glue_times::mul_storage_cost<eT, do_trans_A, do_trans_B>(A, B) <= glu e_times::mul_storage_cost<eT, do_trans_B, do_trans_C>(B, C) )
{ {
// out = (A*B)*C // out = (A*B)*C
glue_times::apply(tmp, A, B, alpha, do_trans_A, do_trans_B, use_alpha
); glue_times::apply<eT, do_trans_A, do_trans_B, use_alpha>(tmp, A, B, a
glue_times::apply(out, tmp, C, eT(0), false, do_trans_C, false lpha);
); glue_times::apply<eT, false, do_trans_C, false >(out, tmp, C, e
T(0));
} }
else else
{ {
// out = A*(B*C) // out = A*(B*C)
glue_times::apply(tmp, B, C, alpha, do_trans_B, do_trans_C, use_alpha
); glue_times::apply<eT, do_trans_B, do_trans_C, use_alpha>(tmp, B, C, a
glue_times::apply(out, A, tmp, eT(0), do_trans_A, false, false lpha);
); glue_times::apply<eT, do_trans_A, false, false >(out, A, tmp, e
T(0));
} }
} }
template<typename eT> template
<
typename eT,
const bool do_trans_A,
const bool do_trans_B,
const bool do_trans_C,
const bool do_trans_D,
const bool use_alpha
>
arma_hot
inline inline
void void
glue_times::apply glue_times::apply
( (
Mat<eT>& out, Mat<eT>& out,
const Mat<eT>& A, const Mat<eT>& A,
const Mat<eT>& B, const Mat<eT>& B,
const Mat<eT>& C, const Mat<eT>& C,
const Mat<eT>& D, const Mat<eT>& D,
const eT alpha, const eT alpha
const bool do_trans_A,
const bool do_trans_B,
const bool do_trans_C,
const bool do_trans_D,
const bool use_alpha
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
if( glue_times::mul_storage_cost(A, C, do_trans_A, do_trans_C) <= glue_ti mes::mul_storage_cost(B, D, do_trans_B, do_trans_D) ) if( glue_times::mul_storage_cost<eT, do_trans_A, do_trans_C>(A, C) <= glu e_times::mul_storage_cost<eT, do_trans_B, do_trans_D>(B, D) )
{ {
// out = (A*B*C)*D // out = (A*B*C)*D
glue_times::apply(tmp, A, B, C, alpha, do_trans_A, do_trans_B, do_trans _C, use_alpha);
glue_times::apply(out, tmp, D, eT(0), false, do_trans_D, false); glue_times::apply<eT, do_trans_A, do_trans_B, do_trans_C, use_alpha>(tm
p, A, B, C, alpha);
glue_times::apply<eT, false, do_trans_D, false>(out, tmp, D, eT(0));
} }
else else
{ {
// out = A*(B*C*D) // out = A*(B*C*D)
glue_times::apply(tmp, B, C, D, alpha, do_trans_B, do_trans_C, do_trans _D, use_alpha);
glue_times::apply(out, A, tmp, eT(0), do_trans_A, false, false); glue_times::apply<eT, do_trans_B, do_trans_C, do_trans_D, use_alpha>(tm
p, B, C, D, alpha);
glue_times::apply<eT, do_trans_A, false, false>(out, A, tmp, eT(0));
} }
} }
// //
// glue_times_diag // glue_times_diag
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
skipping to change at line 603 skipping to change at line 637
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const strip_diagmat<T1> S1(X.A); const strip_diagmat<T1> S1(X.A);
const strip_diagmat<T2> S2(X.B); const strip_diagmat<T2> S2(X.B);
typedef typename strip_diagmat<T1>::stored_type T1_stripped; typedef typename strip_diagmat<T1>::stored_type T1_stripped;
typedef typename strip_diagmat<T2>::stored_type T2_stripped; typedef typename strip_diagmat<T2>::stored_type T2_stripped;
if( (S1.do_diagmat == true) && (S2.do_diagmat == false) ) if( (strip_diagmat<T1>::do_diagmat == true) && (strip_diagmat<T2>::do_dia gmat == false) )
{ {
const diagmat_proxy_check<T1_stripped> A(S1.M, out); const diagmat_proxy_check<T1_stripped> A(S1.M, out);
const unwrap_check<T2> tmp(X.B, out); const unwrap_check<T2> tmp(X.B, out);
const Mat<eT>& B = tmp.M; const Mat<eT>& B = tmp.M;
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_rows, B.n_cols, "mat const uword A_n_elem = A.n_elem;
rix multiplication"); const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols;
out.set_size(A.n_elem, B.n_cols); arma_debug_assert_mul_size(A_n_elem, A_n_elem, B_n_rows, B_n_cols, "mat rix multiplication");
for(uword col=0; col<B.n_cols; ++col) out.set_size(A_n_elem, B_n_cols);
for(uword col=0; col < B_n_cols; ++col)
{ {
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
const eT* B_coldata = B.colptr(col); const eT* B_coldata = B.colptr(col);
for(uword row=0; row<B.n_rows; ++row) uword i,j;
for(i=0, j=1; j < B_n_rows; i+=2, j+=2)
{
eT tmp_i = A[i];
eT tmp_j = A[j];
tmp_i *= B_coldata[i];
tmp_j *= B_coldata[j];
out_coldata[i] = tmp_i;
out_coldata[j] = tmp_j;
}
if(i < B_n_rows)
{ {
out_coldata[row] = A[row] * B_coldata[row]; out_coldata[i] = A[i] * B_coldata[i];
} }
} }
} }
else else
if( (S1.do_diagmat == false) && (S2.do_diagmat == true) ) if( (strip_diagmat<T1>::do_diagmat == false) && (strip_diagmat<T2>::do_di agmat == true) )
{ {
const unwrap_check<T1> tmp(X.A, out); const unwrap_check<T1> tmp(X.A, out);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const diagmat_proxy_check<T2_stripped> B(S2.M, out); const diagmat_proxy_check<T2_stripped> B(S2.M, out);
arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_elem, B.n_elem, "mat const uword A_n_rows = A.n_rows;
rix multiplication"); const uword A_n_cols = A.n_cols;
const uword B_n_elem = B.n_elem;
arma_debug_assert_mul_size(A_n_rows, A_n_cols, B_n_elem, B_n_elem, "mat
rix multiplication");
out.set_size(A.n_rows, B.n_elem); out.set_size(A_n_rows, B_n_elem);
for(uword col=0; col<A.n_cols; ++col) for(uword col=0; col < A_n_cols; ++col)
{ {
const eT val = B[col]; const eT val = B[col];
eT* out_coldata = out.colptr(col); eT* out_coldata = out.colptr(col);
const eT* A_coldata = A.colptr(col); const eT* A_coldata = A.colptr(col);
for(uword row=0; row<A.n_rows; ++row) uword i,j;
for(i=0, j=1; j < A_n_rows; i+=2, j+=2)
{ {
out_coldata[row] = A_coldata[row] * val; const eT tmp_i = A_coldata[i] * val;
const eT tmp_j = A_coldata[j] * val;
out_coldata[i] = tmp_i;
out_coldata[j] = tmp_j;
}
if(i < A_n_rows)
{
out_coldata[i] = A_coldata[i] * val;
} }
} }
} }
else else
if( (S1.do_diagmat == true) && (S2.do_diagmat == true) ) if( (strip_diagmat<T1>::do_diagmat == true) && (strip_diagmat<T2>::do_dia gmat == true) )
{ {
const diagmat_proxy_check<T1_stripped> A(S1.M, out); const diagmat_proxy_check<T1_stripped> A(S1.M, out);
const diagmat_proxy_check<T2_stripped> B(S2.M, out); const diagmat_proxy_check<T2_stripped> B(S2.M, out);
arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "mat const uword A_n_elem = A.n_elem;
rix multiplication"); const uword B_n_elem = B.n_elem;
arma_debug_assert_mul_size(A_n_elem, A_n_elem, B_n_elem, B_n_elem, "mat
rix multiplication");
out.zeros(A.n_elem, A.n_elem); out.zeros(A_n_elem, A_n_elem);
for(uword i=0; i<A.n_elem; ++i) for(uword i=0; i < A_n_elem; ++i)
{ {
out.at(i,i) = A[i] * B[i]; out.at(i,i) = A[i] * B[i];
} }
} }
} }
//! @} //! @}
 End of changes. 47 change blocks. 
82 lines changed or deleted 157 lines changed or added


 injector_bones.hpp   injector_bones.hpp 
skipping to change at line 44 skipping to change at line 44
typedef typename T1::elem_type elem_type; typedef typename T1::elem_type elem_type;
inline void insert(const elem_type val) const; inline void insert(const elem_type val) const;
inline void end_of_row() const; inline void end_of_row() const;
inline ~mat_injector(); inline ~mat_injector();
private: private:
inline mat_injector(T1& in_X, const elem_type val); inline mat_injector(T1& in_X, const elem_type val);
inline mat_injector(T1& in_X, const injector_end_of_row& x); inline mat_injector(T1& in_X, const injector_end_of_row<>&amp; x);
T1& X; T1& X;
mutable uword n_rows; mutable uword n_rows;
mutable podarray< mat_injector_row<elem_type>* >* AA; mutable podarray< mat_injector_row<elem_type>* >* AA;
mutable podarray< mat_injector_row<elem_type>* >* BB; mutable podarray< mat_injector_row<elem_type>* >* BB;
friend class Mat<elem_type>; friend class Mat<elem_type>;
friend class Row<elem_type>; friend class Row<elem_type>;
friend class Col<elem_type>; friend class Col<elem_type>;
skipping to change at line 88 skipping to change at line 88
typedef typename T1::object_type object_type; typedef typename T1::object_type object_type;
inline void insert(const object_type& val) const; inline void insert(const object_type& val) const;
inline void end_of_row() const; inline void end_of_row() const;
inline ~field_injector(); inline ~field_injector();
private: private:
inline field_injector(T1& in_X, const object_type& val); inline field_injector(T1& in_X, const object_type& val);
inline field_injector(T1& in_X, const injector_end_of_row& x); inline field_injector(T1& in_X, const injector_end_of_row<>&amp; x);
T1& X; T1& X;
mutable uword n_rows; mutable uword n_rows;
mutable podarray< field_injector_row<object_type>* >* AA; mutable podarray< field_injector_row<object_type>* >* AA;
mutable podarray< field_injector_row<object_type>* >* BB; mutable podarray< field_injector_row<object_type>* >* BB;
friend class field<object_type>; friend class field<object_type>;
}; };
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 injector_meat.hpp   injector_meat.hpp 
skipping to change at line 83 skipping to change at line 83
for(uword row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
A[row] = new mat_injector_row<eT>; A[row] = new mat_injector_row<eT>;
} }
(*(A[0])).insert(val); (*(A[0])).insert(val);
} }
template<typename T1> template<typename T1>
inline inline
mat_injector<T1>::mat_injector(T1& in_X, const injector_end_of_row& x) mat_injector<T1>::mat_injector(T1& in_X, const injector_end_of_row<>&amp; x)
: X(in_X) : X(in_X)
, n_rows(1) , n_rows(1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(x); arma_ignore(x);
typedef typename mat_injector<T1>::elem_type eT; typedef typename mat_injector<T1>::elem_type eT;
AA = new podarray< mat_injector_row<eT>* >; AA = new podarray< mat_injector_row<eT>* >;
BB = new podarray< mat_injector_row<eT>* >; BB = new podarray< mat_injector_row<eT>* >;
skipping to change at line 258 skipping to change at line 258
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
ref.insert(val); ref.insert(val);
return ref; return ref;
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const mat_injector<T1>& const mat_injector<T1>&
operator<<(const mat_injector<T1>& ref, const injector_end_of_row& x) operator<<(const mat_injector<T1>& ref, const injector_end_of_row<>&amp; x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(x); arma_ignore(x);
ref.end_of_row(); ref.end_of_row();
return ref; return ref;
} }
//// using a mixture of operator << and , doesn't work yet //// using a mixture of operator << and , doesn't work yet
skipping to change at line 288 skipping to change at line 288
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// //
// ref.insert(val); // ref.insert(val);
// //
// return ref; // return ref;
// } // }
// template<typename T1> // template<typename T1>
// arma_inline // arma_inline
// const mat_injector<T1>& // const mat_injector<T1>&
// operator,(const mat_injector<T1>& ref, const injector_end_of_row& x) // operator,(const mat_injector<T1>& ref, const injector_end_of_row<>&amp; x)
// { // {
// arma_extra_debug_sigprint(); // arma_extra_debug_sigprint();
// arma_ignore(x); // arma_ignore(x);
// //
// ref.end_of_row(); // ref.end_of_row();
// //
// return ref; // return ref;
// } // }
// //
skipping to change at line 389 skipping to change at line 389
for(uword row=0; row<n_rows; ++row) for(uword row=0; row<n_rows; ++row)
{ {
A[row] = new field_injector_row<oT>; A[row] = new field_injector_row<oT>;
} }
(*(A[0])).insert(val); (*(A[0])).insert(val);
} }
template<typename T1> template<typename T1>
inline inline
field_injector<T1>::field_injector(T1& in_X, const injector_end_of_row& x) field_injector<T1>::field_injector(T1& in_X, const injector_end_of_row<>& x )
: X(in_X) : X(in_X)
, n_rows(1) , n_rows(1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(x); arma_ignore(x);
typedef typename field_injector<T1>::object_type oT; typedef typename field_injector<T1>::object_type oT;
AA = new podarray< field_injector_row<oT>* >; AA = new podarray< field_injector_row<oT>* >;
BB = new podarray< field_injector_row<oT>* >; BB = new podarray< field_injector_row<oT>* >;
skipping to change at line 525 skipping to change at line 525
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
ref.insert(val); ref.insert(val);
return ref; return ref;
} }
template<typename T1> template<typename T1>
arma_inline arma_inline
const field_injector<T1>& const field_injector<T1>&
operator<<(const field_injector<T1>& ref, const injector_end_of_row& x) operator<<(const field_injector<T1>& ref, const injector_end_of_row<>&amp; x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(x); arma_ignore(x);
ref.end_of_row(); ref.end_of_row();
return ref; return ref;
} }
//! @} //! @}
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 mtGlue_bones.hpp   mtGlue_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 24 skipping to change at line 24
//! @{ //! @{
template<typename out_eT, typename T1, typename T2, typename glue_type> template<typename out_eT, typename T1, typename T2, typename glue_type>
class mtGlue : public Base<out_eT, mtGlue<out_eT, T1, T2, glue_type> > class mtGlue : public Base<out_eT, mtGlue<out_eT, T1, T2, glue_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
static const bool is_row = ( is_glue_mixed_elem<glue_type>::value && (T1:
:is_row || T2::is_row) ) || ( is_glue_mixed_times<glue_type>::value && T1::
is_row );
static const bool is_col = ( is_glue_mixed_elem<glue_type>::value && (T1:
:is_col || T2::is_col) ) || ( is_glue_mixed_times<glue_type>::value && T2::
is_col );
arma_inline mtGlue(const T1& in_A, const T2& in_B); arma_inline mtGlue(const T1& in_A, const T2& in_B);
arma_inline mtGlue(const T1& in_A, const T2& in_B, const uword in_aux_uw ord); arma_inline mtGlue(const T1& in_A, const T2& in_B, const uword in_aux_uw ord);
arma_inline ~mtGlue(); arma_inline ~mtGlue();
arma_aligned const T1& A; //!< first operand arma_aligned const T1& A; //!< first operand
arma_aligned const T2& B; //!< second operand arma_aligned const T2& B; //!< second operand
arma_aligned uword aux_uword; //!< storage of auxiliary data, uword format arma_aligned uword aux_uword; //!< storage of auxiliary data, uword format
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 9 lines changed or added


 mtOp_bones.hpp   mtOp_bones.hpp 
skipping to change at line 26 skipping to change at line 26
template<typename out_eT, typename T1, typename op_type> template<typename out_eT, typename T1, typename op_type>
class mtOp : public Base<out_eT, mtOp<out_eT, T1, op_type> > class mtOp : public Base<out_eT, mtOp<out_eT, T1, op_type> >
{ {
public: public:
typedef out_eT elem_type; typedef out_eT elem_type;
typedef typename get_pod_type<out_eT>::result pod_type; typedef typename get_pod_type<out_eT>::result pod_type;
typedef typename T1::elem_type in_eT; typedef typename T1::elem_type in_eT;
static const bool is_row = T1::is_row && is_op_mixed_elem<op_type>::value
;
static const bool is_col = T1::is_col && is_op_mixed_elem<op_type>::value
;
inline explicit mtOp(const T1& in_m); inline explicit mtOp(const T1& in_m);
inline mtOp(const T1& in_m, const in_eT in_aux); inline mtOp(const T1& in_m, const in_eT in_aux);
inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uw ord in_aux_uword_b); inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uw ord in_aux_uword_b);
inline mtOp(const T1& in_m, const in_eT in_aux, const uw ord in_aux_uword_a, const uword in_aux_uword_b); inline mtOp(const T1& in_m, const in_eT in_aux, const uw ord in_aux_uword_a, const uword in_aux_uword_b);
inline mtOp(const char junk, const T1& in_m, const out_eT in_aux ); inline mtOp(const char junk, const T1& in_m, const out_eT in_aux );
inline ~mtOp(); inline ~mtOp();
arma_aligned const T1& m; //!< storage of reference to the operand (eg. a matrix) arma_aligned const T1& m; //!< storage of reference to the operand (eg. a matrix)
 End of changes. 1 change blocks. 
0 lines changed or deleted 5 lines changed or added


 op_htrans_meat.hpp   op_htrans_meat.hpp 
skipping to change at line 104 skipping to change at line 104
const eT val2 = std::conj(out.at(col,row)); const eT val2 = std::conj(out.at(col,row));
out.at(col,row) = val1; out.at(col,row) = val1;
coldata[row] = val2; coldata[row] = val2;
} }
} }
} }
else else
{ {
Mat<eT> tmp; Mat<eT> tmp;
op_htrans::apply_noalias(tmp, A); op_strans::apply_noalias(tmp, A);
out.steal_mem(tmp); out.steal_mem(tmp);
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 op_max_bones.hpp   op_max_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_max //! \addtogroup op_max
//! @{ //! @{
//! Class for finding maximum values in a matrix //! Class for finding maximum values in a matrix
class op_max class op_max
{ {
public: public:
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_max>& in);
//
// for non-complex numbers
template<typename eT> template<typename eT>
inline static eT direct_max(const eT* const X, const uword N); inline static eT direct_max(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_max(const eT* const X, const uword N, uword& inde x_of_max_val); inline static eT direct_max(const eT* const X, const uword N, uword& inde x_of_max_val);
template<typename eT> template<typename eT>
inline static eT direct_max(const Mat<eT>& X, const uword row); inline static eT direct_max(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_max(const subview<eT>& X); inline static eT max(const subview<eT>& X);
template<typename eT>
inline static eT direct_max(const diagview<eT>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _max>& in); inline static typename arma_not_cx<typename T1::elem_type>::result max(co nst Base<typename T1::elem_type, T1>& X);
// //
// for complex numbers // for complex numbers
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const std::complex<T>* const X, const uword n_elem); inline static std::complex<T> direct_max(const std::complex<T>* const X, const uword n_elem);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const std::complex<T>* const X, const uword n_elem, uword& index_of_max_val); inline static std::complex<T> direct_max(const std::complex<T>* const X, const uword n_elem, uword& index_of_max_val);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const Mat< std::complex<T> >& X, const uword row); inline static std::complex<T> direct_max(const Mat< std::complex<T> >& X, const uword row);
template<typename T> template<typename T>
inline static std::complex<T> direct_max(const subview< std::complex<T> > inline static std::complex<T> max(const subview< std::complex<T> >& X);
& X);
template<typename T>
inline static std::complex<T> direct_max(const diagview< std::complex<T>
>& X);
template<typename T1>
inline static typename arma_cx_only<typename T1::elem_type>::result max(c
onst Base<typename T1::elem_type, T1>& X);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
13 lines changed or deleted 15 lines changed or added


 op_max_meat.hpp   op_max_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_max //! \addtogroup op_max
//! @{ //! @{
//! \brief
//! For each row or for each column, find the maximum value.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the maxima are found, is set via the max() fun
ction.
template<typename T1>
inline
void
op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1"
);
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
if(dim == 0)
{
arma_extra_debug_print("op_max::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "max(): given object has zero rows"
);
out.set_size(1, X_n_cols);
eT* out_mem = out.memptr();
for(uword col=0; col<X_n_cols; ++col)
{
out_mem[col] = op_max::direct_max( X.colptr(col), X_n_rows );
}
}
else
if(dim == 1)
{
arma_extra_debug_print("op_max::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "max(): given object has zero column
s" );
out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row)
{
out_mem[row] = op_max::direct_max( X, row );
}
}
}
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_max::direct_max(const eT* const X, const uword n_elem) op_max::direct_max(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i > max_val) if(X_i > max_val) { max_val = X_i; }
{ if(X_j > max_val) { max_val = X_j; }
max_val = X_i;
}
if(X_j > max_val)
{
max_val = X_j;
}
} }
if(i < n_elem) if(i < n_elem)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
if(X_i > max_val) if(X_i > max_val) { max_val = X_i; }
{
max_val = X_i;
}
} }
return max_val; return max_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const eT* const X, const uword n_elem, uword& index_of_m ax_val) op_max::direct_max(const eT* const X, const uword n_elem, uword& index_of_m ax_val)
{ {
skipping to change at line 115 skipping to change at line 160
inline inline
eT eT
op_max::direct_max(const Mat<eT>& X, const uword row) op_max::direct_max(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
for(uword col=0; col<X_n_cols; ++col) uword i,j;
for(i=0, j=1; j < X_n_cols; i+=2, j+=2)
{ {
const eT tmp_val = X.at(row,col); const eT tmp_i = X.at(row,i);
const eT tmp_j = X.at(row,j);
if(tmp_val > max_val) if(tmp_i > max_val) { max_val = tmp_i; }
{ if(tmp_j > max_val) { max_val = tmp_j; }
max_val = tmp_val; }
}
if(i < X_n_cols)
{
const eT tmp_i = X.at(row,i);
if(tmp_i > max_val) { max_val = tmp_i; }
} }
return max_val; return max_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_max::direct_max(const subview<eT>& X) op_max::max(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; arma_debug_check( (X.n_elem == 0), "max(): given object has no elements"
);
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
eT max_val = priv::most_neg<eT>(); eT max_val = priv::most_neg<eT>();
for(uword i=0; i<X_n_elem; ++i) if(X_n_rows == 1)
{ {
eT tmp_val = X[i]; const Mat<eT>& A = X.m;
if(tmp_val > max_val) const uword start_row = X.aux_row1;
{ const uword start_col = X.aux_col1;
max_val = tmp_val;
}
}
return max_val; const uword end_col_p1 = start_col + X_n_cols;
}
template<typename eT> uword i,j;
inline for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
eT {
op_max::direct_max(const diagview<eT>& X) const eT tmp_i = A.at(start_row, i);
{ const eT tmp_j = A.at(start_row, j);
arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; if(tmp_i > max_val) { max_val = tmp_i; }
if(tmp_j > max_val) { max_val = tmp_j; }
}
eT max_val = priv::most_neg<eT>(); if(i < end_col_p1)
{
const eT tmp_i = A.at(start_row, i);
for(uword i=0; i<X_n_elem; ++i) if(tmp_i > max_val) { max_val = tmp_i; }
}
}
else
{ {
eT tmp_val = X[i]; for(uword col=0; col < X_n_cols; ++col)
if(tmp_val > max_val)
{ {
max_val = tmp_val; eT tmp_val = op_max::direct_max(X.colptr(col), X_n_rows);
if(tmp_val > max_val) { max_val = tmp_val; }
} }
} }
return max_val; return max_val;
} }
//! \brief
//! For each row or for each column, find the maximum value.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the maxima are found, is set via the max() fun
ction.
template<typename T1> template<typename T1>
inline inline
void typename arma_not_cx<typename T1::elem_type>::result
op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in) op_max::max(const Base<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;
const unwrap_check<T1> tmp(in.m, out); const Proxy<T1> P(X.get_ref());
const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a; const uword n_elem = P.get_n_elem();
arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1"
);
const uword X_n_rows = X.n_rows; arma_debug_check( (n_elem == 0), "max(): given object has no elements" );
const uword X_n_cols = X.n_cols;
if(dim == 0) eT max_val = priv::most_neg<eT>();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
arma_extra_debug_print("op_max::apply(), dim = 0"); typedef typename Proxy<T1>::ea_type ea_type;
arma_debug_check( (X_n_rows == 0), "max(): given object has zero rows" ); ea_type A = P.get_ea();
out.set_size(1, X_n_cols); uword i,j;
eT* out_mem = out.memptr(); for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
const eT tmp_i = A[i];
const eT tmp_j = A[j];
for(uword col=0; col<X_n_cols; ++col) if(tmp_i > max_val) { max_val = tmp_i; }
if(tmp_j > max_val) { max_val = tmp_j; }
}
if(i < n_elem)
{ {
out_mem[col] = op_max::direct_max( X.colptr(col), X_n_rows ); const eT tmp_i = A[i];
if(tmp_i > max_val) { max_val = tmp_i; }
} }
} }
else else
if(dim == 1)
{ {
arma_extra_debug_print("op_max::apply(), dim = 1"); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
arma_debug_check( (X_n_cols == 0), "max(): given object has zero column if(n_rows == 1)
s" );
out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row)
{ {
out_mem[row] = op_max::direct_max( X, row ); uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp_i = P.at(0,i);
const eT tmp_j = P.at(0,j);
if(tmp_i > max_val) { max_val = tmp_i; }
if(tmp_j > max_val) { max_val = tmp_j; }
}
if(i < n_cols)
{
const eT tmp_i = P.at(0,i);
if(tmp_i > max_val) { max_val = tmp_i; }
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
uword i,j;
for(i=0, j=1; j < n_rows; i+=2, j+=2)
{
const eT tmp_i = P.at(i,col);
const eT tmp_j = P.at(j,col);
if(tmp_i > max_val) { max_val = tmp_i; }
if(tmp_j > max_val) { max_val = tmp_j; }
}
if(i < n_rows)
{
const eT tmp_i = P.at(i,col);
if(tmp_i > max_val) { max_val = tmp_i; }
}
}
} }
} }
return max_val;
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const std::complex<T>* const X, const uword n_elem) op_max::direct_max(const std::complex<T>* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
uword index = 0; uword index = 0;
skipping to change at line 310 skipping to change at line 404
index = col; index = col;
} }
} }
return X.at(row,index); return X.at(row,index);
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_max::direct_max(const subview< std::complex<T> >& X) op_max::max(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; arma_debug_check( (X.n_elem == 0), "max(): given object has no elements" );
uword index = 0; const Mat< std::complex<T> >& A = X.m;
T max_val = priv::most_neg<T>();
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
const uword start_row = X.aux_row1;
const uword start_col = X.aux_col1;
const uword end_row_p1 = start_row + X_n_rows;
const uword end_col_p1 = start_col + X_n_cols;
for(uword i=0; i<X_n_elem; ++i) T max_val = priv::most_neg<T>();
uword best_row = 0;
uword best_col = 0;
if(X_n_rows == 1)
{ {
const T tmp_val = std::abs(X[i]); best_col = 0;
if(tmp_val > max_val) for(uword col=start_col; col < end_col_p1; ++col)
{ {
max_val = tmp_val; const T tmp_val = std::abs( A.at(start_row, col) );
index = i;
if(tmp_val > max_val)
{
max_val = tmp_val;
best_col = col;
}
}
best_row = start_row;
}
else
{
for(uword col=start_col; col < end_col_p1; ++col)
for(uword row=start_row; row < end_row_p1; ++row)
{
const T tmp_val = std::abs( A.at(row, col) );
if(tmp_val > max_val)
{
max_val = tmp_val;
best_row = row;
best_col = col;
}
} }
} }
return X[index]; return A.at(best_row, best_col);
} }
template<typename T> template<typename T1>
inline inline
std::complex<T> typename arma_cx_only<typename T1::elem_type>::result
op_max::direct_max(const diagview< std::complex<T> >& X) op_max::max(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; typedef typename T1::elem_type eT;
typedef typename get_pod_type<eT>::result T;
uword index = 0; const Proxy<T1> P(X.get_ref());
T max_val = priv::most_neg<T>();
const uword n_elem = P.get_n_elem();
for(uword i=0; i<X_n_elem; ++i) arma_debug_check( (n_elem == 0), "max(): given object has no elements" );
T max_val = priv::most_neg<T>();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
const T tmp_val = std::abs(X[i]); typedef typename Proxy<T1>::ea_type ea_type;
if(tmp_val > max_val) ea_type A = P.get_ea();
uword index = 0;
for(uword i=0; i<n_elem; ++i)
{ {
max_val = tmp_val; const T tmp = std::abs(A[i]);
index = i;
if(tmp > max_val)
{
max_val = tmp;
index = i;
}
} }
return( A[index] );
} }
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
return X[index]; uword best_row = 0;
uword best_col = 0;
if(n_rows == 1)
{
for(uword col=0; col < n_cols; ++col)
{
const T tmp = std::abs(P.at(0,col));
if(tmp > max_val)
{
max_val = tmp;
best_col = col;
}
}
}
else
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const T tmp = std::abs(P.at(row,col));
if(tmp > max_val)
{
max_val = tmp;
best_row = row;
best_col = col;
}
}
}
return P.at(best_row, best_col);
}
} }
//! @} //! @}
 End of changes. 55 change blocks. 
100 lines changed or deleted 286 lines changed or added


 op_mean_bones.hpp   op_mean_bones.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_mean //! \addtogroup op_mean
//! @{ //! @{
//! Class for finding mean values of a matrix //! Class for finding mean values of a matrix
class op_mean class op_mean
{ {
public: public:
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_mean>& in);
//
template<typename eT> template<typename eT>
inline static eT direct_mean(const eT* const X, const uword N); inline static eT direct_mean(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_mean(const Mat<eT>& X, const uword row); inline static eT direct_mean_robust(const eT* const X, const uword N);
//
template<typename eT> template<typename eT>
inline static eT direct_mean(const subview<eT>& X); inline static eT direct_mean(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_mean(const diagview<eT>& X); inline static eT direct_mean_robust(const Mat<eT>& X, const uword row);
template<typename T1> //
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_mean>& in);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const eT* const X, const uword N); inline static eT mean_all(const subview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const Mat<eT>& X, const uword row); inline static eT mean_all_robust(const subview<eT>& X);
//
template<typename eT>
inline static eT mean_all(const diagview<eT>& X);
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const subview<eT>& X); inline static eT mean_all_robust(const diagview<eT>& X);
//
template<typename T1>
inline static typename T1::elem_type mean_all(const Base<typename T1::ele
m_type, T1>& X);
//
template<typename eT> template<typename eT>
inline static eT direct_mean_robust(const diagview<eT>& X); arma_inline static eT robust_mean(const eT A, const eT B);
template<typename T>
arma_inline static std::complex<T> robust_mean(const std::complex<T>& A,
const std::complex<T>& B);
}; };
//! @} //! @}
 End of changes. 10 change blocks. 
12 lines changed or deleted 35 lines changed or added


 op_mean_meat.hpp   op_mean_meat.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_mean //! \addtogroup op_mean
//! @{ //! @{
//! \brief
//! For each row or for each column, find the mean value.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the means are found, is set via the mean() fun
ction.
template<typename T1>
inline
void
op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
typedef typename get_pod_type<eT>::result T;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1
");
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
if(dim == 0)
{
arma_extra_debug_print("op_mean::apply(), dim = 0");
out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols );
if(X_n_rows > 0)
{
eT* out_mem = out.memptr();
for(uword col=0; col < X_n_cols; ++col)
{
out_mem[col] = op_mean::direct_mean( X.colptr(col), X_n_rows );
}
}
}
else
if(dim == 1)
{
arma_extra_debug_print("op_mean::apply(), dim = 1");
out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
if(X_n_cols > 0)
{
eT* out_mem = out.memptr();
for(uword row=0; row < X_n_rows; ++row)
{
out_mem[row] = op_mean::direct_mean( X, row );
}
}
}
}
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_mean::direct_mean(const eT* const X, const uword n_elem) op_mean::direct_mean(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const eT result = arrayops::accumulate(X, n_elem) / T(n_elem); const eT result = arrayops::accumulate(X, n_elem) / T(n_elem);
return arma_isfinite(result) ? result : op_mean::direct_mean_robust(X, n_ elem); return arma_isfinite(result) ? result : op_mean::direct_mean_robust(X, n_ elem);
} }
template<typename eT> template<typename eT>
arma_pure
inline inline
eT eT
op_mean::direct_mean(const Mat<eT>& X, const uword row) op_mean::direct_mean_robust(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// use an adapted form of the mean finding algorithm from the running_sta
t class
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const uword X_n_cols = X.n_cols; uword i,j;
eT val = eT(0); eT r_mean = eT(0);
for(uword col=0; col<X_n_cols; ++col) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val += X.at(row,col); const eT Xi = X[i];
const eT Xj = X[j];
r_mean = r_mean + (Xi - r_mean)/T(j); // we need i+1, and j is equiv
alent to i+1 here
r_mean = r_mean + (Xj - r_mean)/T(j+1);
} }
const eT result = val / T(X_n_cols); if(i < n_elem)
{
const eT Xi = X[i];
return arma_isfinite(result) ? result : direct_mean_robust(X, row); r_mean = r_mean + (Xi - r_mean)/T(i+1);
}
return r_mean;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const subview<eT>& X) op_mean::direct_mean(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const uword X_n_elem = X.n_elem; const uword X_n_cols = X.n_cols;
eT val = eT(0); eT val = eT(0);
for(uword i=0; i<X_n_elem; ++i) uword i,j;
for(i=0, j=1; j < X_n_cols; i+=2, j+=2)
{ {
val += X[i]; val += X.at(row,i);
val += X.at(row,j);
} }
const eT result = val / T(X_n_elem); if(i < X_n_cols)
{
val += X.at(row,i);
}
const eT result = val / T(X_n_cols);
return arma_isfinite(result) ? result : direct_mean_robust(X); return arma_isfinite(result) ? result : op_mean::direct_mean_robust(X, ro w);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean(const diagview<eT>& X) op_mean::direct_mean_robust(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const uword X_n_elem = X.n_elem; const uword X_n_cols = X.n_cols;
eT val = eT(0); eT r_mean = eT(0);
for(uword i=0; i<X_n_elem; ++i) for(uword col=0; col < X_n_cols; ++col)
{ {
val += X[i]; r_mean = r_mean + (X.at(row,col) - r_mean)/T(col+1);
} }
const eT result = val / T(X_n_elem); return r_mean;
return arma_isfinite(result) ? result : direct_mean_robust(X);
} }
//! \brief template<typename eT>
//! For each row or for each column, find the mean value.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the means are found, is set via the mean() fun
ction.
template<typename T1>
inline inline
void eT
op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in) op_mean::mean_all(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename get_pod_type<eT>::result T;
typedef typename get_pod_type<eT>::result T;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1
");
const uword X_n_rows = X.n_rows; const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
const uword X_n_elem = X.n_elem;
if(dim == 0) arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements"
);
eT val = eT(0);
if(X_n_rows == 1)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 0"); const Mat<eT>& A = X.m;
out.set_size( (X_n_rows > 0) ? 1 : 0, X_n_cols ); const uword start_row = X.aux_row1;
const uword start_col = X.aux_col1;
if(X_n_rows > 0) const uword end_col_p1 = start_col + X_n_cols;
uword i,j;
for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
{ {
eT* out_mem = out.memptr(); val += A.at(start_row, i);
val += A.at(start_row, j);
}
for(uword col=0; col<X_n_cols; ++col) if(i < end_col_p1)
{ {
out_mem[col] = op_mean::direct_mean( X.colptr(col), X_n_rows ); val += A.at(start_row, i);
}
} }
} }
else else
if(dim == 1)
{ {
arma_extra_debug_print("op_mean::apply(), dim = 1"); for(uword col=0; col < X_n_cols; ++col)
out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
if(X_n_cols > 0)
{ {
eT* out_mem = out.memptr(); val += arrayops::accumulate(X.colptr(col), X_n_rows);
for(uword row=0; row<X_n_rows; ++row)
{
out_mem[row] = op_mean::direct_mean( X, row );
}
} }
} }
const eT result = val / T(X_n_elem);
return arma_isfinite(result) ? result : op_mean::mean_all_robust(X);
} }
template<typename eT> template<typename eT>
arma_pure
inline inline
eT eT
op_mean::direct_mean_robust(const eT* const X, const uword n_elem) op_mean::mean_all_robust(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
// use an adapted form of the mean finding algorithm from the running_sta
t class
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
uword i,j; const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
const uword start_row = X.aux_row1;
const uword start_col = X.aux_col1;
const uword end_row_p1 = start_row + X_n_rows;
const uword end_col_p1 = start_col + X_n_cols;
const Mat<eT>& A = X.m;
eT r_mean = eT(0); eT r_mean = eT(0);
for(i=0, j=1; j<n_elem; i+=2, j+=2) if(X_n_rows == 1)
{ {
const eT Xi = X[i]; uword i=0;
const eT Xj = X[j];
r_mean = r_mean + (Xi - r_mean)/T(j); // we need i+1, and j is equiv for(uword col = start_col; col < end_col_p1; ++col, ++i)
alent to i+1 here {
r_mean = r_mean + (Xj - r_mean)/T(j+1); r_mean = r_mean + (A.at(start_row,col) - r_mean)/T(i+1);
}
} }
else
if(i < n_elem)
{ {
const eT Xi = X[i]; uword i=0;
r_mean = r_mean + (Xi - r_mean)/T(i+1); for(uword col = start_col; col < end_col_p1; ++col)
for(uword row = start_row; row < end_row_p1; ++row, ++i)
{
r_mean = r_mean + (A.at(row,col) - r_mean)/T(i+1);
}
} }
return r_mean; return r_mean;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean_robust(const Mat<eT>& X, const uword row) op_mean::mean_all(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const uword X_n_cols = X.n_cols; const uword X_n_elem = X.n_elem;
eT r_mean = eT(0); arma_debug_check( (X_n_elem == 0), "mean(): given object has no elements"
);
eT val = eT(0);
for(uword col=0; col<X_n_cols; ++col) for(uword i=0; i<X_n_elem; ++i)
{ {
r_mean = r_mean + (X.at(row,col) - r_mean)/T(col+1); val += X[i];
} }
return r_mean; const eT result = val / T(X_n_elem);
return arma_isfinite(result) ? result : op_mean::mean_all_robust(X);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_mean::direct_mean_robust(const subview<eT>& X) op_mean::mean_all_robust(const diagview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const uword X_n_elem = X.n_elem; const uword X_n_elem = X.n_elem;
eT r_mean = eT(0); eT r_mean = eT(0);
for(uword i=0; i<X_n_elem; ++i) for(uword i=0; i<X_n_elem; ++i)
{ {
r_mean = r_mean + (X[i] - r_mean)/T(i+1); r_mean = r_mean + (X[i] - r_mean)/T(i+1);
} }
return r_mean; return r_mean;
} }
template<typename eT> template<typename T1>
inline inline
eT typename T1::elem_type
op_mean::direct_mean_robust(const diagview<eT>& X) op_mean::mean_all(const Base<typename T1::elem_type, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename T1::elem_type eT;
const uword X_n_elem = X.n_elem; const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
eT r_mean = eT(0); const uword A_n_elem = A.n_elem;
for(uword i=0; i<X_n_elem; ++i) arma_debug_check( (A_n_elem == 0), "mean(): given object has no elements"
{ );
r_mean = r_mean + (X[i] - r_mean)/T(i+1);
}
return r_mean; return op_mean::direct_mean(A.memptr(), A_n_elem);
}
template<typename eT>
arma_inline
eT
op_mean::robust_mean(const eT A, const eT B)
{
return A + (B - A)/eT(2);
}
template<typename T>
arma_inline
std::complex<T>
op_mean::robust_mean(const std::complex<T>& A, const std::complex<T>& B)
{
return A + (B - A)/T(2);
} }
//! @} //! @}
 End of changes. 61 change blocks. 
96 lines changed or deleted 195 lines changed or added


 op_median_bones.hpp   op_median_bones.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 24 skipping to change at line 24
//! @{ //! @{
template<typename T> template<typename T>
struct arma_cx_median_packet struct arma_cx_median_packet
{ {
T val; T val;
uword index; uword index;
}; };
template<typename T> template<typename T>
inline arma_inline
bool bool
operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T >& B) operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T >& B)
{ {
return A.val < B.val; return A.val < B.val;
} }
//! Class for finding median values of a matrix //! Class for finding median values of a matrix
class op_median class op_median
{ {
public: public:
template<typename eT> template<typename T1>
arma_inline static eT robust_mean(const eT A, const eT B); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_median>& in);
template<typename eT>
inline static eT direct_median(std::vector<eT>& X);
template<typename eT> template<typename T, typename T1>
inline static eT direct_median(const eT* X, const uword n_elem); inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_medi
an>& in);
template<typename eT> //
inline static eT direct_median(const subview<eT>& X); //
template<typename eT> template<typename T1>
inline static eT direct_median(const diagview<eT>& X); inline static typename T1::elem_type median_vec(const Base<typename T1::e
lem_type, T1>& X, const typename arma_not_cx<typename T1::elem_type>::resul
t* junk = 0);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _median>& in); inline static typename T1::elem_type median_vec(const Base<typename T1::e lem_type, T1>& X, const typename arma_cx_only<typename T1::elem_type>::resu lt* junk = 0);
// //
// for complex numbers //
template<typename T> template<typename eT>
arma_inline static std::complex<T> robust_mean(const std::complex<T>& A, inline static eT direct_median(std::vector<eT>& X);
const std::complex<T>& B);
template<typename T> template<typename T>
inline static void direct_cx_median_index(uword& out_index1, uword& out_i ndex2, std::vector< arma_cx_median_packet<T> >& X); inline static void direct_cx_median_index(uword& out_index1, uword& out_i ndex2, std::vector< arma_cx_median_packet<T> >& X);
template<typename T>
inline static void direct_cx_median_index(uword& out_index1, uword& out_i
ndex2, const std::complex<T>* X, const uword n_elem);
template<typename T>
inline static void direct_cx_median_index(uword& out_index1, uword& out_i
ndex2, const subview< std::complex<T> >& X);
template<typename T>
inline static void direct_cx_median_index(uword& out_index1, uword& out_i
ndex2, const diagview< std::complex<T> >& X);
template<typename T, typename T1>
inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_medi
an>& in);
}; };
//! @} //! @}
 End of changes. 10 change blocks. 
36 lines changed or deleted 19 lines changed or added


 op_median_meat.hpp   op_median_meat.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_median //! \addtogroup op_median
//! @{ //! @{
template<typename eT>
arma_inline
eT
op_median::robust_mean(const eT A, const eT B)
{
return A + (B - A)/eT(2);
}
//! find the median value of a std::vector (contents is modified)
template<typename eT>
inline
eT
op_median::direct_median(std::vector<eT>& X)
{
arma_extra_debug_sigprint();
const uword n_elem = X.size();
const uword half = n_elem/2;
std::sort(X.begin(), X.end());
if((n_elem % 2) == 0)
{
return op_median::robust_mean(X[half-1], X[half]);
}
else
{
return X[half];
}
}
template<typename eT>
inline
eT
op_median::direct_median(const eT* X, const uword n_elem)
{
arma_extra_debug_sigprint();
std::vector<eT> tmp(X, X+n_elem);
return op_median::direct_median(tmp);
}
template<typename eT>
inline
eT
op_median::direct_median(const subview<eT>& X)
{
arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem;
std::vector<eT> tmp(X_n_elem);
for(uword i=0; i<X_n_elem; ++i)
{
tmp[i] = X[i];
}
return op_median::direct_median(tmp);
}
template<typename eT>
inline
eT
op_median::direct_median(const diagview<eT>& X)
{
arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem;
std::vector<eT> tmp(X_n_elem);
for(uword i=0; i<X_n_elem; ++i)
{
tmp[i] = X[i];
}
return op_median::direct_median(tmp);
}
//! \brief //! \brief
//! For each row or for each column, find the median value. //! For each row or for each column, find the median value.
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! The dimension, for which the medians are found, is set via the median() function. //! The dimension, for which the medians are found, is set via the median() function.
template<typename T1> template<typename T1>
inline inline
void void
op_median::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in) op_median::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 159 skipping to change at line 78
std::vector<eT> tmp_vec(X_n_cols); std::vector<eT> tmp_vec(X_n_cols);
for(uword row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
for(uword col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
tmp_vec[col] = X.at(row,col); tmp_vec[col] = X.at(row,col);
} }
out[row] = op_median::direct_median(tmp_vec); out[row] = op_median::direct_median(tmp_vec);
} }
} }
} }
template<typename T>
arma_inline
std::complex<T>
op_median::robust_mean(const std::complex<T>& A, const std::complex<T>& B)
{
return A + (B - A)/T(2);
}
template<typename T>
inline
void
op_median::direct_cx_median_index
(
uword& out_index1,
uword& out_index2,
std::vector< arma_cx_median_packet<T> >& X
)
{
arma_extra_debug_sigprint();
const uword n_elem = X.size();
const uword half = n_elem/2;
std::sort(X.begin(), X.end());
if((n_elem % 2) == 0)
{
out_index1 = X[half-1].index;
out_index2 = X[half ].index;
}
else
{
out_index1 = X[half].index;
out_index2 = out_index1;
}
}
template<typename T>
inline
void
op_median::direct_cx_median_index
(
uword& out_index1,
uword& out_index2,
const std::complex<T>* X,
const uword n_elem
)
{
arma_extra_debug_sigprint();
std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(uword i=0; i<n_elem; ++i)
{
tmp[i].val = std::abs(X[i]);
tmp[i].index = i;
}
op_median::direct_cx_median_index(out_index1, out_index2, tmp);
}
template<typename T>
inline
void
op_median::direct_cx_median_index
(
uword& out_index1,
uword& out_index2,
const subview< std::complex<T> >&X
)
{
arma_extra_debug_sigprint();
const uword n_elem = X.n_elem;
std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(uword i=0; i<n_elem; ++i)
{
tmp[i].val = std::abs(X[i]);
tmp[i].index = i;
}
op_median::direct_cx_median_index(out_index1, out_index2, tmp);
}
template<typename T>
inline
void
op_median::direct_cx_median_index
(
uword& out_index1,
uword& out_index2,
const diagview< std::complex<T> >&X
)
{
arma_extra_debug_sigprint();
const uword n_elem = X.n_elem;
std::vector< arma_cx_median_packet<T> > tmp(n_elem);
for(uword i=0; i<n_elem; ++i)
{
tmp[i].val = std::abs(X[i]);
tmp[i].index = i;
}
op_median::direct_cx_median_index(out_index1, out_index2, tmp);
}
//! Implementation for complex numbers //! Implementation for complex numbers
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
op_median::apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in) op_median::apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
skipping to change at line 320 skipping to change at line 128
for(uword row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
tmp_vec[row].val = std::abs(colmem[row]); tmp_vec[row].val = std::abs(colmem[row]);
tmp_vec[row].index = row; tmp_vec[row].index = row;
} }
uword index1; uword index1;
uword index2; uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec); op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[col] = op_median::robust_mean(colmem[index1], colmem[index2]); out[col] = op_mean::robust_mean(colmem[index1], colmem[index2]);
} }
} }
else else
if(dim == 1) // in each row if(dim == 1) // in each row
{ {
arma_extra_debug_print("op_median::apply(), dim = 1"); arma_extra_debug_print("op_median::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "median(): given object has zero col umns" ); arma_debug_check( (X_n_cols == 0), "median(): given object has zero col umns" );
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
skipping to change at line 346 skipping to change at line 154
for(uword col=0; col<X_n_cols; ++col) for(uword col=0; col<X_n_cols; ++col)
{ {
tmp_vec[col].val = std::abs(X.at(row,col)); tmp_vec[col].val = std::abs(X.at(row,col));
tmp_vec[col].index = col; tmp_vec[col].index = col;
} }
uword index1; uword index1;
uword index2; uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec); op_median::direct_cx_median_index(index1, index2, tmp_vec);
out[row] = op_median::robust_mean( X.at(row,index1), X.at(row,index2) out[row] = op_mean::robust_mean( X.at(row,index1), X.at(row,index2) )
); ;
}
}
}
template<typename T1>
inline
typename T1::elem_type
op_median::median_vec
(
const Base<typename T1::elem_type, T1>& X,
const typename arma_not_cx<typename T1::elem_type>::result* junk
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
const Proxy<T1> P(X.get_ref());
const uword n_elem = P.get_n_elem();
arma_debug_check( (n_elem == 0), "median(): given object has no elements"
);
std::vector<eT> tmp_vec(n_elem);
if(Proxy<T1>::prefer_at_accessor == false)
{
typedef typename Proxy<T1>::ea_type ea_type;
ea_type A = P.get_ea();
for(uword i=0; i<n_elem; ++i)
{
tmp_vec[i] = A[i];
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(n_cols == 1)
{
for(uword row=0; row < n_rows; ++row)
{
tmp_vec[row] = P.at(row,0);
}
}
else
if(n_rows == 1)
{
for(uword col=0; col < n_cols; ++col)
{
tmp_vec[col] = P.at(0,col);
}
}
else
{
arma_stop("op_median::median_vec(): expected a vector" );
}
}
return op_median::direct_median(tmp_vec);
}
template<typename T1>
inline
typename T1::elem_type
op_median::median_vec
(
const Base<typename T1::elem_type, T1>& X,
const typename arma_cx_only<typename T1::elem_type>::result* junk
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
const Proxy<T1> P(X.get_ref());
const uword n_elem = P.get_n_elem();
arma_debug_check( (n_elem == 0), "median(): given object has no elements"
);
std::vector< arma_cx_median_packet<T> > tmp_vec(n_elem);
if(Proxy<T1>::prefer_at_accessor == false)
{
typedef typename Proxy<T1>::ea_type ea_type;
ea_type A = P.get_ea();
for(uword i=0; i<n_elem; ++i)
{
tmp_vec[i].val = std::abs( A[i] );
tmp_vec[i].index = i;
}
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec);
return op_mean::robust_mean( A[index1], A[index2] );
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(n_cols == 1)
{
for(uword row=0; row < n_rows; ++row)
{
tmp_vec[row].val = std::abs( P.at(row,0) );
tmp_vec[row].index = row;
}
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec);
return op_mean::robust_mean( P.at(index1,0), P.at(index2,0) );
}
else
if(n_rows == 1)
{
for(uword col=0; col < n_cols; ++col)
{
tmp_vec[col].val = std::abs( P.at(0,col) );
tmp_vec[col].index = col;
}
uword index1;
uword index2;
op_median::direct_cx_median_index(index1, index2, tmp_vec);
return op_mean::robust_mean( P.at(0,index1), P.at(0,index2) );
}
else
{
arma_stop("op_median::median_vec(): expected a vector" );
return eT(0);
} }
} }
} }
//! find the median value of a std::vector (contents is modified)
template<typename eT>
inline
eT
op_median::direct_median(std::vector<eT>& X)
{
arma_extra_debug_sigprint();
const uword n_elem = X.size();
const uword half = n_elem/2;
std::sort(X.begin(), X.end());
if((n_elem % 2) == 0)
{
return op_mean::robust_mean(X[half-1], X[half]);
}
else
{
return X[half];
}
}
template<typename T>
inline
void
op_median::direct_cx_median_index
(
uword& out_index1,
uword& out_index2,
std::vector< arma_cx_median_packet<T> >& X
)
{
arma_extra_debug_sigprint();
const uword n_elem = X.size();
const uword half = n_elem/2;
std::sort(X.begin(), X.end());
if((n_elem % 2) == 0)
{
out_index1 = X[half-1].index;
out_index2 = X[half ].index;
}
else
{
out_index1 = X[half].index;
out_index2 = out_index1;
}
}
//! @} //! @}
 End of changes. 7 change blocks. 
198 lines changed or deleted 206 lines changed or added


 op_min_bones.hpp   op_min_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_min //! \addtogroup op_min
//! @{ //! @{
//! Class for finding minimum values in a matrix //! Class for finding minimum values in a matrix
class op_min class op_min
{ {
public: public:
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_min>& in);
//
// for non-complex numbers
template<typename eT> template<typename eT>
inline static eT direct_min(const eT* const X, const uword N); inline static eT direct_min(const eT* const X, const uword N);
template<typename eT> template<typename eT>
inline static eT direct_min(const eT* const X, const uword N, uword& inde x_of_min_val); inline static eT direct_min(const eT* const X, const uword N, uword& inde x_of_min_val);
template<typename eT> template<typename eT>
inline static eT direct_min(const Mat<eT>& X, const uword row); inline static eT direct_min(const Mat<eT>& X, const uword row);
template<typename eT> template<typename eT>
inline static eT direct_min(const subview<eT>& X); inline static eT min(const subview<eT>& X);
template<typename eT>
inline static eT direct_min(const diagview<eT>& X);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op _min>& in); inline static typename arma_not_cx<typename T1::elem_type>::result min(co nst Base<typename T1::elem_type, T1>& X);
// //
// for complex numbers // for complex numbers
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const std::complex<T>* const X, const uword n_elem); inline static std::complex<T> direct_min(const std::complex<T>* const X, const uword n_elem);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const std::complex<T>* const X, const uword n_elem, uword& index_of_min_val); inline static std::complex<T> direct_min(const std::complex<T>* const X, const uword n_elem, uword& index_of_min_val);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const Mat< std::complex<T> >& X, const uword row); inline static std::complex<T> direct_min(const Mat< std::complex<T> >& X, const uword row);
template<typename T> template<typename T>
inline static std::complex<T> direct_min(const subview< std::complex<T> > inline static std::complex<T> min(const subview< std::complex<T> >&X);
&X);
template<typename T>
inline static std::complex<T> direct_min(const diagview< std::complex<T>
>&X);
template<typename T1>
inline static typename arma_cx_only<typename T1::elem_type>::result min(c
onst Base<typename T1::elem_type, T1>& X);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
13 lines changed or deleted 15 lines changed or added


 op_min_meat.hpp   op_min_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_min //! \addtogroup op_min
//! @{ //! @{
//! \brief
//! For each row or for each column, find the minimum value.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the minima are found, is set via the min() fun
ction.
template<typename T1>
inline void op_min::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_
min>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1"
);
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
if(dim == 0) // min in each column
{
arma_extra_debug_print("op_min::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "min(): given object has zero rows"
);
out.set_size(1, X_n_cols);
eT* out_mem = out.memptr();
for(uword col=0; col<X_n_cols; ++col)
{
out_mem[col] = op_min::direct_min( X.colptr(col), X_n_rows );
}
}
else
if(dim == 1) // min in each row
{
arma_extra_debug_print("op_min::apply(), dim = 1");
arma_debug_check( (X_n_cols == 0), "min(): given object has zero column
s" );
out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row)
{
out_mem[row] = op_min::direct_min( X, row );
}
}
}
template<typename eT> template<typename eT>
arma_pure arma_pure
inline inline
eT eT
op_min::direct_min(const eT* const X, const uword n_elem) op_min::direct_min(const eT* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i < min_val) if(X_i < min_val) { min_val = X_i; }
{ if(X_j < min_val) { min_val = X_j; }
min_val = X_i;
}
if(X_j < min_val)
{
min_val = X_j;
}
} }
if(i < n_elem) if(i < n_elem)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
if(X_i < min_val) if(X_i < min_val) { min_val = X_i; }
{
min_val = X_i;
}
} }
return min_val; return min_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const eT* const X, const uword n_elem, uword& index_of_m in_val) op_min::direct_min(const eT* const X, const uword n_elem, uword& index_of_m in_val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
uword best_index = 0; uword best_index = 0;
uword i,j; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
const eT X_i = X[i]; const eT X_i = X[i];
const eT X_j = X[j]; const eT X_j = X[j];
if(X_i < min_val) if(X_i < min_val)
{ {
min_val = X_i; min_val = X_i;
best_index = i; best_index = i;
} }
skipping to change at line 115 skipping to change at line 156
inline inline
eT eT
op_min::direct_min(const Mat<eT>& X, const uword row) op_min::direct_min(const Mat<eT>& X, const uword row)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_cols = X.n_cols; const uword X_n_cols = X.n_cols;
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
for(uword col=0; col<X_n_cols; ++col) uword i,j;
for(i=0, j=1; j < X_n_cols; i+=2, j+=2)
{ {
const eT tmp_val = X.at(row,col); const eT tmp_i = X.at(row,i);
const eT tmp_j = X.at(row,j);
if(tmp_val < min_val) if(tmp_i < min_val) { min_val = tmp_i; }
{ if(tmp_j < min_val) { min_val = tmp_j; }
min_val = tmp_val; }
}
if(i < X_n_cols)
{
const eT tmp_i = X.at(row,i);
if(tmp_i < min_val) { min_val = tmp_i; }
} }
return min_val; return min_val;
} }
template<typename eT> template<typename eT>
inline inline
eT eT
op_min::direct_min(const subview<eT>& X) op_min::min(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; arma_debug_check( (X.n_elem == 0), "min(): given object has no elements"
);
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
eT min_val = priv::most_pos<eT>(); eT min_val = priv::most_pos<eT>();
for(uword i=0; i<X_n_elem; ++i) if(X_n_rows == 1)
{ {
eT tmp_val = X[i]; const Mat<eT>& A = X.m;
if(tmp_val < min_val) const uword start_row = X.aux_row1;
{ const uword start_col = X.aux_col1;
min_val = tmp_val;
}
}
return min_val; const uword end_col_p1 = start_col + X_n_cols;
}
template<typename eT> uword i,j;
inline for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
eT {
op_min::direct_min(const diagview<eT>& X) const eT tmp_i = A.at(start_row, i);
{ const eT tmp_j = A.at(start_row, j);
arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; if(tmp_i < min_val) { min_val = tmp_i; }
if(tmp_j < min_val) { min_val = tmp_j; }
}
eT min_val = priv::most_pos<eT>();; if(i < end_col_p1)
{
const eT tmp_i = A.at(start_row, i);
for(uword i=0; i<X_n_elem; ++i) if(tmp_i < min_val) { min_val = tmp_i; }
}
}
else
{ {
eT tmp_val = X[i]; for(uword col=0; col < X_n_cols; ++col)
if(tmp_val < min_val)
{ {
min_val = tmp_val; eT tmp_val = op_min::direct_min(X.colptr(col), X_n_rows);
if(tmp_val < min_val) { min_val = tmp_val; }
} }
} }
return min_val; return min_val;
} }
//! \brief
//! For each row or for each column, find the minimum value.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the minima are found, is set via the min() fun
ction.
template<typename T1> template<typename T1>
inline void op_min::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ inline
min>& in) typename arma_not_cx<typename T1::elem_type>::result
op_min::min(const Base<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;
const unwrap_check<T1> tmp(in.m, out); const Proxy<T1> P(X.get_ref());
const Mat<eT>& X = tmp.M;
const uword dim = in.aux_uword_a; const uword n_elem = P.get_n_elem();
arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1"
);
const uword X_n_rows = X.n_rows; arma_debug_check( (n_elem == 0), "min(): given object has no elements" );
const uword X_n_cols = X.n_cols;
if(dim == 0) // min in each column eT min_val = priv::most_pos<eT>();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
arma_extra_debug_print("op_min::apply(), dim = 0"); typedef typename Proxy<T1>::ea_type ea_type;
arma_debug_check( (X_n_rows == 0), "min(): given object has zero rows" ); ea_type A = P.get_ea();
out.set_size(1, X_n_cols); uword i,j;
eT* out_mem = out.memptr(); for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
const eT tmp_i = A[i];
const eT tmp_j = A[j];
for(uword col=0; col<X_n_cols; ++col) if(tmp_i < min_val) { min_val = tmp_i; }
if(tmp_j < min_val) { min_val = tmp_j; }
}
if(i < n_elem)
{ {
out_mem[col] = op_min::direct_min( X.colptr(col), X_n_rows ); const eT tmp_i = A[i];
if(tmp_i < min_val) { min_val = tmp_i; }
} }
} }
else else
if(dim == 1) // min in each row
{ {
arma_extra_debug_print("op_min::apply(), dim = 1"); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
arma_debug_check( (X_n_cols == 0), "min(): given object has zero column if(n_rows == 1)
s" );
out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row)
{ {
out_mem[row] = op_min::direct_min( X, row ); uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp_i = P.at(0,i);
const eT tmp_j = P.at(0,j);
if(tmp_i < min_val) { min_val = tmp_i; }
if(tmp_j < min_val) { min_val = tmp_j; }
}
if(i < n_cols)
{
const eT tmp_i = P.at(0,i);
if(tmp_i < min_val) { min_val = tmp_i; }
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
uword i,j;
for(i=0, j=1; j < n_rows; i+=2, j+=2)
{
const eT tmp_i = P.at(i,col);
const eT tmp_j = P.at(j,col);
if(tmp_i < min_val) { min_val = tmp_i; }
if(tmp_j < min_val) { min_val = tmp_j; }
}
if(i < n_rows)
{
const eT tmp_i = P.at(i,col);
if(tmp_i < min_val) { min_val = tmp_i; }
}
}
} }
} }
return min_val;
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const std::complex<T>* const X, const uword n_elem) op_min::direct_min(const std::complex<T>* const X, const uword n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
uword index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
skipping to change at line 261 skipping to change at line 353
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const std::complex<T>* const X, const uword n_elem, uwor d& index_of_min_val) op_min::direct_min(const std::complex<T>* const X, const uword n_elem, uwor d& index_of_min_val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
uword index = 0; uword index = 0;
T min_val = priv::most_pos<T>(); T min_val = priv::most_pos<T>();
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
const T tmp_val = std::abs(X[i]); const T tmp_val = std::abs(X[i]);
if(tmp_val < min_val) if(tmp_val < min_val)
{ {
min_val = tmp_val; min_val = tmp_val;
index = i; index = i;
} }
skipping to change at line 308 skipping to change at line 400
index = col; index = col;
} }
} }
return X.at(row,index); return X.at(row,index);
} }
template<typename T> template<typename T>
inline inline
std::complex<T> std::complex<T>
op_min::direct_min(const subview< std::complex<T> >& X) op_min::min(const subview< std::complex<T> >& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; arma_debug_check( (X.n_elem == 0), "min(): given object has no elements"
uword index = 0; );
T min_val = priv::most_pos<T>();
const Mat< std::complex<T> >& A = X.m;
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
const uword start_row = X.aux_row1;
const uword start_col = X.aux_col1;
const uword end_row_p1 = start_row + X_n_rows;
const uword end_col_p1 = start_col + X_n_cols;
T min_val = priv::most_pos<T>();
uword best_row = 0;
uword best_col = 0;
for(uword i=0; i<X_n_elem; ++i) if(X_n_rows == 1)
{ {
const T tmp_val = std::abs(X[i]); best_col = 0;
if(tmp_val < min_val) for(uword col=start_col; col < end_col_p1; ++col)
{ {
min_val = tmp_val; const T tmp_val = std::abs( A.at(start_row, col) );
index = i;
if(tmp_val < min_val)
{
min_val = tmp_val;
best_col = col;
}
}
best_row = start_row;
}
else
{
for(uword col=start_col; col < end_col_p1; ++col)
for(uword row=start_row; row < end_row_p1; ++row)
{
const T tmp_val = std::abs( A.at(row, col) );
if(tmp_val < min_val)
{
min_val = tmp_val;
best_row = row;
best_col = col;
}
} }
} }
return X[index]; return A.at(best_row, best_col);
} }
template<typename T> template<typename T1>
inline inline
std::complex<T> typename arma_cx_only<typename T1::elem_type>::result
op_min::direct_min(const diagview< std::complex<T> >& X) op_min::min(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword X_n_elem = X.n_elem; typedef typename T1::elem_type eT;
uword index = 0; typedef typename get_pod_type<eT>::result T;
T min_val = priv::most_pos<T>();
const Proxy<T1> P(X.get_ref());
const uword n_elem = P.get_n_elem();
for(uword i=0; i<X_n_elem; ++i) arma_debug_check( (n_elem == 0), "min(): given object has no elements" );
T min_val = priv::most_pos<T>();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
const T tmp_val = std::abs(X[i]); typedef typename Proxy<T1>::ea_type ea_type;
if(tmp_val < min_val) ea_type A = P.get_ea();
uword index = 0;
for(uword i=0; i<n_elem; ++i)
{ {
min_val = tmp_val; const T tmp = std::abs(A[i]);
index = i;
if(tmp < min_val)
{
min_val = tmp;
index = i;
}
} }
return( A[index] );
} }
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
return X[index]; uword best_row = 0;
uword best_col = 0;
if(n_rows == 1)
{
for(uword col=0; col < n_cols; ++col)
{
const T tmp = std::abs(P.at(0,col));
if(tmp < min_val)
{
min_val = tmp;
best_col = col;
}
}
}
else
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const T tmp = std::abs(P.at(row,col));
if(tmp < min_val)
{
min_val = tmp;
best_row = row;
best_col = col;
}
}
}
return P.at(best_row, best_col);
}
} }
//! @} //! @}
 End of changes. 57 change blocks. 
104 lines changed or deleted 291 lines changed or added


 op_misc_meat.hpp   op_misc_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 25 skipping to change at line 25
template<typename T1> template<typename T1>
inline inline
void void
op_real::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_real>& X ) op_real::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_real>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> P(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_elem = out.n_elem; out.set_size(n_rows, n_cols);
T* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) T* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
out_mem[i] = std::real(A[i]); typedef typename Proxy<T1>::ea_type ea_type;
const uword n_elem = P.get_n_elem();
ea_type A = P.get_ea();
for(uword i=0; i < n_elem; ++i)
{
out_mem[i] = std::real( A[i] );
}
}
else
{
uword count = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row, ++count)
{
out_mem[count] = std::real( P.at(row,col) );
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_real::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_real>& X ) op_real::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_real>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 69 skipping to change at line 89
template<typename T1> template<typename T1>
inline inline
void void
op_imag::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_imag>& X ) op_imag::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::po d_type, T1, op_imag>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> P(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_elem = out.n_elem; out.set_size(n_rows, n_cols);
T* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) T* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
out_mem[i] = std::imag(A[i]); typedef typename Proxy<T1>::ea_type ea_type;
const uword n_elem = P.get_n_elem();
ea_type A = P.get_ea();
for(uword i=0; i < n_elem; ++i)
{
out_mem[i] = std::imag( A[i] );
}
}
else
{
uword count = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row, ++count)
{
out_mem[count] = std::imag( P.at(row,col) );
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_imag::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_imag>& X ) op_imag::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T 1::pod_type, T1, op_imag>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 113 skipping to change at line 153
template<typename T1> template<typename T1>
inline inline
void void
op_abs::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod _type, T1, op_abs>& X ) op_abs::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod _type, T1, op_abs>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const Proxy<T1> A(X.m); const Proxy<T1> P(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols()); const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_elem = out.n_elem; out.set_size(n_rows, n_cols);
T* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) T* out_mem = out.memptr();
if(Proxy<T1>::prefer_at_accessor == false)
{ {
out_mem[i] = std::abs(A[i]); typedef typename Proxy<T1>::ea_type ea_type;
const uword n_elem = P.get_n_elem();
ea_type A = P.get_ea();
for(uword i=0; i < n_elem; ++i)
{
out_mem[i] = std::abs( A[i] );
}
}
else
{
uword count = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row, ++count)
{
out_mem[count] = std::abs( P.at(row,col) );
}
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_abs::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1 ::pod_type, T1, op_abs>& X ) op_abs::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1 ::pod_type, T1, op_abs>& X )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 16 change blocks. 
20 lines changed or deleted 80 lines changed or added


 op_prod_bones.hpp   op_prod_bones.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_prod //! \addtogroup op_prod
//! @{ //! @{
//! Class for finding products of values in a matrix (e.g. along rows or c olumns) //! Class for finding products of values in a matrix (e.g. along rows or c olumns)
class op_prod class op_prod
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1, o p_prod>& in); inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1, o p_prod>& in);
template<typename eT>
inline static eT prod(const subview<eT>& S);
template<typename T1>
inline static typename T1::elem_type prod(const Base<typename T1::elem_ty
pe,T1>& X);
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 9 lines changed or added


 op_prod_meat.hpp   op_prod_meat.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 59 skipping to change at line 59
else // traverse across columns (i.e. find the product in each row) else // traverse across columns (i.e. find the product in each row)
{ {
out.set_size(X_n_rows, 1); out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row) for(uword row=0; row<X_n_rows; ++row)
{ {
eT val = eT(1); eT val = eT(1);
for(uword col=0; col<X_n_cols; ++col) uword i,j;
for(i=0, j=1; j < X_n_cols; i+=2, j+=2)
{ {
val *= X.at(row,col); val *= X.at(row,i);
val *= X.at(row,j);
}
if(i < X_n_cols)
{
val *= X.at(row,i);
} }
out_mem[row] = val; out_mem[row] = val;
} }
} }
} }
template<typename eT>
inline
eT
op_prod::prod(const subview<eT>& X)
{
arma_extra_debug_sigprint();
eT val = eT(1);
const uword X_n_rows = X.n_rows;
const uword X_n_cols = X.n_cols;
if(X_n_rows == 1)
{
const Mat<eT>& A = X.m;
const uword start_row = X.aux_row1;
const uword start_col = X.aux_col1;
const uword end_col_p1 = start_col + X_n_cols;
uword i,j;
for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
{
val *= A.at(start_row, i);
val *= A.at(start_row, j);
}
if(i < end_col_p1)
{
val *= A.at(start_row, i);
}
}
else
{
for(uword col=0; col < X_n_cols; ++col)
{
val *= arrayops::product( X.colptr(col), X_n_rows );
}
}
return val;
}
template<typename T1>
inline
typename T1::elem_type
op_prod::prod(const Base<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const Proxy<T1> P(X.get_ref());
eT val = eT(1);
if(Proxy<T1>::prefer_at_accessor == false)
{
typedef typename Proxy<T1>::ea_type ea_type;
const ea_type A = P.get_ea();
const uword n_elem = P.get_n_elem();
uword i,j;
for(i=0, j=1; j < n_elem; i+=2, j+=2)
{
val *= A[i];
val *= A[j];
}
if(i < n_elem)
{
val *= A[i];
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(n_rows == 1)
{
uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
val *= P.at(0,i);
val *= P.at(0,j);
}
if(i < n_cols)
{
val *= P.at(0,i);
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
uword i,j;
for(i=0, j=1; j < n_rows; i+=2, j+=2)
{
val *= P.at(i,col);
val *= P.at(j,col);
}
if(i < n_rows)
{
val *= P.at(i,col);
}
}
}
}
return val;
}
//! @} //! @}
 End of changes. 4 change blocks. 
4 lines changed or deleted 129 lines changed or added


 op_relational_meat.hpp   op_relational_meat.hpp 
skipping to change at line 56 skipping to change at line 56
ea_type PA = P.get_ea();\ ea_type PA = P.get_ea();\
const uword n_elem = out.n_elem;\ const uword n_elem = out.n_elem;\
\ \
for(uword i=0; i<n_elem; ++i)\ for(uword i=0; i<n_elem; ++i)\
{\ {\
out_mem[i] = (val operator_rel PA[i]) ? uword(1) : uword(0);\ out_mem[i] = (val operator_rel PA[i]) ? uword(1) : uword(0);\
}\ }\
}\ }\
else\ else\
{\ {\
uword count = 0;\ if(n_rows == 1)\
\ {\
for(uword col=0; col < n_cols; ++col)\ for(uword count=0; count < n_cols; ++count)\
for(uword row=0; row < n_rows; ++row, ++count)\ {\
out_mem[count] = (val operator_rel P.at(0,count)) ? uword(1) : uw
ord(0);\
}\
}\
else\
{\ {\
out_mem[count] = (val operator_rel P.at(row,col)) ? uword(1) : uwor uword count = 0;\
d(0);\ \
for(uword col=0; col < n_cols; ++col)\
for(uword row=0; row < n_rows; ++row, ++count)\
{\
out_mem[count] = (val operator_rel P.at(row,col)) ? uword(1) : uw
ord(0);\
}\
}\ }\
}\ }\
}\ }\
else\ else\
{\ {\
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);\ const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);\
\ \
out = (val) operator_rel (tmp.M);\ out = (val) operator_rel (tmp.M);\
}\ }\
} }
skipping to change at line 105 skipping to change at line 115
ea_type PA = P.get_ea();\ ea_type PA = P.get_ea();\
const uword n_elem = out.n_elem;\ const uword n_elem = out.n_elem;\
\ \
for(uword i=0; i<n_elem; ++i)\ for(uword i=0; i<n_elem; ++i)\
{\ {\
out_mem[i] = (PA[i] operator_rel val) ? uword(1) : uword(0);\ out_mem[i] = (PA[i] operator_rel val) ? uword(1) : uword(0);\
}\ }\
}\ }\
else\ else\
{\ {\
uword count = 0;\ if(n_rows == 1)\
\ {\
for(uword col=0; col < n_cols; ++col)\ for(uword count=0; count < n_cols; ++count)\
for(uword row=0; row < n_rows; ++row, ++count)\ {\
out_mem[count] = (P.at(0,count) operator_rel val) ? uword(1) : uw
ord(0);\
}\
}\
else\
{\ {\
out_mem[count] = (P.at(row,col) operator_rel val) ? uword(1) : uwor uword count = 0;\
d(0);\ \
for(uword col=0; col < n_cols; ++col)\
for(uword row=0; row < n_rows; ++row, ++count)\
{\
out_mem[count] = (P.at(row,col) operator_rel val) ? uword(1) : uw
ord(0);\
}\
}\ }\
}\ }\
}\ }\
else\ else\
{\ {\
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);\ const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);\
\ \
out = (tmp.M) operator_rel (val);\ out = (tmp.M) operator_rel (val);\
}\ }\
} }
 End of changes. 4 change blocks. 
12 lines changed or deleted 34 lines changed or added


 op_sum_meat.hpp   op_sum_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 27 skipping to change at line 27
//! Immediate sum of elements of a matrix along a specified dimension (eith er rows or columns). //! Immediate sum of elements of a matrix along a specified dimension (eith er rows or columns).
//! The result is stored in a dense matrix that has either one column or on e row. //! The result is stored in a dense matrix that has either one column or on e row.
//! See the sum() function for more details. //! See the sum() function for more details.
template<typename T1> template<typename T1>
inline inline
void void
op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in) op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword dim = in.aux_uword_a; const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" ); arma_debug_check( (dim > 1), "sum(): incorrect usage. dim must be 0 or 1" );
typedef typename T1::elem_type eT; const Proxy<T1> P(in.m);
const unwrap_check<T1> tmp(in.m, out); if( (is_Mat< typename Proxy<T1>::stored_type>::value == true) || (P.is_al
const Mat<eT>& X = tmp.M; ias(out) == true) )
{
const unwrap_check< typename Proxy<T1>::stored_type > tmp(P.Q, out);
const uword X_n_rows = X.n_rows; const Mat<eT>& X = tmp.M;
const uword X_n_cols = X.n_cols;
if(dim == 0) // traverse across rows (i.e. find the sum in each column) const uword X_n_rows = X.n_rows;
{ const uword X_n_cols = X.n_cols;
out.set_size(1, X_n_cols);
if(dim == 0) // traverse across rows (i.e. find the sum in each column
)
{
out.set_size(1, X_n_cols);
eT* out_mem = out.memptr(); eT* out_mem = out.memptr();
for(uword col=0; col<X_n_cols; ++col) for(uword col=0; col < X_n_cols; ++col)
{
out_mem[col] = arrayops::accumulate( X.colptr(col), X_n_rows );
}
}
else // traverse across columns (i.e. find the sum in each row)
{ {
out_mem[col] = arrayops::accumulate(X.colptr(col), X_n_rows); out.set_size(X_n_rows, 1);
eT* out_mem = out.memptr();
for(uword row=0; row < X_n_rows; ++row)
{
eT val = eT(0);
uword i,j;
for(i=0, j=1; j < X_n_cols; i+=2, j+=2)
{
val += X.at(row,i);
val += X.at(row,j);
}
if(i < X_n_cols)
{
val += X.at(row,i);
}
out_mem[row] = val;
}
} }
} }
else // traverse across columns (i.e. find the sum in each row) else
{ {
out.set_size(X_n_rows, 1); const uword P_n_rows = P.get_n_rows();
const uword P_n_cols = P.get_n_cols();
eT* out_mem = out.memptr(); if(dim == 0) // traverse across rows (i.e. find the sum in each column
)
for(uword row=0; row<X_n_rows; ++row)
{ {
eT val = eT(0); out.set_size(1, P_n_cols);
eT* out_mem = out.memptr();
for(uword col=0; col<X_n_cols; ++col) for(uword col=0; col < P_n_cols; ++col)
{ {
val += X.at(row,col); eT val = eT(0);
uword i,j;
for(i=0, j=1; j < P_n_rows; i+=2, j+=2)
{
val += P.at(i,col);
val += P.at(j,col);
}
if(i < P_n_rows)
{
val += P.at(i,col);
}
out_mem[col] = val;
} }
}
else // traverse across columns (i.e. find the sum in each row)
{
out.set_size(P_n_rows, 1);
eT* out_mem = out.memptr();
for(uword row=0; row < P_n_rows; ++row)
{
eT val = eT(0);
uword i,j;
for(i=0, j=1; j < P_n_cols; i+=2, j+=2)
{
val += P.at(row,i);
val += P.at(row,j);
}
if(i < P_n_cols)
{
val += P.at(row,i);
}
out_mem[row] = val; out_mem[row] = val;
}
} }
} }
} }
//! @} //! @}
 End of changes. 17 change blocks. 
22 lines changed or deleted 94 lines changed or added


 op_var_bones.hpp   op_var_bones.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_var //! \addtogroup op_var
//! @{ //! @{
//! Class for finding variance values of a matrix //! Class for finding variance values of a matrix
class op_var class op_var
{ {
public: public:
template<typename eT> template<typename T1>
inline static eT direct_var(const eT* const X, const uword N, const uword inline static void apply(Mat<typename T1::pod_type>& out, const mtOp<type
norm_type = 0); name T1::pod_type, T1, op_var>& in);
template<typename T>
inline static T direct_var(const std::complex<T>* const X, const uword N
, const uword norm_type = 0);
template<typename eT> //
inline static typename get_pod_type<eT>::result direct_var(const subview_
row<eT>& X, const uword norm_type = 0);
template<typename eT> template<typename eT>
inline static typename get_pod_type<eT>::result direct_var(const subview_ col<eT>& X, const uword norm_type = 0); inline static typename get_pod_type<eT>::result var_vec(const subview_col <eT>& X, const uword norm_type = 0);
template<typename eT> template<typename eT>
inline static typename get_pod_type<eT>::result direct_var(const diagview <eT>& X, const uword norm_type = 0); inline static typename get_pod_type<eT>::result var_vec(const subview_row <eT>& X, const uword norm_type = 0);
template<typename T1> template<typename T1>
inline static void apply(Mat<typename T1::pod_type>& out, const mtOp<type inline static typename T1::pod_type var_vec(const Base<typename T1::elem_
name T1::pod_type, T1, op_var>& in); type, T1>& X, const uword norm_type = 0);
//
template<typename eT>
inline static eT direct_var(const eT* const X, const uword N, const uword
norm_type = 0);
template<typename eT> template<typename eT>
inline static eT direct_var_robust(const eT* const X, const uword N, cons t uword norm_type = 0); inline static eT direct_var_robust(const eT* const X, const uword N, cons t uword norm_type = 0);
//
template<typename T>
inline static T direct_var(const std::complex<T>* const X, const uword N
, const uword norm_type = 0);
template<typename T> template<typename T>
inline static T direct_var_robust(const std::complex<T>* const X, const uword N, const uword norm_type = 0); inline static T direct_var_robust(const std::complex<T>* const X, const uword N, const uword norm_type = 0);
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
16 lines changed or deleted 22 lines changed or added


 op_var_meat.hpp   op_var_meat.hpp 
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_var //! \addtogroup op_var
//! @{ //! @{
//! find the variance of an array //! \brief
template<typename eT> //! For each row or for each column, find the variance.
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the variances are found, is set via the var()
function.
template<typename T1>
inline inline
eT void
op_var::direct_var(const eT* const X, const uword n_elem, const uword norm_ op_var::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_
type) type, T1, op_var>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(n_elem >= 2) typedef typename T1::elem_type in_eT;
{ typedef typename T1::pod_type out_eT;
const eT acc1 = op_mean::direct_mean(X, n_elem);
eT acc2 = eT(0);
eT acc3 = eT(0);
uword i,j; const unwrap_check_mixed<T1> tmp(in.m, out);
const Mat<in_eT>& X = tmp.M;
for(i=0, j=1; j<n_elem; i+=2, j+=2) const uword norm_type = in.aux_uword_a;
{ const uword dim = in.aux_uword_b;
const eT Xi = X[i];
const eT Xj = X[j];
const eT tmpi = acc1 - Xi; arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus
const eT tmpj = acc1 - Xj; t be 0 or 1");
arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0
or 1" );
acc2 += tmpi*tmpi + tmpj*tmpj; const uword X_n_rows = X.n_rows;
acc3 += tmpi + tmpj; const uword X_n_cols = X.n_cols;
}
if(i < n_elem) if(dim == 0)
{ {
const eT Xi = X[i]; arma_extra_debug_print("op_var::apply(), dim = 0");
const eT tmpi = acc1 - Xi; arma_debug_check( (X_n_rows == 0), "var(): given object has zero rows" );
acc2 += tmpi*tmpi; out.set_size(1, X_n_cols);
acc3 += tmpi;
}
const eT norm_val = (norm_type == 0) ? eT(n_elem-1) : eT(n_elem); out_eT* out_mem = out.memptr();
const eT var_val = (acc2 - acc3*acc3/eT(n_elem)) / norm_val;
return arma_isfinite(var_val) ? var_val : op_var::direct_var_robust(X, for(uword col=0; col<X_n_cols; ++col)
n_elem, norm_type); {
out_mem[col] = op_var::direct_var( X.colptr(col), X_n_rows, norm_type
);
}
} }
else else
if(dim == 1)
{ {
return eT(0); arma_extra_debug_print("op_var::apply(), dim = 1");
}
}
//! find the variance of an array (version for complex numbers) arma_debug_check( (X_n_cols == 0), "var(): given object has zero column
template<typename T> s" );
inline
T
op_var::direct_var(const std::complex<T>* const X, const uword n_elem, cons
t uword norm_type)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; out.set_size(X_n_rows, 1);
if(n_elem >= 2) podarray<in_eT> tmp(X_n_cols);
{
const eT acc1 = op_mean::direct_mean(X, n_elem);
T acc2 = T(0); in_eT* tmp_mem = tmp.memptr();
eT acc3 = eT(0); out_eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i) for(uword row=0; row<X_n_rows; ++row)
{ {
const eT tmp = acc1 - X[i]; tmp.copy_row(X, row);
acc2 += std::norm(tmp); out_mem[row] = op_var::direct_var( tmp_mem, X_n_cols, norm_type );
acc3 += tmp;
} }
const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem);
const T var_val = (acc2 - std::norm(acc3)/T(n_elem)) / norm_val;
return arma_isfinite(var_val) ? var_val : op_var::direct_var_robust(X,
n_elem, norm_type);
}
else
{
return T(0);
} }
} }
//! find the variance of a subview_row template<typename T1>
template<typename eT>
inline inline
typename get_pod_type<eT>::result typename T1::pod_type
op_var::direct_var(const subview_row<eT>& X, const uword norm_type) op_var::var_vec(const Base<typename T1::elem_type, T1>& X, const uword norm
_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword n_elem = X.n_elem; typedef typename T1::elem_type eT;
podarray<eT> tmp(n_elem); arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus t be 0 or 1");
eT* tmp_mem = tmp.memptr(); const Proxy<T1> P(X.get_ref());
for(uword i=0; i<n_elem; ++i) const podarray<eT> tmp(P);
{
tmp_mem[i] = X[i];
}
return op_var::direct_var(tmp_mem, n_elem, norm_type); return op_var::direct_var(tmp.memptr(), tmp.n_elem, norm_type);
} }
//! find the variance of a subview_col
template<typename eT> template<typename eT>
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
op_var::direct_var(const subview_col<eT>& X, const uword norm_type) op_var::var_vec(const subview_col<eT>& X, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return op_var::direct_var(X.colptr(0), X.n_elem, norm_type); typedef typename get_pod_type<eT>::result T;
arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus
t be 0 or 1");
return op_var::direct_var(X.colptr(0), X.n_rows, norm_type);
} }
//! find the variance of a diagview
template<typename eT> template<typename eT>
inline inline
typename get_pod_type<eT>::result typename get_pod_type<eT>::result
op_var::direct_var(const diagview<eT>& X, const uword norm_type) op_var::var_vec(const subview_row<eT>& X, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword n_elem = X.n_elem; typedef typename get_pod_type<eT>::result T;
arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus
t be 0 or 1");
const Mat<eT>& A = X.m;
const uword start_row = X.aux_row1;
const uword start_col = X.aux_col1;
podarray<eT> tmp(n_elem); const uword end_col_p1 = start_col + X.n_cols;
podarray<eT> tmp(X.n_elem);
eT* tmp_mem = tmp.memptr(); eT* tmp_mem = tmp.memptr();
for(uword i=0; i<n_elem; ++i) for(uword i=0, col=start_col; col < end_col_p1; ++col, ++i)
{ {
tmp_mem[i] = X[i]; tmp_mem[i] = A.at(start_row, col);
} }
return op_var::direct_var(tmp_mem, n_elem, norm_type); return op_var::direct_var(tmp.memptr(), tmp.n_elem, norm_type);
} }
//! \brief //! find the variance of an array
//! For each row or for each column, find the variance. template<typename eT>
//! The result is stored in a dense matrix that has either one column or on
e row.
//! The dimension, for which the variances are found, is set via the var()
function.
template<typename T1>
inline inline
void eT
op_var::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_ op_var::direct_var(const eT* const X, const uword n_elem, const uword norm_
type, T1, op_var>& in) type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type in_eT; if(n_elem >= 2)
typedef typename T1::pod_type out_eT; {
const eT acc1 = op_mean::direct_mean(X, n_elem);
const unwrap_check_mixed<T1> tmp(in.m, out);
const Mat<in_eT>& X = tmp.M;
const uword norm_type = in.aux_uword_a; eT acc2 = eT(0);
const uword dim = in.aux_uword_b; eT acc3 = eT(0);
arma_debug_check( (norm_type > 1), "var(): incorrect usage. norm_type mus uword i,j;
t be 0 or 1");
arma_debug_check( (dim > 1), "var(): incorrect usage. dim must be 0
or 1" );
const uword X_n_rows = X.n_rows; for(i=0, j=1; j<n_elem; i+=2, j+=2)
const uword X_n_cols = X.n_cols; {
const eT Xi = X[i];
const eT Xj = X[j];
if(dim == 0) const eT tmpi = acc1 - Xi;
{ const eT tmpj = acc1 - Xj;
arma_extra_debug_print("op_var::apply(), dim = 0");
arma_debug_check( (X_n_rows == 0), "var(): given object has zero rows" acc2 += tmpi*tmpi + tmpj*tmpj;
); acc3 += tmpi + tmpj;
}
out.set_size(1, X_n_cols); if(i < n_elem)
{
const eT Xi = X[i];
out_eT* out_mem = out.memptr(); const eT tmpi = acc1 - Xi;
for(uword col=0; col<X_n_cols; ++col) acc2 += tmpi*tmpi;
{ acc3 += tmpi;
out_mem[col] = op_var::direct_var( X.colptr(col), X_n_rows, norm_type
);
} }
const eT norm_val = (norm_type == 0) ? eT(n_elem-1) : eT(n_elem);
const eT var_val = (acc2 - acc3*acc3/eT(n_elem)) / norm_val;
return arma_isfinite(var_val) ? var_val : op_var::direct_var_robust(X,
n_elem, norm_type);
} }
else else
if(dim == 1)
{ {
arma_extra_debug_print("op_var::apply(), dim = 1"); return eT(0);
arma_debug_check( (X_n_cols == 0), "var(): given object has zero column
s" );
out.set_size(X_n_rows, 1);
podarray<in_eT> tmp(X_n_cols);
in_eT* tmp_mem = tmp.memptr();
out_eT* out_mem = out.memptr();
for(uword row=0; row<X_n_rows; ++row)
{
tmp.copy_row(X, row);
out_mem[row] = op_var::direct_var( tmp_mem, X_n_cols, norm_type );
}
} }
} }
//! find the variance of an array (robust but slow) //! find the variance of an array (robust but slow)
template<typename eT> template<typename eT>
inline inline
eT eT
op_var::direct_var_robust(const eT* const X, const uword n_elem, const uwor d norm_type) op_var::direct_var_robust(const eT* const X, const uword n_elem, const uwor d norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 252 skipping to change at line 222
} }
return (norm_type == 0) ? r_var : (eT(n_elem-1)/eT(n_elem)) * r_var; return (norm_type == 0) ? r_var : (eT(n_elem-1)/eT(n_elem)) * r_var;
} }
else else
{ {
return eT(0); return eT(0);
} }
} }
//! find the variance of an array (version for complex numbers)
template<typename T>
inline
T
op_var::direct_var(const std::complex<T>* const X, const uword n_elem, cons
t uword norm_type)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
if(n_elem >= 2)
{
const eT acc1 = op_mean::direct_mean(X, n_elem);
T acc2 = T(0);
eT acc3 = eT(0);
for(uword i=0; i<n_elem; ++i)
{
const eT tmp = acc1 - X[i];
acc2 += std::norm(tmp);
acc3 += tmp;
}
const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem);
const T var_val = (acc2 - std::norm(acc3)/T(n_elem)) / norm_val;
return arma_isfinite(var_val) ? var_val : op_var::direct_var_robust(X,
n_elem, norm_type);
}
else
{
return T(0);
}
}
//! find the variance of an array (version for complex numbers) (robust but slow) //! find the variance of an array (version for complex numbers) (robust but slow)
template<typename T> template<typename T>
inline inline
T T
op_var::direct_var_robust(const std::complex<T>* const X, const uword n_ele m, const uword norm_type) op_var::direct_var_robust(const std::complex<T>* const X, const uword n_ele m, const uword norm_type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
 End of changes. 56 change blocks. 
140 lines changed or deleted 148 lines changed or added


 operator_div.hpp   operator_div.hpp 
// Copyright (C) 2009-2010 NICTA (www.nicta.com.au) // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Conrad Sanderson // Copyright (C) 2009-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 113 skipping to change at line 113
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_div>( X.get_ref(), Y.get_ref() ) ; return mtGlue<out_eT, T1, T2, glue_mixed_div>( X.get_ref(), Y.get_ref() ) ;
} }
//
//
//
#undef armaObj
#undef armaObjA
#undef armaObjB
#undef arma_operator_obj_scalar
#undef arma_operator_scalar_obj
#undef arma_operator_obj_cx_scalar
#undef arma_operator_cx_scalar_obj
#undef arma_operator_obj_base
#undef arma_operator_base_obj
#undef arma_operator_obj1_obj2
#undef arma_operator_obj1_obj2_mixed
#define arma_operator_obj_scalar(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_div_post> \
operator/ \
(const armaObj<eT>& X, const typename armaObj<eT>::elem_type k) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_div_post>(X, k); \
}
#define arma_operator_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_div_pre> \
operator/ \
(const typename armaObj<eT>::elem_type k, const armaObj<eT>& X) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_div_pre>(X, k); \
}
#define arma_operator_obj_cx_scalar(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_div_post> \
operator/ \
( \
const armaObj<eT>& X, \
const std::complex<typename armaObj<eT>::pod_type>& k \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_div_post>('j', X, k); \
}
#define arma_operator_cx_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_div_pre> \
operator/ \
( \
const std::complex<typename armaObj<eT>::pod_type>& k, \
const armaObj<eT>& X \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_div_pre>('j', X, k); \
}
#define arma_operator_obj_base(armaObj) \
template<typename BT> \
arma_inline \
const eGlue<armaObj<typename BT::elem_type>, BT, eglue_div> \
operator/ \
( \
const armaObj<typename BT::elem_type>& X, \
const Base<typename BT::elem_type, BT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<armaObj<typename BT::elem_type>, BT, eglue_div>(X, Y.get_ref
()); \
}
#define arma_operator_base_obj(armaObj) \
template<typename BT> \
arma_inline \
const eGlue<BT, armaObj<typename BT::elem_type>, eglue_div> \
operator/ \
( \
const Base<typename BT::elem_type, BT>& X, \
const armaObj<typename BT::elem_type> & Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<BT, armaObj<typename BT::elem_type>, eglue_div>(X.get_ref(),
Y); \
}
#define arma_operator_obj1_obj2(armaObjA, armaObjB) \
template<typename eT> \
arma_inline \
const eGlue<armaObjA<eT>, armaObjB<eT>, eglue_div> \
operator/ \
( \
const armaObjA<eT>& X, \
const armaObjB<eT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<armaObjA<eT>, armaObjB<eT>, eglue_div>(X, Y); \
}
#define arma_operator_obj1_obj2_mixed(armaObjA, armaObjB) \
template<typename eT1, typename eT2> \
inline \
const mtGlue<typename promote_type<eT1, eT2>::result, armaObjA<eT1>, armaOb
jB<eT2>, glue_mixed_div> \
operator/ \
( \
const armaObjA<eT1>& X, \
const armaObjB<eT2>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
typedef typename promote_type<eT1,eT2>::result out_eT; \
\
promote_type<eT1,eT2>::check(); \
\
return mtGlue<out_eT, armaObjA<eT1>, armaObjB<eT2>, glue_mixed_div>( X, Y
); \
}
arma_operator_obj_scalar(Col)
arma_operator_obj_scalar(Row)
arma_operator_obj_scalar(diagview)
arma_operator_obj_scalar(subview_col)
arma_operator_obj_scalar(subview_row)
arma_operator_scalar_obj(Col)
arma_operator_scalar_obj(Row)
arma_operator_scalar_obj(diagview)
arma_operator_scalar_obj(subview_col)
arma_operator_scalar_obj(subview_row)
arma_operator_obj_cx_scalar(Col)
arma_operator_obj_cx_scalar(Row)
arma_operator_obj_cx_scalar(diagview)
arma_operator_obj_cx_scalar(subview_col)
arma_operator_obj_cx_scalar(subview_row)
arma_operator_cx_scalar_obj(Col)
arma_operator_cx_scalar_obj(Row)
arma_operator_cx_scalar_obj(diagview)
arma_operator_cx_scalar_obj(subview_col)
arma_operator_cx_scalar_obj(subview_row)
arma_operator_obj_base(Col)
arma_operator_obj_base(Row)
arma_operator_obj_base(diagview)
arma_operator_obj_base(subview_col)
arma_operator_obj_base(subview_row)
arma_operator_base_obj(Col)
arma_operator_base_obj(Row)
arma_operator_base_obj(diagview)
arma_operator_base_obj(subview_col)
arma_operator_base_obj(subview_row)
arma_operator_obj1_obj2(Col,Col)
arma_operator_obj1_obj2(Col,Row)
arma_operator_obj1_obj2(Col,diagview)
arma_operator_obj1_obj2(Col,subview_col)
arma_operator_obj1_obj2(Col,subview_row)
arma_operator_obj1_obj2(Row,Col)
arma_operator_obj1_obj2(Row,Row)
arma_operator_obj1_obj2(Row,diagview)
arma_operator_obj1_obj2(Row,subview_col)
arma_operator_obj1_obj2(Row,subview_row)
arma_operator_obj1_obj2(diagview,Col)
arma_operator_obj1_obj2(diagview,Row)
arma_operator_obj1_obj2(diagview,diagview)
arma_operator_obj1_obj2(diagview,subview_col)
arma_operator_obj1_obj2(diagview,subview_row)
arma_operator_obj1_obj2(subview_col,Col)
arma_operator_obj1_obj2(subview_col,Row)
arma_operator_obj1_obj2(subview_col,diagview)
arma_operator_obj1_obj2(subview_col,subview_col)
arma_operator_obj1_obj2(subview_col,subview_row)
arma_operator_obj1_obj2(subview_row,Col)
arma_operator_obj1_obj2(subview_row,Row)
arma_operator_obj1_obj2(subview_row,diagview)
arma_operator_obj1_obj2(subview_row,subview_col)
arma_operator_obj1_obj2(subview_row,subview_row)
arma_operator_obj1_obj2_mixed(Col,Col)
arma_operator_obj1_obj2_mixed(Col,Row)
arma_operator_obj1_obj2_mixed(Col,diagview)
arma_operator_obj1_obj2_mixed(Col,subview_col)
arma_operator_obj1_obj2_mixed(Col,subview_row)
arma_operator_obj1_obj2_mixed(Row,Col)
arma_operator_obj1_obj2_mixed(Row,Row)
arma_operator_obj1_obj2_mixed(Row,diagview)
arma_operator_obj1_obj2_mixed(Row,subview_col)
arma_operator_obj1_obj2_mixed(Row,subview_row)
arma_operator_obj1_obj2_mixed(diagview,Col)
arma_operator_obj1_obj2_mixed(diagview,Row)
arma_operator_obj1_obj2_mixed(diagview,diagview)
arma_operator_obj1_obj2_mixed(diagview,subview_col)
arma_operator_obj1_obj2_mixed(diagview,subview_row)
arma_operator_obj1_obj2_mixed(subview_col,Col)
arma_operator_obj1_obj2_mixed(subview_col,Row)
arma_operator_obj1_obj2_mixed(subview_col,diagview)
arma_operator_obj1_obj2_mixed(subview_col,subview_col)
arma_operator_obj1_obj2_mixed(subview_col,subview_row)
arma_operator_obj1_obj2_mixed(subview_row,Col)
arma_operator_obj1_obj2_mixed(subview_row,Row)
arma_operator_obj1_obj2_mixed(subview_row,diagview)
arma_operator_obj1_obj2_mixed(subview_row,subview_col)
arma_operator_obj1_obj2_mixed(subview_row,subview_row)
// TODO: explicit handling of subview_elem1, perhaps via expanding the abov
e macros to take another paramater (for template<T1>)
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 243 lines changed or added


 operator_minus.hpp   operator_minus.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 137 skipping to change at line 137
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_minus>( X.get_ref(), Y.get_ref() ); return mtGlue<out_eT, T1, T2, glue_mixed_minus>( X.get_ref(), Y.get_ref() );
} }
//
//
//
#undef armaObj
#undef armaObjA
#undef armaObjB
#undef arma_operator_unary
#undef arma_operator_obj_scalar
#undef arma_operator_scalar_obj
#undef arma_operator_obj_cx_scalar
#undef arma_operator_cx_scalar_obj
#undef arma_operator_obj_base
#undef arma_operator_base_obj
#undef arma_operator_obj1_obj2
#undef arma_operator_obj1_obj2_mixed
#define arma_operator_unary(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_neg> \
operator- \
(const armaObj<eT>& X) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>,eop_neg>(X); \
}
#define arma_operator_obj_scalar(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_minus_post> \
operator- \
(const armaObj<eT>& X, const typename armaObj<eT>::elem_type k) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_minus_post>(X, k); \
}
#define arma_operator_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_minus_pre> \
operator- \
(const typename armaObj<eT>::elem_type k, const armaObj<eT>& X) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_minus_pre>(X, k); \
}
#define arma_operator_obj_cx_scalar(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_minus_post> \
operator- \
( \
const armaObj<eT>& X, \
const std::complex<typename armaObj<eT>::pod_type>& k \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_minus_post>('j', X, k); \
}
#define arma_operator_cx_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_minus_pre> \
operator- \
( \
const std::complex<typename armaObj<eT>::pod_type>& k, \
const armaObj<eT>& X \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_minus_pre>('j', X, k); \
}
#define arma_operator_obj_base(armaObj) \
template<typename BT> \
arma_inline \
const eGlue<armaObj<typename BT::elem_type>, BT, eglue_minus> \
operator- \
( \
const armaObj<typename BT::elem_type>& X, \
const Base<typename BT::elem_type, BT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<armaObj<typename BT::elem_type>, BT, eglue_minus>(X, Y.get_r
ef()); \
}
#define arma_operator_base_obj(armaObj) \
template<typename BT> \
arma_inline \
const eGlue<BT, armaObj<typename BT::elem_type>, eglue_minus> \
operator- \
( \
const Base<typename BT::elem_type, BT>& X, \
const armaObj<typename BT::elem_type> & Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<BT, armaObj<typename BT::elem_type>, eglue_minus>(X.get_ref(
), Y); \
}
#define arma_operator_obj1_obj2(armaObjA, armaObjB) \
template<typename eT> \
arma_inline \
const eGlue<armaObjA<eT>, armaObjB<eT>, eglue_minus> \
operator- \
( \
const armaObjA<eT>& X, \
const armaObjB<eT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<armaObjA<eT>, armaObjB<eT>, eglue_minus>(X, Y); \
}
#define arma_operator_obj1_obj2_mixed(armaObjA, armaObjB) \
template<typename eT1, typename eT2> \
inline \
const mtGlue<typename promote_type<eT1, eT2>::result, armaObjA<eT1>, armaOb
jB<eT2>, glue_mixed_minus> \
operator- \
( \
const armaObjA<eT1>& X, \
const armaObjB<eT2>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
typedef typename promote_type<eT1,eT2>::result out_eT; \
\
promote_type<eT1,eT2>::check(); \
\
return mtGlue<out_eT, armaObjA<eT1>, armaObjB<eT2>, glue_mixed_minus>( X,
Y ); \
}
arma_operator_unary(Col)
arma_operator_unary(Row)
arma_operator_unary(diagview)
arma_operator_unary(subview_col)
arma_operator_unary(subview_row)
arma_operator_obj_scalar(Col)
arma_operator_obj_scalar(Row)
arma_operator_obj_scalar(diagview)
arma_operator_obj_scalar(subview_col)
arma_operator_obj_scalar(subview_row)
arma_operator_scalar_obj(Col)
arma_operator_scalar_obj(Row)
arma_operator_scalar_obj(diagview)
arma_operator_scalar_obj(subview_col)
arma_operator_scalar_obj(subview_row)
arma_operator_obj_cx_scalar(Col)
arma_operator_obj_cx_scalar(Row)
arma_operator_obj_cx_scalar(diagview)
arma_operator_obj_cx_scalar(subview_col)
arma_operator_obj_cx_scalar(subview_row)
arma_operator_cx_scalar_obj(Col)
arma_operator_cx_scalar_obj(Row)
arma_operator_cx_scalar_obj(diagview)
arma_operator_cx_scalar_obj(subview_col)
arma_operator_cx_scalar_obj(subview_row)
arma_operator_obj_base(Col)
arma_operator_obj_base(Row)
arma_operator_obj_base(diagview)
arma_operator_obj_base(subview_col)
arma_operator_obj_base(subview_row)
arma_operator_base_obj(Col)
arma_operator_base_obj(Row)
arma_operator_base_obj(diagview)
arma_operator_base_obj(subview_col)
arma_operator_base_obj(subview_row)
arma_operator_obj1_obj2(Col,Col)
arma_operator_obj1_obj2(Col,Row)
arma_operator_obj1_obj2(Col,diagview)
arma_operator_obj1_obj2(Col,subview_col)
arma_operator_obj1_obj2(Col,subview_row)
arma_operator_obj1_obj2(Row,Col)
arma_operator_obj1_obj2(Row,Row)
arma_operator_obj1_obj2(Row,diagview)
arma_operator_obj1_obj2(Row,subview_col)
arma_operator_obj1_obj2(Row,subview_row)
arma_operator_obj1_obj2(diagview,Col)
arma_operator_obj1_obj2(diagview,Row)
arma_operator_obj1_obj2(diagview,diagview)
arma_operator_obj1_obj2(diagview,subview_col)
arma_operator_obj1_obj2(diagview,subview_row)
arma_operator_obj1_obj2(subview_col,Col)
arma_operator_obj1_obj2(subview_col,Row)
arma_operator_obj1_obj2(subview_col,diagview)
arma_operator_obj1_obj2(subview_col,subview_col)
arma_operator_obj1_obj2(subview_col,subview_row)
arma_operator_obj1_obj2(subview_row,Col)
arma_operator_obj1_obj2(subview_row,Row)
arma_operator_obj1_obj2(subview_row,diagview)
arma_operator_obj1_obj2(subview_row,subview_col)
arma_operator_obj1_obj2(subview_row,subview_row)
arma_operator_obj1_obj2_mixed(Col,Col)
arma_operator_obj1_obj2_mixed(Col,Row)
arma_operator_obj1_obj2_mixed(Col,diagview)
arma_operator_obj1_obj2_mixed(Col,subview_col)
arma_operator_obj1_obj2_mixed(Col,subview_row)
arma_operator_obj1_obj2_mixed(Row,Col)
arma_operator_obj1_obj2_mixed(Row,Row)
arma_operator_obj1_obj2_mixed(Row,diagview)
arma_operator_obj1_obj2_mixed(Row,subview_col)
arma_operator_obj1_obj2_mixed(Row,subview_row)
arma_operator_obj1_obj2_mixed(diagview,Col)
arma_operator_obj1_obj2_mixed(diagview,Row)
arma_operator_obj1_obj2_mixed(diagview,diagview)
arma_operator_obj1_obj2_mixed(diagview,subview_col)
arma_operator_obj1_obj2_mixed(diagview,subview_row)
arma_operator_obj1_obj2_mixed(subview_col,Col)
arma_operator_obj1_obj2_mixed(subview_col,Row)
arma_operator_obj1_obj2_mixed(subview_col,diagview)
arma_operator_obj1_obj2_mixed(subview_col,subview_col)
arma_operator_obj1_obj2_mixed(subview_col,subview_row)
arma_operator_obj1_obj2_mixed(subview_row,Col)
arma_operator_obj1_obj2_mixed(subview_row,Row)
arma_operator_obj1_obj2_mixed(subview_row,diagview)
arma_operator_obj1_obj2_mixed(subview_row,subview_col)
arma_operator_obj1_obj2_mixed(subview_row,subview_row)
// TODO: explicit handling of subview_elem1, perhaps via expanding the abov
e macros to take another paramater (for template<T1>)
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 262 lines changed or added


 operator_plus.hpp   operator_plus.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup operator_plus //! \addtogroup operator_plus
//! @{ //! @{
//! unary plus operation (does nothing, but is required for completeness) //! unary plus operation (does nothing, but is required for completeness)
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const Base<typename T1::elem_type,T1>&
operator+ operator+
(const Base<typename T1::elem_type,T1>& X) (const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return X.get_ref(); return X;
} }
//! Base + scalar //! Base + scalar
template<typename T1> template<typename T1>
arma_inline arma_inline
const eOp<T1, eop_scalar_plus> const eOp<T1, eop_scalar_plus>
operator+ operator+
(const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type k) (const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type k)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 52 skipping to change at line 52
arma_inline arma_inline
const eOp<T1, eop_scalar_plus> const eOp<T1, eop_scalar_plus>
operator+ operator+
(const typename T1::elem_type k, const Base<typename T1::elem_type,T1>& X) (const typename T1::elem_type k, const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<T1, eop_scalar_plus>(X.get_ref(), k); // NOTE: order is swapp ed return eOp<T1, eop_scalar_plus>(X.get_ref(), k); // NOTE: order is swapp ed
} }
//! non-complex Base + complex scalar (experimental) //! non-complex Base + complex scalar
template<typename T1> template<typename T1>
arma_inline arma_inline
const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_p lus> const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_p lus>
operator+ operator+
( (
const Base<typename T1::pod_type, T1>& X, const Base<typename T1::pod_type, T1>& X,
const std::complex<typename T1::pod_type>& k const std::complex<typename T1::pod_type>& k
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scala r_plus>('j', X.get_ref(), k); return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scala r_plus>('j', X.get_ref(), k);
} }
//! complex scalar + non-complex Base (experimental) //! complex scalar + non-complex Base
template<typename T1> template<typename T1>
arma_inline arma_inline
const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_p lus> const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_p lus>
operator+ operator+
( (
const std::complex<typename T1::pod_type>& k, const std::complex<typename T1::pod_type>& k,
const Base<typename T1::pod_type, T1>& X const Base<typename T1::pod_type, T1>& X
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 119 skipping to change at line 119
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_plus>( X.get_ref(), Y.get_ref() ); return mtGlue<out_eT, T1, T2, glue_mixed_plus>( X.get_ref(), Y.get_ref() );
} }
//
//
//
#undef armaObj
#undef armaObjA
#undef armaObjB
#undef arma_operator_unary
#undef arma_operator_obj_scalar
#undef arma_operator_scalar_obj
#undef arma_operator_obj_cx_scalar
#undef arma_operator_cx_scalar_obj
#undef arma_operator_obj_base
#undef arma_operator_base_obj
#undef arma_operator_obj1_obj2
#undef arma_operator_obj1_obj2_mixed
#define arma_operator_unary(armaObj) \
template<typename eT> \
arma_inline \
const armaObj<eT>& \
operator+ \
(const armaObj<eT>& X) \
{ \
arma_extra_debug_sigprint(); \
\
return X; \
}
#define arma_operator_obj_scalar(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_plus> \
operator+ \
(const armaObj<eT>& X, const typename armaObj<eT>::elem_type k) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_plus>(X, k); \
}
#define arma_operator_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_plus> \
operator+ \
(const typename armaObj<eT>::elem_type k, const armaObj<eT>& X) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_plus>(X, k); \
}
#define arma_operator_obj_cx_scalar(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_plus> \
operator+ \
( \
const armaObj<eT>& X, \
const std::complex<typename armaObj<eT>::pod_type>& k \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_plus>('j', X, k); \
}
#define arma_operator_cx_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_plus> \
operator+ \
( \
const std::complex<typename armaObj<eT>::pod_type>& k, \
const armaObj<eT>& X \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_plus>('j', X, k); \
}
#define arma_operator_obj_base(armaObj) \
template<typename BT> \
arma_inline \
const eGlue<armaObj<typename BT::elem_type>, BT, eglue_plus> \
operator+ \
( \
const armaObj<typename BT::elem_type>& X, \
const Base<typename BT::elem_type, BT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<armaObj<typename BT::elem_type>, BT, eglue_plus>(X, Y.get_re
f()); \
}
#define arma_operator_base_obj(armaObj) \
template<typename BT> \
arma_inline \
const eGlue<BT, armaObj<typename BT::elem_type>, eglue_plus> \
operator+ \
( \
const Base<typename BT::elem_type, BT>& X, \
const armaObj<typename BT::elem_type> & Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<BT, armaObj<typename BT::elem_type>, eglue_plus>(X.get_ref()
, Y); \
}
#define arma_operator_obj1_obj2(armaObjA, armaObjB) \
template<typename eT> \
arma_inline \
const eGlue<armaObjA<eT>, armaObjB<eT>, eglue_plus> \
operator+ \
( \
const armaObjA<eT>& X, \
const armaObjB<eT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return eGlue<armaObjA<eT>, armaObjB<eT>, eglue_plus>(X, Y); \
}
#define arma_operator_obj1_obj2_mixed(armaObjA, armaObjB) \
template<typename eT1, typename eT2> \
inline \
const mtGlue<typename promote_type<eT1, eT2>::result, armaObjA<eT1>, armaOb
jB<eT2>, glue_mixed_plus> \
operator+ \
( \
const armaObjA<eT1>& X, \
const armaObjB<eT2>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
typedef typename promote_type<eT1,eT2>::result out_eT; \
\
promote_type<eT1,eT2>::check(); \
\
return mtGlue<out_eT, armaObjA<eT1>, armaObjB<eT2>, glue_mixed_plus>( X,
Y ); \
}
arma_operator_unary(Col)
arma_operator_unary(Row)
arma_operator_unary(diagview)
arma_operator_unary(subview_col)
arma_operator_unary(subview_row)
arma_operator_obj_scalar(Col)
arma_operator_obj_scalar(Row)
arma_operator_obj_scalar(diagview)
arma_operator_obj_scalar(subview_col)
arma_operator_obj_scalar(subview_row)
arma_operator_scalar_obj(Col)
arma_operator_scalar_obj(Row)
arma_operator_scalar_obj(diagview)
arma_operator_scalar_obj(subview_col)
arma_operator_scalar_obj(subview_row)
arma_operator_obj_cx_scalar(Col)
arma_operator_obj_cx_scalar(Row)
arma_operator_obj_cx_scalar(diagview)
arma_operator_obj_cx_scalar(subview_col)
arma_operator_obj_cx_scalar(subview_row)
arma_operator_cx_scalar_obj(Col)
arma_operator_cx_scalar_obj(Row)
arma_operator_cx_scalar_obj(diagview)
arma_operator_cx_scalar_obj(subview_col)
arma_operator_cx_scalar_obj(subview_row)
arma_operator_obj_base(Col)
arma_operator_obj_base(Row)
arma_operator_obj_base(diagview)
arma_operator_obj_base(subview_col)
arma_operator_obj_base(subview_row)
arma_operator_base_obj(Col)
arma_operator_base_obj(Row)
arma_operator_base_obj(diagview)
arma_operator_base_obj(subview_col)
arma_operator_base_obj(subview_row)
arma_operator_obj1_obj2(Col,Col)
arma_operator_obj1_obj2(Col,Row)
arma_operator_obj1_obj2(Col,diagview)
arma_operator_obj1_obj2(Col,subview_col)
arma_operator_obj1_obj2(Col,subview_row)
arma_operator_obj1_obj2(Row,Col)
arma_operator_obj1_obj2(Row,Row)
arma_operator_obj1_obj2(Row,diagview)
arma_operator_obj1_obj2(Row,subview_col)
arma_operator_obj1_obj2(Row,subview_row)
arma_operator_obj1_obj2(diagview,Col)
arma_operator_obj1_obj2(diagview,Row)
arma_operator_obj1_obj2(diagview,diagview)
arma_operator_obj1_obj2(diagview,subview_col)
arma_operator_obj1_obj2(diagview,subview_row)
arma_operator_obj1_obj2(subview_col,Col)
arma_operator_obj1_obj2(subview_col,Row)
arma_operator_obj1_obj2(subview_col,diagview)
arma_operator_obj1_obj2(subview_col,subview_col)
arma_operator_obj1_obj2(subview_col,subview_row)
arma_operator_obj1_obj2(subview_row,Col)
arma_operator_obj1_obj2(subview_row,Row)
arma_operator_obj1_obj2(subview_row,diagview)
arma_operator_obj1_obj2(subview_row,subview_col)
arma_operator_obj1_obj2(subview_row,subview_row)
arma_operator_obj1_obj2_mixed(Col,Col)
arma_operator_obj1_obj2_mixed(Col,Row)
arma_operator_obj1_obj2_mixed(Col,diagview)
arma_operator_obj1_obj2_mixed(Col,subview_col)
arma_operator_obj1_obj2_mixed(Col,subview_row)
arma_operator_obj1_obj2_mixed(Row,Col)
arma_operator_obj1_obj2_mixed(Row,Row)
arma_operator_obj1_obj2_mixed(Row,diagview)
arma_operator_obj1_obj2_mixed(Row,subview_col)
arma_operator_obj1_obj2_mixed(Row,subview_row)
arma_operator_obj1_obj2_mixed(diagview,Col)
arma_operator_obj1_obj2_mixed(diagview,Row)
arma_operator_obj1_obj2_mixed(diagview,diagview)
arma_operator_obj1_obj2_mixed(diagview,subview_col)
arma_operator_obj1_obj2_mixed(diagview,subview_row)
arma_operator_obj1_obj2_mixed(subview_col,Col)
arma_operator_obj1_obj2_mixed(subview_col,Row)
arma_operator_obj1_obj2_mixed(subview_col,diagview)
arma_operator_obj1_obj2_mixed(subview_col,subview_col)
arma_operator_obj1_obj2_mixed(subview_col,subview_row)
arma_operator_obj1_obj2_mixed(subview_row,Col)
arma_operator_obj1_obj2_mixed(subview_row,Row)
arma_operator_obj1_obj2_mixed(subview_row,diagview)
arma_operator_obj1_obj2_mixed(subview_row,subview_col)
arma_operator_obj1_obj2_mixed(subview_row,subview_row)
// TODO: explicit handling of subview_elem1, perhaps via expanding the abov
e macros to take another paramater (for template<T1>)
//! @} //! @}
 End of changes. 6 change blocks. 
6 lines changed or deleted 266 lines changed or added


 operator_times.hpp   operator_times.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 187 skipping to change at line 187
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2; typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT; typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check(); promote_type<eT1,eT2>::check();
return mtGlue<out_eT, T1, T2, glue_mixed_times>( X.get_ref(), Y.get_ref() ); return mtGlue<out_eT, T1, T2, glue_mixed_times>( X.get_ref(), Y.get_ref() );
} }
//
//
//
#undef armaObj
#undef armaObjA
#undef armaObjB
// TODO: add handling of scalar*trans(object)
// TODO: add handling of trans(object)*scalar
#undef arma_operator_obj_scalar
#undef arma_operator_scalar_obj
#undef arma_operator_obj_cx_scalar
#undef arma_operator_cx_scalar_obj
#undef arma_operator_obj_base
#undef arma_operator_base_obj
#undef arma_operator_obj_diagmat
#undef arma_operator_diagmat_obj
#undef arma_operator_obj1_obj2
#undef arma_operator_obj1_obj2_mixed
#define arma_operator_obj_scalar(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_times> \
operator* \
(const armaObj<eT>& X, const typename armaObj<eT>::elem_type k) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_times>(X, k); \
}
#define arma_operator_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const eOp<armaObj<eT>, eop_scalar_times> \
operator* \
(const typename armaObj<eT>::elem_type k, const armaObj<eT>& X) \
{ \
arma_extra_debug_sigprint(); \
\
return eOp<armaObj<eT>, eop_scalar_times>(X, k); \
}
#define arma_operator_obj_cx_scalar(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_times> \
operator* \
( \
const armaObj<eT>& X, \
const std::complex<typename armaObj<eT>::pod_type>& k \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_times>('j', X, k); \
}
#define arma_operator_cx_scalar_obj(armaObj) \
template<typename eT> \
arma_inline \
const mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaObj<e
T>, op_cx_scalar_times> \
operator* \
( \
const std::complex<typename armaObj<eT>::pod_type>& k, \
const armaObj<eT>& X \
) \
{ \
arma_extra_debug_sigprint(); \
\
return mtOp<typename std::complex<typename armaObj<eT>::pod_type>, armaOb
j<eT>, op_cx_scalar_times>('j', X, k); \
}
#define arma_operator_obj_base(armaObj) \
template<typename BT> \
arma_inline \
const Glue<armaObj<typename BT::elem_type>, BT, glue_times> \
operator* \
( \
const armaObj<typename BT::elem_type>& X, \
const Base<typename BT::elem_type, BT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return Glue<armaObj<typename BT::elem_type>, BT, glue_times>(X, Y.get_ref
()); \
}
#define arma_operator_base_obj(armaObj) \
template<typename BT> \
arma_inline \
const Glue<BT, armaObj<typename BT::elem_type>, glue_times> \
operator* \
( \
const Base<typename BT::elem_type, BT>& X, \
const armaObj<typename BT::elem_type> & Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return Glue<BT, armaObj<typename BT::elem_type>, glue_times>(X.get_ref(),
Y); \
}
#define arma_operator_obj_diagmat(armaObj) \
template<typename T1> \
arma_inline \
const Glue< armaObj<typename T1::elem_type>, Op<T1, op_diagmat>, glue_times
_diag > \
operator* \
( \
const armaObj<typename T1::elem_type>& X, \
const Op<T1, op_diagmat>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return Glue< armaObj<typename T1::elem_type>, Op<T1, op_diagmat>, glue_ti
mes_diag >(X, Y); \
}
#define arma_operator_diagmat_obj(armaObj) \
template<typename T1> \
arma_inline \
const Glue< Op<T1, op_diagmat>, armaObj<typename T1::elem_type>, glue_times
_diag > \
operator* \
( \
const Op<T1, op_diagmat>& X, \
const armaObj<typename T1::elem_type>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return Glue< Op<T1, op_diagmat>, armaObj<typename T1::elem_type>, glue_ti
mes_diag >(X, Y); \
}
#define arma_operator_obj1_obj2(armaObjA, armaObjB) \
template<typename eT> \
arma_inline \
const Glue<armaObjA<eT>, armaObjB<eT>, glue_times> \
operator* \
( \
const armaObjA<eT>& X, \
const armaObjB<eT>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
return Glue<armaObjA<eT>, armaObjB<eT>, glue_times>(X, Y); \
}
#define arma_operator_obj1_obj2_mixed(armaObjA, armaObjB) \
template<typename eT1, typename eT2> \
inline \
const mtGlue<typename promote_type<eT1, eT2>::result, armaObjA<eT1>, armaOb
jB<eT2>, glue_mixed_times> \
operator* \
( \
const armaObjA<eT1>& X, \
const armaObjB<eT2>& Y \
) \
{ \
arma_extra_debug_sigprint(); \
\
typedef typename promote_type<eT1,eT2>::result out_eT; \
\
promote_type<eT1,eT2>::check(); \
\
return mtGlue<out_eT, armaObjA<eT1>, armaObjB<eT2>, glue_mixed_times>( X,
Y ); \
}
arma_operator_obj_scalar(Col)
arma_operator_obj_scalar(Row)
arma_operator_obj_scalar(diagview)
arma_operator_obj_scalar(subview_col)
arma_operator_obj_scalar(subview_row)
arma_operator_scalar_obj(Col)
arma_operator_scalar_obj(Row)
arma_operator_scalar_obj(diagview)
arma_operator_scalar_obj(subview_col)
arma_operator_scalar_obj(subview_row)
arma_operator_obj_cx_scalar(Col)
arma_operator_obj_cx_scalar(Row)
arma_operator_obj_cx_scalar(diagview)
arma_operator_obj_cx_scalar(subview_col)
arma_operator_obj_cx_scalar(subview_row)
arma_operator_cx_scalar_obj(Col)
arma_operator_cx_scalar_obj(Row)
arma_operator_cx_scalar_obj(diagview)
arma_operator_cx_scalar_obj(subview_col)
arma_operator_cx_scalar_obj(subview_row)
arma_operator_obj_base(Col)
arma_operator_obj_base(Row)
arma_operator_obj_base(diagview)
arma_operator_obj_base(subview_col)
arma_operator_obj_base(subview_row)
arma_operator_base_obj(Col)
arma_operator_base_obj(Row)
arma_operator_base_obj(diagview)
arma_operator_base_obj(subview_col)
arma_operator_base_obj(subview_row)
arma_operator_obj_diagmat(Col)
arma_operator_obj_diagmat(Row)
arma_operator_obj_diagmat(diagview)
arma_operator_obj_diagmat(subview_col)
arma_operator_obj_diagmat(subview_row)
arma_operator_diagmat_obj(Col)
arma_operator_diagmat_obj(Row)
arma_operator_diagmat_obj(diagview)
arma_operator_diagmat_obj(subview_col)
arma_operator_diagmat_obj(subview_row)
arma_operator_obj1_obj2(Col,Col)
arma_operator_obj1_obj2(Col,Row)
arma_operator_obj1_obj2(Col,diagview)
arma_operator_obj1_obj2(Col,subview_col)
arma_operator_obj1_obj2(Col,subview_row)
arma_operator_obj1_obj2(Row,Col)
arma_operator_obj1_obj2(Row,Row)
arma_operator_obj1_obj2(Row,diagview)
arma_operator_obj1_obj2(Row,subview_col)
arma_operator_obj1_obj2(Row,subview_row)
arma_operator_obj1_obj2(diagview,Col)
arma_operator_obj1_obj2(diagview,Row)
arma_operator_obj1_obj2(diagview,diagview)
arma_operator_obj1_obj2(diagview,subview_col)
arma_operator_obj1_obj2(diagview,subview_row)
arma_operator_obj1_obj2(subview_col,Col)
arma_operator_obj1_obj2(subview_col,Row)
arma_operator_obj1_obj2(subview_col,diagview)
arma_operator_obj1_obj2(subview_col,subview_col)
arma_operator_obj1_obj2(subview_col,subview_row)
arma_operator_obj1_obj2(subview_row,Col)
arma_operator_obj1_obj2(subview_row,Row)
arma_operator_obj1_obj2(subview_row,diagview)
arma_operator_obj1_obj2(subview_row,subview_col)
arma_operator_obj1_obj2(subview_row,subview_row)
arma_operator_obj1_obj2_mixed(Col,Col)
arma_operator_obj1_obj2_mixed(Col,Row)
arma_operator_obj1_obj2_mixed(Col,diagview)
arma_operator_obj1_obj2_mixed(Col,subview_col)
arma_operator_obj1_obj2_mixed(Col,subview_row)
arma_operator_obj1_obj2_mixed(Row,Col)
arma_operator_obj1_obj2_mixed(Row,Row)
arma_operator_obj1_obj2_mixed(Row,diagview)
arma_operator_obj1_obj2_mixed(Row,subview_col)
arma_operator_obj1_obj2_mixed(Row,subview_row)
arma_operator_obj1_obj2_mixed(diagview,Col)
arma_operator_obj1_obj2_mixed(diagview,Row)
arma_operator_obj1_obj2_mixed(diagview,diagview)
arma_operator_obj1_obj2_mixed(diagview,subview_col)
arma_operator_obj1_obj2_mixed(diagview,subview_row)
arma_operator_obj1_obj2_mixed(subview_col,Col)
arma_operator_obj1_obj2_mixed(subview_col,Row)
arma_operator_obj1_obj2_mixed(subview_col,diagview)
arma_operator_obj1_obj2_mixed(subview_col,subview_col)
arma_operator_obj1_obj2_mixed(subview_col,subview_row)
arma_operator_obj1_obj2_mixed(subview_row,Col)
arma_operator_obj1_obj2_mixed(subview_row,Row)
arma_operator_obj1_obj2_mixed(subview_row,diagview)
arma_operator_obj1_obj2_mixed(subview_row,subview_col)
arma_operator_obj1_obj2_mixed(subview_row,subview_row)
// TODO: explicit handling of subview_elem1, perhaps via expanding the abov
e macros to take another paramater (for template<T1>)
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 294 lines changed or added


 podarray_bones.hpp   podarray_bones.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
static const uword val = 16; static const uword val = 16;
}; };
//! A lightweight array for POD types. If the amount of memory requested is small, the stack is used. //! A lightweight array for POD types. If the amount of memory requested is small, the stack is used.
template<typename eT> template<typename eT>
class podarray class podarray
{ {
public: public:
arma_aligned const uword n_elem; //!< number of elements held arma_aligned const uword n_elem; //!< number of elements held
arma_aligned const eT* const mem; //!< pointer to memory used by the o bject arma_aligned const eT* const mem; //!< pointer to memory used by the o bject
protected: protected:
//! Internal memory, to avoid calling the 'new' operator for small amount s of memory. //! Internal memory, to avoid calling the 'new' operator for small amount s of memory.
arma_aligned eT mem_local[ podarray_prealloc_n_elem::val ]; arma_aligned eT mem_local[ podarray_prealloc_n_elem::val ];
public: public:
inline ~podarray(); inline ~podarray();
inline podarray(); inline podarray();
inline podarray (const podarray& x); inline podarray (const podarray& x);
inline const podarray& operator=(const podarray& x); inline const podarray& operator=(const podarray& x);
arma_inline explicit podarray(const uword new_N); arma_inline explicit podarray(const uword new_N);
arma_inline explicit podarray(const eT* X, const uword new_N); arma_inline explicit podarray(const eT* X, const uword new_N);
template<typename T1>
inline explicit podarray(const Proxy<T1>& P);
arma_inline eT& operator[] (const uword i); arma_inline eT& operator[] (const uword i);
arma_inline eT operator[] (const uword i) const; arma_inline eT operator[] (const uword i) const;
arma_inline eT& operator() (const uword i); arma_inline eT& operator() (const uword i);
arma_inline eT operator() (const uword i) const; arma_inline eT operator() (const uword i) const;
inline void set_size(const uword new_n_elem); inline void set_size(const uword new_n_elem);
inline void reset(); inline void reset();
inline void fill(const eT val); inline void fill(const eT val);
 End of changes. 3 change blocks. 
3 lines changed or deleted 6 lines changed or added


 podarray_meat.hpp   podarray_meat.hpp 
// Copyright (C) 2008-2010 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2010 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 96 skipping to change at line 96
, mem (0) , mem (0)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
init(new_n_elem); init(new_n_elem);
arrayops::copy( memptr(), X, new_n_elem ); arrayops::copy( memptr(), X, new_n_elem );
} }
template<typename eT> template<typename eT>
template<typename T1>
inline
podarray<eT>::podarray(const Proxy<T1>& P)
: n_elem(0)
, mem (0)
{
arma_extra_debug_sigprint_this(this);
const uword P_n_elem = P.get_n_elem();
init(P_n_elem);
eT* out_mem = (*this).memptr();
if(Proxy<T1>::prefer_at_accessor == false)
{
typedef typename Proxy<T1>::ea_type ea_type;
ea_type A = P.get_ea();
uword i,j;
for(i=0, j=1; j < P_n_elem; i+=2, j+=2)
{
const eT val_i = A[i];
const eT val_j = A[j];
out_mem[i] = val_i;
out_mem[j] = val_j;
}
if(i < n_elem)
{
out_mem[i] = A[i];
}
}
else
{
const uword P_n_rows = P.get_n_rows();
const uword P_n_cols = P.get_n_cols();
if(P_n_rows != 1)
{
uword count = 0;
for(uword col=0; col < P_n_cols; ++col)
for(uword row=0; row < P_n_rows; ++row, ++count)
{
out_mem[count] = P.at(row,col);
}
}
else
{
for(uword col=0; col < P_n_cols; ++col)
{
out_mem[col] = P.at(0,col);
}
}
}
}
template<typename eT>
arma_inline arma_inline
eT eT
podarray<eT>::operator[] (const uword i) const podarray<eT>::operator[] (const uword i) const
{ {
return mem[i]; return mem[i];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
 End of changes. 2 change blocks. 
2 lines changed or deleted 63 lines changed or added


 restrictors.hpp   restrictors.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 153 skipping to change at line 153
template<typename T> struct arma_Mat_Col_Row_only { }; template<typename T> struct arma_Mat_Col_Row_only { };
template<typename eT> struct arma_Mat_Col_Row_only< Mat<eT> > { typedef Mat <eT> result; }; template<typename eT> struct arma_Mat_Col_Row_only< Mat<eT> > { typedef Mat <eT> result; };
template<typename eT> struct arma_Mat_Col_Row_only< Col<eT> > { typedef Col <eT> result; }; template<typename eT> struct arma_Mat_Col_Row_only< Col<eT> > { typedef Col <eT> result; };
template<typename eT> struct arma_Mat_Col_Row_only< Row<eT> > { typedef Row <eT> result; }; template<typename eT> struct arma_Mat_Col_Row_only< Row<eT> > { typedef Row <eT> result; };
template<typename T> struct arma_Cube_only { }; template<typename T> struct arma_Cube_only { };
template<typename eT> struct arma_Cube_only< Cube<eT> > { typedef Cube<eT> result; }; template<typename eT> struct arma_Cube_only< Cube<eT> > { typedef Cube<eT> result; };
template<bool> struct enable_if { };
template<> struct enable_if<true> { typedef int result; };
template<bool, typename result_type > struct enable_if2
{ };
template< typename result_type > struct enable_if2<true, result_type>
{ typedef result_type result; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 10 lines changed or added


 strip.hpp   strip.hpp 
skipping to change at line 21 skipping to change at line 21
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup strip //! \addtogroup strip
//! @{ //! @{
template<typename T1> template<typename T1>
struct strip_diagmat struct strip_diagmat
{ {
typedef T1 stored_type; typedef T1 stored_type;
inline strip_diagmat(const Base<typename T1::elem_type, T1>& X) inline strip_diagmat(const T1& X)
: M(X.get_ref()) : M(X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
static const bool do_diagmat = false; static const bool do_diagmat = false;
const T1& M; const T1& M;
}; };
template<typename T1> template<typename T1>
 End of changes. 1 change blocks. 
2 lines changed or deleted 2 lines changed or added


 subview_bones.hpp   subview_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup subview //! \addtogroup subview
//! @{ //! @{
//! Class for storing data required to construct or apply operations to a s ubmatrix //! Class for storing data required to construct or apply operations to a s ubmatrix
//! (i.e. where the submatrix starts and ends as well as a reference/pointe r to the original matrix), //! (i.e. where the submatrix starts and ends as well as a reference/pointe r to the original matrix),
template<typename eT> template<typename eT>
class subview : public Base<eT, subview<eT> > class subview : public Base<eT, subview<eT> >
{ {
public: arma_aligned const Mat<eT>& m;
protected: arma_aligned Mat<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
arma_aligned const Mat<eT>& m;
static const bool is_row = false;
static const bool is_col = false;
const uword aux_row1; const uword aux_row1;
const uword aux_col1; const uword aux_col1;
const uword n_rows; const uword n_rows;
const uword n_cols; const uword n_cols;
const uword n_elem; const uword n_elem;
protected: protected:
arma_inline subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols); arma_inline subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols);
arma_inline subview( Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols);
public: public:
inline ~subview(); inline ~subview();
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);
skipping to change at line 172 skipping to change at line 173
}; };
template<typename eT> template<typename eT>
class subview_col : public subview<eT> class subview_col : public subview<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool is_row = false;
static const bool is_col = true;
inline void operator= (const subview<eT>& x); inline void operator= (const subview<eT>& x);
inline void operator= (const subview_col& x); inline void operator= (const subview_col& x);
template<typename T1> template<typename T1>
inline void operator= (const Base<eT,T1>& x); inline void operator= (const Base<eT,T1>& x);
arma_inline const Op<subview_col<eT>,op_htrans> t() const;
arma_inline const Op<subview_col<eT>,op_htrans> ht() const;
arma_inline const Op<subview_col<eT>,op_strans> st() const;
inline subview_col<eT> rows(const uword in_row1, const uword in_row 2); inline subview_col<eT> rows(const uword in_row1, const uword in_row 2);
inline const subview_col<eT> rows(const uword in_row1, const uword in_row 2) const; inline const subview_col<eT> rows(const uword in_row1, const uword in_row 2) const;
inline subview_col<eT> subvec(const uword in_row1, const uword in_r ow2); inline subview_col<eT> subvec(const uword in_row1, const uword in_r ow2);
inline const subview_col<eT> subvec(const uword in_row1, const uword in_r ow2) const; inline const subview_col<eT> subvec(const uword in_row1, const uword in_r ow2) const;
protected: protected:
inline subview_col(const Mat<eT>& in_m, const uword in_col); inline subview_col(const Mat<eT>& in_m, const uword in_col);
inline subview_col( Mat<eT>& in_m, const uword in_col);
inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword i n_row1, const uword in_n_rows); inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword i n_row1, const uword in_n_rows);
inline subview_col( Mat<eT>& in_m, const uword in_col, const uword i n_row1, const uword in_n_rows);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Col<eT>; friend class Col<eT>;
friend class subview<eT>; friend class subview<eT>;
subview_col(); subview_col();
}; };
template<typename eT> template<typename eT>
class subview_row : public subview<eT> class subview_row : public subview<eT>
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool is_row = true;
static const bool is_col = false;
inline void operator= (const subview<eT>& x); inline void operator= (const subview<eT>& x);
inline void operator= (const subview_row& x); inline void operator= (const subview_row& x);
template<typename T1> template<typename T1>
inline void operator= (const Base<eT,T1>& x); inline void operator= (const Base<eT,T1>& x);
arma_inline const Op<subview_row<eT>,op_htrans> t() const;
arma_inline const Op<subview_row<eT>,op_htrans> ht() const;
arma_inline const Op<subview_row<eT>,op_strans> st() const;
inline subview_row<eT> cols(const uword in_col1, const uword in_col 2); inline subview_row<eT> cols(const uword in_col1, const uword in_col 2);
inline const subview_row<eT> cols(const uword in_col1, const uword in_col 2) const; inline const subview_row<eT> cols(const uword in_col1, const uword in_col 2) const;
inline subview_row<eT> subvec(const uword in_col1, const uword in_c ol2); inline subview_row<eT> subvec(const uword in_col1, const uword in_c ol2);
inline const subview_row<eT> subvec(const uword in_col1, const uword in_c ol2) const; inline const subview_row<eT> subvec(const uword in_col1, const uword in_c ol2) const;
protected: protected:
inline subview_row(const Mat<eT>& in_m, const uword in_row); inline subview_row(const Mat<eT>& in_m, const uword in_row);
inline subview_row( Mat<eT>& in_m, const uword in_row);
inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword i n_col1, const uword in_n_cols); inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword i n_col1, const uword in_n_cols);
inline subview_row( Mat<eT>& in_m, const uword in_row, const uword i n_col1, const uword in_n_cols);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Row<eT>; friend class Row<eT>;
friend class subview<eT>; friend class subview<eT>;
subview_row(); subview_row();
}; };
 End of changes. 12 change blocks. 
12 lines changed or deleted 21 lines changed or added


 subview_cube_bones.hpp   subview_cube_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup subview_cube //! \addtogroup subview_cube
//! @{ //! @{
//! Class for storing data required to construct or apply operations to a s ubcube //! Class for storing data required to construct or apply operations to a s ubcube
//! (i.e. where the subcube starts and ends as well as a reference/pointer to the original cube), //! (i.e. where the subcube starts and ends as well as a reference/pointer to the original cube),
template<typename eT> template<typename eT>
class subview_cube : public BaseCube<eT, subview_cube<eT> > class subview_cube : public BaseCube<eT, subview_cube<eT> >
{ {
public: arma_aligned const Cube<eT>& m;
protected: arma_aligned Cube<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
arma_aligned const Cube<eT>& m;
const uword aux_row1; const uword aux_row1;
const uword aux_col1; const uword aux_col1;
const uword aux_slice1; const uword aux_slice1;
const uword n_rows; const uword n_rows;
const uword n_cols; const uword n_cols;
const uword n_elem_slice; const uword n_elem_slice;
const uword n_slices; const uword n_slices;
const uword n_elem; const uword n_elem;
protected: protected:
arma_inline subview_cube(const Cube<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_slice1, const uword in_n_rows, const uword i n_n_cols, const uword in_n_slices); arma_inline subview_cube(const Cube<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_slice1, const uword in_n_rows, const uword i n_n_cols, const uword in_n_slices);
arma_inline subview_cube( Cube<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_slice1, const uword in_n_rows, const uword i n_n_cols, const uword in_n_slices);
public: public:
inline ~subview_cube(); inline ~subview_cube();
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);
 End of changes. 4 change blocks. 
6 lines changed or deleted 4 lines changed or added


 subview_cube_meat.hpp   subview_cube_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 36 skipping to change at line 36
( (
const Cube<eT>& in_m, const Cube<eT>& in_m,
const uword in_row1, const uword in_row1,
const uword in_col1, const uword in_col1,
const uword in_slice1, const uword in_slice1,
const uword in_n_rows, const uword in_n_rows,
const uword in_n_cols, const uword in_n_cols,
const uword in_n_slices const uword in_n_slices
) )
: m (in_m) : m (in_m)
, m_ptr (0)
, aux_row1 (in_row1)
, aux_col1 (in_col1)
, aux_slice1 (in_slice1)
, n_rows (in_n_rows)
, n_cols (in_n_cols)
, n_elem_slice(in_n_rows * in_n_cols)
, n_slices (in_n_slices)
, n_elem (n_elem_slice * in_n_slices)
{
arma_extra_debug_sigprint();
}
template<typename eT>
arma_inline
subview_cube<eT>::subview_cube
(
Cube<eT>& in_m,
const uword in_row1,
const uword in_col1,
const uword in_slice1,
const uword in_n_rows,
const uword in_n_cols,
const uword in_n_slices
)
: m (in_m)
, m_ptr (&in_m)
, aux_row1 (in_row1) , aux_row1 (in_row1)
, aux_col1 (in_col1) , aux_col1 (in_col1)
, aux_slice1 (in_slice1) , aux_slice1 (in_slice1)
, n_rows (in_n_rows) , n_rows (in_n_rows)
, n_cols (in_n_cols) , n_cols (in_n_cols)
, n_elem_slice(in_n_rows * in_n_cols) , n_elem_slice(in_n_rows * in_n_cols)
, n_slices (in_n_slices) , n_slices (in_n_slices)
, n_elem (n_elem_slice * in_n_slices) , n_elem (n_elem_slice * in_n_slices)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 521 skipping to change at line 494
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(uword i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::copy( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::copy( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) ) if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = const_cast< Cube<eT>& >(t.m);
const uword t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const uword t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const uword t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(uword slice=0; slice < t_n_slices; ++slice) for(uword slice=0; slice < t_n_slices; ++slice)
{ {
const uword mod_slice = t_aux_slice1 + slice; const uword mod_slice = t_aux_slice1 + slice;
const eT* x_colptr = x.colptr(slice); const eT* x_colptr = x.colptr(slice);
skipping to change at line 596 skipping to change at line 569
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(uword i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_plus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ) ; arrayops::inplace_plus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ) ;
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) ) if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = const_cast< Cube<eT>& >(t.m);
const uword t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const uword t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const uword t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(uword slice=0; slice < t_n_slices; ++slice) for(uword slice=0; slice < t_n_slices; ++slice)
{ {
const uword mod_slice = t_aux_slice1 + slice; const uword mod_slice = t_aux_slice1 + slice;
const eT* x_colptr = x.colptr(slice); const eT* x_colptr = x.colptr(slice);
skipping to change at line 671 skipping to change at line 644
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(uword i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_minus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::inplace_minus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) ) if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = const_cast< Cube<eT>& >(t.m);
const uword t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const uword t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const uword t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(uword slice=0; slice < t_n_slices; ++slice) for(uword slice=0; slice < t_n_slices; ++slice)
{ {
const uword mod_slice = t_aux_slice1 + slice; const uword mod_slice = t_aux_slice1 + slice;
const eT* x_colptr = x.colptr(slice); const eT* x_colptr = x.colptr(slice);
skipping to change at line 746 skipping to change at line 719
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(uword i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_mul( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::inplace_mul( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) ) if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = const_cast< Cube<eT>& >(t.m);
const uword t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const uword t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const uword t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(uword slice=0; slice < t_n_slices; ++slice) for(uword slice=0; slice < t_n_slices; ++slice)
{ {
const uword mod_slice = t_aux_slice1 + slice; const uword mod_slice = t_aux_slice1 + slice;
const eT* x_colptr = x.colptr(slice); const eT* x_colptr = x.colptr(slice);
skipping to change at line 821 skipping to change at line 794
if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) ) if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
{ {
for(uword i=0; i < t_n_slices; ++i) for(uword i=0; i < t_n_slices; ++i)
{ {
arrayops::inplace_div( t.slice_colptr(i, 0), x.colptr(i), t_n_rows ); arrayops::inplace_div( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
} }
} }
else else
if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) ) if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
{ {
Cube<eT>& Q = *(t.m_ptr); Cube<eT>& Q = const_cast< Cube<eT>& >(t.m);
const uword t_aux_row1 = t.aux_row1; const uword t_aux_row1 = t.aux_row1;
const uword t_aux_col1 = t.aux_col1; const uword t_aux_col1 = t.aux_col1;
const uword t_aux_slice1 = t.aux_slice1; const uword t_aux_slice1 = t.aux_slice1;
for(uword slice=0; slice < t_n_slices; ++slice) for(uword slice=0; slice < t_n_slices; ++slice)
{ {
const uword mod_slice = t_aux_slice1 + slice; const uword mod_slice = t_aux_slice1 + slice;
const eT* x_colptr = x.colptr(slice); const eT* x_colptr = x.colptr(slice);
skipping to change at line 912 skipping to change at line 885
subview_cube<eT>::operator[](const uword i) subview_cube<eT>::operator[](const uword i)
{ {
const uword in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const uword offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const uword j = i - offset; const uword j = i - offset;
const uword in_col = j / n_rows; const uword in_col = j / n_rows;
const uword in_row = j % n_rows; const uword in_row = j % n_rows;
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Cube<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_cube<eT>::operator[](const uword i) const subview_cube<eT>::operator[](const uword i) const
{ {
const uword in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const uword offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const uword j = i - offset; const uword j = i - offset;
const uword in_col = j / n_rows; const uword in_col = j / n_rows;
const uword in_row = j % n_rows; const uword in_row = j % n_rows;
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview_cube<eT>::operator()(const uword i) subview_cube<eT>::operator()(const uword i)
{ {
arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
const uword in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const uword offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const uword j = i - offset; const uword j = i - offset;
const uword in_col = j / n_rows; const uword in_col = j / n_rows;
const uword in_row = j % n_rows; const uword in_row = j % n_rows;
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Cube<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview_cube<eT>::operator()(const uword i) const subview_cube<eT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
const uword in_slice = i / n_elem_slice; const uword in_slice = i / n_elem_slice;
const uword offset = in_slice * n_elem_slice; const uword offset = in_slice * n_elem_slice;
const uword j = i - offset; const uword j = i - offset;
const uword in_col = j / n_rows; const uword in_col = j / n_rows;
const uword in_row = j % n_rows; const uword in_row = j % n_rows;
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice) subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice)
{ {
arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds"); arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Cube<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice) const subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice) const
{ {
arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds"); arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& eT&
subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in _slice) subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in _slice)
{ {
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Cube<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT eT
subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in _slice) const subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in _slice) const
{ {
const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + au x_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col) subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col)
{ {
return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]); return & access::rw((const_cast< Cube<eT>& >(m)).mem[ (in_slice + aux_sl ice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col) co nst subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col) co nst
{ {
return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_co l1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_co l1)*m.n_rows + aux_row1 ];
} }
 End of changes. 16 change blocks. 
39 lines changed or deleted 20 lines changed or added


 subview_elem1_bones.hpp   subview_elem1_bones.hpp 
// Copyright (C) 2010 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup 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> >
{ {
public: arma_aligned const Mat<eT>& m;
protected: arma_aligned Mat<eT>* m_ptr;
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool is_row = false;
static const bool is_col = true;
arma_aligned const Mat<eT>& m;
arma_aligned const Base<uword,T1>& a; arma_aligned const Base<uword,T1>& a;
protected: protected:
arma_inline subview_elem1(const Mat<eT>& in_m, const Base<uword,T1>& in_a ); arma_inline subview_elem1(const Mat<eT>& in_m, const Base<uword,T1>& in_a );
arma_inline subview_elem1( Mat<eT>& in_m, const Base<uword,T1>& in_a );
public: public:
inline ~subview_elem1(); inline ~subview_elem1();
template<typename op_type> inline void inplace_op(const eT val); template<typename op_type> inline void inplace_op(const eT val);
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> ht() 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 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
skipping to change at line 81 skipping to change at line 85
inline static void minus_inplace(Mat<eT>& out, const subview_elem1& in); inline static void minus_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void schur_inplace(Mat<eT>& out, const subview_elem1& in); inline static void schur_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void div_inplace(Mat<eT>& out, const subview_elem1& in); inline static void div_inplace(Mat<eT>& out, const subview_elem1& in);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
subview_elem1(); subview_elem1();
}; };
class op_subview_elem_equ;
class op_subview_elem_inplace_plus;
class op_subview_elem_inplace_minus;
class op_subview_elem_inplace_schur;
class op_subview_elem_inplace_div;
//! @} //! @}
 End of changes. 6 change blocks. 
12 lines changed or deleted 10 lines changed or added


 subview_elem1_meat.hpp   subview_elem1_meat.hpp 
// Copyright (C) 2010-2011 NICTA (www.nicta.com.au) // Copyright (C) 2010-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2010-2011 Conrad Sanderson // Copyright (C) 2010-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 27 skipping to change at line 27
inline inline
subview_elem1<eT,T1>::~subview_elem1() subview_elem1<eT,T1>::~subview_elem1()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline arma_inline
subview_elem1<eT,T1>::subview_elem1(const Mat<eT>& in_m, const Base<uword,T 1>& in_a) subview_elem1<eT,T1>::subview_elem1(const Mat<eT>& in_m, const Base<uword,T 1>& in_a)
: m(in_m) : m(in_m)
, m_ptr(0)
, a(in_a)
{
arma_extra_debug_sigprint();
}
template<typename eT, typename T1>
arma_inline
subview_elem1<eT,T1>::subview_elem1(Mat<eT>& in_m, const Base<uword,T1>& in
_a)
: m(in_m)
, m_ptr(&in_m)
, a(in_a) , a(in_a)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type> template<typename op_type>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const eT val) subview_elem1<eT,T1>::inplace_op(const eT val)
{ {
Mat<eT>& m_local = *m_ptr; arma_extra_debug_sigprint();
Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = tmp.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
skipping to change at line 101 skipping to change at line 92
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { m_mem[ii] /= val; }
} }
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type, typename T2> template<typename op_type, typename T2>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const subview_elem1<eT,T2>& x) subview_elem1<eT,T1>::inplace_op(const subview_elem1<eT,T2>& x)
{ {
arma_extra_debug_sigprint();
subview_elem1<eT,T1>& t = *this; subview_elem1<eT,T1>& t = *this;
if(&(t.m) == &(x.m)) if(&(t.m) == &(x.m))
{ {
arma_extra_debug_print("subview_elem1::inplace_op(): aliasing detected" ); arma_extra_debug_print("subview_elem1::inplace_op(): aliasing detected" );
const Mat<eT> tmp(x); const Mat<eT> tmp(x);
if(is_same_type<op_type, op_subview_elem_equ >::value == true) { t.operator= (tmp); } if(is_same_type<op_type, op_subview_elem_equ >::value == true) { t.operator= (tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { t.operator+=(tmp); } else if(is_same_type<op_type, op_subview_elem_inplace_plus >::value == true) { t.operator+=(tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { t.operator-=(tmp); } else if(is_same_type<op_type, op_subview_elem_inplace_minus>::value == true) { t.operator-=(tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { t.operator%=(tmp); } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value == true) { t.operator%=(tmp); }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { t.operator/=(tmp); } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value == true) { t.operator/=(tmp); }
} }
else else
{ {
Mat<eT>& t_m_local = *(t.m_ptr); Mat<eT>& t_m_local = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& x_m_local = x.m; const Mat<eT>& x_m_local = x.m;
const unwrap_check_mixed<T1> t_tmp(t.a.get_ref(), t_m_local); const unwrap_check_mixed<T1> t_tmp(t.a.get_ref(), t_m_local);
const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), t_m_local); const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), t_m_local);
const umat& t_aa = t_tmp.M; const umat& t_aa = t_tmp.M;
const umat& x_aa = x_tmp.M; const umat& x_aa = x_tmp.M;
arma_debug_check arma_debug_check
( (
skipping to change at line 195 skipping to change at line 188
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type, typename T2> template<typename op_type, typename T2>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x) subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& m_local = *m_ptr; Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem; const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local); const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M; const umat& aa = tmp.M;
arma_debug_check arma_debug_check
( (
( aa.is_vec() == false ), ( aa.is_vec() == false ),
skipping to change at line 291 skipping to change at line 284
else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_schur>::value = = true) { m_mem[ii] *= X[i]; }
else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; } else if(is_same_type<op_type, op_subview_elem_inplace_div >::value = = true) { m_mem[ii] /= X[i]; }
} }
} }
} }
// //
// //
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline
const Op<subview_elem1<eT,T1>,op_htrans>
subview_elem1<eT,T1>::t() const
{
return Op<subview_elem1<eT,T1>,op_htrans>(*this);
}
template<typename eT, typename T1>
arma_inline
const Op<subview_elem1<eT,T1>,op_htrans>
subview_elem1<eT,T1>::ht() const
{
return Op<subview_elem1<eT,T1>,op_htrans>(*this);
}
template<typename eT, typename T1>
arma_inline
const Op<subview_elem1<eT,T1>,op_strans>
subview_elem1<eT,T1>::st() const
{
return Op<subview_elem1<eT,T1>,op_strans>(*this);
}
template<typename eT, typename T1>
inline inline
void void
subview_elem1<eT,T1>::fill(const eT val) subview_elem1<eT,T1>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
inplace_op<op_subview_elem_equ>(val); inplace_op<op_subview_elem_equ>(val);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
skipping to change at line 556 skipping to change at line 573
{ {
const uword ii = aa_mem[i]; const uword ii = aa_mem[i];
arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" ); arma_debug_check( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
out_mem[i] = m_mem[ii]; out_mem[i] = m_mem[ii];
} }
if(alias == true) if(alias == true)
{ {
actual_out = out; actual_out.steal_mem(out);
delete tmp_out; delete tmp_out;
} }
} }
template<typename eT, typename T1> template<typename eT, typename T1>
template<typename op_type> template<typename op_type>
inline inline
void void
subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in) subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in)
{ {
 End of changes. 8 change blocks. 
18 lines changed or deleted 34 lines changed or added


 subview_field_bones.hpp   subview_field_bones.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup subview_field //! \addtogroup subview_field
//! @{ //! @{
//! Class for storing data required to construct or apply operations to a s ubfield //! Class for storing data required to construct or apply operations to a s ubfield
//! (i.e. where the subfield starts and ends as well as a reference/pointer to the original field), //! (i.e. where the subfield starts and ends as well as a reference/pointer to the original field),
template<typename oT> template<typename oT>
class subview_field class subview_field
{ {
public: const field<oT>& f;
protected: field<oT>* f_ptr;
public: public:
typedef oT object_type; typedef oT object_type;
const field<oT>& f;
const uword aux_row1; const uword aux_row1;
const uword aux_col1; const uword aux_col1;
const uword n_rows; const uword n_rows;
const uword n_cols; const uword n_cols;
const uword n_elem; const uword n_elem;
protected: protected:
arma_inline subview_field(const field<oT>& in_f, const uword in_row1, con st uword in_col1, const uword in_n_rows, const uword in_n_cols); arma_inline subview_field(const field<oT>& in_f, const uword in_row1, con st uword in_col1, const uword in_n_rows, const uword in_n_cols);
arma_inline subview_field( field<oT>& in_f, const uword in_row1, con st uword in_col1, const uword in_n_rows, const uword in_n_cols);
public: public:
inline ~subview_field(); inline ~subview_field();
inline void operator= (const field<oT>& x); inline void operator= (const field<oT>& x);
inline void operator= (const subview_field& x); inline void operator= (const subview_field& x);
arma_inline oT& operator[](const uword i); arma_inline oT& operator[](const uword i);
arma_inline const oT& operator[](const uword i) const; arma_inline const oT& operator[](const uword i) const;
 End of changes. 4 change blocks. 
6 lines changed or deleted 4 lines changed or added


 subview_field_meat.hpp   subview_field_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
subview_field<oT>::~subview_field() subview_field<oT>::~subview_field()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
subview_field<oT>::subview_field subview_field<oT>::subview_field
( (
const field<oT>& in_f, const field<oT>& in_f,
const uword in_row1, const uword in_row1,
const uword in_col1, const uword in_col1,
const uword in_n_rows, const uword in_n_rows,
const uword in_n_cols const uword in_n_cols
) )
: f(in_f) : f(in_f)
, f_ptr(0)
, aux_row1(in_row1)
, aux_col1(in_col1)
, n_rows(in_n_rows)
, n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols)
{
arma_extra_debug_sigprint();
}
template<typename oT>
arma_inline
subview_field<oT>::subview_field
(
field<oT>& in_f,
const uword in_row1,
const uword in_col1,
const uword in_n_rows,
const uword in_n_cols
)
: f(in_f)
, f_ptr(&in_f)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename oT> template<typename oT>
skipping to change at line 123 skipping to change at line 101
delete tmp_subview; delete tmp_subview;
delete tmp_field; delete tmp_field;
} }
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::operator[](const uword i) subview_field<oT>::operator[](const uword i)
{ {
arma_check( (f_ptr == 0), "subview_field::operator[]: field is read-only"
);
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
const uword in_row = i % n_rows; const uword in_row = i % n_rows;
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((const_cast< field<oT>& >(f)).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::operator[](const uword i) const subview_field<oT>::operator[](const uword i) const
{ {
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
const uword in_row = i % n_rows; const uword in_row = i % n_rows;
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::operator()(const uword i) subview_field<oT>::operator()(const uword i)
{ {
arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only" );
arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds");
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
const uword in_row = i % n_rows; const uword in_row = i % n_rows;
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((const_cast< field<oT>& >(f)).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::operator()(const uword i) const subview_field<oT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds"); arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds");
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
skipping to change at line 182 skipping to change at line 157
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::operator()(const uword in_row, const uword in_col) subview_field<oT>::operator()(const uword in_row, const uword in_col)
{ {
arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only" );
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds");
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((const_cast< field<oT>& >(f)).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::operator()(const uword in_row, const uword in_col) const subview_field<oT>::operator()(const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_fi eld::operator(): index out of bounds");
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *(f.mem[index]); return *(f.mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
oT& oT&
subview_field<oT>::at(const uword in_row, const uword in_col) subview_field<oT>::at(const uword in_row, const uword in_col)
{ {
//arma_extra_debug_sigprint();
arma_check( (f_ptr == 0), "subview_field::at(): field is read-only");
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
return *((*f_ptr).mem[index]); return *((const_cast< field<oT>& >(f)).mem[index]);
} }
template<typename oT> template<typename oT>
arma_inline arma_inline
const oT& const oT&
subview_field<oT>::at(const uword in_row, const uword in_col) const subview_field<oT>::at(const uword in_row, const uword in_col) const
{ {
//arma_extra_debug_sigprint(); //arma_extra_debug_sigprint();
const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row;
 End of changes. 11 change blocks. 
41 lines changed or deleted 10 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2012 Conrad Sanderson
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
skipping to change at line 28 skipping to change at line 28
inline inline
subview<eT>::~subview() subview<eT>::~subview()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview<eT>::subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols) subview<eT>::subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols)
: m(in_m) : m(in_m)
, m_ptr(0)
, aux_row1(in_row1)
, aux_col1(in_col1)
, n_rows(in_n_rows)
, n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
subview<eT>::subview(Mat<eT>& in_m, const uword in_row1, const uword in_col
1, const uword in_n_rows, const uword in_n_cols)
: m(in_m)
, m_ptr(&in_m)
, aux_row1(in_row1) , aux_row1(in_row1)
, aux_col1(in_col1) , aux_col1(in_col1)
, n_rows(in_n_rows) , n_rows(in_n_rows)
, n_cols(in_n_cols) , n_cols(in_n_cols)
, n_elem(in_n_rows*in_n_cols) , n_elem(in_n_rows*in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
skipping to change at line 64 skipping to change at line 49
void void
subview<eT>::operator+= (const eT val) subview<eT>::operator+= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) += val; X.at(row, i) += val;
skipping to change at line 104 skipping to change at line 89
void void
subview<eT>::operator-= (const eT val) subview<eT>::operator-= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) -= val; X.at(row, i) -= val;
skipping to change at line 144 skipping to change at line 129
void void
subview<eT>::operator*= (const eT val) subview<eT>::operator*= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) *= val; X.at(row, i) *= val;
skipping to change at line 184 skipping to change at line 169
void void
subview<eT>::operator/= (const eT val) subview<eT>::operator/= (const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) /= val; X.at(row, i) /= val;
skipping to change at line 227 skipping to change at line 212
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> P(in.get_ref()); const Proxy<T1> P(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
const uword t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const uword t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
arma_debug_assert_same_size(t, P, "insert into submatrix"); arma_debug_assert_same_size(t, P, "copy into submatrix");
const bool alias = P.is_alias(t.m); const bool alias = P.is_alias(t.m);
arma_extra_debug_warn(alias, "aliasing detected"); arma_extra_debug_warn(alias, "aliasing detected");
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) = x_mem[i]; A.at(row, start_col+i) = x_mem[i];
A.at(row, start_col+j) = x_mem[j]; A.at(row, start_col+j) = x_mem[j];
skipping to change at line 272 skipping to change at line 257
for(uword col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::copy( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
skipping to change at line 348 skipping to change at line 333
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) += x_mem[i]; A.at(row, start_col+i) += x_mem[i];
A.at(row, start_col+j) += x_mem[j]; A.at(row, start_col+j) += x_mem[j];
skipping to change at line 378 skipping to change at line 363
for(uword col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_plus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
skipping to change at line 452 skipping to change at line 437
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) -= x_mem[i]; A.at(row, start_col+i) -= x_mem[i];
A.at(row, start_col+j) -= x_mem[j]; A.at(row, start_col+j) -= x_mem[j];
skipping to change at line 482 skipping to change at line 467
for(uword col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_minus( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
skipping to change at line 558 skipping to change at line 543
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) *= x_mem[i]; A.at(row, start_col+i) *= x_mem[i];
A.at(row, start_col+j) *= x_mem[j]; A.at(row, start_col+j) *= x_mem[j];
skipping to change at line 588 skipping to change at line 573
for(uword col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_mul( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
skipping to change at line 664 skipping to change at line 649
if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) ) if( (alias == true) || (is_Mat<typename Proxy<T1>::stored_type>::value == true) )
{ {
const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m); const unwrap_check<typename Proxy<T1>::stored_type> tmp(P.Q, t.m);
const Mat<eT>& x = tmp.M; const Mat<eT>& x = tmp.M;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
const eT* x_mem = x.memptr(); const eT* x_mem = x.memptr();
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
A.at(row, start_col+i) /= x_mem[i]; A.at(row, start_col+i) /= x_mem[i];
A.at(row, start_col+j) /= x_mem[j]; A.at(row, start_col+j) /= x_mem[j];
skipping to change at line 694 skipping to change at line 679
for(uword col=0; col<t_n_cols; ++col) for(uword col=0; col<t_n_cols; ++col)
{ {
arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows ); arrayops::inplace_div( t.colptr(col), x.colptr(col), t_n_rows );
} }
} }
} }
else else
{ {
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = (*m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
uword i,j; uword i,j;
for(i=0, j=1; j < t_n_cols; i+=2, j+=2) for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
{ {
const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i]; const eT tmp1 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,i) : P[i];
const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j]; const eT tmp2 = (Proxy<T1>::prefer_at_accessor) ? P.at(0,j) : P[j];
skipping to change at line 756 skipping to change at line 741
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0; const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.n_rows, x_in.n_cols) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix"); arma_debug_assert_same_size(t, x, "copy into submatrix");
const uword t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
const uword t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = t.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword i,j;
skipping to change at line 825 skipping to change at line 810
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "addition"); arma_debug_assert_same_size(t, x, "addition");
const uword t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const uword t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = t.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword i,j;
skipping to change at line 887 skipping to change at line 872
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "subtraction"); arma_debug_assert_same_size(t, x, "subtraction");
const uword t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const uword t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = t.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword i,j;
skipping to change at line 950 skipping to change at line 935
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise multiplication"); arma_debug_assert_same_size(t, x, "element-wise multiplication");
const uword t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const uword t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = t.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword i,j;
skipping to change at line 1013 skipping to change at line 998
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "element-wise division"); arma_debug_assert_same_size(t, x, "element-wise division");
const uword t_n_rows = t.n_rows; const uword t_n_rows = t.n_rows;
const uword t_n_cols = t.n_cols; const uword t_n_cols = t.n_cols;
if(t_n_rows == 1) if(t_n_rows == 1)
{ {
Mat<eT>& A = *(t.m_ptr); Mat<eT>& A = const_cast< Mat<eT>& >(t.m);
const Mat<eT>& B = x.m; const Mat<eT>& B = x.m;
const uword row_A = t.aux_row1; const uword row_A = t.aux_row1;
const uword row_B = x.aux_row1; const uword row_B = x.aux_row1;
const uword start_col_A = t.aux_col1; const uword start_col_A = t.aux_col1;
const uword start_col_B = x.aux_col1; const uword start_col_B = x.aux_col1;
uword i,j; uword i,j;
skipping to change at line 1066 skipping to change at line 1051
void void
subview<eT>::fill(const eT val) subview<eT>::fill(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uword local_n_cols = n_cols; const uword local_n_cols = n_cols;
const uword local_n_rows = n_rows; const uword local_n_rows = n_rows;
if(local_n_rows == 1) if(local_n_rows == 1)
{ {
Mat<eT>& X = (*m_ptr); Mat<eT>& X = const_cast< Mat<eT>& >(m);
const uword row = aux_row1; const uword row = aux_row1;
const uword start_col = aux_col1; const uword start_col = aux_col1;
const uword end_col_plus1 = start_col + local_n_cols; const uword end_col_plus1 = start_col + local_n_cols;
uword i,j; uword i,j;
for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2) for(i=start_col, j=start_col+1; j < end_col_plus1; i+=2, j+=2)
{ {
X.at(row, i) = val; X.at(row, i) = val;
skipping to change at line 1140 skipping to change at line 1125
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator[](const uword i) subview<eT>::operator[](const uword i)
{ {
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
const uword in_row = i % n_rows; const uword in_row = i % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator[](const uword i) const subview<eT>::operator[](const uword i) const
{ {
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
const uword in_row = i % n_rows; const uword in_row = i % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator()(const uword i) subview<eT>::operator()(const uword i)
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
const uword in_row = i % n_rows; const uword in_row = i % n_rows;
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator()(const uword i) const subview<eT>::operator()(const uword i) const
{ {
arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s"); arma_debug_check( (i >= n_elem), "subview::operator(): index out of bound s");
const uword in_col = i / n_rows; const uword in_col = i / n_rows;
skipping to change at line 1191 skipping to change at line 1179
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::operator()(const uword in_row, const uword in_col) subview<eT>::operator()(const uword in_row, const uword in_col)
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::operator()(const uword in_row, const uword in_col) const subview<eT>::operator()(const uword in_row, const uword in_col) const
{ {
arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::o perator(): index out of bounds");
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
inline inline
eT& eT&
subview<eT>::at(const uword in_row, const uword in_col) subview<eT>::at(const uword in_row, const uword in_col)
{ {
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return access::rw( (*m_ptr).mem[index] );
return access::rw( (const_cast< Mat<eT>& >(m)).mem[index] );
} }
template<typename eT> template<typename eT>
inline inline
eT eT
subview<eT>::at(const uword in_row, const uword in_col) const subview<eT>::at(const uword in_row, const uword in_col) const
{ {
const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; const uword index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
return m.mem[index]; return m.mem[index];
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
subview<eT>::colptr(const uword in_col) subview<eT>::colptr(const uword in_col)
{ {
return & access::rw((*m_ptr).mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]); return & access::rw((const_cast< Mat<eT>& >(m)).mem[ (in_col + aux_col1)* m.n_rows + aux_row1 ]);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
const eT* const eT*
subview<eT>::colptr(const uword in_col) const subview<eT>::colptr(const uword in_col) const
{ {
return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]; return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
} }
skipping to change at line 1546 skipping to change at line 1537
inline inline
subview_row<eT> subview_row<eT>
subview<eT>::row(const uword row_num) subview<eT>::row(const uword row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" ); arma_debug_check( row_num >= n_rows, "subview::row(): out of bounds" );
const uword base_row = aux_row1 + row_num; const uword base_row = aux_row1 + row_num;
return subview_row<eT>(*m_ptr, base_row, aux_col1, n_cols); return subview_row<eT>(m, base_row, aux_col1, n_cols);
} }
//! creation of subview (row vector) //! creation of subview (row vector)
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview<eT>::row(const uword row_num) const subview<eT>::row(const uword row_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1591 skipping to change at line 1582
arma_debug_check arma_debug_check
( (
(row_num >= n_rows) (row_num >= n_rows)
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"subview::operator(): indices out of bounds or incorrectly used" "subview::operator(): indices out of bounds or incorrectly used"
); );
return subview_row<eT>(*m_ptr, base_row, base_col1, submat_n_cols); return subview_row<eT>(m, base_row, base_col1, submat_n_cols);
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview<eT>::operator()(const uword row_num, const span& col_span) const subview<eT>::operator()(const uword row_num, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool col_all = col_span.whole; const bool col_all = col_span.whole;
skipping to change at line 1636 skipping to change at line 1627
inline inline
subview_col<eT> subview_col<eT>
subview<eT>::col(const uword col_num) subview<eT>::col(const uword col_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds"); arma_debug_check( col_num >= n_cols, "subview::col(): out of bounds");
const uword base_col = aux_col1 + col_num; const uword base_col = aux_col1 + col_num;
return subview_col<eT>(*m_ptr, base_col, aux_row1, n_rows); return subview_col<eT>(m, base_col, aux_row1, n_rows);
} }
//! creation of subview (column vector) //! creation of subview (column vector)
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview<eT>::col(const uword col_num) const subview<eT>::col(const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1681 skipping to change at line 1672
arma_debug_check arma_debug_check
( (
(col_num >= n_cols) (col_num >= n_cols)
|| ||
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
, ,
"subview::operator(): indices out of bounds or incorrectly used" "subview::operator(): indices out of bounds or incorrectly used"
); );
return subview_col<eT>(*m_ptr, base_col, base_row1, submat_n_rows); return subview_col<eT>(m, base_col, base_row1, submat_n_rows);
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview<eT>::operator()(const span& row_span, const uword col_num) const subview<eT>::operator()(const span& row_span, const uword col_num) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool row_all = row_span.whole; const bool row_all = row_span.whole;
skipping to change at line 1765 skipping to change at line 1756
arma_debug_check arma_debug_check
( (
(in_row1 > in_row2) || (in_row2 >= n_rows), (in_row1 > in_row2) || (in_row2 >= n_rows),
"subview::rows(): indices out of bounds or incorrectly used" "subview::rows(): 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 base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
return subview<eT>(*m_ptr, base_row1, aux_col1, subview_n_rows, n_cols ); return subview<eT>(m, base_row1, aux_col1, subview_n_rows, n_cols );
} }
//! creation of subview (submatrix comprised of specified row vectors) //! creation of subview (submatrix comprised of specified row vectors)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::rows(const uword in_row1, const uword in_row2) const subview<eT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1805 skipping to change at line 1796
arma_debug_check arma_debug_check
( (
(in_col1 > in_col2) || (in_col2 >= n_cols), (in_col1 > in_col2) || (in_col2 >= n_cols),
"subview::cols(): indices out of bounds or incorrectly used" "subview::cols(): indices out of bounds or incorrectly used"
); );
const uword subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const uword base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, aux_row1, base_col1, n_rows, subview_n_cols); return subview<eT>(m, aux_row1, base_col1, n_rows, subview_n_cols);
} }
//! creation of subview (submatrix comprised of specified column vectors) //! creation of subview (submatrix comprised of specified column vectors)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::cols(const uword in_col1, const uword in_col2) const subview<eT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1848 skipping to change at line 1839
(in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols), (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || ( in_col2 >= n_cols),
"subview::submat(): indices out of bounds or incorrectly used" "subview::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;
const uword base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const uword base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, base_row1, base_col1, subview_n_rows, subview_ n_cols); return subview<eT>(m, base_row1, base_col1, subview_n_rows, subview_n_col s);
} }
//! creation of subview (generic submatrix) //! creation of subview (generic submatrix)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::submat(const uword in_row1, const uword in_col1, const uword i n_row2, const uword in_col2) const subview<eT>::submat(const uword in_row1, const uword in_col1, const uword i n_row2, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1908 skipping to change at line 1899
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"subview::submat(): indices out of bounds or incorrectly used" "subview::submat(): indices out of bounds or incorrectly used"
); );
const uword base_row1 = aux_row1 + in_row1; const uword base_row1 = aux_row1 + in_row1;
const uword base_col1 = aux_col1 + in_col1; const uword base_col1 = aux_col1 + in_col1;
return subview<eT>(*m_ptr, base_row1, base_col1, submat_n_rows, submat_n_ cols); return subview<eT>(m, base_row1, base_col1, submat_n_rows, submat_n_cols) ;
} }
//! creation of subview (generic submatrix) //! creation of subview (generic submatrix)
template<typename eT> template<typename eT>
inline inline
const subview<eT> const subview<eT>
subview<eT>::submat(const span& row_span, const span& col_span) const subview<eT>::submat(const span& row_span, const span& col_span) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 1990 skipping to change at line 1981
( (
((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)), ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c ol_offset >= n_cols)),
"subview::diag(): requested diagonal out of bounds" "subview::diag(): requested diagonal out of bounds"
); );
const uword len = (std::min)(n_rows - row_offset, n_cols - col_offset); const uword len = (std::min)(n_rows - row_offset, n_cols - col_offset);
const uword base_row_offset = aux_row1 + row_offset; const uword base_row_offset = aux_row1 + row_offset;
const uword base_col_offset = aux_col1 + col_offset; const uword base_col_offset = aux_col1 + col_offset;
return diagview<eT>(*m_ptr, base_row_offset, base_col_offset, len); return diagview<eT>(m, base_row_offset, base_col_offset, len);
} }
//! creation of diagview (diagonal) //! creation of diagview (diagonal)
template<typename eT> template<typename eT>
inline inline
const diagview<eT> const diagview<eT>
subview<eT>::diag(const sword in_id) const subview<eT>::diag(const sword in_id) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2031 skipping to change at line 2022
subview<eT>::swap_rows(const uword in_row1, const uword in_row2) subview<eT>::swap_rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check arma_debug_check
( (
(in_row1 >= n_rows) || (in_row2 >= n_rows), (in_row1 >= n_rows) || (in_row2 >= n_rows),
"subview::swap_rows(): out of bounds" "subview::swap_rows(): out of bounds"
); );
eT* mem = (*m_ptr).memptr(); eT* mem = (const_cast< Mat<eT>& >(m)).memptr();
for(uword col=0; col<n_cols; ++col) for(uword col=0; col<n_cols; ++col)
{ {
const uword offset = (aux_col1 + col) * m.n_rows; const uword offset = (aux_col1 + col) * m.n_rows;
const uword pos1 = aux_row1 + in_row1 + offset; const uword pos1 = aux_row1 + in_row1 + offset;
const uword pos2 = aux_row1 + in_row2 + offset; const uword pos2 = aux_row1 + in_row2 + offset;
const eT tmp = mem[pos1]; const eT tmp = mem[pos1];
access::rw(mem[pos1]) = mem[pos2]; access::rw(mem[pos1]) = mem[pos2];
access::rw(mem[pos2]) = tmp; access::rw(mem[pos2]) = tmp;
skipping to change at line 2142 skipping to change at line 2133
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const uword in_col) subview_col<eT>::subview_col(const Mat<eT>& in_m, const uword in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1) : subview<eT>(in_m, 0, in_col, in_m.n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const uword in_col)
: subview<eT>(in_m, 0, in_col, in_m.n_rows, 1)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
subview_col<eT>::subview_col(const Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows) subview_col<eT>::subview_col(const Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1) : subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_col<eT>::subview_col(Mat<eT>& in_m, const uword in_col, const uword
in_row1, const uword in_n_rows)
: subview<eT>(in_m, in_row1, in_col, in_n_rows, 1)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
void void
subview_col<eT>::operator=(const subview<eT>& X) subview_col<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
skipping to change at line 2199 skipping to change at line 2174
void void
subview_col<eT>::operator=(const Base<eT,T1>& X) subview_col<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
arma_inline
const Op<subview_col<eT>,op_htrans>
subview_col<eT>::t() const
{
return Op<subview_col<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<subview_col<eT>,op_htrans>
subview_col<eT>::ht() const
{
return Op<subview_col<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<subview_col<eT>,op_strans>
subview_col<eT>::st() const
{
return Op<subview_col<eT>,op_strans>(*this);
}
template<typename eT>
inline inline
subview_col<eT> subview_col<eT>
subview_col<eT>::rows(const uword in_row1, const uword in_row2) subview_col<eT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used");
const uword subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const uword base_row1 = this->aux_row1 + in_row1; const uword base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview _n_rows); return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows );
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview_col<eT>::rows(const uword in_row1, const uword in_row2) const subview_col<eT>::rows(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::rows(): indices out of bounds or incorrectly used");
skipping to change at line 2243 skipping to change at line 2242
subview_col<eT>::subvec(const uword in_row1, const uword in_row2) subview_col<eT>::subvec(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used");
const uword subview_n_rows = in_row2 - in_row1 + 1; const uword subview_n_rows = in_row2 - in_row1 + 1;
const uword base_row1 = this->aux_row1 + in_row1; const uword base_row1 = this->aux_row1 + in_row1;
return subview_col<eT>(*(this->m_ptr), this->aux_col1, base_row1, subview _n_rows); return subview_col<eT>(this->m, this->aux_col1, base_row1, subview_n_rows );
} }
template<typename eT> template<typename eT>
inline inline
const subview_col<eT> const subview_col<eT>
subview_col<eT>::subvec(const uword in_row1, const uword in_row2) const subview_col<eT>::subvec(const uword in_row1, const uword in_row2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= subview<eT>::n_row s) ), "subview_col::subvec(): indices out of bounds or incorrectly used");
skipping to change at line 2276 skipping to change at line 2275
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const uword in_row) subview_row<eT>::subview_row(const Mat<eT>& in_m, const uword in_row)
: subview<eT>(in_m, in_row, 0, 1, in_m.n_cols) : subview<eT>(in_m, in_row, 0, 1, in_m.n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const uword in_row)
: subview<eT>(in_m, in_row, 0, 1, in_m.n_cols)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
subview_row<eT>::subview_row(const Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols) subview_row<eT>::subview_row(const Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols)
: subview<eT>(in_m, in_row, in_col1, 1, in_n_cols) : subview<eT>(in_m, in_row, in_col1, 1, in_n_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT> template<typename eT>
inline inline
subview_row<eT>::subview_row(Mat<eT>& in_m, const uword in_row, const uword
in_col1, const uword in_n_cols)
: subview<eT>(in_m, in_row, in_col1, 1, in_n_cols)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
void void
subview_row<eT>::operator=(const subview<eT>& X) subview_row<eT>::operator=(const subview<eT>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
skipping to change at line 2333 skipping to change at line 2316
void void
subview_row<eT>::operator=(const Base<eT,T1>& X) subview_row<eT>::operator=(const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
subview<eT>::operator=(X); subview<eT>::operator=(X);
arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" ); arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
arma_inline
const Op<subview_row<eT>,op_htrans>
subview_row<eT>::t() const
{
return Op<subview_row<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<subview_row<eT>,op_htrans>
subview_row<eT>::ht() const
{
return Op<subview_row<eT>,op_htrans>(*this);
}
template<typename eT>
arma_inline
const Op<subview_row<eT>,op_strans>
subview_row<eT>::st() const
{
return Op<subview_row<eT>,op_strans>(*this);
}
template<typename eT>
inline inline
subview_row<eT> subview_row<eT>
subview_row<eT>::cols(const uword in_col1, const uword in_col2) subview_row<eT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used" ); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used" );
const uword subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const uword base_col1 = this->aux_col1 + in_col1; const uword base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview _n_cols); return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols );
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview_row<eT>::cols(const uword in_col1, const uword in_col2) const subview_row<eT>::cols(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::cols(): indices out of bounds or incorrectly used");
skipping to change at line 2377 skipping to change at line 2384
subview_row<eT>::subvec(const uword in_col1, const uword in_col2) subview_row<eT>::subvec(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used");
const uword subview_n_cols = in_col2 - in_col1 + 1; const uword subview_n_cols = in_col2 - in_col1 + 1;
const uword base_col1 = this->aux_col1 + in_col1; const uword base_col1 = this->aux_col1 + in_col1;
return subview_row<eT>(*(this->m_ptr), this->aux_row1, base_col1, subview _n_cols); return subview_row<eT>(this->m, this->aux_row1, base_col1, subview_n_cols );
} }
template<typename eT> template<typename eT>
inline inline
const subview_row<eT> const subview_row<eT>
subview_row<eT>::subvec(const uword in_col1, const uword in_col2) const subview_row<eT>::subvec(const uword in_col1, const uword in_col2) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= subview<eT>::n_col s) ), "subview_row::subvec(): indices out of bounds or incorrectly used");
 End of changes. 51 change blocks. 
93 lines changed or deleted 97 lines changed or added


 traits.hpp   traits.hpp 
skipping to change at line 298 skipping to change at line 298
{ static const bool value = true; }; { static const bool value = true; };
template<typename out_eT, typename T1> template<typename out_eT, typename T1>
struct is_op_rel< mtOp<out_eT, T1, op_rel_noteq> > struct is_op_rel< mtOp<out_eT, T1, op_rel_noteq> >
{ static const bool value = true; }; { static const bool value = true; };
// //
// //
// //
template<typename T>
struct is_basevec
{ static const bool value = false; };
template<typename eT>
struct is_basevec< Row<eT> >
{ static const bool value = true; };
template<typename eT>
struct is_basevec< Col<eT> >
{ static const bool value = true; };
template<typename eT>
struct is_basevec< subview_row<eT> >
{ static const bool value = true; };
template<typename eT>
struct is_basevec< subview_col<eT> >
{ static const bool value = true; };
template<typename eT>
struct is_basevec< diagview<eT> >
{ static const bool value = true; };
template<typename eT, typename T1>
struct is_basevec< subview_elem1<eT,T1> >
{ static const bool value = true; };
//
//
//
template<typename T1> template<typename T1>
struct is_arma_type struct is_arma_type
{ {
static const bool value static const bool value
= is_Mat<T1>::value = is_Mat<T1>::value
|| is_Gen<T1>::value || is_Gen<T1>::value
|| is_Op<T1>::value || is_Op<T1>::value
|| is_eOp<T1>::value || is_eOp<T1>::value
|| is_mtOp<T1>::value || is_mtOp<T1>::value
|| is_Glue<T1>::value || is_Glue<T1>::value
skipping to change at line 568 skipping to change at line 600
typedef T2 T2_result; typedef T2 T2_result;
}; };
template<typename T1> template<typename T1>
struct force_different_type<T1,T1> struct force_different_type<T1,T1>
{ {
typedef T1 T1_result; typedef T1 T1_result;
typedef arma_junk_class T2_result; typedef arma_junk_class T2_result;
}; };
//
template<typename T1>
struct resolves_to_vector
{ static const bool value = T1::is_col || T1::is_row; };
template<typename glue_type> struct is_glue_mixed_times {
static const bool value = false; };
template<> struct is_glue_mixed_times<glue_mixed_times> {
static const bool value = true; };
template<typename glue_type> struct is_glue_mixed_elem { static const bool
value = false; };
template<> struct is_glue_mixed_elem<glue_mixed_plus> {
static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_mixed_minus> {
static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_mixed_div> {
static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_mixed_schur> {
static const bool value = true; };
template<> struct is_glue_mixed_elem<glue_rel_lt> { st
atic const bool value = true; };
template<> struct is_glue_mixed_elem<glue_rel_gt> { st
atic const bool value = true; };
template<> struct is_glue_mixed_elem<glue_rel_lteq> { st
atic const bool value = true; };
template<> struct is_glue_mixed_elem<glue_rel_gteq> { st
atic const bool value = true; };
template<> struct is_glue_mixed_elem<glue_rel_eq> { st
atic const bool value = true; };
template<> struct is_glue_mixed_elem<glue_rel_noteq> { st
atic const bool value = true; };
template<typename op_type> struct is_op_mixed_elem { static const bool valu
e = false; };
template<> struct is_op_mixed_elem<op_cx_scalar_times>
{ static const bool value = true; };
template<> struct is_op_mixed_elem<op_cx_scalar_plus>
{ static const bool value = true; };
template<> struct is_op_mixed_elem<op_cx_scalar_minus_pre>
{ static const bool value = true; };
template<> struct is_op_mixed_elem<op_cx_scalar_minus_post>
{ static const bool value = true; };
template<> struct is_op_mixed_elem<op_cx_scalar_div_pre>
{ static const bool value = true; };
template<> struct is_op_mixed_elem<op_cx_scalar_div_post>
{ static const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_lt_pre> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_lt_post> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_gt_pre> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_gt_post> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_lteq_pre> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_lteq_post> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_gteq_pre> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_gteq_post> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_eq> { stat
ic const bool value = true; };
template<> struct is_op_mixed_elem<op_rel_noteq> { stat
ic const bool value = true; };
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 105 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/