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