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