master
1const std = @import("../../std.zig");
2const testing = std.testing;
3const math = std.math;
4const cmath = math.complex;
5const Complex = cmath.Complex;
6
7/// Returns the angular component (in radians) of z.
8pub fn arg(z: anytype) @TypeOf(z.re, z.im) {
9 return math.atan2(z.im, z.re);
10}
11
12test arg {
13 const epsilon = math.floatEps(f32);
14 const a = Complex(f32).init(5, 3);
15 const c = arg(a);
16 try testing.expectApproxEqAbs(0.5404195, c, epsilon);
17}