12 #ifndef RecoTracker_MkFitCore_src_Ice_IceFPU_h
13 #define RecoTracker_MkFitCore_src_Ice_IceFPU_h
15 #define SIGN_BITMASK 0x80000000
18 #define IR(x) ((udword&)(x))
21 #define SIR(x) ((sdword&)(x))
24 #define AIR(x) (IR(x) & 0x7fffffff)
27 #define FR(x) ((float&)(x))
31 #define IS_NEGATIVE_FLOAT(x) (IR(x) & 0x80000000)
36 udword FloatBits =
IR(x) & 0x7fffffff;
67 (
float&)y = (
float&)y * (1.5f - (x * (
float&)y * (
float&)
y));
75 float y = *(
float*)&tmp;
76 return y * (1.47f - 0.47f * x * y *
y);
84 const float threehalfs = 1.5f;
89 i = 0x5f3759df - (i >> 1);
91 y = y * (threehalfs - (x2 * y *
y));
109 (
float&)a -= (
float&)
b;
132 #define CHECK_VALID_FLOAT(x) ASSERT(IsValidFloat(x));
175 #define FCOMI_ST0 _asm _emit 0xdb _asm _emit 0xf0
176 #define FCOMIP_ST0 _asm _emit 0xdf _asm _emit 0xf0
177 #define FCMOVB_ST0 _asm _emit 0xda _asm _emit 0xc0
178 #define FCMOVNB_ST0 _asm _emit 0xdb _asm _emit 0xc0
180 #define FCOMI_ST1 _asm _emit 0xdb _asm _emit 0xf1
181 #define FCOMIP_ST1 _asm _emit 0xdf _asm _emit 0xf1
182 #define FCMOVB_ST1 _asm _emit 0xda _asm _emit 0xc1
183 #define FCMOVNB_ST1 _asm _emit 0xdb _asm _emit 0xc1
185 #define FCOMI_ST2 _asm _emit 0xdb _asm _emit 0xf2
186 #define FCOMIP_ST2 _asm _emit 0xdf _asm _emit 0xf2
187 #define FCMOVB_ST2 _asm _emit 0xda _asm _emit 0xc2
188 #define FCMOVNB_ST2 _asm _emit 0xdb _asm _emit 0xc2
190 #define FCOMI_ST3 _asm _emit 0xdb _asm _emit 0xf3
191 #define FCOMIP_ST3 _asm _emit 0xdf _asm _emit 0xf3
192 #define FCMOVB_ST3 _asm _emit 0xda _asm _emit 0xc3
193 #define FCMOVNB_ST3 _asm _emit 0xdb _asm _emit 0xc3
195 #define FCOMI_ST4 _asm _emit 0xdb _asm _emit 0xf4
196 #define FCOMIP_ST4 _asm _emit 0xdf _asm _emit 0xf4
197 #define FCMOVB_ST4 _asm _emit 0xda _asm _emit 0xc4
198 #define FCMOVNB_ST4 _asm _emit 0xdb _asm _emit 0xc4
200 #define FCOMI_ST5 _asm _emit 0xdb _asm _emit 0xf5
201 #define FCOMIP_ST5 _asm _emit 0xdf _asm _emit 0xf5
202 #define FCMOVB_ST5 _asm _emit 0xda _asm _emit 0xc5
203 #define FCMOVNB_ST5 _asm _emit 0xdb _asm _emit 0xc5
205 #define FCOMI_ST6 _asm _emit 0xdb _asm _emit 0xf6
206 #define FCOMIP_ST6 _asm _emit 0xdf _asm _emit 0xf6
207 #define FCMOVB_ST6 _asm _emit 0xda _asm _emit 0xc6
208 #define FCMOVNB_ST6 _asm _emit 0xdb _asm _emit 0xc6
210 #define FCOMI_ST7 _asm _emit 0xdb _asm _emit 0xf7
211 #define FCOMIP_ST7 _asm _emit 0xdf _asm _emit 0xf7
212 #define FCMOVB_ST7 _asm _emit 0xda _asm _emit 0xc7
213 #define FCMOVNB_ST7 _asm _emit 0xdb _asm _emit 0xc7
218 _asm fld[
a] _asm fld[
b] FCOMI_ST1 FCMOVB_ST1 _asm fstp[Res] _asm fcomp
return Res;
224 _asm fld[
a] _asm fld[
b] FCOMI_ST1 FCMOVNB_ST1 _asm fstp[Res] _asm fcomp
return Res;
228 inline_ float FCMax3(
float a,
float b,
float c) {
230 _asm fld[
a] _asm fld[
b] _asm fld[
c] FCOMI_ST1 FCMOVB_ST1 FCOMI_ST2 FCMOVB_ST2 _asm fstp[Res] _asm fcompp
return Res;
234 inline_ float FCMin3(
float a,
float b,
float c) {
236 _asm fld[
a] _asm fld[
b] _asm fld[
c] FCOMI_ST1 FCMOVNB_ST1 FCOMI_ST2 FCMOVNB_ST2 _asm fstp[Res] _asm fcompp
return Res;
242 int Fmask = (Fi >> 31);
259 FUNCTION ICECORE_API
void SaveFPU();
260 FUNCTION ICECORE_API
void RestoreFPU();
261 FUNCTION ICECORE_API
void SetFPUFloorMode();
262 FUNCTION ICECORE_API
void SetFPUCeilMode();
263 FUNCTION ICECORE_API
void SetFPUBestMode();
265 FUNCTION ICECORE_API
void SetFPUPrecision24();
266 FUNCTION ICECORE_API
void SetFPUPrecision53();
267 FUNCTION ICECORE_API
void SetFPUPrecision64();
268 FUNCTION ICECORE_API
void SetFPURoundingChop();
269 FUNCTION ICECORE_API
void SetFPURoundingUp();
270 FUNCTION ICECORE_API
void SetFPURoundingDown();
271 FUNCTION ICECORE_API
void SetFPURoundingNear();
273 FUNCTION ICECORE_API
int intChop(
const float&
f);
274 FUNCTION ICECORE_API
int intFloor(
const float&
f);
275 FUNCTION ICECORE_API
int intCeil(
const float&
f);
278 #endif // __ICEFPU_H__
#define IR(x)
Integer representation of a floating-point value.
const edm::EventSetup & c
inline_ float frsqrt(float f)
Computes 1.0f / sqrtf(x).
signed int sdword
sizeof(sdword) must be 4
#define FR(x)
Floating-point representation of an integer value.
const udword IEEE_1_0
integer representation of 1.0
inline_ float fepsilon(float f)
Returns the float ranged espilon value.
inline_ bool IsMinusInf(float value)
inline_ float RSqrt(float number)
unsigned int udword
sizeof(udword) must be 4
inline_ bool IsNAN(float value)
Is the float valid ?
inline_ bool IsFloatZero(float x, float epsilon=1e-6f)
inline_ int ConvertToSortable(float f)
inline_ bool IsValidFloat(float value)
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
inline_ float fsqrt(float f)
TO BE DOCUMENTED.
inline_ float fsat(float f)
Saturates positive to zero.
static double square(double x)
inline_ float InvSqrt(const float &x)
Computes 1.0f / sqrtf(x). Comes from NVIDIA.
inline_ bool IsIndeterminate(float value)
inline_ bool IsPlusInf(float value)
inline_ float ComputeFloatEpsilon()
This function computes the slowest possible floating-point value (you can also directly use FLT_EPSIL...
inline_ float FastFabs(float x)