Skip to main content

ComplexMath

Trait ComplexMath 

Source
pub trait ComplexMath: ComplexMathWithPolicy {
    // Provided methods
    fn norm(self) -> Self::Real { ... }
    fn arg(self) -> Self::Real { ... }
    fn to_polar(self) -> (Self::Real, Self::Real) { ... }
    fn from_polar(r: Self::Real, theta: Self::Real) -> Self { ... }
    fn powfr(self, e: Self::Real) -> Self { ... }
    fn expf(self, base: Self::Real) -> Self { ... }
    fn logr(self, base: Self::Real) -> Self { ... }
    fn finv(self) -> Self { ... }
    fn fdiv(self, rhs: Self) -> Self { ... }
}
Expand description

Complex math functions using the default policy. Operations whose result is real (modulus, argument, polar form) or whose argument is (a real power, base, or logarithm base), which the Self -> Self core families cannot express.

The purely complex operations (exp, ln, sin, sqrt, powf, …) fit the core families and come from TranscendentalMath as they do for any other vector.

Every method here has a counterpart in ComplexMathWithPolicy with a _p suffix that takes an explicit Policy.

Implementors of ComplexMathWithPolicy implement this automatically.

Provided Methods§

Source

fn norm(self) -> Self::Real

The modulus $|z|$, as a real value.

Uses hypot, so it does not overflow for large components the way sqrt(norm_sqr()) would.

Source

fn arg(self) -> Self::Real

The principal argument arg(z), in (-pi, pi], as a real value.

Source

fn to_polar(self) -> (Self::Real, Self::Real)

Converts to polar form (r, theta), such that self == r * exp(i*theta).

Source

fn from_polar(r: Self::Real, theta: Self::Real) -> Self

Builds a complex number from a polar representation r * exp(i*theta).

Source

fn powfr(self, e: Self::Real) -> Self

Raises self to a real power.

The complex-exponent form is powf.

Source

fn expf(self, base: Self::Real) -> Self

Raises a real base to the complex power self.

Source

fn logr(self, base: Self::Real) -> Self

The logarithm of self in an arbitrary real base.

The complex-base form is log.

Source

fn finv(self) -> Self

1/self, scaling by the modulus and not its square.

Survives the magnitudes where inv would have norm_sqr() overflow to infinity or underflow to zero.

Source

fn fdiv(self, rhs: Self) -> Self

self/rhs, scaling by the modulus and not its square.

Survives the magnitudes where / would have rhs.norm_sqr() overflow to infinity or underflow to zero.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§