| Cube_meat.hpp | | Cube_meat.hpp | |
| | | | |
| skipping to change at line 217 | | skipping to change at line 217 | |
| } | | } | |
| | | | |
| //! In-place addition of a scalar to all elements of the cube | | //! In-place addition of a scalar to all elements of the cube | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator+=(const eT val) | | Cube<eT>::operator+=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | local_ptr[i] += val; | |
| | | local_ptr[j] += val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
|
| access::rw(mem[i]) += val; | | local_ptr[i] += val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! In-place subtraction of a scalar from all elements of the cube | | //! In-place subtraction of a scalar from all elements of the cube | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator-=(const eT val) | | Cube<eT>::operator-=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) -= val; | | local_ptr[i] -= val; | |
| | | local_ptr[j] -= val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] -= val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! In-place multiplication of all elements of the cube with a scalar | | //! In-place multiplication of all elements of the cube with a scalar | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator*=(const eT val) | | Cube<eT>::operator*=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) *= val; | | local_ptr[i] *= val; | |
| | | local_ptr[j] *= val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] *= val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! In-place division of all elements of the cube with a scalar | | //! In-place division of all elements of the cube with a scalar | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator/=(const eT val) | | Cube<eT>::operator/=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | local_ptr[i] /= val; | |
| | | local_ptr[j] /= val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
|
| access::rw(mem[i]) /= val; | | local_ptr[i] /= val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! construct a cube from a given cube | | //! construct a cube from a given cube | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Cube<eT>::Cube(const Cube<eT>& in_cube) | | Cube<eT>::Cube(const Cube<eT>& in_cube) | |
| : n_rows(0) | | : n_rows(0) | |
| | | | |
| skipping to change at line 379 | | skipping to change at line 423 | |
| //! in-place cube addition | | //! in-place cube addition | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator+=(const Cube<eT>& m) | | Cube<eT>::operator+=(const Cube<eT>& m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "cube addition"); | | arma_debug_assert_same_size(*this, m, "cube addition"); | |
| | | | |
|
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | eT* out_mem = (*this).memptr(); | |
| | | const eT* m_mem = m.memptr(); | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] += m_mem[i]; | |
| | | out_mem[j] += m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] += m_mem[i]; | | out_mem[i] += m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! in-place cube subtraction | | //! in-place cube subtraction | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator-=(const Cube<eT>& m) | | Cube<eT>::operator-=(const Cube<eT>& m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "cube subtraction"); | | arma_debug_assert_same_size(*this, m, "cube subtraction"); | |
| | | | |
|
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | eT* out_mem = (*this).memptr(); | |
| | | const eT* m_mem = m.memptr(); | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] -= m_mem[i]; | |
| | | out_mem[j] -= m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] -= m_mem[i]; | | out_mem[i] -= m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! in-place element-wise cube multiplication | | //! in-place element-wise cube multiplication | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator%=(const Cube<eT>& m) | | Cube<eT>::operator%=(const Cube<eT>& m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "element-wise cube multiplication")
; | | arma_debug_assert_same_size(*this, m, "element-wise cube multiplication")
; | |
| | | | |
|
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | eT* out_mem = (*this).memptr(); | |
| | | const eT* m_mem = m.memptr(); | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] *= m_mem[i]; | |
| | | out_mem[j] *= m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] *= m_mem[i]; | | out_mem[i] *= m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! in-place element-wise cube division | | //! in-place element-wise cube division | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator/=(const Cube<eT>& m) | | Cube<eT>::operator/=(const Cube<eT>& m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "element-wise cube division"); | | arma_debug_assert_same_size(*this, m, "element-wise cube division"); | |
| | | | |
|
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | eT* out_mem = (*this).memptr(); | |
| | | const eT* m_mem = m.memptr(); | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] /= m_mem[i]; | |
| | | out_mem[j] /= m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] /= m_mem[i]; | | out_mem[i] /= m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! for constructing a complex cube out of two non-complex cubes | | //! for constructing a complex cube out of two non-complex cubes | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| | | | |
| skipping to change at line 735 | | skipping to change at line 815 | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator+=(const OpCube<T1, op_type>& X) | | Cube<eT>::operator+=(const OpCube<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "cube addition"); | | return (*this).operator+=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] += m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place cube subtraction, with the right-hand-side operand having dela
yed operations | | //! in-place cube subtraction, with the right-hand-side operand having dela
yed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator-=(const OpCube<T1, op_type>& X) | | Cube<eT>::operator-=(const OpCube<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "cube subtraction"); | | return (*this).operator-=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] -= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place cube element-wise multiplication, with the right-hand-side ope
rand having delayed operations | | //! in-place cube element-wise multiplication, with the right-hand-side ope
rand having delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator%=(const OpCube<T1, op_type>& X) | | Cube<eT>::operator%=(const OpCube<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise cube multiplication") | | return (*this).operator%=(m); | |
| ; | | | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] *= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place cube element-wise division, with the right-hand-side operand h
aving delayed operations | | //! in-place cube element-wise division, with the right-hand-side operand h
aving delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator/=(const OpCube<T1, op_type>& X) | | Cube<eT>::operator/=(const OpCube<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise cube division"); | | return (*this).operator/=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] /= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! create a cube from eOpCube, i.e. run the previously delayed unary opera
tions | | //! create a cube from eOpCube, i.e. run the previously delayed unary opera
tions | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| inline | | inline | |
| Cube<eT>::Cube(const eOpCube<T1, eop_type>& X) | | Cube<eT>::Cube(const eOpCube<T1, eop_type>& X) | |
| : n_rows(0) | | : n_rows(0) | |
| , n_cols(0) | | , n_cols(0) | |
| , n_elem_slice(0) | | , n_elem_slice(0) | |
| | | | |
| skipping to change at line 980 | | skipping to change at line 1016 | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator+=(const GlueCube<T1, T2, glue_type>& X) | | Cube<eT>::operator+=(const GlueCube<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "cube addition"); | | return (*this).operator+=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] += m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place cube subtraction, with the right-hand-side operands having del
ayed operations | | //! in-place cube subtraction, with the right-hand-side operands having del
ayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator-=(const GlueCube<T1, T2, glue_type>& X) | | Cube<eT>::operator-=(const GlueCube<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "cube subtraction"); | | return (*this).operator-=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] -= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place cube element-wise multiplication, with the right-hand-side ope
rands having delayed operations | | //! in-place cube element-wise multiplication, with the right-hand-side ope
rands having delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator%=(const GlueCube<T1, T2, glue_type>& X) | | Cube<eT>::operator%=(const GlueCube<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise cube multiplication") | | return (*this).operator%=(m); | |
| ; | | | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] *= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place cube element-wise division, with the right-hand-side operands
having delayed operations | | //! in-place cube element-wise division, with the right-hand-side operands
having delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| const Cube<eT>& | | const Cube<eT>& | |
| Cube<eT>::operator/=(const GlueCube<T1, T2, glue_type>& X) | | Cube<eT>::operator/=(const GlueCube<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Cube<eT> m(X); | | const Cube<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise cube division"); | | return (*this).operator/=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] /= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! create a cube from eGlue, i.e. run the previously delayed binary operat
ions | | //! create a cube from eGlue, i.e. run the previously delayed binary operat
ions | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename eglue_type> | | template<typename T1, typename T2, typename eglue_type> | |
| inline | | inline | |
| Cube<eT>::Cube(const eGlueCube<T1, T2, eglue_type>& X) | | Cube<eT>::Cube(const eGlueCube<T1, T2, eglue_type>& X) | |
| : n_rows(0) | | : n_rows(0) | |
| , n_cols(0) | | , n_cols(0) | |
| , n_elem_slice(0) | | , n_elem_slice(0) | |
| | | | |
| skipping to change at line 1489 | | skipping to change at line 1481 | |
| } | | } | |
| | | | |
| //! fill the cube with the specified value | | //! fill the cube with the specified value | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Cube<eT>::fill(const eT val) | | Cube<eT>::fill(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) = val; | | local_ptr[i] = val; | |
| | | local_ptr[j] = val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] = val; | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Cube<eT>::zeros() | | Cube<eT>::zeros() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
| skipping to change at line 1692 | | skipping to change at line 1695 | |
| | | | |
| //! prefix ++ | | //! prefix ++ | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::prefix_pp(Cube<eT>& x) | | Cube_aux::prefix_pp(Cube<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | ++(memptr[i]); | |
| | | ++(memptr[j]); | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| ++(memptr[i]); | | ++(memptr[i]); | |
| } | | } | |
| } | | } | |
| | | | |
| //! prefix ++ for complex numbers (work around for limitations of the std::
complex class) | | //! prefix ++ for complex numbers (work around for limitations of the std::
complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::prefix_pp(Cube< std::complex<T> >& x) | | Cube_aux::prefix_pp(Cube< std::complex<T> >& x) | |
| | | | |
| skipping to change at line 1716 | | skipping to change at line 1727 | |
| | | | |
| //! postfix ++ | | //! postfix ++ | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::postfix_pp(Cube<eT>& x) | | Cube_aux::postfix_pp(Cube<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | (memptr[i])++; | |
| | | (memptr[j])++; | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| (memptr[i])++; | | (memptr[i])++; | |
| } | | } | |
| } | | } | |
| | | | |
| //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | | //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::postfix_pp(Cube< std::complex<T> >& x) | | Cube_aux::postfix_pp(Cube< std::complex<T> >& x) | |
| | | | |
| skipping to change at line 1740 | | skipping to change at line 1759 | |
| | | | |
| //! prefix -- | | //! prefix -- | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::prefix_mm(Cube<eT>& x) | | Cube_aux::prefix_mm(Cube<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | --(memptr[i]); | |
| | | --(memptr[j]); | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| --(memptr[i]); | | --(memptr[i]); | |
| } | | } | |
| } | | } | |
| | | | |
| //! prefix -- for complex numbers (work around for limitations of the std::
complex class) | | //! prefix -- for complex numbers (work around for limitations of the std::
complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::prefix_mm(Cube< std::complex<T> >& x) | | Cube_aux::prefix_mm(Cube< std::complex<T> >& x) | |
| | | | |
| skipping to change at line 1764 | | skipping to change at line 1791 | |
| | | | |
| //! postfix -- | | //! postfix -- | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::postfix_mm(Cube<eT>& x) | | Cube_aux::postfix_mm(Cube<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | (memptr[i])--; | |
| | | (memptr[j])--; | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| (memptr[i])--; | | (memptr[i])--; | |
| } | | } | |
| } | | } | |
| | | | |
| //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | | //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Cube_aux::postfix_mm(Cube< std::complex<T> >& x) | | Cube_aux::postfix_mm(Cube< std::complex<T> >& x) | |
| | | | |
End of changes. 30 change blocks. |
| 124 lines changed or deleted | | 157 lines changed or added | |
|
| Mat_meat.hpp | | Mat_meat.hpp | |
| | | | |
| skipping to change at line 300 | | skipping to change at line 300 | |
| } | | } | |
| | | | |
| //! In-place addition of a scalar to all elements of the matrix | | //! In-place addition of a scalar to all elements of the matrix | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator+=(const eT val) | | Mat<eT>::operator+=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) += val; | | local_ptr[i] += val; | |
| | | local_ptr[j] += val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] += val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! In-place subtraction of a scalar from all elements of the matrix | | //! In-place subtraction of a scalar from all elements of the matrix | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator-=(const eT val) | | Mat<eT>::operator-=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) -= val; | | local_ptr[i] -= val; | |
| | | local_ptr[j] -= val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] -= val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! In-place multiplication of all elements of the matrix with a scalar | | //! In-place multiplication of all elements of the matrix with a scalar | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator*=(const eT val) | | Mat<eT>::operator*=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | local_ptr[i] *= val; | |
| | | local_ptr[j] *= val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
|
| access::rw(mem[i]) *= val; | | local_ptr[i] *= val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! In-place division of all elements of the matrix with a scalar | | //! In-place division of all elements of the matrix with a scalar | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator/=(const eT val) | | Mat<eT>::operator/=(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) /= val; | | local_ptr[i] /= val; | |
| | | local_ptr[j] /= val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] /= val; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! construct a matrix from a given matrix | | //! construct a matrix from a given matrix | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Mat<eT>::Mat(const Mat<eT>& in_mat) | | Mat<eT>::Mat(const Mat<eT>& in_mat) | |
| : n_rows(0) | | : n_rows(0) | |
| | | | |
| skipping to change at line 471 | | skipping to change at line 515 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "matrix addition"); | | arma_debug_assert_same_size(*this, m, "matrix addition"); | |
| | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
| eT* out_mem = (*this).memptr(); | | eT* out_mem = (*this).memptr(); | |
| const eT* m_mem = m.memptr(); | | const eT* m_mem = m.memptr(); | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] += m_mem[i]; | |
| | | out_mem[j] += m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] += m_mem[i]; | | out_mem[i] += m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! in-place matrix subtraction | | //! in-place matrix subtraction | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
| skipping to change at line 494 | | skipping to change at line 546 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "matrix subtraction"); | | arma_debug_assert_same_size(*this, m, "matrix subtraction"); | |
| | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
| eT* out_mem = (*this).memptr(); | | eT* out_mem = (*this).memptr(); | |
| const eT* m_mem = m.memptr(); | | const eT* m_mem = m.memptr(); | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] -= m_mem[i]; | |
| | | out_mem[j] -= m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] -= m_mem[i]; | | out_mem[i] -= m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! in-place matrix multiplication | | //! in-place matrix multiplication | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
| skipping to change at line 529 | | skipping to change at line 589 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "element-wise matrix multplication"
); | | arma_debug_assert_same_size(*this, m, "element-wise matrix multplication"
); | |
| | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
| eT* out_mem = (*this).memptr(); | | eT* out_mem = (*this).memptr(); | |
| const eT* m_mem = m.memptr(); | | const eT* m_mem = m.memptr(); | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] *= m_mem[i]; | |
| | | out_mem[j] *= m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] *= m_mem[i]; | | out_mem[i] *= m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! in-place element-wise matrix division | | //! in-place element-wise matrix division | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
| skipping to change at line 552 | | skipping to change at line 620 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(*this, m, "element-wise matrix division"); | | arma_debug_assert_same_size(*this, m, "element-wise matrix division"); | |
| | | | |
| const u32 local_n_elem = m.n_elem; | | const u32 local_n_elem = m.n_elem; | |
| | | | |
| eT* out_mem = (*this).memptr(); | | eT* out_mem = (*this).memptr(); | |
| const eT* m_mem = m.memptr(); | | const eT* m_mem = m.memptr(); | |
| | | | |
|
| for(u32 i=0; i<local_n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| | | { | |
| | | out_mem[i] /= m_mem[i]; | |
| | | out_mem[j] /= m_mem[j]; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| { | | { | |
| out_mem[i] /= m_mem[i]; | | out_mem[i] /= m_mem[i]; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! 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> | |
| | | | |
| skipping to change at line 1166 | | skipping to change at line 1242 | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator+=(const Op<T1, op_type>& X) | | Mat<eT>::operator+=(const Op<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "matrix addition"); | | return (*this).operator+=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] += m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place matrix subtraction, with the right-hand-side operand having de
layed operations | | //! in-place matrix subtraction, with the right-hand-side operand having de
layed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator-=(const Op<T1, op_type>& X) | | Mat<eT>::operator-=(const Op<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "matrix subtraction"); | | return (*this).operator-=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] -= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place matrix multiplication, with the right-hand-side operand having
delayed operations | | //! in-place matrix multiplication, with the right-hand-side operand having
delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator*=(const Op<T1, op_type>& X) | | Mat<eT>::operator*=(const Op<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| skipping to change at line 1236 | | skipping to change at line 1290 | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator%=(const Op<T1, op_type>& X) | | Mat<eT>::operator%=(const Op<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise matrix multiplication | | return (*this).operator%=(m); | |
| "); | | | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] *= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place matrix element-wise division, with the right-hand-side operand
having delayed operations | | //! in-place matrix element-wise division, with the right-hand-side operand
having delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator/=(const Op<T1, op_type>& X) | | Mat<eT>::operator/=(const Op<T1, op_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise matrix division"); | | return (*this).operator/=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] /= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! create a matrix from eOp, i.e. run the previously delayed unary operati
ons | | //! create a matrix from eOp, i.e. run the previously delayed unary operati
ons | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| inline | | inline | |
| Mat<eT>::Mat(const eOp<T1, eop_type>& X) | | Mat<eT>::Mat(const eOp<T1, eop_type>& X) | |
| : n_rows(0) | | : n_rows(0) | |
| , n_cols(0) | | , n_cols(0) | |
| , n_elem(0) | | , n_elem(0) | |
| | | | |
| skipping to change at line 1438 | | skipping to change at line 1470 | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator+=(const Glue<T1, T2, glue_type>& X) | | Mat<eT>::operator+=(const Glue<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "matrix addition"); | | return (*this).operator+=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] += m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place matrix subtraction, with the right-hand-side operands having d
elayed operations | | //! in-place matrix subtraction, with the right-hand-side operands having d
elayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator-=(const Glue<T1, T2, glue_type>& X) | | Mat<eT>::operator-=(const Glue<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "matrix subtraction"); | | return (*this).operator-=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] -= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place matrix multiplications, with the right-hand-side operands havi
ng delayed operations | | //! in-place matrix multiplications, with the right-hand-side operands havi
ng delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator*=(const Glue<T1, T2, glue_type>& X) | | Mat<eT>::operator*=(const Glue<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| skipping to change at line 1511 | | skipping to change at line 1521 | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator%=(const Glue<T1, T2, glue_type>& X) | | Mat<eT>::operator%=(const Glue<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise matrix multiplication | | return (*this).operator%=(m); | |
| "); | | | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] *= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| //! in-place matrix element-wise division, with the right-hand-side operand
s having delayed operations | | //! in-place matrix element-wise division, with the right-hand-side operand
s having delayed operations | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator/=(const Glue<T1, T2, glue_type>& X) | | Mat<eT>::operator/=(const Glue<T1, T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| isnt_same_type<eT, typename T1::elem_type>::check(); | | isnt_same_type<eT, typename T1::elem_type>::check(); | |
| isnt_same_type<eT, typename T2::elem_type>::check(); | | isnt_same_type<eT, typename T2::elem_type>::check(); | |
| | | | |
| const Mat<eT> m(X); | | const Mat<eT> m(X); | |
| | | | |
|
| arma_debug_assert_same_size(*this, m, "element-wise matrix division"); | | return (*this).operator/=(m); | |
| | | | |
| eT* out_mem = (*this).memptr(); | | | |
| const eT* m_mem = m.memptr(); | | | |
| const u32 local_n_elem = m.n_elem; | | | |
| | | | |
| for(u32 i=0; i<local_n_elem; ++i) | | | |
| { | | | |
| out_mem[i] /= m_mem[i]; | | | |
| } | | | |
| | | | |
| return *this; | | | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| const Mat<eT>& | | const Mat<eT>& | |
| Mat<eT>::operator+=(const Glue<T1, T2, glue_times>& X) | | Mat<eT>::operator+=(const Glue<T1, T2, glue_times>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
| skipping to change at line 2065 | | skipping to change at line 2053 | |
| void | | void | |
| Mat<eT>::copy_size(const Mat<eT2>& m) | | Mat<eT>::copy_size(const Mat<eT2>& m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| init(m.n_rows, m.n_cols); | | init(m.n_rows, m.n_cols); | |
| } | | } | |
| | | | |
| //! fill the matrix with the specified value | | //! fill the matrix with the specified value | |
| template<typename eT> | | template<typename eT> | |
|
| | | arma_hot | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::fill(const eT val) | | Mat<eT>::fill(const eT val) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | eT* local_ptr = memptr(); | |
| | | const u32 local_n_elem = n_elem; | |
| | | | |
| | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<local_n_elem; i+=2, j+=2) | |
| { | | { | |
|
| access::rw(mem[i]) = val; | | local_ptr[i] = val; | |
| | | local_ptr[j] = val; | |
| | | } | |
| | | | |
| | | if(i < local_n_elem) | |
| | | { | |
| | | local_ptr[i] = val; | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::zeros() | | Mat<eT>::zeros() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
| skipping to change at line 2274 | | skipping to change at line 2274 | |
| | | | |
| //! 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) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | ++(memptr[i]); | |
| | | ++(memptr[j]); | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| ++(memptr[i]); | | ++(memptr[i]); | |
| } | | } | |
| } | | } | |
| | | | |
| //! prefix ++ for complex numbers (work around for limitations of the std::
complex class) | | //! prefix ++ for complex numbers (work around for limitations of the std::
complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::prefix_pp(Mat< std::complex<T> >& x) | | Mat_aux::prefix_pp(Mat< std::complex<T> >& x) | |
| | | | |
| skipping to change at line 2298 | | skipping to change at line 2306 | |
| | | | |
| //! postfix ++ | | //! postfix ++ | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::postfix_pp(Mat<eT>& x) | | Mat_aux::postfix_pp(Mat<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | (memptr[i])++; | |
| | | (memptr[j])++; | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| (memptr[i])++; | | (memptr[i])++; | |
| } | | } | |
| } | | } | |
| | | | |
| //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | | //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::postfix_pp(Mat< std::complex<T> >& x) | | Mat_aux::postfix_pp(Mat< std::complex<T> >& x) | |
| | | | |
| skipping to change at line 2322 | | skipping to change at line 2338 | |
| | | | |
| //! prefix -- | | //! prefix -- | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::prefix_mm(Mat<eT>& x) | | Mat_aux::prefix_mm(Mat<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | --(memptr[i]); | |
| | | --(memptr[j]); | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| --(memptr[i]); | | --(memptr[i]); | |
| } | | } | |
| } | | } | |
| | | | |
| //! prefix -- for complex numbers (work around for limitations of the std::
complex class) | | //! prefix -- for complex numbers (work around for limitations of the std::
complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::prefix_mm(Mat< std::complex<T> >& x) | | Mat_aux::prefix_mm(Mat< std::complex<T> >& x) | |
| | | | |
| skipping to change at line 2346 | | skipping to change at line 2370 | |
| | | | |
| //! postfix -- | | //! postfix -- | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::postfix_mm(Mat<eT>& x) | | Mat_aux::postfix_mm(Mat<eT>& x) | |
| { | | { | |
| eT* memptr = x.memptr(); | | eT* memptr = x.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = x.n_elem; | |
| | | | |
|
| for(u32 i=0; i<n_elem; ++i) | | u32 i,j; | |
| | | | |
| | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| | | { | |
| | | (memptr[i])--; | |
| | | (memptr[j])--; | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| { | | { | |
| (memptr[i])--; | | (memptr[i])--; | |
| } | | } | |
| } | | } | |
| | | | |
| //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | | //! postfix ++ for complex numbers (work around for limitations of the std:
:complex class) | |
| template<typename T> | | template<typename T> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Mat_aux::postfix_mm(Mat< std::complex<T> >& x) | | Mat_aux::postfix_mm(Mat< std::complex<T> >& x) | |
| | | | |
End of changes. 27 change blocks. |
| 116 lines changed or deleted | | 146 lines changed or added | |
|
| Proxy.hpp | | Proxy.hpp | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 53 | |
| | | | |
| inline explicit Proxy(const Mat<eT>& A) | | inline explicit Proxy(const Mat<eT>& A) | |
| : Q(A) | | : Q(A) | |
| , n_rows(A.n_rows) | | , n_rows(A.n_rows) | |
| , n_cols(A.n_cols) | | , n_cols(A.n_cols) | |
| , n_elem(A.n_elem) | | , n_elem(A.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| | | inline explicit Proxy(const u32 in_n_rows, const u32 in_n_cols) | |
| | | : Q(Q) | |
| | | , n_rows(in_n_rows) | |
| | | , n_cols(in_n_cols) | |
| | | , n_elem(in_n_rows*in_n_cols) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class Proxy< Col<eT> > | | class Proxy< Col<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef eT elem_type; | | typedef eT elem_type; | |
| | | | |
| skipping to change at line 81 | | skipping to change at line 90 | |
| | | | |
| inline explicit Proxy(const Col<eT>& A) | | inline explicit Proxy(const Col<eT>& A) | |
| : Q(A) | | : Q(A) | |
| , n_rows(A.n_rows) | | , n_rows(A.n_rows) | |
| , n_cols(A.n_cols) | | , n_cols(A.n_cols) | |
| , n_elem(A.n_elem) | | , n_elem(A.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| | | inline explicit Proxy(const u32 in_n_rows, const u32 in_n_cols) | |
| | | : Q(Q) | |
| | | , n_rows(in_n_rows) | |
| | | , n_cols(in_n_cols) | |
| | | , n_elem(in_n_rows*in_n_cols) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| }; | | }; | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class Proxy< Row<eT> > | | class Proxy< Row<eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef eT elem_type; | | typedef eT elem_type; | |
| | | | |
| skipping to change at line 109 | | skipping to change at line 127 | |
| | | | |
| inline explicit Proxy(const Row<eT>& A) | | inline explicit Proxy(const Row<eT>& A) | |
| : Q(A) | | : Q(A) | |
| , n_rows(A.n_rows) | | , n_rows(A.n_rows) | |
| , n_cols(A.n_cols) | | , n_cols(A.n_cols) | |
| , n_elem(A.n_elem) | | , n_elem(A.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
|
| | | inline explicit Proxy(const u32 in_n_rows, const u32 in_n_cols) | |
| | | : Q(Q) | |
| | | , n_rows(in_n_rows) | |
| | | , n_cols(in_n_cols) | |
| | | , n_elem(in_n_rows*in_n_cols) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn Q[i]; } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn Q.at(row, col); } | |
| }; | | }; | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| class Proxy< Op<T1, op_type> > | | class Proxy< Op<T1, op_type> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef typename T1::elem_type elem_type; | | typedef typename T1::elem_type elem_type; | |
| | | | |
| skipping to change at line 242 | | skipping to change at line 269 | |
| typedef eOp<T1, eop_type> stored_type; | | typedef eOp<T1, eop_type> stored_type; | |
| | | | |
| const eOp<T1, eop_type>& Q; | | const eOp<T1, eop_type>& Q; | |
| | | | |
| const u32 n_rows; | | const u32 n_rows; | |
| const u32 n_cols; | | const u32 n_cols; | |
| const u32 n_elem; | | const u32 n_elem; | |
| | | | |
| inline explicit Proxy(const eOp<T1, eop_type>& A) | | inline explicit Proxy(const eOp<T1, eop_type>& A) | |
| : Q(A) | | : Q(A) | |
|
| , n_rows(A.n_rows) | | , n_rows(A.P.n_rows) | |
| , n_cols(A.n_cols) | | , n_cols(A.P.n_cols) | |
| , n_elem(A.n_elem) | | , n_elem(A.P.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn eop_type::get_elem(Q, i); } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn eop_type::get_elem(Q, i); } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn eop_type::get_elem(Q, row,col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn eop_type::get_elem(Q, row,col); } | |
| }; | | }; | |
| | | | |
| template<typename T1, typename T2, typename eglue_type> | | template<typename T1, typename T2, typename eglue_type> | |
| class Proxy< eGlue<T1, T2, eglue_type > > | | class Proxy< eGlue<T1, T2, eglue_type > > | |
| | | | |
| skipping to change at line 270 | | skipping to change at line 297 | |
| typedef eGlue<T1, T2, eglue_type> stored_type; | | typedef eGlue<T1, T2, eglue_type> stored_type; | |
| | | | |
| const eGlue<T1, T2, eglue_type>& Q; | | const eGlue<T1, T2, eglue_type>& Q; | |
| | | | |
| const u32 n_rows; | | const u32 n_rows; | |
| const u32 n_cols; | | const u32 n_cols; | |
| const u32 n_elem; | | const u32 n_elem; | |
| | | | |
| inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A) | | inline explicit Proxy(const eGlue<T1, T2, eglue_type>& A) | |
| : Q(A) | | : Q(A) | |
|
| , n_rows(A.n_rows) | | , n_rows(A.P1.n_rows) | |
| , n_cols(A.n_cols) | | , n_cols(A.P1.n_cols) | |
| , n_elem(A.n_elem) | | , n_elem(A.P1.n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| arma_inline elem_type operator[] (const u32 i) const { r
eturn eglue_type::get_elem(Q, i); } | | arma_inline elem_type operator[] (const u32 i) const { r
eturn eglue_type::get_elem(Q, i); } | |
| arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn eglue_type::get_elem(Q, row, col); } | | arma_inline elem_type at (const u32 row, const u32 col) const { r
eturn eglue_type::get_elem(Q, row, col); } | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 5 change blocks. |
| 6 lines changed or deleted | | 33 lines changed or added | |
|
| armadillo | | armadillo | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| #include <fstream> | | #include <fstream> | |
| #include <sstream> | | #include <sstream> | |
| #include <stdexcept> | | #include <stdexcept> | |
| #include <limits> | | #include <limits> | |
| #include <algorithm> | | #include <algorithm> | |
| #include <complex> | | #include <complex> | |
| #include <vector> | | #include <vector> | |
| | | | |
| #if defined(ARMA_HAVE_GETTIMEOFDAY) | | #if defined(ARMA_HAVE_GETTIMEOFDAY) | |
| #include <sys/time.h> | | #include <sys/time.h> | |
|
| | | #undef ARMA_USE_BOOST_DATE | |
| #endif | | #endif | |
| | | | |
| #if defined(ARMA_USE_BOOST) | | #if defined(ARMA_USE_BOOST) | |
|
| #include <boost/format.hpp> | | | |
| #include <boost/current_function.hpp> | | | |
| #include <boost/math/complex.hpp> | | #include <boost/math/complex.hpp> | |
| #include <boost/math/special_functions/acosh.hpp> | | #include <boost/math/special_functions/acosh.hpp> | |
| #include <boost/math/special_functions/asinh.hpp> | | #include <boost/math/special_functions/asinh.hpp> | |
| #include <boost/math/special_functions/atanh.hpp> | | #include <boost/math/special_functions/atanh.hpp> | |
|
| | | #include <boost/current_function.hpp> | |
| | | | |
| | | #if defined(ARMA_EXTRA_DEBUG) | |
| | | #include <boost/format.hpp> | |
| | | #define ARMA_USE_BOOST_FORMAT | |
| | | #endif | |
| #endif | | #endif | |
| | | | |
| #if defined(ARMA_USE_BOOST_DATE) | | #if defined(ARMA_USE_BOOST_DATE) | |
| #include <boost/date_time/posix_time/posix_time.hpp> | | #include <boost/date_time/posix_time/posix_time.hpp> | |
| #endif | | #endif | |
| | | | |
| #if defined(ARMA_USE_ATLAS) | | #if defined(ARMA_USE_ATLAS) | |
| #define ARMA_TMP_STRING(x) x | | #define ARMA_TMP_STRING(x) x | |
| | | | |
| #define ARMA_ATLAS_INCLUDE_1 <ARMA_TMP_STRING(ARMA_ATLAS_INCLUDE_DIR)/ARM
A_TMP_STRING(cblas.h)> | | #define ARMA_ATLAS_INCLUDE_1 <ARMA_TMP_STRING(ARMA_ATLAS_INCLUDE_DIR)/ARM
A_TMP_STRING(cblas.h)> | |
| | | | |
| skipping to change at line 163 | | skipping to change at line 168 | |
| #include "armadillo_bits/op_repmat_proto.hpp" | | #include "armadillo_bits/op_repmat_proto.hpp" | |
| #include "armadillo_bits/op_reshape_proto.hpp" | | #include "armadillo_bits/op_reshape_proto.hpp" | |
| #include "armadillo_bits/op_cov_proto.hpp" | | #include "armadillo_bits/op_cov_proto.hpp" | |
| #include "armadillo_bits/op_cor_proto.hpp" | | #include "armadillo_bits/op_cor_proto.hpp" | |
| #include "armadillo_bits/op_shuffle_proto.hpp" | | #include "armadillo_bits/op_shuffle_proto.hpp" | |
| #include "armadillo_bits/op_prod_proto.hpp" | | #include "armadillo_bits/op_prod_proto.hpp" | |
| #include "armadillo_bits/op_pinv_proto.hpp" | | #include "armadillo_bits/op_pinv_proto.hpp" | |
| #include "armadillo_bits/op_dotext_proto.hpp" | | #include "armadillo_bits/op_dotext_proto.hpp" | |
| #include "armadillo_bits/op_flip_proto.hpp" | | #include "armadillo_bits/op_flip_proto.hpp" | |
| #include "armadillo_bits/op_princomp_proto.hpp" | | #include "armadillo_bits/op_princomp_proto.hpp" | |
|
| | | #include "armadillo_bits/op_princomp_cov_proto.hpp" | |
| | | | |
| #include "armadillo_bits/glue_times_proto.hpp" | | #include "armadillo_bits/glue_times_proto.hpp" | |
| #include "armadillo_bits/glue_cov_proto.hpp" | | #include "armadillo_bits/glue_cov_proto.hpp" | |
| #include "armadillo_bits/glue_cor_proto.hpp" | | #include "armadillo_bits/glue_cor_proto.hpp" | |
| #include "armadillo_bits/glue_kron_proto.hpp" | | #include "armadillo_bits/glue_kron_proto.hpp" | |
| | | | |
| // | | // | |
| // debugging functions | | // debugging functions | |
| | | | |
| #include "armadillo_bits/debug.hpp" | | #include "armadillo_bits/debug.hpp" | |
| | | | |
| skipping to change at line 281 | | skipping to change at line 287 | |
| #include "armadillo_bits/fn_cor.hpp" | | #include "armadillo_bits/fn_cor.hpp" | |
| #include "armadillo_bits/fn_shuffle.hpp" | | #include "armadillo_bits/fn_shuffle.hpp" | |
| #include "armadillo_bits/fn_prod.hpp" | | #include "armadillo_bits/fn_prod.hpp" | |
| #include "armadillo_bits/fn_eps.hpp" | | #include "armadillo_bits/fn_eps.hpp" | |
| #include "armadillo_bits/fn_pinv.hpp" | | #include "armadillo_bits/fn_pinv.hpp" | |
| #include "armadillo_bits/fn_rank.hpp" | | #include "armadillo_bits/fn_rank.hpp" | |
| #include "armadillo_bits/fn_kron.hpp" | | #include "armadillo_bits/fn_kron.hpp" | |
| #include "armadillo_bits/fn_flip.hpp" | | #include "armadillo_bits/fn_flip.hpp" | |
| #include "armadillo_bits/fn_as_scalar.hpp" | | #include "armadillo_bits/fn_as_scalar.hpp" | |
| #include "armadillo_bits/fn_princomp.hpp" | | #include "armadillo_bits/fn_princomp.hpp" | |
|
| | | #include "armadillo_bits/fn_princomp_cov.hpp" | |
| | | | |
| // | | // | |
| // class meat | | // class meat | |
| | | | |
| #include "armadillo_bits/gemm.hpp" | | #include "armadillo_bits/gemm.hpp" | |
| #include "armadillo_bits/gemv.hpp" | | #include "armadillo_bits/gemv.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/eop_cube_core_meat.hpp" | | #include "armadillo_bits/eop_cube_core_meat.hpp" | |
| | | | |
| skipping to change at line 337 | | skipping to change at line 344 | |
| #include "armadillo_bits/op_repmat_meat.hpp" | | #include "armadillo_bits/op_repmat_meat.hpp" | |
| #include "armadillo_bits/op_reshape_meat.hpp" | | #include "armadillo_bits/op_reshape_meat.hpp" | |
| #include "armadillo_bits/op_cov_meat.hpp" | | #include "armadillo_bits/op_cov_meat.hpp" | |
| #include "armadillo_bits/op_cor_meat.hpp" | | #include "armadillo_bits/op_cor_meat.hpp" | |
| #include "armadillo_bits/op_shuffle_meat.hpp" | | #include "armadillo_bits/op_shuffle_meat.hpp" | |
| #include "armadillo_bits/op_prod_meat.hpp" | | #include "armadillo_bits/op_prod_meat.hpp" | |
| #include "armadillo_bits/op_pinv_meat.hpp" | | #include "armadillo_bits/op_pinv_meat.hpp" | |
| #include "armadillo_bits/op_dotext_meat.hpp" | | #include "armadillo_bits/op_dotext_meat.hpp" | |
| #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_princomp_cov_meat.hpp" | |
| | | | |
| #include "armadillo_bits/glue_times_meat.hpp" | | #include "armadillo_bits/glue_times_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" | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 6 change blocks. |
| 2 lines changed or deleted | | 10 lines changed or added | |
|
| auxlib_meat.hpp | | auxlib_meat.hpp | |
| | | | |
| skipping to change at line 1187 | | skipping to change at line 1187 | |
| inline | | inline | |
| bool | | bool | |
| auxlib::svd(Col<eT>& S, const Mat<eT>& X) | | auxlib::svd(Col<eT>& S, const Mat<eT>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| { | | { | |
| Mat<eT> A = X; | | Mat<eT> A = X; | |
| | | | |
|
| | | Mat<eT> U(1, 1); | |
| | | Mat<eT> V(1, A.n_cols); | |
| | | | |
| char jobu = 'N'; | | char jobu = 'N'; | |
| char jobvt = 'N'; | | char jobvt = 'N'; | |
| | | | |
| int m = A.n_rows; | | int m = A.n_rows; | |
| int n = A.n_cols; | | int n = A.n_cols; | |
| int lda = A.n_rows; | | int lda = A.n_rows; | |
|
| int ldu = A.n_rows; | | int ldu = U.n_rows; | |
| int ldvt = A.n_cols; | | int ldvt = V.n_rows; | |
| int lwork = 2; | | int lwork = 2 * (std::max)(1, (std::max)( (3*(std::min)(m,n) + (std::m | |
| | | ax)(m,n)), 5*(std::min)(m,n) ) ); | |
| int info; | | int info; | |
| | | | |
|
| Mat<eT> U(1,1); | | | |
| Mat<eT> V(1,1); | | | |
| | | | |
| S.set_size( (std::min)(m, n) ); | | S.set_size( (std::min)(m, n) ); | |
| | | | |
| podarray<eT> work(lwork); | | podarray<eT> work(lwork); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| int lwork_tmp = -1; | | int lwork_tmp = -1; | |
| | | | |
| lapack::gesvd_<eT> | | lapack::gesvd_<eT> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| | | | |
| skipping to change at line 1222 | | skipping to change at line 1222 | |
| A.memptr(), &lda, | | A.memptr(), &lda, | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork_tmp, | | work.memptr(), &lwork_tmp, | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| if(info == 0) | | if(info == 0) | |
| { | | { | |
|
| lwork = static_cast<int>(work[0]); | | int proposed_lwork = static_cast<int>(work[0]); | |
| work.set_size(lwork); | | | |
| | | if(proposed_lwork > lwork) | |
| | | { | |
| | | lwork = proposed_lwork; | |
| | | work.set_size(lwork); | |
| | | } | |
| | | | |
| lapack::gesvd_<eT> | | lapack::gesvd_<eT> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| &m, &n, | | &m, &n, | |
| A.memptr(), &lda, | | A.memptr(), &lda, | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork, | | work.memptr(), &lwork, | |
| &info | | &info | |
| ); | | ); | |
|
| | | | |
| return (info == 0); | | | |
| } | | | |
| else | | | |
| { | | | |
| return false; | | | |
| } | | } | |
|
| | | | |
| | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_stop("svd(): need LAPACK"); | | arma_stop("svd(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename T> | | template<typename T> | |
| | | | |
| skipping to change at line 1265 | | skipping to change at line 1266 | |
| auxlib::svd(Col<T>& S, const Mat< std::complex<T> >& X) | | auxlib::svd(Col<T>& S, const Mat< std::complex<T> >& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef std::complex<T> eT; | | typedef std::complex<T> eT; | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| { | | { | |
| Mat<eT> A = X; | | Mat<eT> A = X; | |
| | | | |
|
| | | Mat<eT> U(1, 1); | |
| | | Mat<eT> V(1, A.n_cols); | |
| | | | |
| char jobu = 'N'; | | char jobu = 'N'; | |
| char jobvt = 'N'; | | char jobvt = 'N'; | |
| | | | |
| int m = A.n_rows; | | int m = A.n_rows; | |
| int n = A.n_cols; | | int n = A.n_cols; | |
| int lda = A.n_rows; | | int lda = A.n_rows; | |
|
| int ldu = A.n_rows; | | int ldu = U.n_rows; | |
| int ldvt = A.n_cols; | | int ldvt = V.n_rows; | |
| int lwork = 2 * (std::min)(m,n) + (std::max)(m,n); | | int lwork = 2 * (std::max)(1, 2*(std::min)(m,n)+(std::max)(m,n) ); | |
| int info; | | int info; | |
| | | | |
|
| Mat<eT> U(1,1); | | | |
| Mat<eT> V(1,1); | | | |
| | | | |
| S.set_size( (std::min)(m,n) ); | | S.set_size( (std::min)(m,n) ); | |
| | | | |
| podarray<eT> work(lwork); | | podarray<eT> work(lwork); | |
| podarray<T> rwork( 5*(std::min)(m,n) ); | | podarray<T> rwork( 5*(std::min)(m,n) ); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| int lwork_tmp = -1; | | int lwork_tmp = -1; | |
| | | | |
| lapack::cx_gesvd_<T> | | lapack::cx_gesvd_<T> | |
| ( | | ( | |
| | | | |
| skipping to change at line 1321 | | skipping to change at line 1322 | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| &m, &n, | | &m, &n, | |
| A.memptr(), &lda, | | A.memptr(), &lda, | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork, | | work.memptr(), &lwork, | |
| rwork.memptr(), | | rwork.memptr(), | |
| &info | | &info | |
| ); | | ); | |
|
| | | | |
| return (info == 0); | | | |
| } | | | |
| else | | | |
| { | | | |
| return false; | | | |
| } | | } | |
|
| | | | |
| | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_stop("svd(): need LAPACK"); | | arma_stop("svd(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
| auxlib::svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Mat<eT>& X) | | auxlib::svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Mat<eT>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| { | | { | |
| Mat<eT> A = X; | | Mat<eT> A = X; | |
| | | | |
|
| | | U.set_size(A.n_rows, A.n_rows); | |
| | | V.set_size(A.n_cols, A.n_cols); | |
| | | | |
| char jobu = 'A'; | | char jobu = 'A'; | |
| char jobvt = 'A'; | | char jobvt = 'A'; | |
| | | | |
| int m = A.n_rows; | | int m = A.n_rows; | |
| int n = A.n_cols; | | int n = A.n_cols; | |
| int lda = A.n_rows; | | int lda = A.n_rows; | |
|
| int ldu = A.n_rows; | | int ldu = U.n_rows; | |
| int ldvt = A.n_cols; | | int ldvt = V.n_rows; | |
| int lwork = 2; | | int lwork = 2 * (std::max)(1, (std::max)( (3*(std::min)(m,n) + (std::m | |
| | | ax)(m,n)), 5*(std::min)(m,n) ) ); | |
| int info; | | int info; | |
| | | | |
|
| U.set_size(m,m); | | | |
| V.set_size(n,n); | | | |
| | | | |
| S.set_size( (std::min)(m,n) ); | | S.set_size( (std::min)(m,n) ); | |
| podarray<eT> work(lwork); | | podarray<eT> work(lwork); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| int lwork_tmp = -1; | | int lwork_tmp = -1; | |
| | | | |
| lapack::gesvd_<eT> | | lapack::gesvd_<eT> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| &m, &n, | | &m, &n, | |
| A.memptr(), &lda, | | A.memptr(), &lda, | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork_tmp, | | work.memptr(), &lwork_tmp, | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| if(info == 0) | | if(info == 0) | |
| { | | { | |
|
| lwork = static_cast<int>(work[0]); | | int proposed_lwork = static_cast<int>(work[0]); | |
| work.set_size(lwork); | | if(proposed_lwork > lwork) | |
| | | { | |
| | | lwork = proposed_lwork; | |
| | | work.set_size(lwork); | |
| | | } | |
| | | | |
| lapack::gesvd_<eT> | | lapack::gesvd_<eT> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| &m, &n, | | &m, &n, | |
| A.memptr(), &lda, | | A.memptr(), &lda, | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork, | | work.memptr(), &lwork, | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| op_trans::apply(V,V); // op_trans will work out that an in-place tra
nspose can be done | | op_trans::apply(V,V); // op_trans will work out that an in-place tra
nspose can be done | |
|
| | | | |
| return (info == 0); | | | |
| } | | | |
| else | | | |
| { | | | |
| return false; | | | |
| } | | } | |
|
| | | | |
| | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_stop("svd(): need LAPACK"); | | arma_stop("svd(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::svd(Mat< std::complex<T> >& U, Col<T> &S, Mat< std::complex<T> >& V
, const Mat< std::complex<T> >& X) | | auxlib::svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V
, const Mat< std::complex<T> >& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef std::complex<T> eT; | | typedef std::complex<T> eT; | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| { | | { | |
| Mat<eT> A = X; | | Mat<eT> A = X; | |
| | | | |
|
| | | U.set_size(A.n_rows, A.n_rows); | |
| | | V.set_size(A.n_cols, A.n_cols); | |
| | | | |
| char jobu = 'A'; | | char jobu = 'A'; | |
| char jobvt = 'A'; | | char jobvt = 'A'; | |
| | | | |
| int m = A.n_rows; | | int m = A.n_rows; | |
| int n = A.n_cols; | | int n = A.n_cols; | |
| int lda = A.n_rows; | | int lda = A.n_rows; | |
|
| int ldu = A.n_rows; | | int ldu = U.n_rows; | |
| int ldvt = A.n_cols; | | int ldvt = V.n_rows; | |
| int lwork = 2; | | int lwork = 2 * (std::max)(1, 2*(std::min)(m,n)+(std::max)(m,n) ); | |
| int info; | | int info; | |
| | | | |
|
| U.set_size(m,m); | | | |
| V.set_size(n,n); | | | |
| | | | |
| S.set_size( (std::min)(m,n) ); | | S.set_size( (std::min)(m,n) ); | |
| | | | |
| podarray<eT> work(lwork); | | podarray<eT> work(lwork); | |
| podarray<T> rwork( 5*(std::min)(m,n) ); | | podarray<T> rwork( 5*(std::min)(m,n) ); | |
| | | | |
| // let gesvd_() calculate the optimum size of the workspace | | // let gesvd_() calculate the optimum size of the workspace | |
| int lwork_tmp = -1; | | int lwork_tmp = -1; | |
| lapack::cx_gesvd_<T> | | lapack::cx_gesvd_<T> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| | | | |
| skipping to change at line 1463 | | skipping to change at line 1460 | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork_tmp, | | work.memptr(), &lwork_tmp, | |
| rwork.memptr(), | | rwork.memptr(), | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| if(info == 0) | | if(info == 0) | |
| { | | { | |
|
| lwork = static_cast<int>(real(work[0])); | | int proposed_lwork = static_cast<int>(real(work[0])); | |
| work.set_size(lwork); | | if(proposed_lwork > lwork) | |
| | | { | |
| | | lwork = proposed_lwork; | |
| | | work.set_size(lwork); | |
| | | } | |
| | | | |
| lapack::cx_gesvd_<T> | | lapack::cx_gesvd_<T> | |
| ( | | ( | |
| &jobu, &jobvt, | | &jobu, &jobvt, | |
| &m, &n, | | &m, &n, | |
| A.memptr(), &lda, | | A.memptr(), &lda, | |
| S.memptr(), | | S.memptr(), | |
| U.memptr(), &ldu, | | U.memptr(), &ldu, | |
| V.memptr(), &ldvt, | | V.memptr(), &ldvt, | |
| work.memptr(), &lwork, | | work.memptr(), &lwork, | |
| rwork.memptr(), | | rwork.memptr(), | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| op_htrans::apply(V,V); // op_htrans will work out that an in-place t
ranspose can be done | | op_htrans::apply(V,V); // op_htrans will work out that an in-place t
ranspose can be done | |
|
| | | | |
| for(u32 i=0; i<A.n_cols; ++i) | | | |
| { | | | |
| V.at(i,i) = std::conj( V.at(i,i) ); | | | |
| } | | | |
| | | | |
| return (info == 0); | | | |
| } | | | |
| else | | | |
| { | | | |
| return false; | | | |
| } | | } | |
|
| | | | |
| | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_stop("svd(): need LAPACK"); | | arma_stop("svd(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| } | | } | |
| | | | |
| | | | |
End of changes. 24 change blocks. |
| 60 lines changed or deleted | | 54 lines changed or added | |
|
| eOpCube_meat.hpp | | eOpCube_meat.hpp | |
| | | | |
| skipping to change at line 21 | | skipping to change at line 21 | |
| // 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 eOpCube | | //! \addtogroup eOpCube | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m) | | eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m) | |
|
| : P (in_m.get_ref()) | | : P (in_m.get_ref()) | |
| , n_rows (P.n_rows) | | , aux (aux) | |
| , n_cols (P.n_cols) | | , aux_u32_a (aux_u32_a) | |
| , n_elem_slice(P.n_elem_slice) | | , aux_u32_b (aux_u32_b) | |
| , n_slices (P.n_slices) | | , aux_u32_c (aux_u32_c) | |
| , n_elem (P.n_elem) | | | |
| , aux (aux) | | | |
| , aux_u32_a (aux_u32_a) | | | |
| , aux_u32_b (aux_u32_b) | | | |
| , aux_u32_c (aux_u32_c) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const typename T1::elem_type in_aux) | | eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const typename T1::elem_type in_aux) | |
|
| : P (in_m.get_ref()) | | : P (in_m.get_ref()) | |
| , n_rows (P.n_rows) | | , aux (in_aux) | |
| , n_cols (P.n_cols) | | , aux_u32_a (aux_u32_a) | |
| , n_elem_slice(P.n_elem_slice) | | , aux_u32_b (aux_u32_b) | |
| , n_slices (P.n_slices) | | , aux_u32_c (aux_u32_c) | |
| , n_elem (P.n_elem) | | | |
| , aux (in_aux) | | | |
| , aux_u32_a (aux_u32_a) | | | |
| , aux_u32_b (aux_u32_b) | | | |
| , aux_u32_c (aux_u32_c) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b) | | eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b) | |
|
| : P (in_m.get_ref()) | | : P (in_m.get_ref()) | |
| , n_rows (P.n_rows) | | , aux (aux) | |
| , n_cols (P.n_cols) | | , aux_u32_a (in_aux_u32_a) | |
| , n_elem_slice(P.n_elem_slice) | | , aux_u32_b (in_aux_u32_b) | |
| , n_slices (P.n_slices) | | , aux_u32_c (aux_u32_c) | |
| , n_elem (P.n_elem) | | | |
| , aux (aux) | | | |
| , aux_u32_a (in_aux_u32_a) | | | |
| , aux_u32_b (in_aux_u32_b) | | | |
| , aux_u32_c (aux_u32_c) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_
c) | | eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_
c) | |
|
| : P (in_m.get_ref()) | | : P (in_m.get_ref()) | |
| , n_rows (P.n_rows) | | , aux (aux) | |
| , n_cols (P.n_cols) | | , aux_u32_a (in_aux_u32_a) | |
| , n_elem_slice(P.n_elem_slice) | | , aux_u32_b (in_aux_u32_b) | |
| , n_slices (P.n_slices) | | , aux_u32_c (in_aux_u32_c) | |
| , n_elem (P.n_elem) | | | |
| , aux (aux) | | | |
| , aux_u32_a (in_aux_u32_a) | | | |
| , aux_u32_b (in_aux_u32_b) | | | |
| , aux_u32_c (in_aux_u32_c) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u3
2 in_aux_u32_b, const u32 in_aux_u32_c) | | eOpCube<T1, eop_type>::eOpCube(const BaseCube<typename T1::elem_type, T1>&
in_m, const typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u3
2 in_aux_u32_b, const u32 in_aux_u32_c) | |
|
| : P (in_m.get_ref()) | | : P (in_m.get_ref()) | |
| , n_rows (P.n_rows) | | , aux (in_aux) | |
| , n_cols (P.n_cols) | | , aux_u32_a (in_aux_u32_a) | |
| , n_elem_slice(P.n_elem_slice) | | , aux_u32_b (in_aux_u32_b) | |
| , n_slices (P.n_slices) | | , aux_u32_c (in_aux_u32_c) | |
| , n_elem (P.n_elem) | | | |
| , aux (in_aux) | | | |
| , aux_u32_a (in_aux_u32_a) | | | |
| , aux_u32_b (in_aux_u32_b) | | | |
| , aux_u32_c (in_aux_u32_c) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::eOpCube(const u32 in_n_rows, const u32 in_n_cols, co
nst u32 in_n_slices) | | eOpCube<T1, eop_type>::eOpCube(const u32 in_n_rows, const u32 in_n_cols, co
nst u32 in_n_slices) | |
|
| : P (P) | | : P (in_n_rows, in_n_cols, in_n_slices) | |
| , n_rows (in_n_rows) | | , aux (aux) | |
| , n_cols (in_n_cols) | | , aux_u32_a (aux_u32_a) | |
| , n_elem_slice(n_rows*n_cols) | | , aux_u32_b (aux_u32_b) | |
| , n_slices (in_n_slices) | | , aux_u32_c (aux_u32_c) | |
| , n_elem (n_elem_slice*n_slices) | | | |
| , aux (aux) | | | |
| , aux_u32_a (aux_u32_a) | | | |
| , aux_u32_b (aux_u32_b) | | | |
| , aux_u32_c (aux_u32_c) | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOpCube<T1, eop_type>::~eOpCube() | | eOpCube<T1, eop_type>::~eOpCube() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| | | | |
End of changes. 6 change blocks. |
| 60 lines changed or deleted | | 30 lines changed or added | |
|
| eOp_meat.hpp | | eOp_meat.hpp | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| // by the Free Software Foundation, either version 3 | | // by the Free Software Foundation, either version 3 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| //! \addtogroup eOp | | //! \addtogroup eOp | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m) | | eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m) | |
| : P(in_m.get_ref()) | | : P(in_m.get_ref()) | |
|
| , n_rows(P.n_rows) | | | |
| , n_cols(P.n_cols) | | | |
| , n_elem(P.n_elem) | | | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(aux_u32_a) | | , aux_u32_a(aux_u32_a) | |
| , aux_u32_b(aux_u32_b) | | , aux_u32_b(aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_check( (eop_type::size_ok(n_rows, n_cols) == false), eop_type:
:error_msg() ); | | arma_debug_check( (eop_type::size_ok(P.n_rows, P.n_cols) == false), eop_t
ype::error_msg() ); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const
typename T1::elem_type in_aux) | | eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const
typename T1::elem_type in_aux) | |
| : P(in_m.get_ref()) | | : P(in_m.get_ref()) | |
|
| , n_rows(P.n_rows) | | | |
| , n_cols(P.n_cols) | | | |
| , n_elem(P.n_elem) | | | |
| , aux(in_aux) | | , aux(in_aux) | |
| , aux_u32_a(aux_u32_a) | | , aux_u32_a(aux_u32_a) | |
| , aux_u32_b(aux_u32_b) | | , aux_u32_b(aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_check( (eop_type::size_ok(n_rows, n_cols) == false), eop_type:
:error_msg() ); | | arma_debug_check( (eop_type::size_ok(P.n_rows, P.n_cols) == false), eop_t
ype::error_msg() ); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const
u32 in_aux_u32_a, const u32 in_aux_u32_b) | | eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const
u32 in_aux_u32_a, const u32 in_aux_u32_b) | |
| : P(in_m.get_ref()) | | : P(in_m.get_ref()) | |
|
| , n_rows(P.n_rows) | | | |
| , n_cols(P.n_cols) | | | |
| , n_elem(P.n_elem) | | | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(in_aux_u32_a) | | , aux_u32_a(in_aux_u32_a) | |
| , aux_u32_b(in_aux_u32_b) | | , aux_u32_b(in_aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_check( (eop_type::size_ok(n_rows, n_cols) == false), eop_type:
:error_msg() ); | | arma_debug_check( (eop_type::size_ok(P.n_rows, P.n_cols) == false), eop_t
ype::error_msg() ); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const
typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32
_b) | | eOp<T1, eop_type>::eOp(const Base<typename T1::elem_type, T1>& in_m, const
typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32
_b) | |
| : P(in_m.get_ref()) | | : P(in_m.get_ref()) | |
|
| , n_rows(P.n_rows) | | | |
| , n_cols(P.n_cols) | | | |
| , n_elem(P.n_elem) | | | |
| , aux(in_aux) | | , aux(in_aux) | |
| , aux_u32_a(in_aux_u32_a) | | , aux_u32_a(in_aux_u32_a) | |
| , aux_u32_b(in_aux_u32_b) | | , aux_u32_b(in_aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_check( (eop_type::size_ok(n_rows, n_cols) == false), eop_type:
:error_msg() ); | | arma_debug_check( (eop_type::size_ok(P.n_rows, P.n_cols) == false), eop_t
ype::error_msg() ); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOp<T1, eop_type>::eOp(const u32 in_n_rows, const u32 in_n_cols) | | eOp<T1, eop_type>::eOp(const u32 in_n_rows, const u32 in_n_cols) | |
|
| : P(P) | | : P(in_n_rows, in_n_cols) | |
| , n_rows(in_n_rows) | | | |
| , n_cols(in_n_cols) | | | |
| , n_elem(n_rows*n_cols) | | | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(aux_u32_a) | | , aux_u32_a(aux_u32_a) | |
| , aux_u32_b(aux_u32_b) | | , aux_u32_b(aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_check( (eop_type::size_ok(n_rows, n_cols) == false), eop_type:
:error_msg() ); | | arma_debug_check( (eop_type::size_ok(P.n_rows, P.n_cols) == false), eop_t
ype::error_msg() ); | |
| } | | } | |
| | | | |
| template<typename T1, typename eop_type> | | template<typename T1, typename eop_type> | |
| eOp<T1, eop_type>::~eOp() | | eOp<T1, eop_type>::~eOp() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 10 change blocks. |
| 21 lines changed or deleted | | 6 lines changed or added | |
|
| eglue_core_meat.hpp | | eglue_core_meat.hpp | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 96 | |
| eglue_core<eglue_type>::apply_proxy(Mat<typename T1::elem_type>& out, const
eGlue<T1, T2, eglue_type>& x) | | eglue_core<eglue_type>::apply_proxy(Mat<typename T1::elem_type>& out, const
eGlue<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // eglue_type::apply_proxy() function is not allowed to unwrap things | | // eglue_type::apply_proxy() function is not allowed to unwrap things | |
| // (in order to get the input into a common format). | | // (in order to get the input into a common format). | |
| // the proxy class is already providing objects with element access | | // the proxy class is already providing objects with element access | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| out.set_size(x.n_rows, x.n_cols); | | const Proxy<T1>& P1 = x.P1; | |
| | | const Proxy<T2>& P2 = x.P2; | |
| | | | |
|
| eT* out_mem = out.memptr(); | | out.set_size(P1.n_rows, P1.n_cols); | |
| const Proxy<T1>& P1 = x.P1; | | | |
| const Proxy<T2>& P2 = x.P2; | | eT* out_mem = out.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = P1.n_elem; | |
| | | | |
| if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_core::apply_proxy(): unhandled eglue_type"); | | arma_stop("eglue_core::apply_proxy(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 124 | | skipping to change at line 125 | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eglue_core<eglue_type>::apply_unwrap(Mat<typename T1::elem_type>& out, cons
t eGlue<T1, T2, eglue_type>& x) | | eglue_core<eglue_type>::apply_unwrap(Mat<typename T1::elem_type>& out, cons
t eGlue<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| out.set_size(x.n_rows, x.n_cols); | | | |
| | | | |
| const unwrap<typename Proxy<T1>::stored_type> tmp1(x.P1.Q); | | const unwrap<typename Proxy<T1>::stored_type> tmp1(x.P1.Q); | |
| const unwrap<typename Proxy<T2>::stored_type> tmp2(x.P2.Q); | | const unwrap<typename Proxy<T2>::stored_type> tmp2(x.P2.Q); | |
| | | | |
| const Mat<eT>& A = tmp1.M; | | const Mat<eT>& A = tmp1.M; | |
| const Mat<eT>& B = tmp2.M; | | const Mat<eT>& B = tmp2.M; | |
| | | | |
|
| | | out.set_size(A.n_rows, A.n_cols); | |
| | | | |
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const eT* A_mem = A.memptr(); | | const eT* A_mem = A.memptr(); | |
| const eT* B_mem = B.memptr(); | | const eT* B_mem = B.memptr(); | |
|
| const u32 n_elem = x.n_elem; | | const u32 n_elem = A.n_elem; | |
| | | | |
| if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] + B_mem[i]; } | | if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] + B_mem[i]; } | |
| else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] - B_mem[i]; } | | else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] - B_mem[i]; } | |
| else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] / B_mem[i]; } | | else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] / B_mem[i]; } | |
| else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] * B_mem[i]; } | | else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] = A_mem[i] * B_mem[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_core::apply_unwrap(): unhandled eglue_type"); | | arma_stop("eglue_core::apply_unwrap(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 158 | | skipping to change at line 159 | |
| 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(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, "matrix | | const Proxy<T1>& P1 = x.P1; | |
| addition"); | | const Proxy<T2>& P2 = x.P2; | |
| | | | |
| | | arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "matr | |
| | | ix addition"); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const Proxy<T1>& P1 = x.P1; | | const u32 n_elem = P1.n_elem; | |
| const Proxy<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] += P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_core::apply_inplace_plus(): unhandled eglue_type"); | | arma_stop("eglue_core::apply_inplace_plus(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 186 | | skipping to change at line 188 | |
| 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(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, "matrix | | const Proxy<T1>& P1 = x.P1; | |
| subtraction"); | | const Proxy<T2>& P2 = x.P2; | |
| | | | |
|
| eT* out_mem = out.memptr(); | | arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "matr | |
| const Proxy<T1>& P1 = x.P1; | | ix subtraction"); | |
| const Proxy<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P1.n_elem; | |
| | | | |
| if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] -= P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_core::apply_inplace_minus(): unhandled eglue_type"); | | arma_stop("eglue_core::apply_inplace_minus(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 214 | | skipping to change at line 217 | |
| 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(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, "elemen | | const Proxy<T1>& P1 = x.P1; | |
| t-wise matrix multiplication"); | | const Proxy<T2>& P2 = x.P2; | |
| | | | |
| | | arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "elem | |
| | | ent-wise matrix multiplication"); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const Proxy<T1>& P1 = x.P1; | | const u32 n_elem = P1.n_elem; | |
| const Proxy<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] *= P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_core::apply_inplace_schur(): unhandled eglue_type"); | | arma_stop("eglue_core::apply_inplace_schur(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 242 | | skipping to change at line 246 | |
| 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(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, "elemen | | const Proxy<T1>& P1 = x.P1; | |
| t-wise matrix division"); | | const Proxy<T2>& P2 = x.P2; | |
| | | | |
| | | arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "elem | |
| | | ent-wise matrix division"); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const Proxy<T1>& P1 = x.P1; | | const u32 n_elem = P1.n_elem; | |
| const Proxy<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_div >::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0
; i<n_elem; ++i) { out_mem[i] /= P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_core::apply_inplace_div(): unhandled eglue_type"); | | arma_stop("eglue_core::apply_inplace_div(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 13 change blocks. |
| 32 lines changed or deleted | | 37 lines changed or added | |
|
| eglue_cube_core_meat.hpp | | eglue_cube_core_meat.hpp | |
| | | | |
| skipping to change at line 74 | | skipping to change at line 74 | |
| eglue_cube_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const
eGlueCube<T1, T2, eglue_type>& x) | | eglue_cube_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const
eGlueCube<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // eglue_type::apply() function is not allowed to unwrap things | | // eglue_type::apply() function is not allowed to unwrap things | |
| // (in order to get the input into a common format). | | // (in order to get the input into a common format). | |
| // the proxy class is already providing objects with element access | | // the proxy class is already providing objects with element access | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| out.set_size(x.n_rows, x.n_cols, x.n_slices); | | const ProxyCube<T1>& P1 = x.P1; | |
| | | const ProxyCube<T2>& P2 = x.P2; | |
| | | | |
|
| eT* out_mem = out.memptr(); | | out.set_size(P1.n_rows, P1.n_cols, P1.n_slices); | |
| const ProxyCube<T1>& P1 = x.P1; | | | |
| const ProxyCube<T2>& P2 = x.P2; | | eT* out_mem = out.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = P1.n_elem; | |
| | | | |
| if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_cube_core::apply(): unhandled eglue_type"); | | arma_stop("eglue_cube_core::apply(): unhandled eglue_type"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 103 | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eglue_cube_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type
>& out, const eGlueCube<T1, T2, eglue_type>& x) | | eglue_cube_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type
>& out, const eGlueCube<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_rows, x.n | | const ProxyCube<T1>& P1 = x.P1; | |
| _cols, x.n_slices, "cube addition"); | | const ProxyCube<T2>& P2 = x.P2; | |
| | | | |
| | | arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P1.n_rows, P1 | |
| | | .n_cols, P1.n_slices, "cube addition"); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const ProxyCube<T1>& P1 = x.P1; | | const u32 n_elem = P1.n_elem; | |
| const ProxyCube<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_cube_core::apply_inplace_plus(): unhandled eglue_type"
); | | arma_stop("eglue_cube_core::apply_inplace_plus(): unhandled eglue_type"
); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 130 | | skipping to change at line 132 | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eglue_cube_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_typ
e>& out, const eGlueCube<T1, T2, eglue_type>& x) | | eglue_cube_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_typ
e>& out, const eGlueCube<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_rows, x.n | | const ProxyCube<T1>& P1 = x.P1; | |
| _cols, x.n_slices, "cube subtraction"); | | const ProxyCube<T2>& P2 = x.P2; | |
| | | | |
| | | arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P1.n_rows, P1 | |
| | | .n_cols, P1.n_slices, "cube subtraction"); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const ProxyCube<T1>& P1 = x.P1; | | const u32 n_elem = P1.n_elem; | |
| const ProxyCube<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_cube_core::apply_inplace_minus(): unhandled eglue_type
"); | | arma_stop("eglue_cube_core::apply_inplace_minus(): unhandled eglue_type
"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 158 | | skipping to change at line 161 | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eglue_cube_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_typ
e>& out, const eGlueCube<T1, T2, eglue_type>& x) | | eglue_cube_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_typ
e>& out, const eGlueCube<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_rows, x.n | | const ProxyCube<T1>& P1 = x.P1; | |
| _cols, x.n_slices, "element-wise cube multiplication"); | | const ProxyCube<T2>& P2 = x.P2; | |
| | | | |
|
| eT* out_mem = out.memptr(); | | arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P1.n_rows, P1 | |
| const ProxyCube<T1>& P1 = x.P1; | | .n_cols, P1.n_slices, "element-wise cube multiplication"); | |
| const ProxyCube<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P1.n_elem; | |
| | | | |
| if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_cube_core::apply_inplace_schur(): unhandled eglue_type
"); | | arma_stop("eglue_cube_core::apply_inplace_schur(): unhandled eglue_type
"); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 186 | | skipping to change at line 190 | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eglue_cube_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>
& out, const eGlueCube<T1, T2, eglue_type>& x) | | eglue_cube_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>
& out, const eGlueCube<T1, T2, eglue_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_rows, x.n | | const ProxyCube<T1>& P1 = x.P1; | |
| _cols, x.n_slices, "element-wise cube division"); | | const ProxyCube<T2>& P2 = x.P2; | |
| | | | |
| | | arma_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P1.n_rows, P1 | |
| | | .n_cols, P1.n_slices, "element-wise cube division"); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const ProxyCube<T1>& P1 = x.P1; | | const u32 n_elem = P1.n_elem; | |
| const ProxyCube<T2>& P2 = x.P2; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] + P2[i]; } | | if(is_same_type<eglue_type, eglue_cube_plus >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] + P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] - P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_minus>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] - P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] / P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_div >::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] / P2[i]; } | |
| else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] * P2[i]; } | | else if(is_same_type<eglue_type, eglue_cube_schur>::value == true) for(u3
2 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] * P2[i]; } | |
| else | | else | |
| { | | { | |
| arma_stop("eglue_cube_core::apply_inplace_div(): unhandled eglue_type")
; | | arma_stop("eglue_cube_core::apply_inplace_div(): unhandled eglue_type")
; | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 10 change blocks. |
| 29 lines changed or deleted | | 34 lines changed or added | |
|
| eop_core_meat.hpp | | eop_core_meat.hpp | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| arma_inline | | arma_inline | |
| typename T1::elem_type | | typename T1::elem_type | |
| eop_core<eop_type>::get_elem(const eOp<T1, eop_type>& x, const u32 i) | | eop_core<eop_type>::get_elem(const eOp<T1, eop_type>& x, const u32 i) | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| if(is_generator<eop_type>::value == true) { return eo | | if(is_generator<eop_type>::value == true) { return eo | |
| p_aux::generate<eT,eop_type>(); } | | p_aux::generate<eT,eop_type>(); } | |
| else if(is_same_type<eop_type, eop_ones_diag>::value == true) { return (( | | else if(is_same_type<eop_type, eop_ones_diag>::value == true) { return (( | |
| i % x.n_rows) == (i / x.n_rows)) ? eT(1) : eT(0); } | | i % x.P.n_rows) == (i / x.P.n_rows)) ? eT(1) : eT(0); } | |
| else { return eo | | else { return eo | |
| p_core<eop_type>::process(x, x.P[i]); } | | p_core<eop_type>::process(x, x.P[i]); } | |
| } | | } | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| arma_inline | | arma_inline | |
| typename T1::elem_type | | typename T1::elem_type | |
| eop_core<eop_type>::get_elem(const eOp<T1, eop_type>& x, const u32 row, con
st u32 col) | | eop_core<eop_type>::get_elem(const eOp<T1, eop_type>& x, const u32 row, con
st u32 col) | |
| { | | { | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| skipping to change at line 73 | | skipping to change at line 73 | |
| else if(is_same_type<eop_type, eop_scalar_div_pre >::value == true) { r
eturn x.aux / val; } | | else if(is_same_type<eop_type, eop_scalar_div_pre >::value == true) { r
eturn x.aux / val; } | |
| else if(is_same_type<eop_type, eop_scalar_div_post >::value == true) { r
eturn val / x.aux; } | | else if(is_same_type<eop_type, eop_scalar_div_post >::value == true) { r
eturn val / x.aux; } | |
| else if(is_same_type<eop_type, eop_square >::value == true) { r
eturn val*val; } | | else if(is_same_type<eop_type, eop_square >::value == true) { r
eturn val*val; } | |
| else if(is_same_type<eop_type, eop_sqrt >::value == true) { r
eturn std::sqrt(val); } | | else if(is_same_type<eop_type, eop_sqrt >::value == true) { r
eturn std::sqrt(val); } | |
| else if(is_same_type<eop_type, eop_log10 >::value == true) { r
eturn std::log10(val); } | | else if(is_same_type<eop_type, eop_log10 >::value == true) { r
eturn std::log10(val); } | |
| else if(is_same_type<eop_type, eop_log >::value == true) { r
eturn std::log(val); } | | else if(is_same_type<eop_type, eop_log >::value == true) { r
eturn std::log(val); } | |
| else if(is_same_type<eop_type, eop_trunc_log >::value == true) { r
eturn eop_aux::trunc_log(val); } | | else if(is_same_type<eop_type, eop_trunc_log >::value == true) { r
eturn eop_aux::trunc_log(val); } | |
| else if(is_same_type<eop_type, eop_exp >::value == true) { r
eturn std::exp(val); } | | else if(is_same_type<eop_type, eop_exp >::value == true) { r
eturn std::exp(val); } | |
| else if(is_same_type<eop_type, eop_trunc_exp >::value == true) { r
eturn eop_aux::trunc_exp(val); } | | else if(is_same_type<eop_type, eop_trunc_exp >::value == true) { r
eturn eop_aux::trunc_exp(val); } | |
| else if(is_same_type<eop_type, eop_cos >::value == true) { r
eturn std::cos(val); } | | else if(is_same_type<eop_type, eop_cos >::value == true) { r
eturn std::cos(val); } | |
|
| else if(is_same_type<eop_type, eop_cosh >::value == true) { r | | | |
| eturn std::cosh(val); } | | | |
| else if(is_same_type<eop_type, eop_acos >::value == true) { r | | | |
| eturn eop_aux::acos(val); } | | | |
| else if(is_same_type<eop_type, eop_acosh >::value == true) { r | | | |
| eturn eop_aux::acosh(val); } | | | |
| else if(is_same_type<eop_type, eop_sin >::value == true) { r
eturn std::sin(val); } | | else if(is_same_type<eop_type, eop_sin >::value == true) { r
eturn std::sin(val); } | |
|
| else if(is_same_type<eop_type, eop_sinh >::value == true) { r | | | |
| eturn std::sinh(val); } | | | |
| else if(is_same_type<eop_type, eop_asin >::value == true) { r | | | |
| eturn eop_aux::asin(val); } | | | |
| else if(is_same_type<eop_type, eop_asinh >::value == true) { r | | | |
| eturn eop_aux::asinh(val); } | | | |
| else if(is_same_type<eop_type, eop_tan >::value == true) { r
eturn std::tan(val); } | | else if(is_same_type<eop_type, eop_tan >::value == true) { r
eturn std::tan(val); } | |
|
| else if(is_same_type<eop_type, eop_tanh >::value == true) { r | | else if(is_same_type<eop_type, eop_acos >::value == true) { r | |
| eturn std::tanh(val); } | | eturn eop_aux::acos(val); } | |
| | | else if(is_same_type<eop_type, eop_asin >::value == true) { r | |
| | | eturn eop_aux::asin(val); } | |
| else if(is_same_type<eop_type, eop_atan >::value == true) { r
eturn eop_aux::atan(val); } | | else if(is_same_type<eop_type, eop_atan >::value == true) { r
eturn eop_aux::atan(val); } | |
|
| | | else if(is_same_type<eop_type, eop_cosh >::value == true) { r | |
| | | eturn std::cosh(val); } | |
| | | else if(is_same_type<eop_type, eop_sinh >::value == true) { r | |
| | | eturn std::sinh(val); } | |
| | | else if(is_same_type<eop_type, eop_tanh >::value == true) { r | |
| | | eturn std::tanh(val); } | |
| | | else if(is_same_type<eop_type, eop_acosh >::value == true) { r | |
| | | eturn eop_aux::acosh(val); } | |
| | | else if(is_same_type<eop_type, eop_asinh >::value == true) { r | |
| | | eturn eop_aux::asinh(val); } | |
| else if(is_same_type<eop_type, eop_atanh >::value == true) { r
eturn eop_aux::atanh(val); } | | else if(is_same_type<eop_type, eop_atanh >::value == true) { r
eturn eop_aux::atanh(val); } | |
| else if(is_same_type<eop_type, eop_eps >::value == true) { r
eturn eop_aux::direct_eps(val); } | | else if(is_same_type<eop_type, eop_eps >::value == true) { r
eturn eop_aux::direct_eps(val); } | |
| else if(is_same_type<eop_type, eop_abs >::value == true) { r
eturn eop_aux::arma_abs(val); } | | else if(is_same_type<eop_type, eop_abs >::value == true) { r
eturn eop_aux::arma_abs(val); } | |
| else if(is_same_type<eop_type, eop_conj >::value == true) { r
eturn eop_aux::conj(val); } | | else if(is_same_type<eop_type, eop_conj >::value == true) { r
eturn eop_aux::conj(val); } | |
| else if(is_same_type<eop_type, eop_pow >::value == true) { r
eturn eop_aux::pow(val, x.aux); } | | else if(is_same_type<eop_type, eop_pow >::value == true) { r
eturn eop_aux::pow(val, x.aux); } | |
| else if(is_same_type<eop_type, eop_pow_int >::value == true) | | else if(is_same_type<eop_type, eop_pow_int >::value == true) | |
| { | | { | |
| const int exponent = (x.aux_u32_b == 0) ? int(x.aux_u32_a) : -int(x.aux
_u32_a); | | const int exponent = (x.aux_u32_b == 0) ? int(x.aux_u32_a) : -int(x.aux
_u32_a); | |
| | | | |
| return eop_aux::pow_int(val, exponent); | | return eop_aux::pow_int(val, exponent); | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 135 | |
| eop_core<eop_type>::apply_proxy(Mat<typename T1::elem_type>& out, const eOp
<T1, eop_type>& x) | | eop_core<eop_type>::apply_proxy(Mat<typename T1::elem_type>& out, const eOp
<T1, eop_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // eop_type::apply_proxy() function is not allowed to unwrap things | | // eop_type::apply_proxy() function is not allowed to unwrap things | |
| // (in order to get the input into a common format). | | // (in order to get the input into a common format). | |
| // the proxy class is already providing objects with element access | | // the proxy class is already providing objects with element access | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| if(is_generator<eop_type>::value == true) | | const Proxy<T1>& P = x.P; | |
| { | | | |
| out.set_size(x.n_rows, x.n_cols); | | out.set_size(P.n_rows, P.n_cols); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = P.n_elem; | |
| | | | |
|
| | | if(is_generator<eop_type>::value == true) | |
| | | { | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = eop_aux::generate<eT,eop_type>(); | | out_mem[i] = eop_aux::generate<eT,eop_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
|
| if(is_same_type<eop_type, eop_ones_diag>::value == true) | | | |
| { | | { | |
|
| out.set_size(x.n_rows, x.n_cols); | | if(is_same_type<eop_type, eop_ones_diag>::value == true) | |
| | | | |
| for(u32 col=0; col<x.n_rows; ++col) | | | |
| { | | { | |
|
| for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); } | | for(u32 col=0; col<P.n_rows; ++col) | |
| | | { | |
| | | for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); | |
| | | } | |
| | | | |
|
| out.at(col,col) = eT(1); | | out.at(col,col) = eT(1); | |
| | | | |
|
| for(u32 row=col+1; row<x.n_rows; ++row) { out.at(row,col) = eT(0); } | | for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); | |
| | | } | |
| | | } | |
| } | | } | |
|
| } | | else | |
| else | | | |
| { | | | |
| out.set_size(x.n_rows, x.n_cols); | | | |
| | | | |
| eT* out_mem = out.memptr(); | | | |
| const Proxy<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | | |
| { | | { | |
|
| out_mem[i] = eop_core<eop_type>::process(x, P[i]); | | for(u32 i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] = eop_core<eop_type>::process(x, P[i]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_core<eop_type>::apply_unwrap(Mat<typename T1::elem_type>& out, const eO
p<T1, eop_type>& x) | | eop_core<eop_type>::apply_unwrap(Mat<typename T1::elem_type>& out, const eO
p<T1, eop_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap<typename Proxy<T1>::stored_type> tmp(x.P.Q); | | const Proxy<T1>& P = x.P; | |
| | | | |
| | | out.set_size(P.n_rows, P.n_cols); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| | | const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q); | |
| const Mat<eT>& A = tmp.M; | | const Mat<eT>& A = tmp.M; | |
| | | | |
| if(is_generator<eop_type>::value == true) | | if(is_generator<eop_type>::value == true) | |
| { | | { | |
|
| out.set_size(x.n_rows, x.n_cols); | | | |
| | | | |
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = eop_aux::generate<eT,eop_type>(); | | out_mem[i] = eop_aux::generate<eT,eop_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
|
| if(is_same_type<eop_type, eop_ones_diag>::value == true) | | | |
| { | | { | |
|
| out.set_size(x.n_rows, x.n_cols); | | if(is_same_type<eop_type, eop_ones_diag>::value == true) | |
| | | | |
| for(u32 col=0; col<x.n_rows; ++col) | | | |
| { | | { | |
|
| for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); } | | for(u32 col=0; col<P.n_rows; ++col) | |
| | | { | |
| | | for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); | |
| | | } | |
| | | | |
|
| out.at(col,col) = eT(1); | | out.at(col,col) = eT(1); | |
| | | | |
|
| for(u32 row=col+1; row<x.n_rows; ++row) { out.at(row,col) = eT(0); } | | for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); | |
| | | } | |
| | | } | |
| } | | } | |
|
| } | | else | |
| else | | | |
| { | | | |
| out.set_size(x.n_rows, x.n_cols); | | | |
| | | | |
| eT* out_mem = out.memptr(); | | | |
| const eT* A_mem = A.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | | |
| { | | { | |
|
| out_mem[i] = eop_core<eop_type>::process(x, A_mem[i]); | | const eT* A_mem = A.memptr(); | |
| | | | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] = eop_core<eop_type>::process(x, A_mem[i]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, co
nst eOp<T1, eop_type>& x) | | eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, co
nst eOp<T1, eop_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, " | | const Proxy<T1>& P = x.P; | |
| matrix addition"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, P.n_rows, P.n_cols, " | |
| | | matrix addition"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_generator<eop_type>::value == true) | | if(is_generator<eop_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] += eop_aux::generate<eT,eop_type>(); | | out_mem[i] += eop_aux::generate<eT,eop_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
|
| if(is_same_type<eop_type, eop_ones_diag>::value == true) | | | |
| { | | | |
| for(u32 row=0; row<x.n_rows; ++row) | | | |
| { | | | |
| out.at(row,row) += eT(1); | | | |
| } | | | |
| } | | | |
| else | | | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | if(is_same_type<eop_type, eop_ones_diag>::value == true) | |
| const Proxy<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | | |
| { | | { | |
|
| out_mem[i] += eop_core<eop_type>::process(x, P[i]); | | for(u32 row=0; row<P.n_rows; ++row) | |
| | | { | |
| | | out.at(row,row) += eT(1); | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] += eop_core<eop_type>::process(x, P[i]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, c
onst eOp<T1, eop_type>& x) | | eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, c
onst eOp<T1, eop_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, " | | const Proxy<T1>& P = x.P; | |
| matrix subtraction"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, P.n_rows, P.n_cols, " | |
| | | matrix subtraction"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_generator<eop_type>::value == true) | | if(is_generator<eop_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] -= eop_aux::generate<eT,eop_type>(); | | out_mem[i] -= eop_aux::generate<eT,eop_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
|
| if(is_same_type<eop_type, eop_ones_diag>::value == true) | | | |
| { | | { | |
|
| for(u32 row=0; row<x.n_rows; ++row) | | if(is_same_type<eop_type, eop_ones_diag>::value == true) | |
| { | | | |
| out.at(row,row) -= eT(1); | | | |
| } | | | |
| } | | | |
| else | | | |
| { | | | |
| eT* out_mem = out.memptr(); | | | |
| const Proxy<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | | |
| { | | { | |
|
| out_mem[i] -= eop_core<eop_type>::process(x, P[i]); | | for(u32 row=0; row<P.n_rows; ++row) | |
| | | { | |
| | | out.at(row,row) -= eT(1); | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] -= eop_core<eop_type>::process(x, P[i]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, c
onst eOp<T1, eop_type>& x) | | eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, c
onst eOp<T1, eop_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, " | | const Proxy<T1>& P = x.P; | |
| element-wise matrix multiplication"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, P.n_rows, P.n_cols, " | |
| | | element-wise matrix multiplication"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_generator<eop_type>::value == true) | | if(is_generator<eop_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] *= eop_aux::generate<eT,eop_type>(); | | out_mem[i] *= eop_aux::generate<eT,eop_type>(); | |
| } | | } | |
| } | | } | |
|
| if(is_same_type<eop_type, eop_ones_diag>::value == true) | | | |
| { | | | |
| for(u32 col=0; col<x.n_rows; ++col) | | | |
| { | | | |
| for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); } | | | |
| for(u32 row=col+1; row<x.n_rows; ++row) { out.at(row,col) = eT(0); } | | | |
| } | | | |
| } | | | |
| else | | else | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | if(is_same_type<eop_type, eop_ones_diag>::value == true) | |
| const Proxy<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | | |
| { | | { | |
|
| out_mem[i] *= eop_core<eop_type>::process(x, P[i]); | | for(u32 col=0; col<P.n_rows; ++col) | |
| | | { | |
| | | for(u32 row=0; row<col; ++row) { out.at(row,col) = eT(0); | |
| | | } | |
| | | for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) = eT(0); | |
| | | } | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] *= eop_core<eop_type>::process(x, P[i]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_type> | | template<typename eop_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, con
st eOp<T1, eop_type>& x) | | eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, con
st eOp<T1, eop_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, x.n_rows, x.n_cols, " | | const Proxy<T1>& P = x.P; | |
| element-wise matrix division"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, P.n_rows, P.n_cols, " | |
| | | element-wise matrix division"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_generator<eop_type>::value == true) | | if(is_generator<eop_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] /= eop_aux::generate<eT,eop_type>(); | | out_mem[i] /= eop_aux::generate<eT,eop_type>(); | |
| } | | } | |
| } | | } | |
|
| if(is_same_type<eop_type, eop_ones_diag>::value == true) | | | |
| { | | | |
| for(u32 col=0; col<x.n_rows; ++col) | | | |
| { | | | |
| for(u32 row=0; row<col; ++row) { out.at(row,col) /= eT(0); } | | | |
| for(u32 row=col+1; row<x.n_rows; ++row) { out.at(row,col) /= eT(0); } | | | |
| } | | | |
| } | | | |
| else | | else | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | if(is_same_type<eop_type, eop_ones_diag>::value == true) | |
| const Proxy<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | | |
| { | | { | |
|
| out_mem[i] /= eop_core<eop_type>::process(x, P[i]); | | for(u32 col=0; col<P.n_rows; ++col) | |
| | | { | |
| | | for(u32 row=0; row<col; ++row) { out.at(row,col) /= eT(0); | |
| | | } | |
| | | for(u32 row=col+1; row<P.n_rows; ++row) { out.at(row,col) /= eT(0); | |
| | | } | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| | | { | |
| | | out_mem[i] /= eop_core<eop_type>::process(x, P[i]); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 44 change blocks. |
| 143 lines changed or deleted | | 147 lines changed or added | |
|
| eop_cube_core_meat.hpp | | eop_cube_core_meat.hpp | |
| | | | |
| skipping to change at line 133 | | skipping to change at line 133 | |
| eop_cube_core<eop_cube_type>::apply_proxy(Cube<typename T1::elem_type>& out
, const eOpCube<T1, eop_cube_type>& x) | | eop_cube_core<eop_cube_type>::apply_proxy(Cube<typename T1::elem_type>& out
, const eOpCube<T1, eop_cube_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // eop_cube_type::apply() function is not allowed to unwrap things | | // eop_cube_type::apply() function is not allowed to unwrap things | |
| // (in order to get the input into a common format). | | // (in order to get the input into a common format). | |
| // the proxy class is already providing objects with element access | | // the proxy class is already providing objects with element access | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| if(is_cube_generator<eop_cube_type>::value == true) | | const ProxyCube<T1>& P = x.P; | |
| { | | | |
| out.set_size(x.n_rows, x.n_cols, x.n_slices); | | | |
| | | | |
|
| eT* out_mem = out.memptr(); | | out.set_size(P.n_rows, P.n_cols, P.n_slices); | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| | | if(is_cube_generator<eop_cube_type>::value == true) | |
| | | { | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = eop_aux::generate<eT,eop_cube_type>(); | | out_mem[i] = eop_aux::generate<eT,eop_cube_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| out.set_size(x.n_rows, x.n_cols, x.n_slices); | | | |
| | | | |
| eT* out_mem = out.memptr(); | | | |
| const ProxyCube<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = eop_cube_core<eop_cube_type>::process(x, P[i]); | | out_mem[i] = eop_cube_core<eop_cube_type>::process(x, P[i]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_cube_type> | | template<typename eop_cube_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_cube_core<eop_cube_type>::apply_unwrap(Cube<typename T1::elem_type>& ou
t, const eOpCube<T1, eop_cube_type>& x) | | eop_cube_core<eop_cube_type>::apply_unwrap(Cube<typename T1::elem_type>& ou
t, const eOpCube<T1, eop_cube_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(x.P.Q); | | const ProxyCube<T1>& P = x.P; | |
| const Cube<eT>& A = tmp.M; | | | |
| | | | |
|
| if(is_cube_generator<eop_cube_type>::value == true) | | out.set_size(P.n_rows, P.n_cols, P.n_slices); | |
| { | | | |
| out.set_size(x.n_rows, x.n_cols, x.n_slices); | | | |
| | | | |
|
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const u32 n_elem = x.n_elem; | | const u32 n_elem = P.n_elem; | |
| | | | |
|
| | | if(is_cube_generator<eop_cube_type>::value == true) | |
| | | { | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = eop_aux::generate<eT,eop_cube_type>(); | | out_mem[i] = eop_aux::generate<eT,eop_cube_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| out.set_size(x.n_rows, x.n_cols, x.n_slices); | | const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(P.Q); | |
| | | | |
|
| eT* out_mem = out.memptr(); | | const Cube<eT>& A = tmp.M; | |
| const eT* A_mem = A.memptr(); | | const eT* A_mem = A.memptr(); | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] = eop_cube_core<eop_cube_type>::process(x, A_mem[i]); | | out_mem[i] = eop_cube_core<eop_cube_type>::process(x, A_mem[i]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_cube_type> | | template<typename eop_cube_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_cube_core<eop_cube_type>::apply_inplace_plus(Cube<typename T1::elem_typ
e>& out, const eOpCube<T1, eop_cube_type>& x) | | eop_cube_core<eop_cube_type>::apply_inplace_plus(Cube<typename T1::elem_typ
e>& out, const eOpCube<T1, eop_cube_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_row | | const ProxyCube<T1>& P = x.P; | |
| s, x.n_cols, x.n_slices, "cube addition"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P.n_row | |
| | | s, P.n_cols, P.n_slices, "cube addition"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_cube_generator<eop_cube_type>::value == true) | | if(is_cube_generator<eop_cube_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] += eop_aux::generate<eT,eop_cube_type>(); | | out_mem[i] += eop_aux::generate<eT,eop_cube_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const ProxyCube<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] += eop_cube_core<eop_cube_type>::process(x, P[i]); | | out_mem[i] += eop_cube_core<eop_cube_type>::process(x, P[i]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_cube_type> | | template<typename eop_cube_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_cube_core<eop_cube_type>::apply_inplace_minus(Cube<typename T1::elem_ty
pe>& out, const eOpCube<T1, eop_cube_type>& x) | | eop_cube_core<eop_cube_type>::apply_inplace_minus(Cube<typename T1::elem_ty
pe>& out, const eOpCube<T1, eop_cube_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_row | | const ProxyCube<T1>& P = x.P; | |
| s, x.n_cols, x.n_slices, "cube subtraction"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P.n_row | |
| | | s, P.n_cols, P.n_slices, "cube subtraction"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_cube_generator<eop_cube_type>::value == true) | | if(is_cube_generator<eop_cube_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] -= eop_aux::generate<eT,eop_cube_type>(); | | out_mem[i] -= eop_aux::generate<eT,eop_cube_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const ProxyCube<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] -= eop_cube_core<eop_cube_type>::process(x, P[i]); | | out_mem[i] -= eop_cube_core<eop_cube_type>::process(x, P[i]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_cube_type> | | template<typename eop_cube_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_cube_core<eop_cube_type>::apply_inplace_schur(Cube<typename T1::elem_ty
pe>& out, const eOpCube<T1, eop_cube_type>& x) | | eop_cube_core<eop_cube_type>::apply_inplace_schur(Cube<typename T1::elem_ty
pe>& out, const eOpCube<T1, eop_cube_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_row | | const ProxyCube<T1>& P = x.P; | |
| s, x.n_cols, x.n_slices, "element-wise cube multiplication"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P.n_row | |
| | | s, P.n_cols, P.n_slices, "element-wise cube multiplication"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_cube_generator<eop_cube_type>::value == true) | | if(is_cube_generator<eop_cube_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] *= eop_aux::generate<eT,eop_cube_type>(); | | out_mem[i] *= eop_aux::generate<eT,eop_cube_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const ProxyCube<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] *= eop_cube_core<eop_cube_type>::process(x, P[i]); | | out_mem[i] *= eop_cube_core<eop_cube_type>::process(x, P[i]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eop_cube_type> | | template<typename eop_cube_type> | |
| template<typename T1> | | template<typename T1> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| eop_cube_core<eop_cube_type>::apply_inplace_div(Cube<typename T1::elem_type
>& out, const eOpCube<T1, eop_cube_type>& x) | | eop_cube_core<eop_cube_type>::apply_inplace_div(Cube<typename T1::elem_type
>& out, const eOpCube<T1, eop_cube_type>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, x.n_row | | const ProxyCube<T1>& P = x.P; | |
| s, x.n_cols, x.n_slices, "element-wise cube division"); | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, P.n_row | |
| | | s, P.n_cols, P.n_slices, "element-wise cube division"); | |
| | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const u32 n_elem = P.n_elem; | |
| | | | |
| if(is_cube_generator<eop_cube_type>::value == true) | | if(is_cube_generator<eop_cube_type>::value == true) | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] /= eop_aux::generate<eT,eop_cube_type>(); | | out_mem[i] /= eop_aux::generate<eT,eop_cube_type>(); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| eT* out_mem = out.memptr(); | | | |
| const ProxyCube<T1>& P = x.P; | | | |
| const u32 n_elem = x.n_elem; | | | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| out_mem[i] /= eop_cube_core<eop_cube_type>::process(x, P[i]); | | out_mem[i] /= eop_cube_core<eop_cube_type>::process(x, P[i]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 22 change blocks. |
| 58 lines changed or deleted | | 44 lines changed or added | |
|
| fn_max.hpp | | fn_max.hpp | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| max(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | | max(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op<T1, op_max>(X.get_ref(), dim, 0); | | return Op<T1, op_max>(X.get_ref(), dim, 0); | |
| } | | } | |
| | | | |
| //! Immediate 'find the maximum value in a row vector' operation | | //! Immediate 'find the maximum value in a row vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| max(const Row<eT>& A) | | max(const Row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | |
| | | | |
| return op_max::direct_max(A.mem, A.n_elem); | | return op_max::direct_max(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! Immediate 'find the maximum value in a column vector' operation | | //! Immediate 'find the maximum value in a column vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| max(const Col<eT>& A) | | max(const Col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | |
| | | | |
| return op_max::direct_max(A.mem, A.n_elem); | | return op_max::direct_max(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! Immediate 'find maximum value' operation, | | //! Immediate 'find maximum value' operation, | |
| //! invoked, for example, by: max(max(A)) | | //! invoked, for example, by: max(max(A)) | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| typename T1::elem_type | | typename T1::elem_type | |
| max(const Op<T1, op_max>& in) | | max(const Op<T1, op_max>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_extra_debug_print("max(): two consecutive max() calls detected"); | | arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap<T1> tmp1(in.m); | | const unwrap<T1> tmp1(in.m); | |
| const Mat<eT>& X = tmp1.M; | | const Mat<eT>& X = tmp1.M; | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 99 | |
| const Op< Op<T1, op_max>, op_max> | | const Op< Op<T1, op_max>, op_max> | |
| max(const Op<T1, op_max>& in, const u32 dim) | | max(const Op<T1, op_max>& in, const u32 dim) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op< Op<T1, op_max>, op_max>(in, dim, 0); | | return Op< Op<T1, op_max>, op_max>(in, dim, 0); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| max(const subview_row<eT>& A) | | max(const subview_row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | |
| | | | |
| return op_max::direct_max(A); | | return op_max::direct_max(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| max(const subview_col<eT>& A) | | max(const subview_col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | |
| | | | |
| return op_max::direct_max(A); | | return op_max::direct_max(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| max(const Op<subview<eT>, op_max>& in) | | max(const Op<subview<eT>, op_max>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_extra_debug_print("max(): two consecutive max() calls detected"); | | arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
| | | | |
| const subview<eT>& X = in.m; | | const subview<eT>& X = in.m; | |
| | | | |
| arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements"
); | | arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements"
); | |
| | | | |
| return op_max::direct_max(X); | | return op_max::direct_max(X); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| max(const diagview<eT>& A) | | max(const diagview<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "max(): given vector has no elements"
); | |
| | | | |
| return op_max::direct_max(A); | | return op_max::direct_max(A); | |
| } | | } | |
| | | | |
| | | | |
End of changes. 7 change blocks. |
| 0 lines changed or deleted | | 7 lines changed or added | |
|
| fn_mean.hpp | | fn_mean.hpp | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| mean(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | | mean(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op<T1, op_mean>(X.get_ref(), dim, 0); | | return Op<T1, op_mean>(X.get_ref(), dim, 0); | |
| } | | } | |
| | | | |
| //! Immediate 'find the mean value of a row vector' operation | | //! Immediate 'find the mean value of a row vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| mean(const Row<eT>& A) | | mean(const Row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | |
| | | | |
| return op_mean::direct_mean(A.mem, A.n_elem); | | return op_mean::direct_mean(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! Immediate 'find the mean value of a column vector' operation | | //! Immediate 'find the mean value of a column vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| mean(const Col<eT>& A) | | mean(const Col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | |
| | | | |
| return op_mean::direct_mean(A.mem, A.n_elem); | | return op_mean::direct_mean(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! Immediate 'find mean value' operation, | | //! Immediate 'find mean value' operation, | |
| //! invoked, for example, by: mean(mean(A)) | | //! invoked, for example, by: mean(mean(A)) | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| typename T1::elem_type | | typename T1::elem_type | |
| mean(const Op<T1, op_mean>& in) | | mean(const Op<T1, op_mean>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_extra_debug_print("mean(): two consecutive mean() calls detected"); | | arma_extra_debug_print("mean(): two consecutive mean() calls detected"); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap<T1> tmp1(in.m); | | const unwrap<T1> tmp1(in.m); | |
| const Mat<eT>& X = tmp1.M; | | const Mat<eT>& X = tmp1.M; | |
| | | | |
| skipping to change at line 88 | | skipping to change at line 91 | |
| const Op< Op<T1, op_mean>, op_mean> | | const Op< Op<T1, op_mean>, op_mean> | |
| mean(const Op<T1, op_mean>& in, const u32 dim) | | mean(const Op<T1, op_mean>& in, const u32 dim) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op< Op<T1, op_mean>, op_mean>(in, dim, 0); | | return Op< Op<T1, op_mean>, op_mean>(in, dim, 0); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| mean(const subview_row<eT>& A) | | mean(const subview_row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | |
| | | | |
| return op_mean::direct_mean(A); | | return op_mean::direct_mean(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| mean(const subview_col<eT>& A) | | mean(const subview_col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | |
| | | | |
| return op_mean::direct_mean(A); | | return op_mean::direct_mean(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| mean(const Op<subview<eT>, op_mean>& in) | | mean(const Op<subview<eT>, op_mean>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_extra_debug_print("mean(): two consecutive mean() calls detected"); | | arma_extra_debug_print("mean(): two consecutive mean() calls detected"); | |
| | | | |
| const subview<eT>& X = in.m; | | const subview<eT>& X = in.m; | |
| | | | |
| arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements"
); | | arma_debug_check( (X.n_elem == 0), "mean(): given matrix has no elements"
); | |
| | | | |
| return op_mean::direct_mean(X); | | return op_mean::direct_mean(X); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| mean(const diagview<eT>& A) | | mean(const diagview<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "mean(): given vector has no elements"
); | |
| | | | |
| return op_mean::direct_mean(A); | | return op_mean::direct_mean(A); | |
| } | | } | |
| | | | |
| | | | |
End of changes. 7 change blocks. |
| 0 lines changed or deleted | | 7 lines changed or added | |
|
| fn_median.hpp | | fn_median.hpp | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| median(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | | median(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op<T1, op_median>(X.get_ref(), dim, 0); | | return Op<T1, op_median>(X.get_ref(), dim, 0); | |
| } | | } | |
| | | | |
| //! Immediate 'find the median value of a row vector' operation | | //! Immediate 'find the median value of a row vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| median(const Row<eT>& A) | | median(const Row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| return op_median::direct_median(A.mem, A.n_elem); | | return op_median::direct_median(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! Immediate 'find the median value of a column vector' operation | | //! Immediate 'find the median value of a column vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| median(const Col<eT>& A) | | median(const Col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| return op_median::direct_median(A.mem, A.n_elem); | | return op_median::direct_median(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! Immediate 'find the median value of a row vector' operation (complex nu
mber version) | | //! Immediate 'find the median value of a row vector' operation (complex nu
mber version) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| std::complex<T> | | std::complex<T> | |
| median(const Row< std::complex<T> >& A) | | median(const Row< std::complex<T> >& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| u32 index1; | | u32 index1; | |
| u32 index2; | | u32 index2; | |
| op_median::direct_cx_median_index(index1, index2, A.mem, A.n_elem); | | op_median::direct_cx_median_index(index1, index2, A.mem, A.n_elem); | |
| | | | |
| return (A.mem[index1] + A.mem[index2]) / T(2); | | return (A.mem[index1] + A.mem[index2]) / T(2); | |
| } | | } | |
| | | | |
| //! Immediate 'find the median value of a column vector' operation (complex
number version) | | //! Immediate 'find the median value of a column vector' operation (complex
number version) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| std::complex<T> | | std::complex<T> | |
| median(const Col< std::complex<T> >& A) | | median(const Col< std::complex<T> >& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| u32 index1; | | u32 index1; | |
| u32 index2; | | u32 index2; | |
| op_median::direct_cx_median_index(index1, index2, A.mem, A.n_elem); | | op_median::direct_cx_median_index(index1, index2, A.mem, A.n_elem); | |
| | | | |
| return (A.mem[index1] + A.mem[index2]) / T(2); | | return (A.mem[index1] + A.mem[index2]) / T(2); | |
| } | | } | |
| | | | |
| //! find the median value of a subview_row | | //! find the median value of a subview_row | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| median(const subview_row<eT>& A) | | median(const subview_row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| return op_median::direct_median(A); | | return op_median::direct_median(A); | |
| } | | } | |
| | | | |
| //! find the median value of a subview_col | | //! find the median value of a subview_col | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| median(const subview_col<eT>& A) | | median(const subview_col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| return op_median::direct_median(A); | | return op_median::direct_median(A); | |
| } | | } | |
| | | | |
| //! find the median value of a subview_row (complex number version) | | //! find the median value of a subview_row (complex number version) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| std::complex<T> | | std::complex<T> | |
| median(const subview_row< std::complex<T> >& A) | | median(const subview_row< std::complex<T> >& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| u32 index1; | | u32 index1; | |
| u32 index2; | | u32 index2; | |
| op_median::direct_cx_median_index(index1, index2, A); | | op_median::direct_cx_median_index(index1, index2, A); | |
| | | | |
| return (A[index1] + A[index2]) / T(2); | | return (A[index1] + A[index2]) / T(2); | |
| } | | } | |
| | | | |
| //! find the median value of a subview_col (complex number version) | | //! find the median value of a subview_col (complex number version) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| std::complex<T> | | std::complex<T> | |
| median(const subview_col< std::complex<T> >& A) | | median(const subview_col< std::complex<T> >& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| u32 index1; | | u32 index1; | |
| u32 index2; | | u32 index2; | |
| op_median::direct_cx_median_index(index1, index2, A); | | op_median::direct_cx_median_index(index1, index2, A); | |
| | | | |
| return (A[index1] + A[index2]) / T(2); | | return (A[index1] + A[index2]) / T(2); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| median(const diagview<eT>& A) | | median(const diagview<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| return op_median::direct_median(A); | | return op_median::direct_median(A); | |
| } | | } | |
| | | | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| std::complex<T> | | std::complex<T> | |
| median(const diagview< std::complex<T> >& A) | | median(const diagview< std::complex<T> >& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | | arma_debug_check( (A.n_elem == 0), "median(): given vector has no element
s" ); | |
| | | | |
| u32 index1; | | u32 index1; | |
| u32 index2; | | u32 index2; | |
| op_median::direct_cx_median_index(index1, index2, A); | | op_median::direct_cx_median_index(index1, index2, A); | |
| | | | |
End of changes. 10 change blocks. |
| 0 lines changed or deleted | | 10 lines changed or added | |
|
| fn_min.hpp | | fn_min.hpp | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| min(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | | min(const Base<typename T1::elem_type,T1>& X, const u32 dim = 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op<T1, op_min>(X.get_ref(), dim, 0); | | return Op<T1, op_min>(X.get_ref(), dim, 0); | |
| } | | } | |
| | | | |
| //! Immediate 'find the minimum value in a row vector' operation | | //! Immediate 'find the minimum value in a row vector' operation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| min(const Row<eT>& A) | | min(const Row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | |
| | | | |
| return op_min::direct_min(A.mem, A.n_elem); | | return op_min::direct_min(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! Immediate 'find the minimum value in a column vector' | | //! Immediate 'find the minimum value in a column vector' | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| min(const Col<eT>& A) | | min(const Col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | |
| | | | |
| return op_min::direct_min(A.mem, A.n_elem); | | return op_min::direct_min(A.mem, A.n_elem); | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! Immediate 'find minimum value' operation, | | //! Immediate 'find minimum value' operation, | |
| //! invoked, for example, by: min(min(A)) | | //! invoked, for example, by: min(min(A)) | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| typename T1::elem_type | | typename T1::elem_type | |
| min(const Op<T1, op_min>& in) | | min(const Op<T1, op_min>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_extra_debug_print("min(): two consecutive min() calls detected"); | | arma_extra_debug_print("min(): two consecutive min() calls detected"); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap<T1> tmp1(in.m); | | const unwrap<T1> tmp1(in.m); | |
| const Mat<eT>& X = tmp1.M; | | const Mat<eT>& X = tmp1.M; | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 99 | |
| const Op< Op<T1, op_min>, op_min> | | const Op< Op<T1, op_min>, op_min> | |
| min(const Op<T1, op_min>& in, const u32 dim) | | min(const Op<T1, op_min>& in, const u32 dim) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op< Op<T1, op_min>, op_min>(in, dim, 0); | | return Op< Op<T1, op_min>, op_min>(in, dim, 0); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| min(const subview_row<eT>& A) | | min(const subview_row<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | |
| | | | |
| return op_min::direct_min(A); | | return op_min::direct_min(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| min(const subview_col<eT>& A) | | min(const subview_col<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | |
| | | | |
| return op_min::direct_min(A); | | return op_min::direct_min(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| min(const diagview<eT>& A) | | min(const diagview<eT>& A) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | | arma_debug_check( (A.n_elem == 0), "min(): given vector has no elements"
); | |
| | | | |
| return op_min::direct_min(A); | | return op_min::direct_min(A); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| min(const Op<subview<eT>, op_min>& in) | | min(const Op<subview<eT>, op_min>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| arma_extra_debug_print("max(): two consecutive max() calls detected"); | | arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
| | | | |
| const subview<eT>& X = in.m; | | const subview<eT>& X = in.m; | |
| | | | |
| arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements"
); | | arma_debug_check( (X.n_elem == 0), "max(): given matrix has no elements"
); | |
| | | | |
| | | | |
End of changes. 7 change blocks. |
| 0 lines changed or deleted | | 7 lines changed or added | |
|
| op_princomp_meat.hpp | | op_princomp_meat.hpp | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 49 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| | | | |
| if(n_rows > 1) // more than one sample | | if(n_rows > 1) // more than one sample | |
| { | | { | |
| // subtract the mean - use score_out as temporary matrix | | // subtract the mean - use score_out as temporary matrix | |
| score_out = in - repmat(mean(in), n_rows, 1); | | score_out = in - repmat(mean(in), n_rows, 1); | |
| | | | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col<eT> s; | | Col<eT> s; | |
| | | | |
| const bool svd_ok = svd(U,s,coeff_out,score_out); | | const bool svd_ok = svd(U,s,coeff_out,score_out); | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | | |
| tion failed"); | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | score_out.reset(); | |
| | | latent_out.reset(); | |
| | | tsquared_out.reset(); | |
| | | | |
| | | return; | |
| | | } | |
| | | | |
| //U.reset(); // TODO: do we need this ? U will get automatically dele
ted anyway | | //U.reset(); // TODO: do we need this ? U will get automatically dele
ted anyway | |
| | | | |
| // normalize the eigenvalues | | // normalize the eigenvalues | |
| s /= std::sqrt(n_rows - 1); | | s /= std::sqrt(n_rows - 1); | |
| | | | |
| // project the samples to the principals | | // project the samples to the principals | |
| score_out *= coeff_out; | | score_out *= coeff_out; | |
| | | | |
| if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | | if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | |
| | | | |
| skipping to change at line 144 | | skipping to change at line 155 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| | | | |
| if(n_rows > 1) // more than one sample | | if(n_rows > 1) // more than one sample | |
| { | | { | |
| // subtract the mean - use score_out as temporary matrix | | // subtract the mean - use score_out as temporary matrix | |
| score_out = in - repmat(mean(in), n_rows, 1); | | score_out = in - repmat(mean(in), n_rows, 1); | |
| | | | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col<eT> s; | | Col<eT> s; | |
| | | | |
| const bool svd_ok = svd(U,s,coeff_out,score_out); | | const bool svd_ok = svd(U,s,coeff_out,score_out); | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | | |
| tion failed"); | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | score_out.reset(); | |
| | | latent_out.reset(); | |
| | | | |
| | | return; | |
| | | } | |
| | | | |
| // U.reset(); | | // U.reset(); | |
| | | | |
| // normalize the eigenvalues | | // normalize the eigenvalues | |
| s /= std::sqrt(n_rows - 1); | | s /= std::sqrt(n_rows - 1); | |
| | | | |
| // project the samples to the principals | | // project the samples to the principals | |
| score_out *= coeff_out; | | score_out *= coeff_out; | |
| | | | |
| if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | | if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | |
| | | | |
| skipping to change at line 219 | | skipping to change at line 240 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| | | | |
| if(n_rows > 1) // more than one sample | | if(n_rows > 1) // more than one sample | |
| { | | { | |
| // subtract the mean - use score_out as temporary matrix | | // subtract the mean - use score_out as temporary matrix | |
| score_out = in - repmat(mean(in), n_rows, 1); | | score_out = in - repmat(mean(in), n_rows, 1); | |
| | | | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col<eT> s; | | Col<eT> s; | |
| | | | |
| const bool svd_ok = svd(U,s,coeff_out,score_out); | | const bool svd_ok = svd(U,s,coeff_out,score_out); | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | | |
| tion failed"); | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | score_out.reset(); | |
| | | | |
| | | return; | |
| | | } | |
| | | | |
| // U.reset(); | | // U.reset(); | |
| | | | |
| // normalize the eigenvalues | | // normalize the eigenvalues | |
| s /= std::sqrt(n_rows - 1); | | s /= std::sqrt(n_rows - 1); | |
| | | | |
| // project the samples to the principals | | // project the samples to the principals | |
| score_out *= coeff_out; | | score_out *= coeff_out; | |
| | | | |
| if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | | if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | |
| | | | |
| skipping to change at line 276 | | skipping to change at line 306 | |
| op_princomp::direct_princomp | | op_princomp::direct_princomp | |
| ( | | ( | |
| Mat<eT>& coeff_out, | | Mat<eT>& coeff_out, | |
| const Mat<eT>& in | | const Mat<eT>& in | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if(in.n_elem != 0) | | if(in.n_elem != 0) | |
| { | | { | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col<eT> s; | | Col<eT> s; | |
| | | | |
|
| const bool svd_ok = svd(U,s,coeff_out, (in - repmat(mean(in), in.n_rows | | const Mat<eT> tmp = in - repmat(mean(in), in.n_rows, 1); | |
| , 1))); | | | |
| | | const bool svd_ok = svd(U,s,coeff_out, tmp); | |
| | | | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | if(svd_ok == false) | |
| tion failed"); | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| coeff_out.reset(); | | coeff_out.reset(); | |
| } | | } | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! principal component analysis -- 4 arguments complex version | | //! principal component analysis -- 4 arguments complex version | |
| //! computation is done via singular value decomposition | | //! computation is done via singular value decomposition | |
| | | | |
| skipping to change at line 321 | | skipping to change at line 358 | |
| typedef std::complex<T> eT; | | typedef std::complex<T> eT; | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| | | | |
| if(n_rows > 1) // more than one sample | | if(n_rows > 1) // more than one sample | |
| { | | { | |
| // subtract the mean - use score_out as temporary matrix | | // subtract the mean - use score_out as temporary matrix | |
| score_out = in - repmat(mean(in), n_rows, 1); | | score_out = in - repmat(mean(in), n_rows, 1); | |
| | | | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col<T> s; | | Col<T> s; | |
| | | | |
| const bool svd_ok = svd(U,s,coeff_out,score_out); | | const bool svd_ok = svd(U,s,coeff_out,score_out); | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | | |
| tion failed"); | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | score_out.reset(); | |
| | | latent_out.reset(); | |
| | | tsquared_out.reset(); | |
| | | | |
| | | return; | |
| | | } | |
| | | | |
| //U.reset(); | | //U.reset(); | |
| | | | |
| // normalize the eigenvalues | | // normalize the eigenvalues | |
| s /= std::sqrt(n_rows - 1); | | s /= std::sqrt(n_rows - 1); | |
| | | | |
| // project the samples to the principals | | // project the samples to the principals | |
| score_out *= coeff_out; | | score_out *= coeff_out; | |
| | | | |
| if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | | if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | |
| | | | |
| skipping to change at line 352 | | skipping to change at line 400 | |
| s = s_tmp; | | s = s_tmp; | |
| | | | |
| // compute the Hotelling's T-squared | | // compute the Hotelling's T-squared | |
| s_tmp.rows(0,n_rows-2) = 1.0 / s_tmp.rows(0,n_rows-2); | | s_tmp.rows(0,n_rows-2) = 1.0 / s_tmp.rows(0,n_rows-2); | |
| const Mat<eT> S = score_out * diagmat(Col<T>(s_tmp)); | | const Mat<eT> S = score_out * diagmat(Col<T>(s_tmp)); | |
| tsquared_out = sum(S%S,1); | | tsquared_out = sum(S%S,1); | |
| } | | } | |
| else | | else | |
| { | | { | |
| // compute the Hotelling's T-squared | | // compute the Hotelling's T-squared | |
|
| const Mat<eT> S = score_out * diagmat(Col<T>(eT(1) / s)); | | const Mat<eT> S = score_out * diagmat(Col<T>(T(1) / s)); | |
| tsquared_out = sum(S%S,1); | | tsquared_out = sum(S%S,1); | |
| } | | } | |
| | | | |
| // compute the eigenvalues of the principal vectors | | // compute the eigenvalues of the principal vectors | |
| latent_out = s%s; | | latent_out = s%s; | |
| | | | |
| } | | } | |
| else // single sample - row | | else // single sample - row | |
| { | | { | |
| if(n_rows == 1) | | if(n_rows == 1) | |
| | | | |
| skipping to change at line 414 | | skipping to change at line 462 | |
| typedef std::complex<T> eT; | | typedef std::complex<T> eT; | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| | | | |
| if(n_rows > 1) // more than one sample | | if(n_rows > 1) // more than one sample | |
| { | | { | |
| // subtract the mean - use score_out as temporary matrix | | // subtract the mean - use score_out as temporary matrix | |
| score_out = in - repmat(mean(in), n_rows, 1); | | score_out = in - repmat(mean(in), n_rows, 1); | |
| | | | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col< T> s; | | Col< T> s; | |
| | | | |
| const bool svd_ok = svd(U,s,coeff_out,score_out); | | const bool svd_ok = svd(U,s,coeff_out,score_out); | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | | |
| tion failed"); | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | score_out.reset(); | |
| | | latent_out.reset(); | |
| | | | |
| | | return; | |
| | | } | |
| | | | |
| // U.reset(); | | // U.reset(); | |
| | | | |
| // normalize the eigenvalues | | // normalize the eigenvalues | |
| s /= std::sqrt(n_rows - 1); | | s /= std::sqrt(n_rows - 1); | |
| | | | |
| // project the samples to the principals | | // project the samples to the principals | |
| score_out *= coeff_out; | | score_out *= coeff_out; | |
| | | | |
| if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | | if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | |
| | | | |
| skipping to change at line 488 | | skipping to change at line 546 | |
| typedef std::complex<T> eT; | | typedef std::complex<T> eT; | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| | | | |
| if(n_rows > 1) // more than one sample | | if(n_rows > 1) // more than one sample | |
| { | | { | |
| // subtract the mean - use score_out as temporary matrix | | // subtract the mean - use score_out as temporary matrix | |
| score_out = in - repmat(mean(in), n_rows, 1); | | score_out = in - repmat(mean(in), n_rows, 1); | |
| | | | |
|
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col< T> s; | | Col< T> s; | |
| | | | |
| const bool svd_ok = svd(U,s,coeff_out,score_out); | | const bool svd_ok = svd(U,s,coeff_out,score_out); | |
|
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | | |
| tion failed"); | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | score_out.reset(); | |
| | | | |
| | | return; | |
| | | } | |
| | | | |
| // U.reset(); | | // U.reset(); | |
| | | | |
| // normalize the eigenvalues | | // normalize the eigenvalues | |
| s /= std::sqrt(n_rows - 1); | | s /= std::sqrt(n_rows - 1); | |
| | | | |
| // project the samples to the principals | | // project the samples to the principals | |
| score_out *= coeff_out; | | score_out *= coeff_out; | |
| | | | |
| if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | | if(n_rows <= n_cols) // number of samples is less than their dimensiona
lity | |
| | | | |
| skipping to change at line 549 | | skipping to change at line 616 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename std::complex<T> eT; | | typedef typename std::complex<T> eT; | |
| | | | |
| if(in.n_elem != 0) | | if(in.n_elem != 0) | |
| { | | { | |
| // singular value decomposition | | // singular value decomposition | |
| Mat<eT> U; | | Mat<eT> U; | |
| Col< T> s; | | Col< T> s; | |
| | | | |
|
| const bool svd_ok = svd(U,s,coeff_out, (in - repmat(mean(in), in.n_rows | | const Mat<eT> tmp = in - repmat(mean(in), in.n_rows, 1); | |
| , 1))); | | | |
| arma_debug_check(svd_ok == false, "princomp(): singular value decomposi | | const bool svd_ok = svd(U,s,coeff_out, tmp); | |
| tion failed"); | | | |
| | | if(svd_ok == false) | |
| | | { | |
| | | arma_print("princomp(): singular value decomposition failed"); | |
| | | | |
| | | coeff_out.reset(); | |
| | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| coeff_out.reset(); | | coeff_out.reset(); | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| | | | |
End of changes. 17 change blocks. |
| 35 lines changed or deleted | | 100 lines changed or added | |
|