跳转到内容

std.math.complex.arg

标准库Zig 0.17.0官方原文
源码std/math/complex/arg.zig

第 1 行

std.math.complex.arg.arg

函数

第 8 行

返回 z 的角度分量(以弧度表示)。

pub fn arg(z: anytype) @TypeOf(z.re, z.im)

用法示例

test arg {
    const epsilon = math.floatEps(f32);
    const a = Complex(f32).init(5, 3);
    const c = arg(a);
    try testing.expectApproxEqAbs(0.5404195, c, epsilon);
}

std.math.complex.arg.cmath

别名

第 4 行

别名目标 std.math.complex

std.math.complex.arg.Complex

别名

第 5 行

别名目标 std.math.complex.Complex

std.math.complex.arg.math

别名

第 3 行

别名目标 std.math

std.math.complex.arg.std

别名

第 1 行

别名目标 std

std.math.complex.arg.testing

别名

第 2 行

别名目标 std.testing

源码

std/math/complex/arg.zig

const std = @import("../../std.zig");
const testing = std.testing;
const math = std.math;
const cmath = math.complex;
const Complex = cmath.Complex;

/// 返回 z 的角度分量(以弧度表示)。
pub fn arg(z: anytype) @TypeOf(z.re, z.im) {
    return math.atan2(z.im, z.re);
}

test arg {
    const epsilon = math.floatEps(f32);
    const a = Complex(f32).init(5, 3);
    const c = arg(a);
    try testing.expectApproxEqAbs(0.5404195, c, epsilon);
}