DD-AVX  2.0.0
vector_sub_dd.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(hi[i]);
23  reg a_lo = load(lo[i]);
24 
25  reg b_hi = load(vec1.hi[i]);
26  reg b_lo = load(vec1.lo[i]);
27 
28  reg c_hi = load(vec2.hi[i]);
29  reg c_lo = load(vec2.lo[i]);
30  to_minus(c_hi, regs);
31  to_minus(c_lo, regs);
32 
33  Add(a_hi, a_lo, b_hi, b_lo, c_hi, c_lo, regs);
34 
35  store(hi[i], a_hi);
36  store(lo[i], a_lo);
37  }
38  for(;i<ie;i++){
39  Add(hi[i], lo[i], vec1.hi[i], vec1.lo[i], -vec2.hi[i], -vec2.lo[i]);
40  }
41  }
42 }
43 
45 {
46  if(size() != vec1.size() || size() != vec2.size()){
47  std::cerr << "error bad vector size" << std::endl;
48  assert(1);
49  }
50  registers regs;
51 
52 #pragma omp parallel private(regs)
53  {
54  int i=0, is=0, ie=0;
55  get_isie(size(), is, ie);
56  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
57  reg a_hi = load(hi[i]);
58  reg a_lo = load(lo[i]);
59 
60  reg b_hi = load(vec1.data()[i]);
61  reg b_lo = regs.zeros;
62 
63  reg c_hi = load(vec2.hi[i]);
64  reg c_lo = load(vec2.lo[i]);
65  to_minus(c_hi, regs);
66  to_minus(c_lo, regs);
67 
68  Add(a_hi, a_lo, b_hi, b_lo, c_hi, c_lo, regs);
69 
70  store(hi[i], a_hi);
71  store(lo[i], a_lo);
72  }
73  for(;i<ie;i++){
74  Add(hi[i], lo[i], vec1.data()[i], 0.0, -vec2.hi[i], -vec2.lo[i]);
75  }
76  }
77 }
78 
80 {
81  if(size() != vec1.size() || size() != vec2.size()){
82  std::cerr << "error bad vector size" << std::endl;
83  assert(1);
84  }
85  registers regs;
86 
87 #pragma omp parallel private(regs)
88  {
89  int i=0, is=0, ie=0;
90  get_isie(size(), is, ie);
91  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
92  reg a_hi = load(hi[i]);
93  reg a_lo = load(lo[i]);
94 
95  reg b_hi = load(vec1.hi[i]);
96  reg b_lo = load(vec1.lo[i]);
97 
98  reg c_hi = load(vec2.data()[i]);
99  reg c_lo = regs.zeros;
100 
101  to_minus(c_hi, regs);
102  to_minus(c_lo, regs);
103 
104  Add(a_hi, a_lo, b_hi, b_lo, c_hi, c_lo, regs);
105 
106  store(hi[i], a_hi);
107  store(lo[i], a_lo);
108  }
109  for(;i<ie;i++){
110  Add(hi[i], lo[i], vec1.hi[i], vec1.lo[i], -1 * vec2.data()[i], -1 * 0.0);
111  }
112  }
113 }
114 
116 {
117  if(size() != vec1.size() || size() != vec2.size()){
118  std::cout << "error vecvor size is" << size() << vec1.size() << vec2.size() << std::endl;
119  assert(1);
120  }
121 
122 #pragma omp parallel for
123  for(int i = 0; i < size(); i++){
124  hi[i] = vec1.data()[i] - vec2.data()[i];
125  lo[i] = 0.0;
126 
127  }
128 }
129 
130 //=========================================================
131 // operator
132 //=========================================================
134 {
135  sub(*this, vec);
136  return *this;
137 }
138 
140 {
141  sub(*this, vec);
142  return *this;
143 }
144 
146 {
147  sub(*this, vec);
148  return *this;
149 }
150 
152 {
153  sub(*this, vec);
154  return *this;
155 }
156 
Double precision vector class, This class is almost same as std::vector<double>
Double-double precision vector class.
std::vector< double > lo
int size() const
get size
void sub(dd_real_vector &vec1, dd_real_vector &vec2)
all elemetnt arithmetic function
std::vector< double > hi
dd_real_vector operator-()
sign
dd_real_vector operator-=(dd_real_vector &vec)
all elemetnt arithmetic function