Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

operator/submatrix.hh
Go to the documentation of this file.
00001 /* interface for a submatrix and implemention for sparse matrix
00002  */
00003 
00004 #ifndef submatrix_hh
00005 #define submatrix_hh
00006 
00007 #include "matrix.hh"
00008 #include "matrixMult.hh"
00009 #include "subMatrixIterator.hh"
00010 #include "CRS.hh"
00011 #include "space/spaceSet.hh"
00012 #include "basics/outputOperator.hh"
00013 
00014 namespace concepts {
00015 
00016   // forward declaration
00017   template<class F, class G>
00018   class SubMatrix;
00019 
00020   template<class F>
00021   class SubMatrixN;
00022 
00023 
00024   // ************************************************************* SubMatrix **
00025 
00034   template<class F>
00035   class SubMatrixN : public Matrix<typename F::type>,
00036                      public CRSConvertable<typename F::type> {
00037   public:
00038     typedef typename F::type type;
00040     typedef typename Realtype<type>::type r_type;
00042     typedef typename Cmplxtype<type>::type c_type;
00043 
00044     typedef _SubMatrix_iterator<F, type&, type*>              iterator;
00045     typedef _SubMatrix_iterator<F, const type&, const type*>  const_iterator;
00046 
00048     SubMatrixN(F& m,
00049                const Set<IndexRange>& indicesX,
00050                const Set<IndexRange>& indicesY);
00052     SubMatrixN();
00053                   
00054     virtual ~SubMatrixN() {}
00055 
00056     virtual void operator()(const Function<r_type>& fncY,
00057                             Function<type>& fncX);
00058     virtual void operator()(const Function<c_type>& fncY,
00059                             Function<c_type>& fncX);
00060 
00061     virtual void transpMult(const Vector<r_type>& fncY,
00062                             Vector<type>& fncX);
00063     virtual void transpMult(const Vector<c_type>& fncY,
00064                             Vector<c_type>& fncX);
00065 
00066     template<class H, class I>
00067     void multiply(const H& fact, I& dest) const {
00068       matrixMultiplyRowSorting(*this, fact, dest);
00069     }
00070 
00072     virtual type operator()(const uint i, const uint j) const;
00073     virtual type& operator()(const uint i, const uint j);
00074 
00076     iterator begin(uint r = 0);
00078     const_iterator begin(uint r = 0) const;
00080     const_iterator end() const;
00081 
00087     uint used() const;
00088 
00090     virtual void convertCRS(type* a, int* asub, int* xa) const;
00092     virtual void convertCCS(type* a, int* asub, int* xa) const;
00093 
00101     template<class H, class I>
00102     void addInto(Matrix<H>& dest, const I fact,
00103                  const uint rowoffset = 0, const uint coloffset = 0) const;
00104 
00106     const Set<IndexRange>& indicesX() const { return indicesX_; }
00108     const Set<IndexRange>& indicesY() const { return indicesY_; }
00109 
00111     F& matrix() { return *m_; }
00112     const F& matrix() const { return *m_; }
00113   protected:
00114     virtual std::ostream& info(std::ostream& os) const;
00116     const Set<IndexRange> indicesX_, indicesY_;
00117   private:
00119     F* m_;
00120   };
00121 
00122   template<class F>
00123   template<class H, class I>
00124   void SubMatrixN<F>::addInto(Matrix<H>& dest, const I fact,
00125                               const uint rowoffset,
00126                               const uint coloffset) const {
00127     for(const_iterator i = begin(); i != end(); ++i)
00128       dest(rowoffset + i.row(), coloffset + i.col()) += fact * *i;
00129   }
00130 
00131 } // namespace concepts
00132 
00133 #endif // submatrix_hh
00134 

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)