2019-03-03 05:46:04 +08:00
|
|
|
const std = @import("../../std.zig");
|
2019-02-09 07:18:47 +08:00
|
|
|
const testing = std.testing;
|
2018-04-24 15:18:31 +08:00
|
|
|
const math = std.math;
|
|
|
|
const cmath = math.complex;
|
|
|
|
const Complex = cmath.Complex;
|
|
|
|
|
|
|
|
pub fn conj(z: var) Complex(@typeOf(z.re)) {
|
|
|
|
const T = @typeOf(z.re);
|
|
|
|
return Complex(T).new(z.re, -z.im);
|
|
|
|
}
|
|
|
|
|
|
|
|
test "complex.conj" {
|
|
|
|
const a = Complex(f32).new(5, 3);
|
|
|
|
const c = a.conjugate();
|
|
|
|
|
2019-02-09 07:18:47 +08:00
|
|
|
testing.expect(c.re == 5 and c.im == -3);
|
2018-04-24 15:18:31 +08:00
|
|
|
}
|