feature. See also
. The project being documented here (as the example) is the Zig library itself.
atan.atanBinary64Vec
fn atanBinary64Vec(comptime vec_len: comptime_int, x: @Vector(vec_len, f64)) @TypeOf(x)
File
Code
fn atanBinary64Vec(comptime vec_len: comptime_int, x: @Vector(vec_len, f64)) @TypeOf(x) {
const sign_mask: @Vector(vec_len, u64) = @splat(0x8000000000000000);
const neg_one: @Vector(vec_len, f64) = @splat(-1.0);
const pi_over_2: @Vector(vec_len, u64) = @splat(0x3ff921fb54442d18);
const zero: @Vector(vec_len, u64) = @splat(0);
const c0: @Vector(vec_len, f64) = @splat(-0x1.555555555552ap-2);
const c1: @Vector(vec_len, f64) = @splat(0x1.9999999995aebp-3);
const c2: @Vector(vec_len, f64) = @splat(-0x1.24924923923f6p-3);
const c3: @Vector(vec_len, f64) = @splat(0x1.c71c7184288a2p-4);
const c4: @Vector(vec_len, f64) = @splat(-0x1.745d11fb3d32bp-4);
const c5: @Vector(vec_len, f64) = @splat(0x1.3b136a18051b9p-4);
const c6: @Vector(vec_len, f64) = @splat(-0x1.110e6d985f496p-4);
const c7: @Vector(vec_len, f64) = @splat(0x1.e1bcf7f08801dp-5);
const c8: @Vector(vec_len, f64) = @splat(-0x1.ae644e28058c3p-5);
const c9: @Vector(vec_len, f64) = @splat(0x1.82eeb1fed85c6p-5);
const c10: @Vector(vec_len, f64) = @splat(-0x1.59d7f901566cbp-5);
const c11: @Vector(vec_len, f64) = @splat(0x1.2c982855ab069p-5);
const c12: @Vector(vec_len, f64) = @splat(-0x1.eb49592998177p-6);
const c13: @Vector(vec_len, f64) = @splat(0x1.69d8b396e3d38p-6);
const c14: @Vector(vec_len, f64) = @splat(-0x1.ca980345c4204p-7);
const c15: @Vector(vec_len, f64) = @splat(0x1.dc050eafde0b3p-8);
const c16: @Vector(vec_len, f64) = @splat(-0x1.7ea70755b8eccp-9);
const c17: @Vector(vec_len, f64) = @splat(0x1.ba3da3de903e8p-11);
const c18: @Vector(vec_len, f64) = @splat(-0x1.44a4b059b6f67p-13);
const c19: @Vector(vec_len, f64) = @splat(0x1.c4a45029e5a91p-17);
const ix: @Vector(vec_len, u64) = @bitCast(x);
const sign = ix & sign_mask;
const pred = @abs(x) > @abs(neg_one);
const shift: @Vector(vec_len, f64) = @bitCast(@select(u64, pred, pi_over_2 ^ sign, zero));
const z = @select(f64, pred, neg_one / x, x);
const z2 = z * z;
const z3 = z * z2;
const z4 = z2 * z2;
const z8 = z4 * z4;
const z16 = z8 * z8;
const p0_1 = @mulAdd(@Vector(vec_len, f64), z2, c1, c0);
const p2_3 = @mulAdd(@Vector(vec_len, f64), z2, c3, c2);
const p0_3 = @mulAdd(@Vector(vec_len, f64), z4, p2_3, p0_1);
const p4_5 = @mulAdd(@Vector(vec_len, f64), z2, c5, c4);
const p6_7 = @mulAdd(@Vector(vec_len, f64), z2, c7, c6);
const p4_7 = @mulAdd(@Vector(vec_len, f64), z4, p6_7, p4_5);
const p0_7 = @mulAdd(@Vector(vec_len, f64), z8, p4_7, p0_3);
const p8_9 = @mulAdd(@Vector(vec_len, f64), z2, c9, c8);
const p10_11 = @mulAdd(@Vector(vec_len, f64), z2, c11, c10);
const p8_11 = @mulAdd(@Vector(vec_len, f64), z4, p10_11, p8_9);
const p12_13 = @mulAdd(@Vector(vec_len, f64), z2, c13, c12);
const p14_15 = @mulAdd(@Vector(vec_len, f64), z2, c15, c14);
const p12_15 = @mulAdd(@Vector(vec_len, f64), z4, p14_15, p12_13);
const p16_17 = @mulAdd(@Vector(vec_len, f64), z2, c17, c16);
const p18_19 = @mulAdd(@Vector(vec_len, f64), z2, c19, c18);
const p16_19 = @mulAdd(@Vector(vec_len, f64), z4, p18_19, p16_17);
const p8_15 = @mulAdd(@Vector(vec_len, f64), z8, p12_15, p8_11);
const p8_19 = @mulAdd(@Vector(vec_len, f64), z16, p16_19, p8_15);
const p0_19 = @mulAdd(@Vector(vec_len, f64), p8_19, z16, p0_7);
return @mulAdd(@Vector(vec_len, f64), z3, p0_19, shift + z);
}