aboutsummaryrefslogtreecommitdiff
path: root/std/math/complex/conj.zig
blob: ad3e8b50365746d1308709bb177b47ad2d775bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const std = @import("../../index.zig");
const debug = std.debug;
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();

    debug.assert(c.re == 5 and c.im == -3);
}