Complex numbers.

Type Complex

type Complex = Cmplx<float>

Type Complex32

type Complex32 = Cmplx<f32>

Type Complex64

type Complex64 = Cmplx<f64>

Struct Cmplx

pub struct Cmplx<T> {
    /// Real portion of the complex number
    re: T,
    /// Imaginary portion of the complex number
    im: T,
}

A complex number in Cartesian form.

Implementation of ::std::cmp::Eq for Cmplx<T> where <T: ::std::cmp::Eq>

Automatically derived.

Method eq

fn eq(&self, __arg_0: &Cmplx<T>) -> ::bool

Method ne

fn ne(&self, __arg_0: &Cmplx<T>) -> ::bool

Implementation of ::std::clone::Clone for Cmplx<T> where <T: ::std::clone::Clone>

Automatically derived.

Method clone

fn clone(&self) -> Cmplx<T>

Implementation for Cmplx<T> where <T: Clone + Num>

Method new

fn new(re: T, im: T) -> Cmplx<T>

Create a new Cmplx

Method norm_sqr

fn norm_sqr(&self) -> T

Returns the square of the norm (since T doesn't necessarily have a sqrt function), i.e. re^2 + im^2.

Method conj

fn conj(&self) -> Cmplx<T>

Returns the complex conjugate. i.e. re - i im

Method scale

fn scale(&self, t: T) -> Cmplx<T>

Multiplies self by the scalar t.

Method unscale

fn unscale(&self, t: T) -> Cmplx<T>

Divides self by the scalar t.

Method inv

fn inv(&self) -> Cmplx<T>

Returns 1/self

Implementation for Cmplx<T> where <T: Clone + Algebraic + Num>

Method norm

fn norm(&self) -> T

Calculate |self|

Implementation for Cmplx<T> where <T: Clone + Trigonometric + Algebraic + Num>

Method arg

fn arg(&self) -> T

Calculate the principal Arg of self.

Method to_polar

fn to_polar(&self) -> (T, T)

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

Method from_polar

fn from_polar(r: &T, theta: &T) -> Cmplx<T>

Convert a polar representation into a complex number.

Implementation of Add<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>

Method add

fn add(&self, other: &Cmplx<T>) -> Cmplx<T>

Implementation of Sub<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>

Method sub

fn sub(&self, other: &Cmplx<T>) -> Cmplx<T>

Implementation of Mul<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>

Method mul

fn mul(&self, other: &Cmplx<T>) -> Cmplx<T>

Implementation of Div<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>

Method div

fn div(&self, other: &Cmplx<T>) -> Cmplx<T>

Implementation of Neg<Cmplx<T>> for Cmplx<T> where <T: Clone + Num>

Method neg

fn neg(&self) -> Cmplx<T>

Implementation of Zero for Cmplx<T> where <T: Clone + Num>

Method zero

fn zero() -> Cmplx<T>

Method is_zero

fn is_zero(&self) -> bool

Implementation of One for Cmplx<T> where <T: Clone + Num>

Method one

fn one() -> Cmplx<T>

Implementation of ToStr for Cmplx<T> where <T: ToStr + Num + Ord>

Method to_str

fn to_str(&self) -> ~str

Implementation of ToStrRadix for Cmplx<T> where <T: ToStrRadix + Num + Ord>

Method to_str_radix

fn to_str_radix(&self, radix: uint) -> ~str