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
interactiveExample.ui
ui
Definition: interactiveExample.py:13
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
approx_math::binary32::ui32
uint32_t ui32
Definition: approx_math.h:18
approx_math::binary32
Definition: approx_math.h:12
approx_math::binary32::binary32
constexpr binary32(int32_t ii)
Definition: approx_math.h:15
approx_math::binary32::binary32
constexpr binary32()
Definition: approx_math.h:13
alignCSCRings.ff
ff
Definition: alignCSCRings.py:148
approx_math::binary32::f
float f
Definition: approx_math.h:20
approx_math::fpfloor
constexpr float fpfloor(float x)
Definition: approx_math.h:25
approx_math
Definition: approx_math.h:9
approx_math::binary32::binary32
constexpr binary32(uint32_t ui)
Definition: approx_math.h:16
approx_math::binary32::i32
int32_t i32
Definition: approx_math.h:19
cuy.ii
ii
Definition: cuy.py:590
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
approx_math::binary32::binary32
constexpr binary32(float ff)
Definition: approx_math.h:14