MCPcopy Create free account
hub / github.com/numpy/numpy / npyv_recip_f32

Function npyv_recip_f32

numpy/core/src/common/simd/neon/math.h:58–77  ·  view source on GitHub ↗

Reciprocal

Source from the content-addressed store, hash-verified

56
57// Reciprocal
58NPY_FINLINE npyv_f32 npyv_recip_f32(npyv_f32 a)
59{
60#if NPY_SIMD_F64
61 const npyv_f32 one = vdupq_n_f32(1.0f);
62 return npyv_div_f32(one, a);
63#else
64 npyv_f32 recipe = vrecpeq_f32(a);
65 /**
66 * Newton-Raphson iteration:
67 * x[n+1] = x[n] * (2-d * x[n])
68 * converges to (1/d) if x0 is the result of VRECPE applied to d.
69 *
70 * NOTE: at least 3 iterations is needed to improve precision
71 */
72 recipe = vmulq_f32(vrecpsq_f32(a, recipe), recipe);
73 recipe = vmulq_f32(vrecpsq_f32(a, recipe), recipe);
74 recipe = vmulq_f32(vrecpsq_f32(a, recipe), recipe);
75 return recipe;
76#endif
77}
78#if NPY_SIMD_F64
79 NPY_FINLINE npyv_f64 npyv_recip_f64(npyv_f64 a)
80 {

Callers

nothing calls this directly

Calls 1

npyv_div_f32Function · 0.85

Tested by

no test coverage detected