pub struct Complex {
pub real: f64,
pub imaginary: f64,
}
Expand description
Represents a complex number
Fields§
§real: f64
The real part
imaginary: f64
The 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§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