| Op_bones.hpp | | Op_bones.hpp | |
|
| // Copyright (C) 2008-2012 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup Op | | //! \addtogroup Op | |
| //! @{ | | //! @{ | |
| | | | |
| //! Class for storing data required for delayed unary operations, | | //! Class for storing data required for delayed unary operations, | |
| //! such as the operand (e.g. the matrix to which the operation is to be ap
plied) and the unary operator (e.g. inverse). | | //! such as the operand (e.g. the matrix to which the operation is to be ap
plied) and the unary operator (e.g. inverse). | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| //! Op< Glue< Mat, Mat, glue_times >, op_htrans > | | //! Op< Glue< Mat, Mat, glue_times >, op_htrans > | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| class Op : public Base<typename T1::elem_type, Op<T1, op_type> > | | class Op : public Base<typename T1::elem_type, Op<T1, op_type> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef typename T1::elem_type elem_type; | | typedef typename T1::elem_type elem_type; | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| | | | |
|
| static const bool is_row = ( T1::is_col && (is_same_type<op_type, op_stra | | static const bool is_row = \ | |
| ns>::value || is_same_type<op_type, op_htrans>::value || is_same_type<op_ty | | (T1::is_col && (is_same_type<op_type, op_strans>::yes || is_same_type< | |
| pe, op_htrans2>::value) ) || (is_same_type<op_type, op_normalise_rowvec>::v | | op_type, op_htrans>::yes || is_same_type<op_type, op_htrans2>::yes)) | |
| alue); | | || (T1::is_row && (is_same_type<op_type, op_sort>::yes || is_same_type<op | |
| static const bool is_col = ( T1::is_row && (is_same_type<op_type, op_stra | | _type, op_shuffle>::yes || is_same_type<op_type, op_cumsum_vec>::yes || is_ | |
| ns>::value || is_same_type<op_type, op_htrans>::value || is_same_type<op_ty | | same_type<op_type, op_flipud>::yes || is_same_type<op_type, op_fliplr>::yes | |
| pe, op_htrans2>::value) ) || (is_same_type<op_type, op_normalise_colvec>::v | | )) | |
| alue) || (is_same_type<op_type, op_diagvec>::value) || (is_same_type<op_typ | | || (is_same_type<op_type, op_normalise_rowvec>::yes); | |
| e, op_vectorise_col>::value); | | | |
| | | static const bool is_col = \ | |
| | | (T1::is_row && (is_same_type<op_type, op_strans>::yes || is_same_type< | |
| | | op_type, op_htrans>::yes || is_same_type<op_type, op_htrans2>::yes)) | |
| | | || (T1::is_col && (is_same_type<op_type, op_sort>::yes || is_same_type<op | |
| | | _type, op_shuffle>::yes || is_same_type<op_type, op_cumsum_vec>::yes || is_ | |
| | | same_type<op_type, op_flipud>::yes || is_same_type<op_type, op_fliplr>::yes | |
| | | )) | |
| | | || (is_same_type<op_type, op_normalise_colvec>::yes) | |
| | | || (is_same_type<op_type, op_diagvec>::yes) | |
| | | || (is_same_type<op_type, op_vectorise_col>::yes); | |
| | | | |
| inline explicit Op(const T1& in_m); | | inline explicit Op(const T1& in_m); | |
| inline Op(const T1& in_m, const elem_type in_aux); | | inline Op(const T1& in_m, const elem_type in_aux); | |
| inline Op(const T1& in_m, const elem_type in_aux, const
uword in_aux_uword_a, const uword in_aux_uword_b); | | inline Op(const T1& in_m, const elem_type in_aux, const
uword in_aux_uword_a, const uword in_aux_uword_b); | |
| inline Op(const T1& in_m, const uword in_aux_uword_a, const
uword in_aux_uword_b); | | inline Op(const T1& in_m, const uword in_aux_uword_a, const
uword in_aux_uword_b); | |
| inline Op(const T1& in_m, const uword in_aux_uword_a, const
uword in_aux_uword_b, const uword in_aux_uword_c, const char junk); | | inline Op(const T1& in_m, const uword in_aux_uword_a, const
uword in_aux_uword_b, const uword in_aux_uword_c, const char junk); | |
| inline ~Op(); | | inline ~Op(); | |
| | | | |
| arma_aligned const T1& m; //!< storage of reference to t
he operand (eg. a matrix) | | arma_aligned const T1& m; //!< storage of reference to t
he operand (eg. a matrix) | |
| arma_aligned elem_type aux; //!< storage of auxiliary data
, user defined format | | arma_aligned elem_type aux; //!< storage of auxiliary data
, user defined format | |
| | | | |
End of changes. 2 change blocks. |
| 11 lines changed or deleted | | 21 lines changed or added | |
|
| Proxy.hpp | | Proxy.hpp | |
| | | | |
| skipping to change at line 1109 | | skipping to change at line 1109 | |
| | | | |
| arma_inline ea_type get_ea() const { return Q.memptr(); } | | arma_inline ea_type get_ea() const { return Q.memptr(); } | |
| arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | | arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
| | | | |
| template<typename eT2> | | template<typename eT2> | |
| arma_inline bool is_alias(const Mat<eT2>& X) const { return ( void_ptr(&X
) == void_ptr(&(U.M)) ); } | | arma_inline bool is_alias(const Mat<eT2>& X) const { return ( void_ptr(&X
) == void_ptr(&(U.M)) ); } | |
| | | | |
| arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr(
)); } | | arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr(
)); } | |
| }; | | }; | |
| | | | |
|
| template<typename T1> | | | |
| class Proxy< Op<T1, op_vectorise_cube_col> > | | | |
| { | | | |
| public: | | | |
| | | | |
| typedef typename T1::elem_type elem_type; | | | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | | |
| typedef Mat<elem_type> stored_type; | | | |
| typedef const elem_type* ea_type; | | | |
| typedef const Mat<elem_type>& aligned_ea_type; | | | |
| | | | |
| static const bool prefer_at_accessor = false; | | | |
| static const bool has_subview = true; | | | |
| static const bool fake_mat = true; | | | |
| | | | |
| static const bool is_row = false; | | | |
| static const bool is_col = true; | | | |
| | | | |
| arma_aligned const unwrap_cube<T1> U; | | | |
| arma_aligned const Mat<elem_type> Q; | | | |
| | | | |
| inline explicit Proxy(const Op<T1, op_vectorise_cube_col>& A) | | | |
| : U(A.m) | | | |
| , Q(const_cast<elem_type*>(U.M.memptr()), U.M.n_elem, 1, false, false) | | | |
| { | | | |
| arma_extra_debug_sigprint(); | | | |
| } | | | |
| | | | |
| arma_inline uword get_n_rows() const { return Q.n_rows; } | | | |
| arma_inline uword get_n_cols() const { return 1; } | | | |
| arma_inline uword get_n_elem() const { return Q.n_elem; } | | | |
| | | | |
| arma_inline elem_type operator[] (const uword i) const { r | | | |
| eturn Q[i]; } | | | |
| arma_inline elem_type at (const uword row, const uword) const { r | | | |
| eturn Q[row]; } | | | |
| arma_inline elem_type at_alt (const uword i) const { r | | | |
| eturn Q.at_alt(i); } | | | |
| | | | |
| arma_inline ea_type get_ea() const { return Q.memptr(); } | | | |
| arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | | | |
| | | | |
| template<typename eT2> | | | |
| arma_inline bool is_alias(const Mat<eT2>&) const { return false; } | | | |
| | | | |
| arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr( | | | |
| )); } | | | |
| }; | | | |
| | | | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| class Proxy< Glue<T1, T2, glue_type> > | | class Proxy< Glue<T1, T2, glue_type> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef typename T1::elem_type elem_type; | | typedef typename T1::elem_type elem_type; | |
| typedef typename get_pod_type<elem_type>::result pod_type; | | typedef typename get_pod_type<elem_type>::result pod_type; | |
| typedef Mat<elem_type> stored_type; | | typedef Mat<elem_type> stored_type; | |
| typedef const elem_type* ea_type; | | typedef const elem_type* ea_type; | |
| typedef const Mat<elem_type>& aligned_ea_type; | | typedef const Mat<elem_type>& aligned_ea_type; | |
| | | | |
End of changes. 1 change blocks. |
| 49 lines changed or deleted | | 0 lines changed or added | |
|
| arma_version.hpp | | arma_version.hpp | |
| | | | |
| skipping to change at line 13 | | skipping to change at line 13 | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup arma_version | | //! \addtogroup arma_version | |
| //! @{ | | //! @{ | |
| | | | |
| #define ARMA_VERSION_MAJOR 4 | | #define ARMA_VERSION_MAJOR 4 | |
| #define ARMA_VERSION_MINOR 600 | | #define ARMA_VERSION_MINOR 600 | |
|
| #define ARMA_VERSION_PATCH 3 | | #define ARMA_VERSION_PATCH 4 | |
| #define ARMA_VERSION_NAME "Off The Reservation" | | #define ARMA_VERSION_NAME "Off The Reservation" | |
| | | | |
| struct arma_version | | struct arma_version | |
| { | | { | |
| static const unsigned int major = ARMA_VERSION_MAJOR; | | static const unsigned int major = ARMA_VERSION_MAJOR; | |
| static const unsigned int minor = ARMA_VERSION_MINOR; | | static const unsigned int minor = ARMA_VERSION_MINOR; | |
| static const unsigned int patch = ARMA_VERSION_PATCH; | | static const unsigned int patch = ARMA_VERSION_PATCH; | |
| | | | |
| static | | static | |
| inline | | inline | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| fn_elem.hpp | | fn_elem.hpp | |
|
| // Copyright (C) 2008-2013 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup fn_elem | | //! \addtogroup fn_elem | |
| //! @{ | | //! @{ | |
| | | | |
| // | | // | |
| // real | | // real | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_inline | | arma_inline | |
|
| const T1& | | typename enable_if2< (is_arma_type<T1>::value && is_cx<typename T1::elem_ty | |
| real(const Base<typename T1::pod_type, T1>& X) | | pe>::no), const T1& >::result | |
| | | real(const T1& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return X.get_ref(); | | return X; | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_inline | | arma_inline | |
| const T1& | | const T1& | |
| real(const BaseCube<typename T1::pod_type, T1>& X) | | real(const BaseCube<typename T1::pod_type, T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return X.get_ref(); | | return X.get_ref(); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| const mtOp<typename T1::pod_type, T1, op_real> | | typename enable_if2< (is_arma_type<T1>::value && is_cx<typename T1::elem_ty | |
| real(const Base<std::complex<typename T1::pod_type>, T1>& X) | | pe>::yes), const mtOp<typename T1::pod_type, T1, op_real> >::result | |
| | | real(const T1& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return mtOp<typename T1::pod_type, T1, op_real>( X.get_ref() ); | | return mtOp<typename T1::pod_type, T1, op_real>( X ); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| const mtOpCube<typename T1::pod_type, T1, op_real> | | const mtOpCube<typename T1::pod_type, T1, op_real> | |
| real(const BaseCube<std::complex<typename T1::pod_type>, T1>& X) | | real(const BaseCube<std::complex<typename T1::pod_type>, T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return mtOpCube<typename T1::pod_type, T1, op_real>( X.get_ref() ); | | return mtOpCube<typename T1::pod_type, T1, op_real>( X.get_ref() ); | |
| | | | |
| skipping to change at line 83 | | skipping to change at line 83 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const ProxyCube<T1> A(X.get_ref()); | | const ProxyCube<T1> A(X.get_ref()); | |
| | | | |
| return GenCube<typename T1::pod_type, gen_zeros>(A.get_n_rows(), A.get_n_
cols(), A.get_n_slices()); | | return GenCube<typename T1::pod_type, gen_zeros>(A.get_n_rows(), A.get_n_
cols(), A.get_n_slices()); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| const mtOp<typename T1::pod_type, T1, op_imag> | | typename enable_if2< (is_arma_type<T1>::value && is_cx<typename T1::elem_ty | |
| imag(const Base<std::complex<typename T1::pod_type>, T1>& X) | | pe>::yes), const mtOp<typename T1::pod_type, T1, op_imag> >::result | |
| | | imag(const T1& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return mtOp<typename T1::pod_type, T1, op_imag>( X.get_ref() ); | | return mtOp<typename T1::pod_type, T1, op_imag>( X ); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| const mtOpCube<typename T1::pod_type, T1, op_imag> | | const mtOpCube<typename T1::pod_type, T1, op_imag> | |
| imag(const BaseCube<std::complex<typename T1::pod_type>,T1>& X) | | imag(const BaseCube<std::complex<typename T1::pod_type>,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return mtOpCube<typename T1::pod_type, T1, op_imag>( X.get_ref() ); | | return mtOpCube<typename T1::pod_type, T1, op_imag>( X.get_ref() ); | |
| | | | |
End of changes. 7 change blocks. |
| 11 lines changed or deleted | | 14 lines changed or added | |
|
| fn_find.hpp | | fn_find.hpp | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 50 | |
| | | | |
| const uword type = ( (sig == 'f') || (sig == 'F') ) ? 0 : 1; | | const uword type = ( (sig == 'f') || (sig == 'F') ) ? 0 : 1; | |
| | | | |
| return mtOp<uword, T1, op_find>(X.get_ref(), k, type); | | return mtOp<uword, T1, op_find>(X.get_ref(), k, type); | |
| } | | } | |
| | | | |
| // | | // | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| umat | | uvec | |
| find(const BaseCube<typename T1::elem_type,T1>& X) | | find(const BaseCube<typename T1::elem_type,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap_cube<T1> tmp(X.get_ref()); | | const unwrap_cube<T1> tmp(X.get_ref()); | |
| | | | |
| const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | | const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | |
| | | | |
| return find(R); | | return find(R); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| umat | | uvec | |
| find(const BaseCube<typename T1::elem_type,T1>& X, const uword k, const cha
r* direction = "first") | | find(const BaseCube<typename T1::elem_type,T1>& X, const uword k, const cha
r* direction = "first") | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap_cube<T1> tmp(X.get_ref()); | | const unwrap_cube<T1> tmp(X.get_ref()); | |
| | | | |
| const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | | const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | |
| | | | |
| return find(R, k, direction); | | return find(R, k, direction); | |
| } | | } | |
| | | | |
| template<typename T1, typename op_rel_type> | | template<typename T1, typename op_rel_type> | |
| inline | | inline | |
|
| umat | | uvec | |
| find(const mtOpCube<uword, T1, op_rel_type>& X, const uword k = 0, const ch
ar* direction = "first") | | find(const mtOpCube<uword, T1, op_rel_type>& X, const uword k = 0, const ch
ar* direction = "first") | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap_cube<T1> tmp(X.m); | | const unwrap_cube<T1> tmp(X.m); | |
| | | | |
| const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | | const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | |
| | | | |
| return find( mtOp<uword, Mat<eT>, op_rel_type>(R, X.aux), k, direction ); | | return find( mtOp<uword, Mat<eT>, op_rel_type>(R, X.aux), k, direction ); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename glue_rel_type> | | template<typename T1, typename T2, typename glue_rel_type> | |
| inline | | inline | |
|
| umat | | uvec | |
| find(const mtGlueCube<uword, T1, T2, glue_rel_type>& X, const uword k = 0,
const char* direction = "first") | | find(const mtGlueCube<uword, T1, T2, glue_rel_type>& X, const uword k = 0,
const char* direction = "first") | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT1; | | typedef typename T1::elem_type eT1; | |
| typedef typename T2::elem_type eT2; | | typedef typename T2::elem_type eT2; | |
| | | | |
| const unwrap_cube<T1> tmp1(X.A); | | const unwrap_cube<T1> tmp1(X.A); | |
| const unwrap_cube<T2> tmp2(X.B); | | const unwrap_cube<T2> tmp2(X.B); | |
| | | | |
| | | | |
| skipping to change at line 153 | | skipping to change at line 153 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return mtOp<uword, T1, op_find_nonfinite>(X); | | return mtOp<uword, T1, op_find_nonfinite>(X); | |
| } | | } | |
| | | | |
| // | | // | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| umat | | uvec | |
| find_finite(const BaseCube<typename T1::elem_type,T1>& X) | | find_finite(const BaseCube<typename T1::elem_type,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap_cube<T1> tmp(X.get_ref()); | | const unwrap_cube<T1> tmp(X.get_ref()); | |
| | | | |
| const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | | const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | |
| | | | |
| return find_finite(R); | | return find_finite(R); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
|
| umat | | uvec | |
| find_nonfinite(const BaseCube<typename T1::elem_type,T1>& X) | | find_nonfinite(const BaseCube<typename T1::elem_type,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const unwrap_cube<T1> tmp(X.get_ref()); | | const unwrap_cube<T1> tmp(X.get_ref()); | |
| | | | |
| const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | | const Mat<eT> R( const_cast< eT* >(tmp.M.memptr()), tmp.M.n_elem, 1, fals
e ); | |
| | | | |
| | | | |
End of changes. 6 change blocks. |
| 6 lines changed or deleted | | 6 lines changed or added | |
|
| fn_flip.hpp | | fn_flip.hpp | |
|
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2010-2015 Conrad Sanderson | |
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup fn_flip | | //! \addtogroup fn_flip | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_inline | | arma_inline | |
|
| const Op<T1, op_flipud> | | typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_flipud> >::re | |
| flipud(const Base<typename T1::elem_type,T1>& X) | | sult | |
| | | flipud(const T1& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return Op<T1, op_flipud>(X.get_ref()); | | return Op<T1, op_flipud>(X); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_inline | | arma_inline | |
|
| const Op<T1, op_fliplr> | | typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_fliplr> >::re | |
| fliplr(const Base<typename T1::elem_type,T1>& X) | | sult | |
| | | fliplr(const T1& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return Op<T1, op_fliplr>(X.get_ref()); | | return Op<T1, op_fliplr>(X); | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 5 change blocks. |
| 8 lines changed or deleted | | 10 lines changed or added | |
|
| mtOp_bones.hpp | | mtOp_bones.hpp | |
|
| // Copyright (C) 2008-2014 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup mtOp | | //! \addtogroup mtOp | |
| //! @{ | | //! @{ | |
| | | | |
| struct mtOp_dual_aux_indicator {}; | | struct mtOp_dual_aux_indicator {}; | |
| | | | |
| template<typename out_eT, typename T1, typename op_type> | | template<typename out_eT, typename T1, typename op_type> | |
| class mtOp : public Base<out_eT, mtOp<out_eT, T1, op_type> > | | class mtOp : public Base<out_eT, mtOp<out_eT, T1, op_type> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef out_eT elem_type; | | typedef out_eT elem_type; | |
| typedef typename get_pod_type<out_eT>::result pod_type; | | typedef typename get_pod_type<out_eT>::result pod_type; | |
| | | | |
| typedef typename T1::elem_type in_eT; | | typedef typename T1::elem_type in_eT; | |
| | | | |
|
| static const bool is_row = T1::is_row && (is_op_mixed_elem<op_type>::valu | | static const bool is_row = \ | |
| e || is_same_type<op_type, op_clamp>::value); | | (T1::is_row && (is_op_mixed_elem<op_type>::value || is_same_type<op_ty | |
| static const bool is_col = T1::is_col && (is_op_mixed_elem<op_type>::valu | | pe, op_clamp>::value || is_same_type<op_type, op_real>::value || is_same_ty | |
| e || is_same_type<op_type, op_clamp>::value); | | pe<op_type, op_imag>::value)); | |
| | | | |
| | | static const bool is_col = \ | |
| | | (T1::is_col && (is_op_mixed_elem<op_type>::value || is_same_type<op_ty | |
| | | pe, op_clamp>::value || is_same_type<op_type, op_real>::value || is_same_ty | |
| | | pe<op_type, op_imag>::value)) | |
| | | || (is_same_type<op_type, op_find_simple>::value) | |
| | | || (is_same_type<op_type, op_find>::value); | |
| | | | |
| inline explicit mtOp(const T1& in_m); | | inline explicit mtOp(const T1& in_m); | |
| inline mtOp(const T1& in_m, const in_eT in_aux); | | inline mtOp(const T1& in_m, const in_eT in_aux); | |
| inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uw
ord in_aux_uword_b); | | inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uw
ord in_aux_uword_b); | |
| inline mtOp(const T1& in_m, const in_eT in_aux, const uw
ord in_aux_uword_a, const uword in_aux_uword_b); | | inline mtOp(const T1& in_m, const in_eT in_aux, const uw
ord in_aux_uword_a, const uword in_aux_uword_b); | |
| | | | |
| inline mtOp(const char junk, const T1& in_m, const out_eT in_aux
); | | inline mtOp(const char junk, const T1& in_m, const out_eT in_aux
); | |
| | | | |
| inline mtOp(const mtOp_dual_aux_indicator&, const T1& in_m, cons
t in_eT in_aux_a, const out_eT in_aux_b); | | inline mtOp(const mtOp_dual_aux_indicator&, const T1& in_m, cons
t in_eT in_aux_a, const out_eT in_aux_b); | |
| | | | |
| | | | |
End of changes. 2 change blocks. |
| 6 lines changed or deleted | | 13 lines changed or added | |
|
| op_cumsum_bones.hpp | | op_cumsum_bones.hpp | |
|
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2010-2015 Conrad Sanderson | |
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_cumsum | | //! \addtogroup op_cumsum | |
| //! @{ | | //! @{ | |
| | | | |
| class op_cumsum_mat | | class op_cumsum_mat | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| | | template<typename eT> | |
| | | inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& X, const uw | |
| | | ord dim); | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_cumsum_mat>& in); | | inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_cumsum_mat>& in); | |
| }; | | }; | |
| | | | |
| class op_cumsum_vec | | class op_cumsum_vec | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| | | template<typename eT> | |
| | | inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& X); | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_cumsum_vec>& in); | | inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_cumsum_vec>& in); | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 9 lines changed or added | |
|
| op_cumsum_meat.hpp | | op_cumsum_meat.hpp | |
|
| // Copyright (C) 2010-2012 Conrad Sanderson | | // Copyright (C) 2010-2015 Conrad Sanderson | |
| // Copyright (C) 2010-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_cumsum | | //! \addtogroup op_cumsum | |
| //! @{ | | //! @{ | |
| | | | |
|
| template<typename T1> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
|
| op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu
m_mat>& in) | | op_cumsum_mat::apply_noalias(Mat<eT>& out, const Mat<eT>& X, const uword di
m) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| typedef typename T1::elem_type eT; | | | |
| | | | |
| const unwrap_check<T1> tmp(in.m, out); | | | |
| const Mat<eT>& X = tmp.M; | | | |
| | | | |
| const uword dim = in.aux_uword_a; | | | |
| arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or | | | |
| 1"); | | | |
| | | | |
| out.copy_size(X); | | out.copy_size(X); | |
| | | | |
| const uword X_n_rows = X.n_rows; | | const uword X_n_rows = X.n_rows; | |
| const uword X_n_cols = X.n_cols; | | const uword X_n_cols = X.n_cols; | |
| | | | |
| if(dim == 0) | | if(dim == 0) | |
| { | | { | |
|
| arma_extra_debug_print("op_cumsum::apply(), dim = 0"); | | arma_extra_debug_print("op_cumsum_mat::apply(), dim = 0"); | |
| | | | |
| for(uword col=0; col<X_n_cols; ++col) | | for(uword col=0; col<X_n_cols; ++col) | |
| { | | { | |
| eT* out_colmem = out.colptr(col); | | eT* out_colmem = out.colptr(col); | |
| const eT* X_colmem = X.colptr(col); | | const eT* X_colmem = X.colptr(col); | |
| | | | |
| eT acc = eT(0); | | eT acc = eT(0); | |
| | | | |
| for(uword row=0; row<X_n_rows; ++row) | | for(uword row=0; row<X_n_rows; ++row) | |
| { | | { | |
| acc += X_colmem[row]; | | acc += X_colmem[row]; | |
| | | | |
| out_colmem[row] = acc; | | out_colmem[row] = acc; | |
| } | | } | |
| } | | } | |
| } | | } | |
| else | | else | |
| if(dim == 1) | | if(dim == 1) | |
| { | | { | |
|
| arma_extra_debug_print("op_cumsum::apply(), dim = 1"); | | arma_extra_debug_print("op_cumsum_mat::apply(), dim = 1"); | |
| | | | |
| for(uword row=0; row<X_n_rows; ++row) | | for(uword row=0; row<X_n_rows; ++row) | |
| { | | { | |
| eT acc = eT(0); | | eT acc = eT(0); | |
| | | | |
| for(uword col=0; col<X_n_cols; ++col) | | for(uword col=0; col<X_n_cols; ++col) | |
| { | | { | |
| acc += X.at(row,col); | | acc += X.at(row,col); | |
| | | | |
| out.at(row,col) = acc; | | out.at(row,col) = acc; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
|
| op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu
m_vec>& in) | | op_cumsum_mat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu
m_mat>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap_check<T1> tmp(in.m, out); | | const unwrap<T1> tmp(in.m); | |
| const Mat<eT>& X = tmp.M; | | const Mat<eT>& X = tmp.M; | |
| | | | |
| | | const uword dim = in.aux_uword_a; | |
| | | arma_debug_check( (dim > 1), "cumsum(): incorrect usage. dim must be 0 or | |
| | | 1"); | |
| | | | |
| | | if(&out == &X) | |
| | | { | |
| | | Mat<eT> out2; | |
| | | | |
| | | op_cumsum_mat::apply_noalias(out2, X, dim); | |
| | | | |
| | | out.steal_mem(out2); | |
| | | } | |
| | | else | |
| | | { | |
| | | op_cumsum_mat::apply_noalias(out, X, dim); | |
| | | } | |
| | | } | |
| | | | |
| | | template<typename eT> | |
| | | inline | |
| | | void | |
| | | op_cumsum_vec::apply_noalias(Mat<eT>& out, const Mat<eT>& X) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| const uword n_elem = X.n_elem; | | const uword n_elem = X.n_elem; | |
| | | | |
| out.copy_size(X); | | out.copy_size(X); | |
| | | | |
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| const eT* X_mem = X.memptr(); | | const eT* X_mem = X.memptr(); | |
| | | | |
| eT acc = eT(0); | | eT acc = eT(0); | |
| | | | |
| for(uword i=0; i<n_elem; ++i) | | for(uword i=0; i<n_elem; ++i) | |
| { | | { | |
| acc += X_mem[i]; | | acc += X_mem[i]; | |
| | | | |
| out_mem[i] = acc; | | out_mem[i] = acc; | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | template<typename T1> | |
| | | inline | |
| | | void | |
| | | op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsu | |
| | | m_vec>& in) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const quasi_unwrap<T1> U(in.m); | |
| | | | |
| | | const Mat<eT>& X = U.M; | |
| | | | |
| | | if(U.is_alias(out)) | |
| | | { | |
| | | Mat<eT> out2; | |
| | | | |
| | | op_cumsum_vec::apply_noalias(out2, X); | |
| | | | |
| | | out.steal_mem(out2); | |
| | | } | |
| | | else | |
| | | { | |
| | | op_cumsum_vec::apply_noalias(out, X); | |
| | | } | |
| | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 9 change blocks. |
| 18 lines changed or deleted | | 62 lines changed or added | |
|
| op_flip_meat.hpp | | op_flip_meat.hpp | |
|
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2010-2015 Conrad Sanderson | |
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_flip | | //! \addtogroup op_flip | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| op_flipud::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_flipud>&
in) | | op_flipud::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_flipud>&
in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap<T1> tmp(in.m); | | const unwrap<T1> tmp(in.m); | |
| const Mat<eT> X = tmp.M; | | const Mat<eT>& X = tmp.M; | |
| | | | |
| | | const uword X_n_rows = X.n_rows; | |
| | | | |
| if(&out != &X) | | if(&out != &X) | |
| { | | { | |
| out.copy_size(X); | | out.copy_size(X); | |
| | | | |
|
| for(uword i=0; i<X.n_rows; ++i) | | if(T1::is_col || X.is_colvec()) | |
| | | { | |
| | | for(uword i=0; i<X_n_rows; ++i) { out[i] = X[X_n_rows-1 - i]; } | |
| | | } | |
| | | else | |
| { | | { | |
|
| out.row(i) = X.row(X.n_rows-1 - i); | | for(uword i=0; i<X_n_rows; ++i) { out.row(i) = X.row(X_n_rows-1 - i)
; } | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| const uword N = X.n_rows / 2; | | const uword N = X_n_rows / 2; | |
| | | | |
|
| for(uword i=0; i<N; ++i) | | if(T1::is_col || X.is_colvec()) | |
| | | { | |
| | | for(uword i=0; i<N; ++i) { std::swap(out[i], out[X_n_rows-1 - i]); } | |
| | | } | |
| | | else | |
| { | | { | |
|
| out.swap_rows(i, X.n_rows-1 - i); | | for(uword i=0; i<N; ++i) { out.swap_rows(i, X_n_rows-1 - i); } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| op_fliplr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_fliplr>&
in) | | op_fliplr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_fliplr>&
in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap<T1> tmp(in.m); | | const unwrap<T1> tmp(in.m); | |
| const Mat<eT> X = tmp.M; | | const Mat<eT>& X = tmp.M; | |
| | | | |
| | | const uword X_n_cols = X.n_cols; | |
| | | | |
| if(&out != &X) | | if(&out != &X) | |
| { | | { | |
| out.copy_size(X); | | out.copy_size(X); | |
| | | | |
|
| for(uword i=0; i<X.n_cols; ++i) | | if(T1::is_row || X.is_rowvec()) | |
| | | { | |
| | | for(uword i=0; i<X_n_cols; ++i) { out[i] = X[X_n_cols-1 - i]; } | |
| | | } | |
| | | else | |
| { | | { | |
|
| out.col(i) = X.col(X.n_cols-1 - i); | | for(uword i=0; i<X_n_cols; ++i) { out.col(i) = X.col(X_n_cols-1 - i)
; } | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| const uword N = X.n_cols / 2; | | const uword N = X_n_cols / 2; | |
| | | | |
|
| for(uword i=0; i<N; ++i) | | if(T1::is_row || X.is_rowvec()) | |
| | | { | |
| | | for(uword i=0; i<N; ++i) { std::swap(out[i], out[X_n_cols-1 - i]); } | |
| | | } | |
| | | else | |
| { | | { | |
|
| out.swap_cols(i, X.n_cols-1 - i); | | for(uword i=0; i<N; ++i) { out.swap_cols(i, X_n_cols-1 - i); } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 13 change blocks. |
| 16 lines changed or deleted | | 36 lines changed or added | |
|
| op_sort_bones.hpp | | op_sort_bones.hpp | |
|
| // Copyright (C) 2008-2012 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_sort | | //! \addtogroup op_sort | |
| //! @{ | | //! @{ | |
| | | | |
| class op_sort | | class op_sort | |
| { | | { | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline static void copy_row(Mat<eT>& A, const eT* X, const uword row); | | inline static void copy_row(Mat<eT>& A, const eT* X, const uword row); | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline static void direct_sort(eT* X, const uword N, const uword sort_typ
e = 0); | | inline static void direct_sort(eT* X, const uword N, const uword sort_typ
e = 0); | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline static void direct_sort_ascending(eT* X, const uword N); | | inline static void direct_sort_ascending(eT* X, const uword N); | |
| | | | |
|
| | | template<typename eT> | |
| | | inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& X, const uw | |
| | | ord sort_type, const uword dim); | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_sort>& in); | | inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op
_sort>& in); | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 6 lines changed or added | |
|
| op_sort_meat.hpp | | op_sort_meat.hpp | |
|
| // Copyright (C) 2008-2012 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_sort | | //! \addtogroup op_sort | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| class arma_ascend_sort_helper | | class arma_ascend_sort_helper | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 142 | |
| A.at(row,i) = X[i]; | | A.at(row,i) = X[i]; | |
| A.at(row,j) = X[j]; | | A.at(row,j) = X[j]; | |
| } | | } | |
| | | | |
| if(i < N) | | if(i < N) | |
| { | | { | |
| A.at(row,i) = X[i]; | | A.at(row,i) = X[i]; | |
| } | | } | |
| } | | } | |
| | | | |
|
| template<typename T1> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
|
| op_sort::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort>& in) | | op_sort::apply_noalias(Mat<eT>& out, const Mat<eT>& X, const uword sort_typ
e, const uword dim) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| typedef typename T1::elem_type eT; | | | |
| | | | |
| const unwrap_check<T1> tmp(in.m, out); | | | |
| const Mat<eT>& X = tmp.M; | | | |
| | | | |
| const uword sort_type = in.aux_uword_a; | | | |
| const uword dim = in.aux_uword_b; | | | |
| | | | |
| arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor | | | |
| t_type must be 0 or 1"); | | | |
| arma_debug_check( (dim > 1), "sort(): incorrect usage. dim | | | |
| must be 0 or 1" ); | | | |
| arma_debug_check( (X.is_finite() == false), "sort(): given object has non | | | |
| -finite elements" ); | | | |
| | | | |
| if( (X.n_rows * X.n_cols) <= 1 ) | | if( (X.n_rows * X.n_cols) <= 1 ) | |
| { | | { | |
| out = X; | | out = X; | |
| return; | | return; | |
| } | | } | |
| | | | |
| if(dim == 0) // sort the contents of each column | | if(dim == 0) // sort the contents of each column | |
| { | | { | |
| arma_extra_debug_print("op_sort::apply(), dim = 0"); | | arma_extra_debug_print("op_sort::apply(), dim = 0"); | |
| | | | |
| | | | |
| skipping to change at line 212 | | skipping to change at line 200 | |
| for(uword row=0; row < n_rows; ++row) | | for(uword row=0; row < n_rows; ++row) | |
| { | | { | |
| op_sort::copy_row(tmp_array.memptr(), X, row); | | op_sort::copy_row(tmp_array.memptr(), X, row); | |
| | | | |
| op_sort::direct_sort( tmp_array.memptr(), n_cols, sort_type ); | | op_sort::direct_sort( tmp_array.memptr(), n_cols, sort_type ); | |
| | | | |
| op_sort::copy_row(out, tmp_array.memptr(), row); | | op_sort::copy_row(out, tmp_array.memptr(), row); | |
| } | | } | |
| } | | } | |
| } | | } | |
|
| | | } | |
| | | | |
|
| | | template<typename T1> | |
| | | inline | |
| | | void | |
| | | op_sort::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort>& in) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const quasi_unwrap<T1> U(in.m); | |
| | | | |
| | | const Mat<eT>& X = U.M; | |
| | | | |
| | | const uword sort_type = in.aux_uword_a; | |
| | | const uword dim = in.aux_uword_b; | |
| | | | |
| | | arma_debug_check( (sort_type > 1), "sort(): incorrect usage. sor | |
| | | t_type must be 0 or 1"); | |
| | | arma_debug_check( (dim > 1), "sort(): incorrect usage. dim | |
| | | must be 0 or 1" ); | |
| | | arma_debug_check( (X.is_finite() == false), "sort(): given object has non | |
| | | -finite elements" ); | |
| | | | |
| | | if(U.is_alias(out)) | |
| | | { | |
| | | Mat<eT> out2; | |
| | | | |
| | | op_sort::apply_noalias(out2, X, sort_type, dim); | |
| | | | |
| | | out.steal_mem(out2); | |
| | | } | |
| | | else | |
| | | { | |
| | | apply_noalias(out, X, sort_type, dim); | |
| | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 6 change blocks. |
| 19 lines changed or deleted | | 40 lines changed or added | |
|
| op_vectorise_bones.hpp | | op_vectorise_bones.hpp | |
|
| // Copyright (C) 2013-2014 Conrad Sanderson | | // Copyright (C) 2013-2015 Conrad Sanderson | |
| // Copyright (C) 2013-2014 NICTA (www.nicta.com.au) | | // Copyright (C) 2013-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_vectorise | | //! \addtogroup op_vectorise | |
| //! @{ | | //! @{ | |
| | | | |
| class op_vectorise_col | | class op_vectorise_col | |
| { | | { | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| { | | { | |
| public: | | public: | |
| | | | |
| template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_vectorise_all>& in); | | template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_vectorise_all>& in); | |
| }; | | }; | |
| | | | |
| class op_vectorise_cube_col | | class op_vectorise_cube_col | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_vectorise_cube_col>& in); | | template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const BaseCube<typename T1::elem_type, T1>& in); | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 3 lines changed or added | |
|
| op_vectorise_meat.hpp | | op_vectorise_meat.hpp | |
|
| // Copyright (C) 2013 Conrad Sanderson | | // Copyright (C) 2013-2015 Conrad Sanderson | |
| // Copyright (C) 2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2013-2015 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup op_vectorise | | //! \addtogroup op_vectorise | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| | | | |
| skipping to change at line 197 | | skipping to change at line 197 | |
| op_vectorise_col::apply_proxy(out, P); | | op_vectorise_col::apply_proxy(out, P); | |
| } | | } | |
| else | | else | |
| { | | { | |
| op_vectorise_row::apply_proxy(out, P); | | op_vectorise_row::apply_proxy(out, P); | |
| } | | } | |
| } | | } | |
| | | | |
| // | | // | |
| | | | |
|
| //! experimental: vectorisation of cubes | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
|
| op_vectorise_cube_col::apply(Mat<typename T1::elem_type>& out, const Op<T1,
op_vectorise_cube_col>& in) | | op_vectorise_cube_col::apply(Mat<typename T1::elem_type>& out, const BaseCu
be<typename T1::elem_type, T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| ProxyCube<T1> P(in.m); | | ProxyCube<T1> P(in.get_ref()); | |
| | | | |
| const uword N = P.get_n_elem(); | | const uword N = P.get_n_elem(); | |
| | | | |
| out.set_size(N, 1); | | out.set_size(N, 1); | |
| | | | |
| if(is_Cube<typename ProxyCube<T1>::stored_type>::value == true) | | if(is_Cube<typename ProxyCube<T1>::stored_type>::value == true) | |
| { | | { | |
| const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(P.Q); | | const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(P.Q); | |
| | | | |
| arrayops::copy(out.memptr(), tmp.M.memptr(), N); | | arrayops::copy(out.memptr(), tmp.M.memptr(), N); | |
| | | | |
End of changes. 4 change blocks. |
| 5 lines changed or deleted | | 4 lines changed or added | |
|