std.math.complex.arg.arg
函数
返回 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
别名
别名目标 std.math.complex
std.math.complex.arg.Complex
别名
std.math.complex.arg.math
别名
别名目标 std.math
std.math.complex.arg.std
别名
别名目标 std
std.math.complex.arg.testing
别名
别名目标 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);
}