Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

atanBinary32Vec

Private Function
std.math.atan.atanBinary32Vec
fn atanBinary32Vec(comptime vec_len: comptime_int, x: @Vector(vec_len, f32)) @TypeOf(x)

Params

  • vec_len: comptime_int
  • x: @Vector(vec_len, f32)

File

math/atan.zig:598
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
fn atanBinary32Vec(comptime vec_len: comptime_int, x: @Vector(vec_len, f32)) @TypeOf(x) {
    const sign_mask: @Vector(vec_len, u32) = @splat(0x80000000);
    const neg_one: @Vector(vec_len, f32) = @splat(-1.0);
    const pi_over_2: @Vector(vec_len, u32) = @splat(0x3fc90fdb);
    const zero: @Vector(vec_len, u32) = @splat(0);
    const c0: @Vector(vec_len, f32) = @splat(-0x1.5554dcp-2);
    const c1: @Vector(vec_len, f32) = @splat(0x1.9978ecp-3);
    const c2: @Vector(vec_len, f32) = @splat(-0x1.230a94p-3);
    const c3: @Vector(vec_len, f32) = @splat(0x1.b4debp-4);
    const c4: @Vector(vec_len, f32) = @splat(-0x1.3550dap-4);
    const c5: @Vector(vec_len, f32) = @splat(0x1.61eebp-5);
    const c6: @Vector(vec_len, f32) = @splat(-0x1.0c17d4p-6);
    const c7: @Vector(vec_len, f32) = @splat(0x1.7ea694p-9);

    const ix: @Vector(vec_len, u32) = @bitCast(x);
    const sign = ix & sign_mask;
    const pred = @abs(x) > @abs(neg_one);
    const z = @select(f32, pred, neg_one / x, x);
    const shift: @Vector(vec_len, f32) = @bitCast(@select(u32, pred, pi_over_2 ^ sign, zero));
    const z2 = z * z;
    const z3 = z * z2;
    const z4 = z2 * z2;
    const z8 = z4 * z4;
    const p0_1 = @mulAdd(@Vector(vec_len, f32), z2, c1, c0);
    const p2_3 = @mulAdd(@Vector(vec_len, f32), z2, c3, c2);
    const p4_5 = @mulAdd(@Vector(vec_len, f32), z2, c5, c4);
    const p6_7 = @mulAdd(@Vector(vec_len, f32), z2, c7, c6);
    const p0_3 = @mulAdd(@Vector(vec_len, f32), z4, p2_3, p0_1);
    const p4_7 = @mulAdd(@Vector(vec_len, f32), z4, p6_7, p4_5);
    const p0_7 = @mulAdd(@Vector(vec_len, f32), z8, p4_7, p0_3);
    return @mulAdd(@Vector(vec_len, f32), z3, p0_7, shift + z);
}