FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CoefAccess.hpp
1 #ifndef _CoefAccess_h_
2 #define _CoefAccess_h_
3 
4 /*--------------------------------------------------------------------*/
5 /* Copyright 2005 Sandia Corporation. */
6 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
7 /* non-exclusive license for use of this work by or on behalf */
8 /* of the U.S. Government. Export of this program may require */
9 /* a license from the United States Government. */
10 /*--------------------------------------------------------------------*/
11 
12 #include <cstdlib>
13 
14 class CoefAccess {
15  public:
16  CoefAccess() : patternID_(-1), numRowIDs_(0), rowIDs_(NULL),
17  numColIDsPerRow_(0), colIDs_(NULL), numRowCoefs_(0), numColCoefs_(0),
18  coefs_(NULL) {}
19 
20  CoefAccess(const CoefAccess& src)
21  {
22  *this = src;
23  }
24 
25  CoefAccess& operator=(const CoefAccess& src)
26  {
27  patternID_ = src.patternID_;
28 
29  numRowIDs_ = src.numRowIDs_;
30  numColIDsPerRow_ = src.numColIDsPerRow_;
31  numRowCoefs_ = src.numRowCoefs_;
32  numColCoefs_ = src.numColCoefs_;
33 
34  if (numRowIDs_ > 0) {
35  rowIDs_ = new GlobalID[numRowIDs_];
36  for(int i=0; i<numRowIDs_; i++) rowIDs_[i] = src.rowIDs_[i];
37  }
38 
39  if (numColIDsPerRow_ > 0 && numRowIDs_ > 0) {
40  int len = numRowIDs_*numColIDsPerRow_;
41  colIDs_ = new GlobalID[len];
42  for(int i=0; i<len; i++) colIDs_[i] = src.colIDs_[i];
43  }
44 
45  if (numRowCoefs_ > 0 && numColCoefs_ > 0) {
46  int len = numRowCoefs_*numColCoefs_;
47  coefs_ = new double[len];
48  for(int i=0; i<len; i++) coefs_[i] = src.coefs_[i];
49  }
50 
51  return(*this);
52  }
53 
54  ~CoefAccess()
55  {
56  delete [] rowIDs_; delete [] colIDs_; delete [] coefs_;
57  numRowIDs_ = 0; numColIDsPerRow_ = 0; numRowCoefs_ = 0; numColCoefs_ = 0;
58  }
59 
60  int patternID_;
61 
62  int numRowIDs_;
63  GlobalID* rowIDs_;
64 
65  int numColIDsPerRow_;
66  GlobalID* colIDs_;
67 
68  int numRowCoefs_;
69  int numColCoefs_;
70 
71  double* coefs_;
72 };
73 
74 #endif // _CoefAccess_h_