Complex numbers.
Complex
Complex32
Complex64
Cmplx
- A complex number in Cartesian form.of ::std::cmp::Eq for Cmplx<T> where <T: ::std::cmp::Eq>
- Automatically derived.of ::std::clone::Clone for Cmplx<T> where <T: ::std::clone::Clone>
- Automatically derived.for Cmplx<T> where <T: Clone + Num>
for Cmplx<T> where <T: Clone + Algebraic + Num>
for Cmplx<T> where <T: Clone + Trigonometric + Algebraic + Num>
of Add<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>
of Sub<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>
of Mul<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>
of Div<Cmplx<T>, Cmplx<T>> for Cmplx<T> where <T: Clone + Num>
of Neg<Cmplx<T>> for Cmplx<T> where <T: Clone + Num>
of Zero for Cmplx<T> where <T: Clone + Num>
of One for Cmplx<T> where <T: Clone + Num>
of ToStr for Cmplx<T> where <T: ToStr + Num + Ord>
of ToStrRadix for Cmplx<T> where <T: ToStrRadix + Num + Ord>
Complex
type Complex = Cmplx<float>
Complex32
type Complex32 = Cmplx<f32>
Complex64
type Complex64 = Cmplx<f64>
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.
::std::cmp::Eq
for Cmplx<T>
where <T: ::std::cmp::Eq>
Automatically derived.
eq
fn eq(&self, __arg_0: &Cmplx<T>) -> ::bool
ne
fn ne(&self, __arg_0: &Cmplx<T>) -> ::bool
::std::clone::Clone
for Cmplx<T>
where <T: ::std::clone::Clone>
Automatically derived.
clone
fn clone(&self) -> Cmplx<T>
Cmplx<T>
where <T: Clone + Num>
new
fn new(re: T, im: T) -> Cmplx<T>
Create a new Cmplx
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
.
conj
fn conj(&self) -> Cmplx<T>
Returns the complex conjugate. i.e. re - i im
scale
fn scale(&self, t: T) -> Cmplx<T>
Multiplies self
by the scalar t
.
unscale
fn unscale(&self, t: T) -> Cmplx<T>
Divides self
by the scalar t
.
inv
fn inv(&self) -> Cmplx<T>
Returns 1/self
Cmplx<T>
where <T: Clone + Algebraic + Num>
norm
fn norm(&self) -> T
Calculate |self|
Cmplx<T>
where <T: Clone + Trigonometric + Algebraic + Num>
arg
fn arg(&self) -> T
Calculate the principal Arg of self.
to_polar
fn to_polar(&self) -> (T, T)
Convert to polar form (r, theta), such that self = r * exp(i * theta)
from_polar
fn from_polar(r: &T, theta: &T) -> Cmplx<T>
Convert a polar representation into a complex number.
Add<Cmplx<T>, Cmplx<T>>
for Cmplx<T>
where <T: Clone + Num>
add
fn add(&self, other: &Cmplx<T>) -> Cmplx<T>
Sub<Cmplx<T>, Cmplx<T>>
for Cmplx<T>
where <T: Clone + Num>
sub
fn sub(&self, other: &Cmplx<T>) -> Cmplx<T>
Mul<Cmplx<T>, Cmplx<T>>
for Cmplx<T>
where <T: Clone + Num>
mul
fn mul(&self, other: &Cmplx<T>) -> Cmplx<T>
Div<Cmplx<T>, Cmplx<T>>
for Cmplx<T>
where <T: Clone + Num>
div
fn div(&self, other: &Cmplx<T>) -> Cmplx<T>
Neg<Cmplx<T>>
for Cmplx<T>
where <T: Clone + Num>
neg
fn neg(&self) -> Cmplx<T>
Zero
for Cmplx<T>
where <T: Clone + Num>
zero
fn zero() -> Cmplx<T>
is_zero
fn is_zero(&self) -> bool
One
for Cmplx<T>
where <T: Clone + Num>
one
fn one() -> Cmplx<T>
ToStr
for Cmplx<T>
where <T: ToStr + Num + Ord>
to_str
fn to_str(&self) -> ~str
ToStrRadix
for Cmplx<T>
where <T: ToStrRadix + Num + Ord>
to_str_radix
fn to_str_radix(&self, radix: uint) -> ~str