Skip to main content

Complex

Struct Complex 

Source
#[repr(C)]
pub struct Complex<T> { pub re: T, pub im: T, }
๐Ÿ”ฌThis is a nightly-only experimental API. (complex_numbers #154023)
Expand description

A complex number.

Fieldsยง

ยงre: T
๐Ÿ”ฌThis is a nightly-only experimental API. (complex_numbers #154023)

The real component.

ยงim: T
๐Ÿ”ฌThis is a nightly-only experimental API. (complex_numbers #154023)

The imaginary component.

Implementationsยง

Sourceยง

impl<T> Complex<T>

Source

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

๐Ÿ”ฌThis is a nightly-only experimental API. (complex_numbers #154023)

Create a new complex number from a real and imaginary component.

Sourceยง

impl<T> Complex<T>
where T: Neg<Output = T>,

Source

pub fn conjugate(self) -> Self

๐Ÿ”ฌThis is a nightly-only experimental API. (complex_numbers #154023)

The complex conjugate of a complex number.

The conjugate of a + bi is a - bi: the imaginary component is negated. Geometrically, this is a reflection across the real axis.

Trait Implementationsยง

Sourceยง

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

Sourceยง

type Output = Complex<<T as Add>::Output>

The resulting type after applying the + operator.
Sourceยง

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Sourceยง

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

Sourceยง

type Output = Complex<<T as Add>::Output>

The resulting type after applying the + operator.
Sourceยง

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Sourceยง

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

Sourceยง

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Performs copy-assignment from source. Read more
Sourceยง

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

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() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Div for Complex<f16>

Sourceยง

type Output = Complex<f16>

The resulting type after applying the / operator.
Sourceยง

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Sourceยง

impl Div for Complex<f32>

Sourceยง

type Output = Complex<f32>

The resulting type after applying the / operator.
Sourceยง

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Sourceยง

impl Div for Complex<f64>

Sourceยง

type Output = Complex<f64>

The resulting type after applying the / operator.
Sourceยง

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Sourceยง

impl Div for Complex<f128>

Sourceยง

type Output = Complex<f128>

The resulting type after applying the / operator.
Sourceยง

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Sourceยง

impl<T: Eq> Eq for Complex<T>

Sourceยง

impl Mul for Complex<f16>

Sourceยง

type Output = Complex<f16>

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Sourceยง

impl Mul for Complex<f32>

Sourceยง

type Output = Complex<f32>

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Sourceยง

impl Mul for Complex<f64>

Sourceยง

type Output = Complex<f64>

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Sourceยง

impl Mul for Complex<f128>

Sourceยง

type Output = Complex<f128>

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Sourceยง

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

Sourceยง

fn neg(self) -> Self::Output

Negate a complex number.

The negation of a + bi is -a - bi: both components are negated. Geometrically this is a rotation of 180ยฐ.

Sourceยง

type Output = Complex<<T as Neg>::Output>

The resulting type after applying the - operator.
Sourceยง

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

Sourceยง

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Inequality operator !=. Read more
Sourceยง

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

Sourceยง

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

Sourceยง

type Output = Complex<<T as Sub>::Output>

The resulting type after applying the - operator.
Sourceยง

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Sourceยง

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

Sourceยง

type Output = Complex<<T as Sub>::Output>

The resulting type after applying the - operator.
Sourceยง

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more

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> UnsafeUnpin for Complex<T>
where T: UnsafeUnpin,

ยง

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 #126799)
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, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.