VERB_code_2.3
zrovector-_zrovector.hpp
1 //=============================================================================
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] zrovector::operator=(const _zrovector&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  shallow_copy(vec);
11  return *this;
12 }
13 
17 
18 //=============================================================================
21 {
22 #ifdef CPPL_VERBOSE
23  std::cerr << "# [MARK] zrovector::operator+=(const _zrovector&)"
24  << std::endl;
25 #endif//CPPL_VERBOSE
26 
27 #ifdef CPPL_DEBUG
28  if( L!=vec.L ){
29  std::cerr << "[ERROR] zrovector::operator+=(const _zrovector&)" << std::endl
30  << "These two vectors can not make a sumation." << std::endl
31  << "Your input was (" << L << ") += (" << vec.L << ")."
32  << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  for(long i=0; i<L; i++){ Array[i]+=vec.Array[i]; }
38 
39  vec.destroy();
40  return *this;
41 }
42 
43 //=============================================================================
46 {
47 #ifdef CPPL_VERBOSE
48  std::cerr << "# [MARK] zrovector::operator-=(const _zrovector&)"
49  << std::endl;
50 #endif//CPPL_VERBOSE
51 
52 #ifdef CPPL_DEBUG
53  if( L!=vec.L ){
54  std::cerr << "[ERROR] zrovector::operator-=(const _zrovector&)" << std::endl
55  << "These two vectors can not make a subtraction." << std::endl
56  << "Your input was (" << L << ") -= (" << vec.L << ")."
57  << std::endl;
58  exit(1);
59  }
60 #endif//CPPL_DEBUG
61 
62  for(long i=0; i<L; i++){ Array[i]-=vec.Array[i]; }
63 
64  vec.destroy();
65  return *this;
66 }
67 
71 
72 //=============================================================================
74 inline _zrovector operator+(const zrovector& vecA, const _zrovector& vecB)
75 {
76 #ifdef CPPL_VERBOSE
77  std::cerr << "# [MARK] operator+(const zrovector&, const _zrovector&)"
78  << std::endl;
79 #endif//CPPL_VERBOSE
80 
81 #ifdef CPPL_DEBUG
82  if(vecA.L!=vecB.L){
83  std::cerr << "[ERROR] operator+(const zrovector&, const _zrovector&)"
84  << std::endl
85  << "These two vectors can not make a sumation." << std::endl
86  << "Your input was (" << vecA.L << ") + (" << vecB.L << ")."
87  << std::endl;
88  exit(1);
89  }
90 
91 #endif//CPPL_DEBUG
92 
93  for(long i=0; i<vecA.L; i++){ vecB.Array[i]+=vecA.Array[i]; }
94 
95  return vecB;
96 }
97 
98 //=============================================================================
100 inline _zrovector operator-(const zrovector& vecA, const _zrovector& vecB)
101 {
102 #ifdef CPPL_VERBOSE
103  std::cerr << "# [MARK] operator-(const zrovector&, const _zrovector&)"
104  << std::endl;
105 #endif//CPPL_VERBOSE
106 
107 #ifdef CPPL_DEBUG
108  if(vecA.L!=vecB.L){
109  std::cerr << "[ERROR] operator-(const zrovector&, const _zrovector&)"
110  << std::endl
111  << "These two vectors can not make a subtraction." << std::endl
112  << "Your input was (" << vecA.L << ") - (" << vecB.L << ")."
113  << std::endl;
114  exit(1);
115  }
116 #endif//CPPL_DEBUG
117 
118  for(long i=0; i<vecA.L; i++){
119  vecB.Array[i] =vecA.Array[i]-vecB.Array[i];
120  }
121 
122  return vecB;
123 }
124 
125 //=============================================================================
127 inline std::complex<double> operator%(const zrovector& vecA, const _zrovector& vecB)
128 {
129 #ifdef CPPL_VERBOSE
130  std::cerr << "# [MARK] operator%(const zrovector&, const _zrovector&)"
131  << std::endl;
132 #endif//CPPL_VERBOSE
133 
134 #ifdef CPPL_DEBUG
135  if(vecA.L!=vecB.L){
136  std::cerr << "[ERROR] operator%(const zrovector&, const _zrovector&)"
137  << std::endl
138  << "These two vectors can not make a dot product." << std::endl
139  << "Your input was (" << vecA.L << ") % (" << vecB.L << ")."
140  << std::endl;
141  exit(1);
142  }
143 #endif//CPPL_DEBUG
144 
145  std::complex<double> val( zdotu_( vecA.L, vecA.Array, 1, vecB.Array, 1 ) );
146 
147  vecB.destroy();
148  return val;
149 }
void shallow_copy(const _zrovector &)
Definition: zrovector-misc.hpp:73
zrovector & operator-=(const zrovector &)
Definition: zrovector-zrovector.hpp:46
void destroy() const
Definition: _zrovector-misc.hpp:3
long L
vector size
Definition: _zrovector.hpp:7
friend _zrovector operator-(const _zrovector &)
Definition: _zrovector-unary.hpp:15
zrovector & operator+=(const zrovector &)
Definition: zrovector-zrovector.hpp:22
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
zrovector & operator=(const zrovector &)
Definition: zrovector-zrovector.hpp:3
std::complex< double > * Array
1D Array to store vector data
Definition: _zrovector.hpp:8
friend std::complex< double > operator%(const zrovector &, const _zrovector &)
Definition: zrovector-_zrovector.hpp:127
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3