pub struct Complex {
pub real: f64,
pub imaginary: f64,
}Expand description
Represents a complex number
Fields§
§real: f64The real part
imaginary: f64The imaginary part.
Implementations§
source§impl Complex
impl Complex
sourcepub const fn new(real: f64, imaginary: f64) -> Self
pub const fn new(real: f64, imaginary: f64) -> Self
Create a new complex from its real and imaginary parts.
sourcepub fn polar(theta: f64, radius: f64) -> Self
pub fn polar(theta: f64, radius: f64) -> Self
Create a new complex from its polar representation.
sourcepub fn partial_mul(self, other: Complex) -> Complex
pub fn partial_mul(self, other: Complex) -> Complex
Multiply the complex’s parts by other complex’s parts (ab + cdi)
sourcepub fn partial_div(self, other: Complex) -> Complex
pub fn partial_div(self, other: Complex) -> Complex
Divide the complex’s parts by other complex’s parts (a/b + (c/d)i)
sourcepub fn len_squared(self) -> f64
pub fn len_squared(self) -> f64
Number-theoretical norm. Simply a^2 + b^2 with self = a + bi
Trait Implementations§
source§impl AddAssign for Complex
impl AddAssign for Complex
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl MulAssign<f64> for Complex
impl MulAssign<f64> for Complex
source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Performs the
*= operation. Read moresource§impl MulAssign for Complex
impl MulAssign for Complex
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moresource§impl SubAssign for Complex
impl SubAssign for Complex
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Complex
Auto Trait Implementations§
impl Freeze for Complex
impl RefUnwindSafe for Complex
impl Send for Complex
impl Sync for Complex
impl Unpin for Complex
impl UnwindSafe for Complex
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneWithNode for Twhere
T: Clone,
impl<T> CloneWithNode for Twhere
T: Clone,
source§fn clone_with_node(&mut self) -> T
fn clone_with_node(&mut self) -> T
Clone
self and take its node.source§fn clone_without_node(&self) -> T
fn clone_without_node(&self) -> T
Clone
self without taking its node.source§impl<T> Convert for T
impl<T> Convert for T
source§fn convert<U>(self, context: &CompileContext) -> Expr<U>where
U: ConvertFrom<T>,
fn convert<U>(self, context: &CompileContext) -> Expr<U>where
U: ConvertFrom<T>,
Convert
self into a specific type. Read moresource§fn can_convert<U>(&self) -> boolwhere
U: ConvertFrom<T>,
fn can_convert<U>(&self) -> boolwhere
U: ConvertFrom<T>,
Check if
self can be converted into a specific type. Read more