DD-AVX  2.0.0
vector_sub_d.cpp
Go to the documentation of this file.
1 #include<DD-AVX_internal.hpp>
2 
3 using namespace ddavx_core;
4 
5 //=========================================================
6 // function
7 //=========================================================
8 
10 {
11  if(size() != vec1.size() || size() != vec2.size()){
12  std::cerr << "error bad vector size" << std::endl;
13  assert(1);
14  }
15  registers regs;
16 
17 #pragma omp parallel private(regs)
18  {
19  int i=0, is=0, ie=0;
20  get_isie(size(), is, ie);
21  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
22  reg a_hi = load(data()[i]);
23 
24  reg b_hi = load(vec1.hi[i]);
25  reg b_lo = load(vec1.lo[i]);
26 
27  reg c_hi = load(vec2.hi[i]);
28  reg c_lo = load(vec2.lo[i]);
29  to_minus(c_hi, regs);
30  to_minus(c_lo, regs);
31 
32  Add(a_hi, b_hi, b_lo, c_hi, c_lo, regs);
33 
34  store(data()[i], a_hi);
35  }
36  for(;i<ie;i++){
37  Add(data()[i], vec1.hi[i], vec1.lo[i], -vec2.hi[i], -vec2.lo[i]);
38  }
39  }
40 }
41 
43 {
44  if(size() != vec1.size() || size() != vec2.size()){
45  std::cerr << "error bad vector size" << std::endl;
46  assert(1);
47  }
48  registers regs;
49  double *vv = data();
50 
51 #pragma omp parallel private(regs)
52  {
53  int i=0, is=0, ie=0;
54  get_isie(size(), is, ie);
55  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
56  reg a_hi = load(data()[i]);
57 
58  reg b_hi = load(vec1.data()[i]);
59  reg b_lo = regs.zeros;
60 
61  reg c_hi = load(vec2.hi[i]);
62  reg c_lo = load(vec2.lo[i]);
63  to_minus(c_hi, regs);
64  to_minus(c_lo, regs);
65 
66  Add(a_hi, b_hi, b_lo, c_hi, c_lo, regs);
67 
68  store(data()[i], a_hi);
69  }
70  for(;i<ie;i++){
71  Add(data()[i], vec1.data()[i], 0.0, -1 * vec2.hi[i], -1 * vec2.lo[i]);
72  }
73  }
74 }
75 
77 {
78  if(size() != vec1.size() || size() != vec2.size()){
79  std::cerr << "error bad vector size" << std::endl;
80  assert(1);
81  }
82  registers regs;
83  double *vv = data();
84 
85 #pragma omp parallel private(regs)
86  {
87  int i=0, is=0, ie=0;
88  get_isie(size(), is, ie);
89  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
90  reg a_hi = load(data()[i]);
91 
92  reg b_hi = load(vec1.hi[i]);
93  reg b_lo = load(vec1.lo[i]);
94 
95  reg c_hi = load(vec2.data()[i]);
96  reg c_lo = regs.zeros;
97 
98  to_minus(c_hi, regs);
99  to_minus(c_lo, regs);
100 
101  Add(a_hi, b_hi, b_lo, c_hi, c_lo, regs);
102 
103  store(data()[i], a_hi);
104  }
105  for(;i<ie;i++){
106  Add(data()[i], vec1.hi[i], vec1.lo[i], -1 * vec2.data()[i], -1 * 0.0);
107  }
108  }
109 }
110 
112 {
113  if(size() != vec1.size() || size() != vec2.size()){
114  std::cout << "error vecvor size is" << size() << vec1.size() << vec2.size() << std::endl;
115  assert(1);
116  }
117 
118 #pragma omp parallel for
119  for(int i = 0; i < size(); i++){
120  data()[i] = vec1.data()[i] - vec2.data()[i];
121  }
122 }
123 
124 //=========================================================
125 // operator
126 //=========================================================
128 {
129  sub(*this, vec);
130  return *this;
131 }
133 {
134  sub(*this, vec);
135  return *this;
136 }
137 
139 {
140  sub(*this, vec);
141  return *this;
142 }
144 {
145  sub(*this, vec);
146  return *this;
147 }
148 
Double precision vector class, This class is almost same as std::vector<double>
void sub(dd_real_vector &vec1, dd_real_vector &vec2)
all elemetnt arithmetic function
Definition: vector_sub_d.cpp:9
d_real_vector operator-=(dd_real_vector &vec)
all elemetnt arithmetic function
d_real_vector operator-()
sign
Double-double precision vector class.
std::vector< double > lo
int size() const
get size
std::vector< double > hi