pub struct Cmplx<T> { re: T, im: T, }
A complex number in Cartesian form.
impl<T: std::clone::Clone + std::num::Num> Cmplx<T>
fn new(re: T, im: T) -> Cmplx<T>
Create a new Cmplx
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) -> Cmplx<T>
Returns the complex conjugate. i.e. re - i im
fn scale(&self, t: T) -> Cmplx<T>
Multiplies self
by the scalar t
.
fn unscale(&self, t: T) -> Cmplx<T>
Divides self
by the scalar t
.
fn inv(&self) -> Cmplx<T>
Returns 1/self
impl<T: std::clone::Clone + std::num::Algebraic + std::num::Num> Cmplx<T>
fn norm(&self) -> T
Calculate |self|
impl<T: std::clone::Clone + std::num::Trigonometric + std::num::Algebraic + std::num::Num> Cmplx<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) -> Cmplx<T>
Convert a polar representation into a complex number.
impl<T: std::cmp::Eq> std::cmp::Eq for Cmplx<T>
impl<T: std::clone::Clone> std::clone::Clone for Cmplx<T>
fn clone(&self) -> Cmplx<T>
impl<T: std::clone::Clone + std::num::Num> std::ops::Add for Cmplx<T>
impl<T: std::clone::Clone + std::num::Num> std::ops::Sub for Cmplx<T>
impl<T: std::clone::Clone + std::num::Num> std::ops::Mul for Cmplx<T>
impl<T: std::clone::Clone + std::num::Num> std::ops::Div for Cmplx<T>
impl<T: std::clone::Clone + std::num::Num> std::ops::Neg for Cmplx<T>
fn neg(&self) -> Cmplx<T>
impl<T: std::clone::Clone + std::num::Num> std::num::Zero for Cmplx<T>
fn zero() -> Cmplx<T>
fn is_zero(&self) -> bool
impl<T: std::clone::Clone + std::num::Num> std::num::One for Cmplx<T>
fn one() -> Cmplx<T>
impl<T: std::to_str::ToStr + std::num::Num + std::cmp::Ord> std::to_str::ToStr for Cmplx<T>
fn to_str(&self) -> ~str
impl<T: std::num::ToStrRadix + std::num::Num + std::cmp::Ord> std::num::ToStrRadix for Cmplx<T>
fn to_str_radix(&self, radix: uint) -> ~str
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).