subview_cube_proto.hpp

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