VERB_code_2.3
zrovector-misc.hpp
1 //=============================================================================
3 inline void zrovector::clear()
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] zrovector::clear()"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  std::cerr << "# [NOTE] zrovector::clear() "
12  << " An array at " << Array
13  << " is going to be cleared." << std::endl;
14 #endif//CPPL_DEBUG
15 
16  L =0;
17  delete [] Array;
18  Array =NULL;
19 }
20 
21 //=============================================================================
23 inline void zrovector::zero()
24 {
25 #ifdef CPPL_VERBOSE
26  std::cerr << "# [MARK] zrovector::zero()"
27  << std::endl;
28 #endif//CPPL_VERBOSE
29 
30  for(long i=0; i<L; i++){ Array[i] =std::complex<double>(0.0,0.0); }
31 }
32 
33 //=============================================================================
35 inline void zrovector::chsign()
36 {
37 #ifdef CPPL_VERBOSE
38  std::cerr << "# [MARK] zrovector::chsign()"
39  << std::endl;
40 #endif//CPPL_VERBOSE
41 
42  for(long i=0; i<L; i++){ Array[i] =-Array[i]; }
43 }
44 
45 //=============================================================================
47 inline void zrovector::copy(const zrovector& vec)
48 {
49 #ifdef CPPL_VERBOSE
50  std::cerr << "# [MARK] zrovector::copy(const zrovector&)"
51  << std::endl;
52 #endif//CPPL_VERBOSE
53 
54 #ifdef CPPL_DEBUG
55  std::cerr << "# [NOTE] zrovector::copy(const zrovector&) "
56  << "A zrovector at " << Array << " is going to be deleted. ";
57 #endif//CPPL_DEBUG
58 
59  delete [] Array;
60  L =vec.L;
61  Array =new std::complex<double>[vec.L];
62  zcopy_(vec.L, vec.Array, 1, Array, 1);
63 
64 #ifdef CPPL_DEBUG
65  std::cerr << "Then, a COPY of a zrovector has been cleated at "
66  << Array << "." << std::endl;
67 #endif//CPPL_DEBUG
68 }
69 
70 //=============================================================================
73 inline void zrovector::shallow_copy(const _zrovector& vec)
74 {
75 #ifdef CPPL_VERBOSE
76  std::cerr << "# [MARK] zrovector::shallow_copy(const _zrovector&)"
77  << std::endl;
78 #endif//CPPL_VERBOSE
79 
80 #ifdef CPPL_DEBUG
81  std::cerr << "# [NOTE] zrovector::shallow_copy(const _zrovector&) "
82  << "A zrovector at " << Array << " is going to be deleted "
83  << "and point at " << vec.Array << " instead." << std::endl;
84 #endif//CPPL_DEBUG
85 
86  delete [] Array;
87  L =vec.L;
88  Array =vec.Array;
89 }
90 
91 //=============================================================================
93 inline void zrovector::resize(const long& _l)
94 {
95 #ifdef CPPL_VERBOSE
96  std::cerr << "# [MARK] zrovector::resize(const long&)"
97  << std::endl;
98 #endif//CPPL_VERBOSE
99 
100 #ifdef CPPL_DEBUG
101  if( _l<0 ){
102  std::cerr << "[ERROR] zrovector::resize(const long&)" << std::endl
103  << "Vector size must be positive integers." << std::endl
104  << "Your input was (" << _l << ")." << std::endl;
105  exit(1);
106  }
107 #endif//CPPL_DEBUG
108 
109  L =_l;
110  delete [] Array;
111  Array =new std::complex<double>[_l];
112 }
113 
114 //=============================================================================
116 inline void swap(zrovector& u, zrovector& v)
117 {
118 #ifdef CPPL_VERBOSE
119  std::cerr << "# [MARK] swap(zrovector&, zrovector&)"
120  << std::endl;
121 #endif//CPPL_VERBOSE
122 
123  long u_L(u.L);
124  std::complex<double>* u_Array(u.Array);
125  u.L=v.L; u.Array=v.Array;
126  v.L=u_L; v.Array=u_Array;
127 }
128 
129 //=============================================================================
131 inline _zrovector _(zrovector& vec)
132 {
133 #ifdef CPPL_VERBOSE
134  std::cerr << "# [MARK] _(zrovector&)"
135  << std::endl;
136 #endif//CPPL_VERBOSE
137 
138  _zrovector newvec;
139 
140  newvec.L =vec.L;
141  newvec.Array =vec.Array;
142 
143  vec.L =0;
144  vec.Array =NULL;
145 
146  return newvec;
147 }
void shallow_copy(const _zrovector &)
Definition: zrovector-misc.hpp:73
long L
vector size
Definition: _zrovector.hpp:7
void clear()
Definition: zrovector-misc.hpp:3
Complex Double-precision Row Vector Class.
Definition: zrovector.hpp:3
(DO NOT USE) Smart-temporary Complex Double-precision Row Vector Class
Definition: _zrovector.hpp:3
void resize(const long &)
Definition: zrovector-misc.hpp:93
std::complex< double > * Array
1D Array to store vector data
Definition: _zrovector.hpp:8
void zero()
Definition: zrovector-misc.hpp:23
void chsign()
Definition: zrovector-misc.hpp:35
void copy(const zrovector &)
Definition: zrovector-misc.hpp:47