Struct oxygen_quark::imaginary::complex::Complex
source · Fields§
§real: Fraction
The real component of the complex number
imaginary: Fraction
The imaginary component of the complex number
Implementations§
source§impl Complex
impl Complex
sourcepub fn new(real: Fraction, imaginary: Fraction) -> Complex
pub fn new(real: Fraction, imaginary: Fraction) -> Complex
Generates a new Complex
Examples
let complex = Complex::new(Fraction::new(3, 1), Fraction::new(4, 1));
// Prints out "(3+1i)"
println!("{}", complex);
sourcepub fn add(self, other: Complex) -> Complex
pub fn add(self, other: Complex) -> Complex
Adds two Complex
s and returns their sum, another Complex
.
Examples
let complex1 = Complex::new(a, b);
let complex2 = Complex::new(x, y);
// Prints out "(8+16i)"
println!("{}", complex1.add(complex2));
// This also works:
println!("{}", complex1 + complex2);
pub fn subtract(self, other: Complex) -> Complex
pub fn multiply(self, other: Complex) -> Complex
pub fn divide(self, other: Complex) -> Complex
pub fn reciprocal(&self) -> Complex
pub fn zero() -> Complex
pub fn conjugate(self) -> Complex
pub fn norm(self) -> Fraction
pub fn angle(self) -> Fraction
pub fn as_matrix2x2(self) -> Matrix2x2
Trait Implementations§
source§impl AddAssign<Complex> for Complex
impl AddAssign<Complex> for Complex
source§fn add_assign(&mut self, other: Complex)
fn add_assign(&mut self, other: Complex)
Performs the
+=
operation. Read moresource§impl Ord for Complex
impl Ord for Complex
source§impl PartialOrd<Complex> for Complex
impl PartialOrd<Complex> for Complex
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more