pub trait ComplexField: Copy + Num + Neg<Output = Self> + Conjugate<Num = Self> + Send + Sync + Debug + 'static {
    type Real: RealField;

    // Required methods
    fn from_real(real: Self::Real) -> Self;
    fn into_real_imag(self) -> (Self::Real, Self::Real);
    fn inv(self) -> Self;
    fn conj(self) -> Self;
    fn score(self) -> Self::Real;
    fn nan() -> Self;

    // Provided methods
    fn real(self) -> Self::Real { ... }
    fn imag(self) -> Self::Real { ... }
    fn scale_real(self, factor: Self::Real) -> Self { ... }
    fn abs(self) -> Self::Real { ... }
    fn is_nan(self) -> bool { ... }
}
Expand description

Trait that describes a complex number field.

Real numbers can also be seen as complex numbers, where the imaginary part is always zero.

Note

The implementation currently implies Copy, but this may be replaced by Clone in a future version of this library.

Required Associated Types§

Required Methods§

source

fn from_real(real: Self::Real) -> Self

Returns a complex number whose real part is equal to real, and a zero imaginary part.

source

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

Returns the real and imaginary part.

source

fn inv(self) -> Self

source

fn conj(self) -> Self

Returns the conjugate of the number.

source

fn score(self) -> Self::Real

Returns either the norm or squared norm of the number.

An implementation may choose either, so long as it chooses consistently.

source

fn nan() -> Self

Provided Methods§

source

fn real(self) -> Self::Real

Returns the real part.

source

fn imag(self) -> Self::Real

Returns the imaginary part.

source

fn scale_real(self, factor: Self::Real) -> Self

Returns the input, scaled by factor.

source

fn abs(self) -> Self::Real

source

fn is_nan(self) -> bool

Implementations on Foreign Types§

source§

impl<T: RealField> ComplexField for Complex<T>

§

type Real = T

source§

fn from_real(real: Self::Real) -> Self

source§

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

source§

fn conj(self) -> Self

source§

fn score(self) -> Self::Real

source§

fn nan() -> Self

source§

fn inv(self) -> Self

source§

impl ComplexField for f32

§

type Real = f32

source§

fn from_real(real: Self::Real) -> Self

source§

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

source§

fn conj(self) -> Self

source§

fn score(self) -> Self::Real

source§

fn abs(self) -> Self::Real

source§

fn nan() -> Self

source§

fn inv(self) -> Self

source§

impl ComplexField for f64

§

type Real = f64

source§

fn from_real(real: Self::Real) -> Self

source§

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

source§

fn conj(self) -> Self

source§

fn score(self) -> Self::Real

source§

fn abs(self) -> Self::Real

source§

fn nan() -> Self

source§

fn inv(self) -> Self

Implementors§