CPPLapack
 All Classes Files Functions Variables Friends Pages
zcovector-zcovector.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! zcovector=zcovector 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 /*! zcovector+=zcovector 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 /*! zcovector 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 /*! zcovector+zcovector operator */
61 inline _zcovector operator+(const zcovector& vecA, const zcovector& 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  zcovector 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 /*! zcovector-zcovector operator */
84 inline _zcovector operator-(const zcovector& vecA, const zcovector& 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  zcovector 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 /*! zcovector^T*zcovector operator (inner product) */
106 inline comple operator%(const zcovector& vecA, const zcovector& 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 
120  return val;
121 }
122 
123 ///////////////////////////////////////////////////////////////////////////////
124 ///////////////////////////////////////////////////////////////////////////////
125 ///////////////////////////////////////////////////////////////////////////////
126 
127 //=============================================================================
128 /*! return Hadamerd product */
129 inline _zcovector hadamerd(const zcovector& vecA, const zcovector& vecB)
130 {CPPL_VERBOSE_REPORT;
131 #ifdef CPPL_DEBUG
132  if( vecA.l!=vecB.l ){
133  ERROR_REPORT;
134  std::cerr << "These two vectors can not make Hadamerd product." << std::endl
135  << "Your input was (" << vecA.l << ") and (" << vecB.l << ")." << std::endl;
136  exit(1);
137  }
138 #endif//CPPL_DEBUG
139 
140  zcovector newvec(vecA.l);
141 
142  for(CPPL_INT i=0; i<newvec.l; i++){
143  newvec(i) =vecA(i)*vecB(i);
144  }
145 
146  return _(newvec);
147 }
comple * array
1D array to store vector data
Definition: zcovector.hpp:10
_zcovector hadamerd(const zcovector &vecA, const zcovector &vecB)
CPPL_INT l
vector size
Definition: zcovector.hpp:9
zcovector & operator=(const zcovector &)
comple operator%(const zcovector &vecA, const zcovector &vecB)
_dgematrix i(const _dgbmatrix &mat)
zcovector & operator-=(const zcovector &)
void copy(const zcovector &)
_zcovector operator-(const zcovector &vecA, const zcovector &vecB)
Complex Double-precision Column Vector Class.
Definition: zcovector.hpp:3
(DO NOT USE) Smart-temporary Complex Double-precision Column Vector Class
Definition: _zcovector.hpp:3
_dcovector _(dcovector &vec)
_zcovector operator+(const zcovector &vecA, const zcovector &vecB)
zcovector & operator+=(const zcovector &)