CPPLapack
 All Classes Files Functions Variables Friends Pages
_dcovector-_dcovector.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _dcovector+_dcovector operator */
3 inline _dcovector operator+(const _dcovector& vecA, const _dcovector& vecB)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(vecA.l!=vecB.l){
7  ERROR_REPORT;
8  std::cerr << "These two vectors can not make a sumation." << std::endl
9  << "Your input was (" << vecA.l << ") + (" << vecB.l << ")." << std::endl;
10  exit(1);
11  }
12 
13 #endif//CPPL_DEBUG
14 
15  for(CPPL_INT i=0; i<vecA.l; i++){ vecA.array[i]+=vecB.array[i]; }
16 
17  vecB.destroy();
18  return vecA;
19 }
20 
21 //=============================================================================
22 /*! _dcovector-_dcovector operator */
23 inline _dcovector operator-(const _dcovector& vecA, const _dcovector& vecB)
24 {CPPL_VERBOSE_REPORT;
25 #ifdef CPPL_DEBUG
26  if(vecA.l!=vecB.l){
27  ERROR_REPORT;
28  std::cerr << "These two vectors can not make a subtraction." << std::endl
29  << "Your input was (" << vecA.l << ") - (" << vecB.l << ")." << std::endl;
30  exit(1);
31  }
32 #endif//CPPL_DEBUG
33 
34  for(CPPL_INT i=0; i<vecA.l; i++){ vecA.array[i]-=vecB.array[i]; }
35 
36  vecB.destroy();
37  return vecA;
38 }
39 
40 //=============================================================================
41 /*! _dcovector^T*_dcovector operator (inner product) */
42 inline double operator%(const _dcovector& vecA, const _dcovector& vecB)
43 {CPPL_VERBOSE_REPORT;
44 #ifdef CPPL_DEBUG
45  if(vecA.l!=vecB.l){
46  ERROR_REPORT;
47  std::cerr << "These two vectors can not make a dot product." << std::endl
48  << "Your input was (" << vecA.l << ") % (" << vecB.l << ")." << std::endl;
49  exit(1);
50  }
51 #endif//CPPL_DEBUG
52  CPPL_INT inc =1;
53 
54  double val =ddot_( &vecA.l, vecA.array, &inc, vecB.array, &inc );
55 
56  vecA.destroy();
57  vecB.destroy();
58  return val;
59 }
CPPL_INT l
vector size
Definition: _dcovector.hpp:9
double operator%(const _dcovector &vecA, const _dcovector &vecB)
_dgematrix i(const _dgbmatrix &mat)
_dcovector operator+(const _dcovector &vecA, const _dcovector &vecB)
_dcovector operator-(const _dcovector &vecA, const _dcovector &vecB)
void destroy() const
(DO NOT USE) Smart-temporary Real Double-precision Column Vector Class
Definition: _dcovector.hpp:3
double * array
1D array to store vector data
Definition: _dcovector.hpp:11