Trait complex::Complex [] [src]

pub trait Complex: Number {
    type Real: Real;
    fn new(Self::Real, Self::Real) -> Self;
    fn from_polar(Self::Real, Self::Real) -> Self;
    fn re(&self) -> Self::Real;
    fn re_mut(&mut self) -> &mut Self::Real;
    fn im(&self) -> Self::Real;
    fn im_mut(&mut self) -> &mut Self::Real;
    fn abs(&self) -> Self::Real;
    fn arg(&self) -> Self::Real;

    fn to_polar(&self) -> (Self::Real, Self::Real) { ... }
    fn conj(&self) -> Self { ... }
}

A complex number.

Associated Types

type Real: Real

A real number.

Required Methods

fn new(Self::Real, Self::Real) -> Self

Create a complex number from a real and an imaginary part.

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

Create a complex number from a modulus and an argument.

fn re(&self) -> Self::Real

Return the real part.

fn re_mut(&mut self) -> &mut Self::Real

Return the real part as a mutable reference.

fn im(&self) -> Self::Real

Return the imaginary part.

fn im_mut(&mut self) -> &mut Self::Real

Return the imaginary part as a mutable reference.

fn abs(&self) -> Self::Real

Compute the modulus.

fn arg(&self) -> Self::Real

Compute the argument.

Provided Methods

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

Compute the modulus and the argument.

fn conj(&self) -> Self

Compute the complex conjugate.

Implementors