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

acosBinary32Vec

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

Params

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

File

math/acos.zig:461
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
fn acosBinary32Vec(comptime vec_len: comptime_int, x: @Vector(vec_len, f32)) @TypeOf(x) {
    const pi: @Vector(vec_len, f32) = @splat(math.pi);
    const pi_over_2: @Vector(vec_len, f32) = @splat(math.pi / 2.0);
    const zero: @Vector(vec_len, f32) = @splat(0.0);
    const half: @Vector(vec_len, f32) = @splat(0.5);
    const neg_one: @Vector(vec_len, f32) = @splat(-1.0);
    const two: @Vector(vec_len, f32) = @splat(2.0);
    const c0: @Vector(vec_len, f32) = @splat(0x1.55555ep-3);
    const c1: @Vector(vec_len, f32) = @splat(0x1.33261ap-4);
    const c2: @Vector(vec_len, f32) = @splat(0x1.70d7dcp-5);
    const c3: @Vector(vec_len, f32) = @splat(0x1.b059dp-6);
    const c4: @Vector(vec_len, f32) = @splat(0x1.3af7d8p-5);

    const ax = @abs(x);
    const ax_lt_half = ax < half;
    const is_neg = x < zero;
    const z2 = @select(f32, ax_lt_half, x * x, @mulAdd(@Vector(vec_len, f32), -half, ax, half));
    const z = @select(f32, ax_lt_half, ax, @sqrt(z2));
    const z3 = z2 * z;
    const p3_4 = @mulAdd(@Vector(vec_len, f32), z2, c4, c3);
    const p2_4 = @mulAdd(@Vector(vec_len, f32), z2, p3_4, c2);
    const p1_4 = @mulAdd(@Vector(vec_len, f32), z2, p2_4, c1);
    const p0_4 = @mulAdd(@Vector(vec_len, f32), z2, p1_4, c0);
    const p = @mulAdd(@Vector(vec_len, f32), z3, p0_4, z);
    const mul = @select(f32, ax_lt_half, neg_one, two);
    const add = @select(f32, ax_lt_half, pi_over_2, @select(f32, is_neg, pi, zero));
    return @mulAdd(@Vector(vec_len, f32), mul, @select(f32, is_neg, -p, p), add);
}