CPPLapack
 All Classes Files Functions Variables Friends Pages
zrovector-zrovector.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! zrovector=zrovector operator */
4 {CPPL_VERBOSE_REPORT;
5  if(array!=vec.array){ // if it is NOT self substitution
6  copy(vec);
7  }
8  return *this;
9 }
10 
11 ///////////////////////////////////////////////////////////////////////////////
12 ///////////////////////////////////////////////////////////////////////////////
13 ///////////////////////////////////////////////////////////////////////////////
14 
15 //=============================================================================
16 /*! zrovector+=zrovector operator */
18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if( l!=vec.l ){
21  ERROR_REPORT;
22  std::cerr << "These two vectors can not make a sumation." << std::endl
23  << "Your input was (" << l << ") += (" << vec.l << ")." << std::endl;
24  exit(1);
25  }
26 #endif//CPPL_DEBUG
27 
28  for(CPPL_INT i=0; i<l; i++){
29  array[i] += vec.array[i];
30  }
31 
32  return *this;
33 }
34 
35 //=============================================================================
36 /*! zrovector operator-= */
38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if( l!=vec.l ){
41  ERROR_REPORT;
42  std::cerr << "These two vectors can not make a subtraction." << std::endl
43  << "Your input was (" << l << ") -= (" << vec.l << ")." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
47 
48  for(CPPL_INT i=0; i<l; i++){
49  array[i] -= vec.array[i];
50  }
51 
52  return *this;
53 }
54 
55 ///////////////////////////////////////////////////////////////////////////////
56 ///////////////////////////////////////////////////////////////////////////////
57 ///////////////////////////////////////////////////////////////////////////////
58 
59 //=============================================================================
60 /*! zrovector+zrovector operator */
61 inline _zrovector operator+(const zrovector& vecA, const zrovector& vecB)
62 {CPPL_VERBOSE_REPORT;
63 #ifdef CPPL_DEBUG
64  if(vecA.l!=vecB.l){
65  ERROR_REPORT;
66  std::cerr << "These two vectors can not make a sumation." << std::endl
67  << "Your input was (" << vecA.l << ") + (" << vecB.l << ")." << std::endl;
68  exit(1);
69  }
70 
71 #endif//CPPL_DEBUG
72 
73  zrovector newvec(vecA.l);
74 
75  for(CPPL_INT i=0; i<newvec.l; i++){
76  newvec.array[i] =vecA.array[i]+vecB.array[i];
77  }
78 
79  return _(newvec);
80 }
81 
82 //=============================================================================
83 /*! zrovector-zrovector operator */
84 inline _zrovector operator-(const zrovector& vecA, const zrovector& vecB)
85 {CPPL_VERBOSE_REPORT;
86 #ifdef CPPL_DEBUG
87  if(vecA.l!=vecB.l){
88  ERROR_REPORT;
89  std::cerr << "These two vectors can not make a subtraction." << std::endl
90  << "Your input was (" << vecA.l << ") - (" << vecB.l << ")." << std::endl;
91  exit(1);
92  }
93 #endif//CPPL_DEBUG
94 
95  zrovector newvec(vecA.l);
96 
97  for(CPPL_INT i=0; i<newvec.l; i++){
98  newvec.array[i] =vecA.array[i]-vecB.array[i];
99  }
100 
101  return _(newvec);
102 }
103 
104 //=============================================================================
105 /*! zrovector^T*zrovector operator (inner product) */
106 inline comple operator%(const zrovector& vecA, const zrovector& vecB)
107 {CPPL_VERBOSE_REPORT;
108 #ifdef CPPL_DEBUG
109  if(vecA.l!=vecB.l){
110  ERROR_REPORT;
111  std::cerr << "These two vectors can not make a dot product." << std::endl
112  << "Your input was (" << vecA.l << ") % (" << vecB.l << ")." << std::endl;
113  exit(1);
114  }
115 #endif//CPPL_DEBUG
116 
117  CPPL_INT inc =1;
118  comple val =zdotu_( &vecA.l, vecA.array, &inc, vecB.array, &inc );
119  return val;
120 }
121 
122 ///////////////////////////////////////////////////////////////////////////////
123 ///////////////////////////////////////////////////////////////////////////////
124 ///////////////////////////////////////////////////////////////////////////////
125 
126 //=============================================================================
127 /*! return Hadamerd product */
128 inline _zrovector hadamerd(const zrovector& vecA, const zrovector& vecB)
129 {CPPL_VERBOSE_REPORT;
130 #ifdef CPPL_DEBUG
131  if( vecA.l!=vecB.l ){
132  ERROR_REPORT;
133  std::cerr << "These two vectors can not make Hadamerd product." << std::endl
134  << "Your input was (" << vecA.l << ") and (" << vecB.l << ")." << std::endl;
135  exit(1);
136  }
137 #endif//CPPL_DEBUG
138 
139  zrovector newvec(vecA.l);
140  for(CPPL_INT i=0; i<newvec.l; i++){
141  newvec(i) =vecA(i)*vecB(i);
142  }
143  return _(newvec);
144 }
zrovector & operator-=(const zrovector &)
CPPL_INT l
vector size
Definition: zrovector.hpp:9
_zrovector hadamerd(const zrovector &vecA, const zrovector &vecB)
_dgematrix i(const _dgbmatrix &mat)
_zrovector operator-(const zrovector &vecA, const zrovector &vecB)
zrovector & operator+=(const zrovector &)
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 &)
_zrovector operator+(const zrovector &vecA, const zrovector &vecB)
comple operator%(const zrovector &vecA, const zrovector &vecB)
_dcovector _(dcovector &vec)
comple * array
1D array to store vector data
Definition: zrovector.hpp:10
void copy(const zrovector &)