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

asinBinary32Vec

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

Params

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

File

math/asin.zig:455
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
fn asinBinary32Vec(comptime vec_len: comptime_int, x: @Vector(vec_len, f32)) @TypeOf(x) {
    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_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 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 y = @select(f32, ax_lt_half, p, @mulAdd(@Vector(vec_len, f32), p, neg_two, pi_over_2));
    return @select(f32, x < zero, -y, y);
}