std.math.complex.pow.cmath
alias
Alias of std.math.complex
std.math.complex.pow.Complex
alias
Alias of std.math.complex.Complex
std.math.complex.pow.math
alias
Alias of std.math
std.math.complex.pow.pow
function
Returns z raised to the complex power of c.
pub fn pow(z: anytype, s: anytype) Complex(@TypeOf(z.re, z.im, s.re, s.im))
Example usage
test pow {
const epsilon = math.floatEps(f32);
const a = Complex(f32).init(5, 3);
const b = Complex(f32).init(2.3, -1.3);
const c = pow(a, b);
try testing.expectApproxEqAbs(58.049110, c.re, epsilon);
try testing.expectApproxEqAbs(-101.003433, c.im, epsilon);
}
std.math.complex.pow.std
alias
Alias of std
std.math.complex.pow.testing
alias
Alias of std.testing
Source code
std/math/complex/pow.zig
const std = @import("../../std.zig");
const testing = std.testing;
const math = std.math;
const cmath = math.complex;
const Complex = cmath.Complex;
/// Returns z raised to the complex power of c.
pub fn pow(z: anytype, s: anytype) Complex(@TypeOf(z.re, z.im, s.re, s.im)) {
return cmath.exp(cmath.log(z).mul(s));
}
test pow {
const epsilon = math.floatEps(f32);
const a = Complex(f32).init(5, 3);
const b = Complex(f32).init(2.3, -1.3);
const c = pow(a, b);
try testing.expectApproxEqAbs(58.049110, c.re, epsilon);
try testing.expectApproxEqAbs(-101.003433, c.im, epsilon);
}