FEI Version of the Day
CoefAccess.hpp
00001 #ifndef _CoefAccess_h_
00002 #define _CoefAccess_h_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 #include <cstdlib>
00013 
00014 class CoefAccess {
00015  public:
00016   CoefAccess() : patternID_(-1), numRowIDs_(0), rowIDs_(NULL),
00017     numColIDsPerRow_(0), colIDs_(NULL), numRowCoefs_(0), numColCoefs_(0),
00018     coefs_(NULL) {}
00019 
00020   CoefAccess(const CoefAccess& src)
00021     {
00022       *this = src;
00023     }
00024 
00025   CoefAccess& operator=(const CoefAccess& src)
00026     {
00027       patternID_ = src.patternID_;
00028 
00029       numRowIDs_ = src.numRowIDs_;
00030       numColIDsPerRow_ = src.numColIDsPerRow_;
00031       numRowCoefs_ = src.numRowCoefs_;
00032       numColCoefs_ = src.numColCoefs_;
00033 
00034       if (numRowIDs_ > 0) {
00035   rowIDs_ = new GlobalID[numRowIDs_];
00036   for(int i=0; i<numRowIDs_; i++) rowIDs_[i] = src.rowIDs_[i];
00037       }
00038 
00039       if (numColIDsPerRow_ > 0 && numRowIDs_ > 0) {
00040   int len = numRowIDs_*numColIDsPerRow_;
00041   colIDs_ = new GlobalID[len];
00042   for(int i=0; i<len; i++) colIDs_[i] = src.colIDs_[i];
00043       }
00044 
00045       if (numRowCoefs_ > 0 && numColCoefs_ > 0) {
00046   int len = numRowCoefs_*numColCoefs_;
00047   coefs_ = new double[len];
00048   for(int i=0; i<len; i++) coefs_[i] = src.coefs_[i];
00049       }
00050 
00051       return(*this);
00052     }
00053 
00054   ~CoefAccess()
00055     {
00056       delete [] rowIDs_; delete [] colIDs_; delete [] coefs_;
00057       numRowIDs_ = 0; numColIDsPerRow_ = 0; numRowCoefs_ = 0; numColCoefs_ = 0;
00058     }
00059 
00060   int patternID_;
00061 
00062   int numRowIDs_;
00063   GlobalID* rowIDs_;
00064 
00065   int numColIDsPerRow_;
00066   GlobalID* colIDs_;
00067 
00068   int numRowCoefs_;
00069   int numColCoefs_;
00070 
00071   double* coefs_;
00072 };
00073 
00074 #endif // _CoefAccess_h_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends