Complex

Struct Complex 

Source
#[repr(C)]
pub struct Complex<T> { pub re: T, pub im: T, }
Expand description

Complex number.

Fields§

§re: T§im: T

Implementations§

Source§

impl<T> Complex<T>

Source

pub const fn new(re: T, im: T) -> Complex<T>

Constructs a new complex number from components.

Source§

impl<T: Zero> Complex<T>

Source

pub const ZERO: Complex<T>

Zero complex number.

Source§

impl<T: Zero + One> Complex<T>

Source

pub const UNIT: Complex<T>

Unit complex number.

Source§

impl<T: Float> Complex<T>

Source

pub fn rotate(angle: Angle<T>) -> Complex<T>

Rotating complex number.

Source§

impl<T: Float> Complex<T>

Source

pub fn sqr(self) -> Complex<T>

Squares the complex number.

Source

pub fn abs_sqr(self) -> T

Calculates the squared absolute value.

Source

pub fn abs(self) -> T

Calculates the absolute value.

Source

pub fn arg(self) -> Angle<T>

Calculates the argument (angle).

Source

pub fn conj(self) -> Complex<T>

Calculates the complex conjugate.

Source

pub fn norm(self) -> Complex<T>

Normalizes the complex number.

After normalization, the complex number has an absolute value of 1.0 except zero remains zero.

Source

pub fn polar(self) -> Polar<T>

Converts to polar coordinates.

Source

pub fn recip(self) -> Complex<T>

Calculates the reciprocal.

Source

pub fn powf(self, exp: T) -> Complex<T>

Raises the complex number to a power.

Source

pub fn powi(self, n: i32) -> Complex<T>

Raises the complex number to an integer power.

Source

pub fn ln(self) -> Complex<T>

Calculates the natural logarithm.

Source

pub fn exp(self) -> Complex<T>

Calculates the exponential.

Source§

impl<T: Copy + Neg<Output = T>> Complex<T>

Source

pub fn mat2(self) -> Mat2<T>

Source

pub fn vec2(self) -> Vec2<T>

Trait Implementations§

Source§

impl<T: Add<Output = T>> Add for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: Complex<T>) -> Complex<T>

Performs the + operation. Read more
Source§

impl<T: AddAssign> AddAssign for Complex<T>

Source§

fn add_assign(&mut self, other: Complex<T>)

Performs the += operation. Read more
Source§

impl<T> AsMut<[T; 2]> for Complex<T>

Source§

fn as_mut(&mut self) -> &mut [T; 2]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<[T; 2]> for Complex<T>

Source§

fn as_ref(&self) -> &[T; 2]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Binary> Binary for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone> Clone for Complex<T>

Source§

fn clone(&self) -> Complex<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Complex<T>

Source§

fn default() -> Complex<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Display> Display for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Div<Output = T> + Copy> Div<T> for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Complex<T>

Performs the / operation. Read more
Source§

impl<T: Copy + Mul<Output = T> + Div<Output = T> + Add<Output = T> + Sub<Output = T>> Div for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the / operator.
Source§

fn div(self, other: Complex<T>) -> Complex<T>

Performs the / operation. Read more
Source§

impl<T: Copy + DivAssign> DivAssign<T> for Complex<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Copy + Mul<Output = T> + Div<Output = T> + Add<Output = T> + Sub<Output = T>> DivAssign for Complex<T>

Source§

fn div_assign(&mut self, other: Complex<T>)

Performs the /= operation. Read more
Source§

impl<T> From<Complex<T>> for Vec2<T>

Source§

fn from(complex: Complex<T>) -> Vec2<T>

Converts to this type from the input type.
Source§

impl<T> From<Vec2<T>> for Complex<T>

Source§

fn from(vec: Vec2<T>) -> Complex<T>

Converts to this type from the input type.
Source§

impl<T: FromStr + Default> FromStr for Complex<T>

Source§

type Err = ParseComplexError<<T as FromStr>::Err>

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T: LowerExp> LowerExp for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: LowerHex> LowerHex for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Mul<Output = T> + Copy> Mul<T> for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Complex<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Mul<Output = T> + Add<Output = T> + Sub<Output = T>> Mul<Vec2<T>> for Complex<T>

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec2<T>) -> Vec2<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Mul<Output = T> + Add<Output = T> + Sub<Output = T>> Mul for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Complex<T>) -> Complex<T>

Performs the * operation. Read more
Source§

impl<T: Copy + MulAssign> MulAssign<T> for Complex<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Copy + Mul<Output = T> + Add<Output = T> + Sub<Output = T>> MulAssign for Complex<T>

Source§

fn mul_assign(&mut self, other: Complex<T>)

Performs the *= operation. Read more
Source§

impl<T: Neg<Output = T>> Neg for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Complex<T>

Performs the unary - operation. Read more
Source§

impl<T: Octal> Octal for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq> PartialEq for Complex<T>

Source§

fn eq(&self, other: &Complex<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Sub<Output = T>> Sub for Complex<T>

Source§

type Output = Complex<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Complex<T>) -> Complex<T>

Performs the - operation. Read more
Source§

impl<T: SubAssign> SubAssign for Complex<T>

Source§

fn sub_assign(&mut self, other: Complex<T>)

Performs the -= operation. Read more
Source§

impl<T: UpperExp> UpperExp for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: UpperHex> UpperHex for Complex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy> Copy for Complex<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.