Reciprocal
| 56 | |
| 57 | // Reciprocal |
| 58 | NPY_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 | { |
nothing calls this directly
no test coverage detected