My Project
zrovector-zrovector.hpp
1 //=============================================================================
3 inline zrovector& zrovector::operator=(const zrovector& vec)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] zrovector::operator=(const zrovector&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  if(Array!=vec.Array){ // if it is NOT self substitution
11  copy(vec);
12  }
13  return *this;
14 }
15 
19 
20 //=============================================================================
22 inline zrovector& zrovector::operator+=(const zrovector& vec)
23 {
24 #ifdef CPPL_VERBOSE
25  std::cerr << "# [MARK] zrovector::operator+=(const zrovector&)"
26  << std::endl;
27 #endif//CPPL_VERBOSE
28 
29 #ifdef CPPL_DEBUG
30  if( L!=vec.L ){
31  std::cerr << "[ERROR] zrovector::operator+=(const zrovector&)" << std::endl
32  << "These two vectors can not make a sumation." << std::endl
33  << "Your input was (" << L << ") += (" << vec.L << ")."
34  << std::endl;
35  exit(1);
36  }
37 #endif//CPPL_DEBUG
38 
39  for(long i=0; i<L; i++){ Array[i]+=vec.Array[i]; }
40 
41  return *this;
42 }
43 
44 //=============================================================================
46 inline zrovector& zrovector::operator-=(const zrovector& vec)
47 {
48 #ifdef CPPL_VERBOSE
49  std::cerr << "# [MARK] zrovector::operator-=(const zrovector&)"
50  << std::endl;
51 #endif//CPPL_VERBOSE
52 
53 #ifdef CPPL_DEBUG
54  if( L!=vec.L ){
55  std::cerr << "[ERROR] zrovector::operator-=(const zrovector&)" << std::endl
56  << "These two vectors can not make a subtraction." << std::endl
57  << "Your input was (" << L << ") -= (" << vec.L << ")."
58  << std::endl;
59  exit(1);
60  }
61 #endif//CPPL_DEBUG
62 
63  for(long i=0; i<L; i++){ Array[i]-=vec.Array[i]; }
64 
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  zrovector newvec(vecA.L);
94  for(long i=0; i<newvec.l; i++){
95  newvec.array[i] =vecA.Array[i]+vecB.Array[i];
96  }
97 
98  return _(newvec);
99 }
100 
101 //=============================================================================
103 inline _zrovector operator-(const zrovector& vecA, const zrovector& vecB)
104 {
105 #ifdef CPPL_VERBOSE
106  std::cerr << "# [MARK] operator-(const zrovector&, const zrovector&)"
107  << std::endl;
108 #endif//CPPL_VERBOSE
109 
110 #ifdef CPPL_DEBUG
111  if(vecA.L!=vecB.L){
112  std::cerr << "[ERROR] operator-(const zrovector&, const zrovector&)"
113  << std::endl
114  << "These two vectors can not make a subtraction." << std::endl
115  << "Your input was (" << vecA.L << ") - (" << vecB.L << ")."
116  << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  zrovector newvec(vecA.L);
122  for(long i=0; i<newvec.l; i++){
123  newvec.array[i] =vecA.Array[i]-vecB.Array[i];
124  }
125 
126  return _(newvec);
127 }
128 
129 //=============================================================================
131 inline std::complex<double> operator%(const zrovector& vecA, const zrovector& vecB)
132 {
133 #ifdef CPPL_VERBOSE
134  std::cerr << "# [MARK] operator%(const zrovector&, const zrovector&)"
135  << std::endl;
136 #endif//CPPL_VERBOSE
137 
138 #ifdef CPPL_DEBUG
139  if(vecA.L!=vecB.L){
140  std::cerr << "[ERROR] operator%(const zrovector&, const zrovector&)"
141  << std::endl
142  << "These two vectors can not make a dot product." << std::endl
143  << "Your input was (" << vecA.L << ") % (" << vecB.L << ")."
144  << std::endl;
145  exit(1);
146  }
147 #endif//CPPL_DEBUG
148 
149  std::complex<double> val( zdotu_( vecA.L, vecA.Array, 1, vecB.Array, 1 ) );
150  return val;
151 }
zrovector & operator-=(const zrovector &)
Definition: zrovector-zrovector.hpp:46
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
friend std::complex< double > operator%(const zrovector &, const _zrovector &)
Definition: zrovector-_zrovector.hpp:127
void copy(const zrovector &)
Definition: zrovector-misc.hpp:47
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3
std::complex< double > * Array
1D Array to store vector data
Definition: _zrovector.hpp:8