Skip to main content

ComplexMathWithPolicy

Trait ComplexMathWithPolicy 

Source
pub trait ComplexMathWithPolicy: ComplexVector {
    // Required methods
    fn norm_p<P: Policy>(self) -> Self::Real;
    fn arg_p<P: Policy>(self) -> Self::Real;
    fn to_polar_p<P: Policy>(self) -> (Self::Real, Self::Real);
    fn from_polar_p<P: Policy>(r: Self::Real, theta: Self::Real) -> Self;
    fn powfr_p<P: Policy>(self, e: Self::Real) -> Self;
    fn expf_p<P: Policy>(self, base: Self::Real) -> Self;
    fn logr_p<P: Policy>(self, base: Self::Real) -> Self;
    fn finv_p<P: Policy>(self) -> Self;
    fn fdiv_p<P: Policy>(self, rhs: Self) -> Self;
}
Expand description

Complex math functions with customizable policies. 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.

Each function takes a Policy as its first generic argument. For the default-policy versions (same names, no _p suffix), see ComplexMath.

Implemented automatically for every type implementing SpecializedComplexMath.

Required Methods§

Source

fn norm_p<P: Policy>(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_p<P: Policy>(self) -> Self::Real

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

Source

fn to_polar_p<P: Policy>(self) -> (Self::Real, Self::Real)

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

Source

fn from_polar_p<P: Policy>(r: Self::Real, theta: Self::Real) -> Self

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

Source

fn powfr_p<P: Policy>(self, e: Self::Real) -> Self

Raises self to a real power.

The complex-exponent form is powf.

Source

fn expf_p<P: Policy>(self, base: Self::Real) -> Self

Raises a real base to the complex power self.

Source

fn logr_p<P: Policy>(self, base: Self::Real) -> Self

The logarithm of self in an arbitrary real base.

The complex-base form is log.

Source

fn finv_p<P: Policy>(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_p<P: Policy>(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§