Skip to content

Complex

spcan edited this page Mar 27, 2018 · 3 revisions

Complex

What is it?

Complex is a struct representation of a complex number in the usual form

(a + b*i)

Methods

new

Method:

new() -> Complex

Takes no arguments, returns a Complex with value (0 + 0*i)


new_from

Method:

new_from(&EComplex) -> Complex

Takes a reference to a EComplex number, returns a Complex number of the same value

Can be considered to be a cast or transformation between types

It is a static method


module

Method:

module(&self) -> f64

Takes no arguments, returns the module of the equivalent EComplex


arg

Method:

arg(&self) -> f64

Takes no arguments, returns the argument (angle) of the equivalent EComplex in radians


argd

Method:

argd(&self) -> f64

Takes no arguments, returns the argument (angle) of the equivalent EComplex in degrees


sqrt

Method:

sqrt(&self) -> Result<Vec<Complex>, &'static str>

Takes no arguments, returns the two square roots of the number


root

Method:

root(&self, n: usize) -> Result<Vec<Complex>, &'static str>

Takes a usize, returns n possible nth roots of a number or a string error if it fails.


powi

Method:

powi(&self, p: isize) -> Complex

Takes an isize, returns the number to the power of p


powf

Method:

powf(&self, p: f64) -> Complex

Takes a 64 bit float, returns the number to the power of p

It uses a 64 bit float to reduce inaccuracies


conjugate

Method:

conjugate(&self) -> Complex

Takes no arguments, returns the conjugate Complex number


abs

Method:

abs(&self) -> f64

Takes no arguments, returns the absolute value of the module of the number


exp

Method:

exp(&self) -> Complex

Takes no arguments, returns the result of elevating e to the complex number


ln

Method:

ln(&self) -> Complex

Takes no arguments, return the main logarithm of the number


log

Method:

log(&self, b: f64) -> Complex

Takes a 64 bit float, returns the logarithm in base b of the number


inverse

Method:

inverse(&self) -> Complex

Takes no arguments, returns one divided by the number (1/number)


cos

Method:

cos(&self) -> Complex

Takes no arguments, returns the cosine of the number


sin

Method:

sin(&self) -> Complex

Takes no arguments, returns the sine of the number


tan

Method:

tan(&self) -> Option<Complex>

Takes no arguments, returns the tangent of the number or None if it tends to infinity


cosh

Method:

cosh(&self) -> Complex

Takes no arguments, returns the hyperbolic cosine of the number


sinh

Method:

sinh(&self) -> Complex

Takes no arguments, returns the hyperbolic sine of the number


tuple

Method:

tuple(&self) -> (f64, f64)

Takes no arguments, returns the real and imaginary part of the number as a tuple (real, imag)


exp_tuple

Method:

exp_tuple(&self) -> (f64, f64)

Takes no arguments, returns the module and argument of the equivalent EComplex


Clone this wiki locally