MCPcopy Create free account
hub / github.com/defold/defold / recip_est1_pn

Method recip_est1_pn

engine/dlib/src/basis/encoder/cppspmd_math.h:356–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354}
355
356CPPSPMD_FORCE_INLINE vfloat spmd_kernel::recip_est1_pn(const vfloat& t)
357{
358 //const int mag = 0x7EF312AC; // 2 NR iters, 3 is 0x7EEEEBB3
359 const int mag = 0x7EF311C3;
360 const float fMinThresh = .0000125f;
361
362 vfloat s = sign(t);
363 vfloat q = abs(t);
364
365 vfloat l = spmd_ternaryf(q >= fMinThresh, q, cast_vint_to_vfloat(vint(mag)));
366
367 vint x_l = vint(mag) - cast_vfloat_to_vint(l);
368
369 vfloat rcp_l = cast_vint_to_vfloat(x_l);
370
371 return rcp_l * vfnma(rcp_l, q, 2.0f) * s;
372}
373
374// https://basesandframes.files.wordpress.com/2020/04/even_faster_math_functions_green_2020.pdf
375// https://github.com/hcs0/Hackers-Delight/blob/master/rsqrt.c.txt

Callers

nothing calls this directly

Calls 7

absFunction · 0.85
spmd_ternaryfFunction · 0.85
cast_vint_to_vfloatFunction · 0.85
vintClass · 0.85
cast_vfloat_to_vintFunction · 0.85
vfnmaFunction · 0.85
signFunction · 0.70

Tested by

no test coverage detected