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 <fei_CSVec.hpp>
00013 #include <fei_Pool_alloc.hpp>
00014 #include <fei_EqnBuffer.hpp>
00015 #include <vector>
00016 #include <map>
00017 
00018 namespace fei {
00019 
00020 class FillableMat {
00021  public:
00022   FillableMat();
00023   FillableMat(EqnBuffer& eqnbuf);
00024   virtual ~FillableMat();
00025 
00026   FillableMat& operator=(const FillableMat& src);
00027 
00028   void setValues(double value);
00029 
00030   void createPosition(int row, int col);
00031 
00032   void sumInCoef(int row, int col, double coef);
00033   void putCoef(int row, int col, double coef);
00034 
00035   void sumInRow(int row, const int* cols, const double* coefs, unsigned len);
00036   void putRow(int row, const int* cols, const double* coefs, unsigned len);
00037 
00038   unsigned getNumRows() const;
00039 
00040   bool hasRow(int row) const;
00041 
00042   const CSVec* getRow(int row) const;
00043   CSVec* create_or_getRow(int row);
00044 
00045   typedef std::map<int, CSVec*, std::less<int>,
00046                 fei_Pool_alloc<std::pair<const int,CSVec*> > > feipoolmat;
00047 
00048   typedef feipoolmat::iterator iterator;
00049   typedef feipoolmat::const_iterator const_iterator;
00050 
00051   iterator begin() {return matdata_.begin();}
00052   iterator end() {return matdata_.end();}
00053 
00054   const_iterator begin() const {return matdata_.begin();}
00055   const_iterator end() const {return matdata_.end();}
00056 
00057   void clear();
00058 
00059   bool operator==(const FillableMat& rhs) const;
00060 
00061   bool operator!=(const FillableMat& rhs) const;
00062 
00063  private:
00064   feipoolmat matdata_;
00065   fei_Pool_alloc<CSVec> vecpool_;
00066 }; //class FillableMat
00067 
00069 void print(std::ostream& os, const FillableMat& mat);
00070 
00072 int count_nnz(const FillableMat& mat);
00073 
00075 void get_row_numbers(const FillableMat& mat, std::vector<int>& rows);
00076 
00077 }//namespace fei
00078 
00079 #endif
00080 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends