VERB_code_2.3
zssmatrix-constructor.hpp
1 //============================================================================
4  : m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx)
5 {
6 #ifdef CPPL_VERBOSE
7  std::cerr << "# [MARK] zssmatrix::zssmatrix()"
8  << std::endl;
9 #endif//CPPL_VERBOSE
10 
12  M =N =0;
13  CAP =VOL =0;
14  Array =NULL;
15  Indx =Jndx =NULL;
16 
17 #ifdef CPPL_DEBUG
18  std::cerr << "# [NOTE] zssmatrix::zssmatrix() "
19  << "A new 0x0 matrix at " << Array
20  << " has been made." << std::endl;
21 #endif//CPPL_DEBUG
22 }
23 
24 //============================================================================
26 inline zssmatrix::zssmatrix(const zssmatrix& mat)
27  : m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx)
28 {
29 #ifdef CPPL_VERBOSE
30  std::cerr << "# [MARK] zssmatrix::zssmatrix(const zssmatrix&)"
31  << std::endl;
32 #endif//CPPL_VERBOSE
33 
35  M =mat.M; N =mat.N;
36  CAP =mat.CAP;
37  VOL =mat.VOL;
38  Array =new std::complex<double>[CAP];
39  Indx =new long[CAP];
40  Jndx =new long[CAP];
41 
43  zcopy_(VOL, mat.Array, 1, Array, 1);
44  for(long i=0; i<VOL; i++){
45  Indx[i] =mat.Indx[i];
46  Jndx[i] =mat.Jndx[i];
47  }
48 
49 #ifdef CPPL_DEBUG
50  std::cerr << "# [NOTE] zssmatrix::zssmatrix(const zssmatrix&) "
51  << "A new matrix at " << Array << " has been made." << std::endl;
52 #endif//CPPL_DEBUG
53 }
54 
55 //============================================================================
57 inline zssmatrix::zssmatrix(const _zssmatrix& mat)
58  : m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx)
59 {
60 #ifdef CPPL_VERBOSE
61  std::cerr << "# [MARK] zssmatrix::zssmatrix(const _zssmatrix&)"
62  << std::endl;
63 #endif//CPPL_VERBOSE
64 
65  M =mat.M; N =mat.N;
66  CAP =mat.CAP;
67  VOL =mat.VOL;
68  Array =mat.Array;
69  Indx =mat.Indx;
70  Jndx =mat.Jndx;
71 
72 #ifdef CPPL_DEBUG
73  std::cerr << "# [NOTE] zssmatrix::zssmatrix(const _zssmatrix&) "
74  << "A new matrix pointing at " << Array << " has been made."
75  << std::endl;
76 #endif//CPPL_DEBUG
77 }
78 
79 //============================================================================
81 inline zssmatrix::zssmatrix(const long& _m, const long& _n, const long& _c)
82  : m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx)
83 {
84 #ifdef CPPL_VERBOSE
85  std::cerr << "# [MARK] zssmatrix::zssmatrix(const long&, const long&, const long&)"
86  << std::endl;
87 #endif//CPPL_VERBOSE
88 
89 #ifdef CPPL_DEBUG
90  if( _m<0 || _n<0 || _c<0 ){
91  std::cerr << "[ERROR] zssmatrix::zssmatrix"
92  << "(const long&, const long&, const long&)" << std::endl
93  << "Matrix sizes and the length of arrays "
94  << "must be positive integers. " << std::endl
95  << "Your input was (" << _m << "," << _n << "," << _c << ")."
96  << std::endl;
97  exit(1);
98  }
99 #endif//CPPL_DEBUG
100 
102  M =_m; N =_n;
103  CAP =_c;
104  VOL =0;
105  Array =new std::complex<double>[CAP];
106  Indx =new long[CAP];
107  Jndx =new long[CAP];
108 
109 #ifdef CPPL_DEBUG
110  std::cerr << "# [NOTE] zssmatrix(const long&, const long&, const long&) "
111  << "A new matrix at " << Array << " has been made." << std::endl;
112 #endif//CPPL_DEBUG
113 }
114 
115 //============================================================================
117 inline zssmatrix::zssmatrix(const char* filename)
118  : m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx)
119 {
120 #ifdef CPPL_VERBOSE
121  std::cerr << "# [MARK] zssmatrix::zssmatrix(const char*)"
122  << std::endl;
123 #endif//CPPL_VERBOSE
124 
125  Array =NULL;
126 
128  read(filename);
129 
130 #ifdef CPPL_DEBUG
131  std::cerr << "# [NOTE] zssmatrix::zssmatrix(const char*) "
132  << "A new matrix at " << Array << " has been made." << std::endl;
133 #endif//CPPL_DEBUG
134 }
135 
139 
140 //============================================================================
143 {
144 #ifdef CPPL_VERBOSE
145  std::cerr << "# [MARK] zssmatrix::~zssmatrix()"
146  << std::endl;
147 #endif//CPPL_VERBOSE
148 
149 #ifdef CPPL_DEBUG
150  std::cerr << "# [NOTE] zssmatrix::~zssmatrix() "
151  << "A matrix at " << Array << " is going to be deleted."
152  << std::endl;
153 #endif//CPPL_DEBUG
154 
156  delete [] Array;
157  delete [] Indx;
158  delete [] Jndx;
159 }
long M
matrix row size
Definition: _zssmatrix.hpp:7
long VOL
the number of non-zero components
Definition: _zssmatrix.hpp:10
(DO NOT USE) Smart-temporary Complex Double-precision Sparse Matrix Class
Definition: _zssmatrix.hpp:3
long * Jndx
1D array to store the j-index of non-zero matrix components
Definition: _zssmatrix.hpp:13
zssmatrix()
Definition: zssmatrix-constructor.hpp:3
long CAP
the length of data arrays
Definition: _zssmatrix.hpp:9
std::complex< double > * Array
1D array to store non-zero matrix data
Definition: _zssmatrix.hpp:11
~zssmatrix()
Definition: zssmatrix-constructor.hpp:142
std::complex< double > * Array
1D Array to store vector data
Definition: _zrovector.hpp:8
long N
matrix column size
Definition: _zssmatrix.hpp:8
Complex Double-precision Sparse Matrix Class.
Definition: zssmatrix.hpp:3
long * Indx
1D array to store the i-index of non-zero matrix components
Definition: _zssmatrix.hpp:12