CMS 3D CMS Logo

approx_math.h
Go to the documentation of this file.
1 #ifndef DataFormatsMathApproxMath_H
2 #define DataFormatsMathApproxMath_H
3 
4 #include <cstdint>
5 #include <cmath>
6 #include <limits>
7 #include <algorithm>
8 
9 namespace approx_math {
10  // not c++ compliant (only C compliant)
11  // to be c++ compliaint one must use memcpy...
12  union binary32 {
13  constexpr binary32() : ui32(0){};
14  constexpr binary32(float ff) : f(ff){};
15  constexpr binary32(int32_t ii) : i32(ii) {}
16  constexpr binary32(uint32_t ui) : ui32(ui) {}
17 
18  uint32_t ui32; /* unsigned int */
19  int32_t i32; /* Signed int */
20  float f;
21  };
22 #ifdef __SSE4_1__
23  constexpr float fpfloor(float x) { return std::floor(x); }
24 #else
25  constexpr float fpfloor(float x) {
26  int32_t ret = x;
27  binary32 xx(x);
28  ret -= (xx.ui32 >> 31);
29  return ret;
30  }
31 #endif
32 } // namespace approx_math
33 
34 #endif
ret
prodAgent to be discontinued
constexpr binary32(int32_t ii)
Definition: approx_math.h:15
constexpr float fpfloor(float x)
Definition: approx_math.h:25
constexpr binary32()
Definition: approx_math.h:13
ii
Definition: cuy.py:589
constexpr binary32(float ff)
Definition: approx_math.h:14
float x
constexpr binary32(uint32_t ui)
Definition: approx_math.h:16