pub struct Complex<T> { /* private fields */ }Implementations§
Source§impl Complex<f64>
impl Complex<f64>
Sourcepub fn modulus(&self) -> f64
pub fn modulus(&self) -> f64
calculates absolute value (modulus) of complex number
§Example
let z = Complex::new(3.0, 4.0);
assert_eq!(z.modulus(), 5.0);computes √(re² + im²)
Sourcepub fn argument(&self) -> f64
pub fn argument(&self) -> f64
calculates argument (phase) of complex number
§Example
let z = Complex::new(1.0, 1.0);
assert_eq!(z.argument(), std::f64::consts::PI/4.0);returns angle in radians from positive real axis
Sourcepub fn conjugate(&self) -> Self
pub fn conjugate(&self) -> Self
returns complex conjugate
§Example
let z = Complex::new(3.0, 4.0);
let conj = z.conjugate(); // 3 - 4inegates imaginary part while keeping real part
Sourcepub fn exp(&self) -> Self
pub fn exp(&self) -> Self
computes exponential of complex number
§Example
let z = Complex::I * std::f64::consts::PI;
let exp_z = z.exp(); // ≈ -1 + 0iuses euler’s formula: e^(a+bi) = e^a(cos(b) + i*sin(b))
Sourcepub fn ln(&self) -> Self
pub fn ln(&self) -> Self
computes natural logarithm of complex number
§Example
let z = Complex::new(1.0, 0.0);
let ln_z = z.ln(); // 0 + 0ireturns ln|z| + i*arg(z)
Sourcepub fn pow(&self, n: f64) -> Self
pub fn pow(&self, n: f64) -> Self
raises complex number to real power
§Example
let z = Complex::new(1.0, 1.0);
let z_squared = z.pow(2.0);uses polar form for computation
Sourcepub fn sqrt(&self) -> Self
pub fn sqrt(&self) -> Self
calculates square root of complex number
§Example
let z = Complex::new(-1.0, 0.0);
let sqrt_z = z.sqrt(); // 0 + 1ireturns principal square root
pub fn sin(&self) -> Self
pub fn cos(&self) -> Self
pub fn tan(&self) -> Self
pub fn sinh(&self) -> Self
pub fn cosh(&self) -> Self
pub fn tanh(&self) -> Self
Trait Implementations§
Source§impl<T: Copy + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T>> Div for Complex<T>
impl<T: Copy + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T>> Div for Complex<T>
impl<T: Copy> Copy for Complex<T>
impl<T> StructuralPartialEq for Complex<T>
Auto Trait Implementations§
impl<T> Freeze for Complex<T>where
T: Freeze,
impl<T> RefUnwindSafe for Complex<T>where
T: RefUnwindSafe,
impl<T> Send for Complex<T>where
T: Send,
impl<T> Sync for Complex<T>where
T: Sync,
impl<T> Unpin for Complex<T>where
T: Unpin,
impl<T> UnwindSafe for Complex<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more