Struct num::complex::ComplexExperimental [-]  [+] [src]

pub struct Complex<T> {
    pub re: T,
    pub im: T,
}

A complex number in Cartesian form.

Fields

re

Real portion of the complex number

im

Imaginary portion of the complex number

Methods

impl<T: Clone + Num> Complex<T>

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

Create a new Complex

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.

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

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

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

Multiplies self by the scalar t.

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

Divides self by the scalar t.

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

Returns 1/self

impl<T: Clone + FloatMath> Complex<T>

fn norm(&self) -> T

Calculate |self|

impl<T: Clone + FloatMath + Num> Complex<T>

fn arg(&self) -> T

Calculate the principal Arg of self.

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

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

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

Convert a polar representation into a complex number.

Trait Implementations

impl<T: Clone + Num> Add<Complex<T>, Complex<T>> for Complex<T>

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

impl<T: Clone + Num> Sub<Complex<T>, Complex<T>> for Complex<T>

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

impl<T: Clone + Num> Mul<Complex<T>, Complex<T>> for Complex<T>

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

impl<T: Clone + Num> Div<Complex<T>, Complex<T>> for Complex<T>

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

impl<T: Clone + Num> Neg<Complex<T>> for Complex<T>

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

impl<T: Clone + Num> Zero for Complex<T>

fn zero() -> Complex<T>

fn is_zero(&self) -> bool

impl<T: Clone + Num> One for Complex<T>

fn one() -> Complex<T>

impl<T: Show + Num + PartialOrd> Show for Complex<T>

fn fmt(&self, f: &mut Formatter) -> Result

Derived Implementations

impl<__D: Decoder<__E>, __E, T: Decodable<__D, __E>> Decodable<__D, __E> for Complex<T>

fn decode(__arg_0: &mut __D) -> Result<Complex<T>, __E>

impl<__S: Encoder<__E>, __E, T: Encodable<__S, __E>> Encodable<__S, __E> for Complex<T>

fn encode(&self, __arg_0: &mut __S) -> Result<(), __E>

impl<__S: Writer, T: Hash<__S>> Hash<__S> for Complex<T>

fn hash(&self, __arg_0: &mut __S)

impl<T: Clone> Clone for Complex<T>

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

fn clone_from(&mut self, source: &Self)

impl<T: PartialEq> PartialEq for Complex<T>

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

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