max@0: // Copyright (C) 2010-2012 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2010-2012 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup ProxyCube max@0: //! @{ max@0: max@0: max@0: max@0: template max@0: class ProxyCube max@0: { max@0: public: max@0: inline ProxyCube(const T1& A) max@0: { max@0: arma_type_check(( is_arma_cube_type::value == false )); max@0: } max@0: }; max@0: max@0: max@0: max@0: // ea_type is the "element accessor" type, max@0: // which can provide access to elements via operator[] max@0: max@0: template max@0: class ProxyCube< Cube > max@0: { max@0: public: max@0: max@0: typedef eT elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef Cube stored_type; max@0: typedef const eT* ea_type; max@0: max@0: static const bool prefer_at_accessor = false; max@0: static const bool has_subview = false; max@0: max@0: arma_aligned const Cube& Q; max@0: max@0: inline explicit ProxyCube(const Cube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_elem; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q.memptr(); } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube& X) const { return (void_ptr(&Q) == void_ptr(&X)); } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< GenCube > max@0: { max@0: public: max@0: max@0: typedef eT elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef GenCube stored_type; max@0: typedef const GenCube& ea_type; max@0: max@0: static const bool prefer_at_accessor = false; max@0: static const bool has_subview = false; max@0: max@0: arma_aligned const GenCube& Q; max@0: max@0: inline explicit ProxyCube(const GenCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_rows*Q.n_cols; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols*Q.n_slices; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q; } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube&) const { return false; } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< OpCube > max@0: { max@0: public: max@0: max@0: typedef typename T1::elem_type elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef Cube stored_type; max@0: typedef const elem_type* ea_type; max@0: max@0: static const bool prefer_at_accessor = false; max@0: static const bool has_subview = false; max@0: max@0: arma_aligned const Cube Q; max@0: max@0: inline explicit ProxyCube(const OpCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_elem; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q.memptr(); } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube&) const { return false; } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< GlueCube > max@0: { max@0: public: max@0: max@0: typedef typename T1::elem_type elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef Cube stored_type; max@0: typedef const elem_type* ea_type; max@0: max@0: static const bool prefer_at_accessor = false; max@0: static const bool has_subview = false; max@0: max@0: arma_aligned const Cube Q; max@0: max@0: inline explicit ProxyCube(const GlueCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_elem; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q.memptr(); } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube&) const { return false; } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< subview_cube > max@0: { max@0: public: max@0: max@0: typedef eT elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef subview_cube stored_type; max@0: typedef const subview_cube& ea_type; max@0: max@0: static const bool prefer_at_accessor = true; max@0: static const bool has_subview = true; max@0: max@0: arma_aligned const subview_cube& Q; max@0: max@0: inline explicit ProxyCube(const subview_cube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_elem; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q; } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube& X) const { return (void_ptr(&(Q.m)) == void_ptr(&X)); } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< eOpCube > max@0: { max@0: public: max@0: max@0: typedef typename T1::elem_type elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef eOpCube stored_type; max@0: typedef const eOpCube& ea_type; max@0: max@0: static const bool prefer_at_accessor = eOpCube::prefer_at_accessor; max@0: static const bool has_subview = eOpCube::has_subview; max@0: max@0: arma_aligned const eOpCube& Q; max@0: max@0: inline explicit ProxyCube(const eOpCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.get_n_rows(); } max@0: arma_inline uword get_n_cols() const { return Q.get_n_cols(); } max@0: arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); } max@0: arma_inline uword get_n_slices() const { return Q.get_n_slices(); } max@0: arma_inline uword get_n_elem() const { return Q.get_n_elem(); } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q; } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube& X) const { return Q.P.is_alias(X); } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< eGlueCube > max@0: { max@0: public: max@0: max@0: typedef typename T1::elem_type elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef eGlueCube stored_type; max@0: typedef const eGlueCube& ea_type; max@0: max@0: static const bool prefer_at_accessor = eGlueCube::prefer_at_accessor; max@0: static const bool has_subview = eGlueCube::has_subview; max@0: max@0: arma_aligned const eGlueCube& Q; max@0: max@0: inline explicit ProxyCube(const eGlueCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.get_n_rows(); } max@0: arma_inline uword get_n_cols() const { return Q.get_n_cols(); } max@0: arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); } max@0: arma_inline uword get_n_slices() const { return Q.get_n_slices(); } max@0: arma_inline uword get_n_elem() const { return Q.get_n_elem(); } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q; } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube& X) const { return (Q.P1.is_alias(X) || Q.P2.is_alias(X)); } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< mtOpCube > max@0: { max@0: public: max@0: max@0: typedef out_eT elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef Cube stored_type; max@0: typedef const elem_type* ea_type; max@0: max@0: static const bool prefer_at_accessor = false; max@0: static const bool has_subview = false; max@0: max@0: arma_aligned const Cube Q; max@0: max@0: inline explicit ProxyCube(const mtOpCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_elem; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q.memptr(); } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube&) const { return false; } max@0: }; max@0: max@0: max@0: max@0: template max@0: class ProxyCube< mtGlueCube > max@0: { max@0: public: max@0: max@0: typedef out_eT elem_type; max@0: typedef typename get_pod_type::result pod_type; max@0: typedef Cube stored_type; max@0: typedef const elem_type* ea_type; max@0: max@0: static const bool prefer_at_accessor = false; max@0: static const bool has_subview = false; max@0: max@0: arma_aligned const Cube Q; max@0: max@0: inline explicit ProxyCube(const mtGlueCube& A) max@0: : Q(A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: arma_inline uword get_n_rows() const { return Q.n_rows; } max@0: arma_inline uword get_n_cols() const { return Q.n_cols; } max@0: arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } max@0: arma_inline uword get_n_slices() const { return Q.n_slices; } max@0: arma_inline uword get_n_elem() const { return Q.n_elem; } max@0: max@0: arma_inline elem_type operator[] (const uword i) const { return Q[i]; } max@0: arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } max@0: max@0: arma_inline ea_type get_ea() const { return Q.memptr(); } max@0: max@0: template max@0: arma_inline bool is_alias(const Cube&) const { return false; } max@0: }; max@0: max@0: max@0: max@0: //! @}