| 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_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 | |
|
| 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<>& 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<>& 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 | |
|
| 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_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 | |
|
| 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 | |
|
| 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 | |
|
| 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 | |
|
| 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 | |
|
| 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_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 | |
|
| 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_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 | |
|
| 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_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_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_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_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 | |
|
| 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_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 | |
|