MCPcopy Index your code
hub / github.com/RustPython/RustPython / powc

Function powc

crates/vm/src/builtins/complex.rs:175–184  ·  view source on GitHub ↗

num-complex changed their powc() implementation in 0.4.4, making it incompatible with what the regression tests expect. this is that old formula.

(a: Complex64, exp: Complex64)

Source from the content-addressed store, hash-verified

173// num-complex changed their powc() implementation in 0.4.4, making it incompatible
174// with what the regression tests expect. this is that old formula.
175fn powc(a: Complex64, exp: Complex64) -> Complex64 {
176 let (r, theta) = a.to_polar();
177 if r.is_zero() {
178 return Complex64::new(r, r);
179 }
180 Complex64::from_polar(
181 r.powf(exp.re) * (-exp.im * theta).exp(),
182 exp.re * theta + exp.im * r.ln(),
183 )
184}
185
186impl Constructor for PyComplex {
187 type Args = ComplexArgs;

Callers 1

inner_powFunction · 0.85

Calls 4

newFunction · 0.85
is_zeroMethod · 0.45
expMethod · 0.45
lnMethod · 0.45

Tested by

no test coverage detected