subview_field_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_field
00018 //! @{
00019 
00020 
00021 //! Class for storing data required to construct or apply operations to a subfield
00022 //! (i.e. where the subfield starts and ends as well as a reference/pointer to the original field),
00023 template<typename oT>
00024 class subview_field
00025   {
00026   public:  const field<oT>& f;
00027   protected:     field<oT>* f_ptr;
00028   
00029   public:
00030   
00031   typedef oT object_type;
00032   
00033   const u32 aux_row1;
00034   const u32 aux_col1;
00035   
00036   const u32 aux_row2;
00037   const u32 aux_col2;
00038   
00039   const u32 n_rows;
00040   const u32 n_cols;
00041   const u32 n_elem;
00042   
00043   
00044   protected:
00045   
00046   arma_inline subview_field(const field<oT>& in_f, const u32 in_row1, const u32 in_col1, const u32 in_row2,  const u32 in_col2);
00047   arma_inline subview_field(      field<oT>& in_f, const u32 in_row1, const u32 in_col1, const u32 in_row2,  const u32 in_col2);
00048   
00049   
00050   public:
00051   
00052   inline ~subview_field();
00053   
00054   inline void operator= (const field<oT>& x);
00055   inline void operator= (const subview_field& x);
00056   
00057   arma_inline       oT& operator[](const u32 i);
00058   arma_inline const oT& operator[](const u32 i) const;
00059   
00060   arma_inline       oT& operator()(const u32 i);
00061   arma_inline const oT& operator()(const u32 i) const;
00062   
00063   arma_inline       oT&         at(const u32 row, const u32 col);
00064   arma_inline const oT&         at(const u32 row, const u32 col) const;
00065   
00066   arma_inline       oT& operator()(const u32 row, const u32 col);
00067   arma_inline const oT& operator()(const u32 row, const u32 col) const;
00068   
00069   inline bool check_overlap(const subview_field& x) const;
00070   
00071   inline static void extract(field<oT>& out, const subview_field& in);
00072   
00073   
00074   private:
00075   
00076   friend class field<oT>;
00077   
00078   
00079   subview_field();
00080   //subview_field(const subview_field&);
00081   };
00082 
00083 
00084 //! @}