FEI Version of the Day
fei_FillableMat.hpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_FillableMat_hpp_
00010 #define _fei_FillableMat_hpp_
00011 
00012 #include <vector>
00013 #include <fei_FillableVec.hpp>
00014 #include <fei_EqnBuffer.hpp>
00015 
00016 namespace fei {
00017 
00018 class FillableMat {
00019  public:
00020   FillableMat();
00021   FillableMat(EqnBuffer& eqnbuf);
00022   virtual ~FillableMat();
00023 
00024   FillableMat& operator=(const FillableMat& src);
00025 
00026   void setValues(double value);
00027 
00028   void createPosition(int row, int col);
00029 
00030   void sumInCoef(int row, int col, double coef);
00031   void putCoef(int row, int col, double coef);
00032 
00033   void sumInRow(int row, const int* cols, const double* coefs, unsigned len);
00034   void putRow(int row, const int* cols, const double* coefs, unsigned len);
00035 
00036   unsigned getNumRows() const;
00037 
00038   bool hasRow(int row) const;
00039 
00040   const FillableVec* getRow(int row) const;
00041   FillableVec* create_or_getRow(int row);
00042 
00043   typedef std::map<int, FillableVec*, std::less<int>,
00044                 fei_Pool_alloc<std::pair<const int,FillableVec*> > > feipoolmat;
00045 
00046   typedef feipoolmat::iterator iterator;
00047   typedef feipoolmat::const_iterator const_iterator;
00048 
00049   iterator begin() {return matdata_.begin();}
00050   iterator end() {return matdata_.end();}
00051 
00052   const_iterator begin() const {return matdata_.begin();}
00053   const_iterator end() const {return matdata_.end();}
00054 
00055   void clear();
00056 
00057   bool operator==(const FillableMat& rhs) const;
00058 
00059   bool operator!=(const FillableMat& rhs) const;
00060 
00061  private:
00062   feipoolmat matdata_;
00063   fei_Pool_alloc<FillableVec> vecpool_;
00064 }; //class FillableMat
00065 
00067 void print(std::ostream& os, const FillableMat& mat);
00068 
00070 int count_nnz(const FillableMat& mat);
00071 
00073 void get_row_numbers(const FillableMat& mat, std::vector<int>& rows);
00074 
00075 }//namespace fei
00076 
00077 #endif
00078 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends