diagview_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 diagview
00018 //! @{
00019 
00020 
00021 //! Class for storing data required to extract and set the diagonals of a matrix
00022 template<typename eT>
00023 class diagview : public Base<eT, diagview<eT> >
00024   {
00025   public:   const Mat<eT>& m;
00026   protected:      Mat<eT>* m_ptr;
00027   
00028   public:
00029   
00030   typedef eT                                elem_type;
00031   typedef typename get_pod_type<eT>::result pod_type;
00032 
00033   const u32 row_offset;
00034   const u32 col_offset;
00035   
00036   const u32 n_rows;  // equal to n_elem
00037   const u32 n_cols;  // equal to one if n_elem > 0, otherwise equal to zero
00038   const u32 n_elem;
00039   
00040   
00041   
00042   protected:
00043   
00044   arma_inline diagview(const Mat<eT>& in_m, const u32 in_row_offset, const u32 in_col_offset, const u32 len);
00045   arma_inline diagview(      Mat<eT>& in_m, const u32 in_row_offset, const u32 in_col_offset, const u32 len);
00046   
00047   
00048   public:
00049   
00050   inline ~diagview();
00051   
00052   template<typename T1>
00053   inline void operator=(const Base<eT,T1>& x);
00054   
00055   inline void operator=(const diagview& x);
00056   
00057   arma_inline eT& operator[](const u32 i);
00058   arma_inline eT  operator[](const u32 i) const;
00059   
00060   arma_inline eT& operator()(const u32 i);
00061   arma_inline eT  operator()(const u32 i) const;
00062 
00063   arma_inline eT& at(const u32 in_n_row, const u32 in_n_col);
00064   arma_inline eT  at(const u32 in_n_row, const u32 in_n_col) const;
00065    
00066   arma_inline eT& operator()(const u32 in_n_row, const u32 in_n_col);
00067   arma_inline eT  operator()(const u32 in_n_row, const u32 in_n_col) const;
00068   
00069   inline void fill(const eT val);
00070   inline void zeros();
00071   inline void ones();
00072   
00073   inline static void extract(Mat<eT>& out, const diagview& in);
00074   
00075   inline static void  plus_inplace(Mat<eT>& out, const diagview& in);
00076   inline static void minus_inplace(Mat<eT>& out, const diagview& in);
00077   inline static void schur_inplace(Mat<eT>& out, const diagview& in);
00078   inline static void   div_inplace(Mat<eT>& out, const diagview& in);
00079   
00080   
00081   private:
00082   
00083   friend class Mat<eT>;
00084   diagview();
00085   //diagview(const diagview&);  // making this private causes an error under gcc 4.1/4.2, but not 4.3
00086   };
00087 
00088 
00089 //! @}