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 
00042   FillableVec* getRow(int row, bool create_if_not_already_present=false);
00043 
00044   typedef std::map<int, FillableVec*, std::less<int>,
00045                 fei_Pool_alloc<std::pair<const int,FillableVec*> > > feipoolmat;
00046 
00047   typedef feipoolmat::iterator iterator;
00048   typedef feipoolmat::const_iterator const_iterator;
00049 
00050   iterator begin() {return matdata_.begin();}
00051   iterator end() {return matdata_.end();}
00052 
00053   const_iterator begin() const {return matdata_.begin();}
00054   const_iterator end() const {return matdata_.end();}
00055 
00056   void clear();
00057 
00058   bool operator==(const FillableMat& rhs) const;
00059 
00060   bool operator!=(const FillableMat& rhs) const;
00061 
00062  private:
00063   feipoolmat matdata_;
00064   fei_Pool_alloc<FillableVec> vecpool_;
00065 }; //class FillableMat
00066 
00068 void print(std::ostream& os, const FillableMat& mat);
00069 
00071 int count_nnz(const FillableMat& mat);
00072 
00074 void get_row_numbers(const FillableMat& mat, std::vector<int>& rows);
00075 
00076 }//namespace fei
00077 
00078 #endif
00079 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends