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