source: proto/PDF/simd-float.cpp @ 4355

Last change on this file since 4355 was 3251, checked in by cameron, 6 years ago

Decimal point bug fix

File size: 1.6 KB
Line 
1#define unaligned_numerics
2#ifdef unaligned_numerics
3#define load4(v) bitblock::load_unaligned((BitBlock *) x)
4#define store4(p, v) bitblock::store_unaligned(v, (BitBlock *) p)
5#endif
6#ifndef unaligned_numerics
7#define load4(x) bitblock::load_aligned((BitBlock *) x)
8#define store4(p, v) bitblock::store_aligned(v, (BitBlock *) p)
9#endif
10
11
12static inline void ints_2_floats(int value[], int powten[], float rslt[], int numcount) {
13  for (int i = 0; i < numcount; i++) {
14    rslt[i] = ((float) value[i]) / ((float) powten[i]);
15  }
16}
17
18
19static inline void simd_ints_2_floats(int value[], int powten[], float rslt[], int numcount) {
20  for (int i = 0; i < numcount; i+=4) {
21    BitBlock val4 = load4(&value[i]);
22    BitBlock powten4 = load4(&powten[i]);
23    BitBlock rslt4 = simd<32>::fdiv(simd<32>::i2f(val4), simd<32>::i2f(powten4));
24    store4(&rslt[i], rslt4); 
25  }
26}
27
28/*
29  Assume that we have stored the inverse power of ten value for the number
30  of decimal places in our fixed point number.
31  float inv_pow_ten[8] = {1.0,0.1,0.01,0.001,0.0001,0.00001,0.000001,0.0000001};
32*/
33
34 
35static inline void ints_x_floats(int value[], float invpowten[], float rslt[], int numcount) {
36  for (int i = 0; i < numcount; i++) {
37    rslt[i] = ((float) value[i]) * invpowten[i];
38  }
39}
40
41
42static inline void simd_ints_x_floats(int value[], float invpowten[], float rslt[], int numcount) {
43  for (int i = 0; i < numcount; i+=4) {
44    BitBlock val4 = load4(&value[i]);
45    BitBlock invpowten4 = load4(&invpowten[i]);
46    BitBlock rslt4 = simd<32>::fmul(simd<32>::i2f(val4), invpowten4);
47    store4(&rslt[i], rslt4); 
48  }
49}
50
51
52
Note: See TracBrowser for help on using the repository browser.