My Project
_dcovector-dcovector.hpp
1 //=============================================================================
3 inline _dcovector operator+(const _dcovector& vecA, const dcovector& vecB)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] operator+(const _dcovector&, const dcovector&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if(vecA.L!=vecB.L){
12  std::cerr << "[ERROR] operator+(const _dcovector&, const dcovector&)"
13  << std::endl
14  << "These two vectors can not make a sumation." << std::endl
15  << "Your input was (" << vecA.L << ") + (" << vecB.L << ")."
16  << std::endl;
17  exit(1);
18  }
19 
20 #endif//CPPL_DEBUG
21 
22  for(long i=0; i<vecA.L; i++){ vecA.Array[i]+=vecB.Array[i]; }
23 
24  return vecA;
25 }
26 
27 //=============================================================================
29 inline _dcovector operator-(const _dcovector& vecA, const dcovector& vecB)
30 {
31 #ifdef CPPL_VERBOSE
32  std::cerr << "# [MARK] operator-(const _dcovector&, const dcovector&)"
33  << std::endl;
34 #endif//CPPL_VERBOSE
35 
36 #ifdef CPPL_DEBUG
37  if(vecA.L!=vecB.L){
38  std::cerr << "[ERROR] operator-(const _dcovector&, const dcovector&)"
39  << std::endl
40  << "These two vectors can not make a subtraction." << std::endl
41  << "Your input was (" << vecA.L << ") - (" << vecB.L << ")."
42  << std::endl;
43  exit(1);
44  }
45 #endif//CPPL_DEBUG
46 
47  for(long i=0; i<vecA.L; i++){ vecA.Array[i]-=vecB.Array[i]; }
48 
49  return vecA;
50 }
51 
52 //=============================================================================
54 inline double operator%(const _dcovector& vecA, const dcovector& vecB)
55 {
56 #ifdef CPPL_VERBOSE
57  std::cerr << "# [MARK] operator%(const _dcovector&, const dcovector&)"
58  << std::endl;
59 #endif//CPPL_VERBOSE
60 
61 #ifdef CPPL_DEBUG
62  if(vecA.L!=vecB.L){
63  std::cerr << "[ERROR] operator%(const _dcovector&, const dcovector&)"
64  << std::endl
65  << "These two vectors can not make a dot product." << std::endl
66  << "Your input was (" << vecA.L << ") % (" << vecB.L << ")."
67  << std::endl;
68  exit(1);
69  }
70 #endif//CPPL_DEBUG
71 
72  double val( ddot_( vecA.L, vecA.Array, 1, vecB.Array, 1 ) );
73 
74  vecA.destroy();
75  return val;
76 }
double * Array
1D Array to store vector data
Definition: _dcovector.hpp:8
long L
vector size
Definition: _dcovector.hpp:7
void destroy() const
Definition: _dcovector-misc.hpp:3
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