subview_cube_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2010 NICTA and the authors listed below
00002 // http://nicta.com.au
00003 // 
00004 // Authors:
00005 // - Conrad Sanderson (conradsand at ieee dot org)
00006 // 
00007 // This file is part of the Armadillo C++ library.
00008 // It is provided without any warranty of fitness
00009 // for any purpose. You can redistribute this file
00010 // and/or modify it under the terms of the GNU
00011 // Lesser General Public License (LGPL) as published
00012 // by the Free Software Foundation, either version 3
00013 // of the License or (at your option) any later version.
00014 // (see http://www.opensource.org/licenses for more info)
00015 
00016 
00017 //! \addtogroup subview_cube
00018 //! @{
00019 
00020 
00021 //! Class for storing data required to construct or apply operations to a subcube
00022 //! (i.e. where the subcube starts and ends as well as a reference/pointer to the original cube),
00023 template<typename eT>
00024 class subview_cube : public BaseCube<eT, subview_cube<eT> >
00025   {
00026   public:    arma_aligned const Cube<eT>& m;
00027   protected: arma_aligned       Cube<eT>* m_ptr;
00028   
00029   public:
00030   
00031   typedef eT                                       elem_type;
00032   typedef typename get_pod_type<elem_type>::result pod_type;
00033 
00034   const u32 aux_row1;
00035   const u32 aux_col1;
00036   const u32 aux_slice1;
00037   
00038   const u32 aux_row2;
00039   const u32 aux_col2;
00040   const u32 aux_slice2;
00041   
00042   const u32 n_rows;
00043   const u32 n_cols;
00044   const u32 n_elem_slice;
00045   const u32 n_slices;
00046   const u32 n_elem;
00047   
00048   
00049   protected:
00050   
00051   arma_inline subview_cube(const Cube<eT>& in_m, const u32 in_row1, const u32 in_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u32 in_slice2);
00052   arma_inline subview_cube(      Cube<eT>& in_m, const u32 in_row1, const u32 in_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u32 in_slice2);
00053   
00054   
00055   public:
00056   
00057   inline ~subview_cube();
00058   
00059   inline void operator+= (const eT val);
00060   inline void operator-= (const eT val);
00061   inline void operator*= (const eT val);
00062   inline void operator/= (const eT val);
00063   
00064   // deliberately returning void
00065   template<typename T1> inline void operator=  (const BaseCube<eT,T1>& x);
00066   template<typename T1> inline void operator+= (const BaseCube<eT,T1>& x);
00067   template<typename T1> inline void operator-= (const BaseCube<eT,T1>& x);
00068   template<typename T1> inline void operator%= (const BaseCube<eT,T1>& x);
00069   template<typename T1> inline void operator/= (const BaseCube<eT,T1>& x);
00070   
00071   inline void operator=  (const subview_cube& x);
00072   inline void operator+= (const subview_cube& x);
00073   inline void operator-= (const subview_cube& x);
00074   inline void operator%= (const subview_cube& x);
00075   inline void operator/= (const subview_cube& x);
00076   
00077   template<typename T1> inline void operator=  (const Base<eT,T1>& x);
00078   template<typename T1> inline void operator+= (const Base<eT,T1>& x);
00079   template<typename T1> inline void operator-= (const Base<eT,T1>& x);
00080   template<typename T1> inline void operator%= (const Base<eT,T1>& x);
00081   template<typename T1> inline void operator/= (const Base<eT,T1>& x);
00082 
00083   inline static void extract(Cube<eT>& out, const subview_cube& in);
00084   inline static void extract(Mat<eT>&  out, const subview_cube& in);
00085   
00086   inline static void  plus_inplace(Cube<eT>& out, const subview_cube& in);
00087   inline static void minus_inplace(Cube<eT>& out, const subview_cube& in);
00088   inline static void schur_inplace(Cube<eT>& out, const subview_cube& in);
00089   inline static void   div_inplace(Cube<eT>& out, const subview_cube& in);
00090   
00091   inline static void  plus_inplace(Mat<eT>& out, const subview_cube& in);
00092   inline static void minus_inplace(Mat<eT>& out, const subview_cube& in);
00093   inline static void schur_inplace(Mat<eT>& out, const subview_cube& in);
00094   inline static void   div_inplace(Mat<eT>& out, const subview_cube& in);
00095 
00096   inline void fill(const eT val);
00097   inline void zeros();
00098   inline void ones();
00099   
00100   arma_inline eT& operator[](const u32 i);
00101   arma_inline eT  operator[](const u32 i) const;
00102   
00103   arma_inline eT& operator()(const u32 i);
00104   arma_inline eT  operator()(const u32 i) const;
00105   
00106   arma_inline eT& operator()(const u32 in_row, const u32 in_col, const u32 in_slice);
00107   arma_inline eT  operator()(const u32 in_row, const u32 in_col, const u32 in_slice) const;
00108   
00109   arma_inline eT&         at(const u32 in_row, const u32 in_col, const u32 in_slice);
00110   arma_inline eT          at(const u32 in_row, const u32 in_col, const u32 in_slice) const;
00111   
00112   arma_inline       eT* slice_colptr(const u32 in_slice, const u32 in_col);
00113   arma_inline const eT* slice_colptr(const u32 in_slice, const u32 in_col) const;
00114   
00115   inline bool check_overlap(const subview_cube& x) const;
00116   inline bool check_overlap(const Mat<eT>&      x) const;
00117   
00118   
00119   private:
00120   
00121   friend class  Mat<eT>;
00122   friend class Cube<eT>;
00123   
00124   subview_cube();
00125   };
00126 
00127 
00128 
00129 //! @}