uiua

Struct Complex

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

Uiua’s complex number type

Fields§

§re: f64

The real part

§im: f64

The imaginary part

Implementations§

Source§

impl Complex

Source

pub const ZERO: Self = _

The complex number 0 + 0i

Source

pub const ONE: Self = _

The complex number 1 + 0i

Source

pub const I: Self = _

The complex number 0 + 1i

Source

pub fn new(re: f64, im: f64) -> Self

Create a new complex number

Source

pub fn min(self, rhs: impl Into<Self>) -> Self

Get the minimum of the real and imaginary parts of two complex numbers, ignoring NaN

Source

pub fn max(self, rhs: impl Into<Self>) -> Self

Get the maximum of the real and imaginary parts of two complex numbers, ignoring NaN

Source

pub fn floor(self) -> Self

Get the floor of the real and imaginary parts of a complex number

Source

pub fn ceil(self) -> Self

Get the ceiling of the real and imaginary parts of a complex number

Source

pub fn round(self) -> Self

Round the real and imaginary parts of a complex number

Source

pub fn abs(self) -> f64

Get the absolute value of a complex number

Source

pub fn atan2(self, x: impl Into<Self>) -> Complex

Get the arctangent of a complex number

Source

pub fn normalize(self) -> Self

Normalize a complex number

Source

pub fn arg(self) -> f64

Calculate the principal value of the complex number

Source

pub fn to_polar(self) -> (f64, f64)

Convert a complex number to polar coordinates

Source

pub fn from_polar(r: f64, theta: f64) -> Self

Convert polar coordinates to a complex number

Source

pub fn powc(self, power: impl Into<Self>) -> Self

Raise a complex number to a complex power

Source

pub fn powf(self, power: f64) -> Self

Raise a complex number to a real power

Source

pub fn exp(self) -> Self

Calculate the exponential of a complex number

Source

pub fn ln(self) -> Self

Calculate the natural logarithm of a complex number

Source

pub fn log(self, base: impl Into<Self>) -> Self

Calculate the logarithm of a complex number

Source

pub fn sqrt(self) -> Self

Calculate the square root of a complex number

Source

pub fn sin(self) -> Self

Calculate the sine of a complex number

Source

pub fn cos(self) -> Self

Calculate the cosine of a complex number

Source

pub fn asin(self) -> Self

Calculate the arc sine of a complex number

Source

pub fn acos(self) -> Self

Calculate the arc cosine of a complex number

Source

pub fn is_nan(&self) -> bool

Check if either real or imaginary part is NaN

Source

pub fn into_real(self) -> Option<f64>

Get the complex number as a real number

Trait Implementations§

Source§

impl Add<Complex> for f64

Source§

type Output = Complex

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for Complex

Source§

type Output = Complex

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T> AddAssign<T> for Complex
where Complex: Add<T, Output = Complex>,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl ArrayCmp for Complex

Source§

fn array_cmp(&self, other: &Self) -> Ordering

Compare two elements
Source§

fn array_eq(&self, other: &U) -> bool

Check if two elements are equal
Source§

impl ArrayValue for Complex

Source§

const NAME: &'static str = "complex"

The type name
Source§

const SYMBOL: char = 'ℂ'

A glyph indicating the type
Source§

const TYPE_ID: u8 = 3u8

An ID for the type
Source§

fn get_scalar_fill(fill: &Fill<'_>) -> Result<Self, &'static str>

Get the scalar fill value from the environment
Source§

fn get_array_fill(fill: &Fill<'_>) -> Result<Array<Self>, &'static str>

Get the array fill value from the environment
Source§

fn array_hash<H: Hasher>(&self, hasher: &mut H)

Hash the value
Source§

fn proxy() -> Self

Get the proxy value
Source§

fn empty_list_inner() -> &'static str

Marker for empty lists in grid formatting
Source§

fn summarize(elems: &[Self]) -> String

Summarize the elements of an array of this type
Source§

fn format_delims() -> (&'static str, &'static str)

Delimiters for formatting
Source§

fn format_sep() -> &'static str

Separator for formatting
Source§

fn grid_fmt_delims(boxed: bool) -> (char, char)

Delimiters for grid formatting
Source§

fn compress_list_grid() -> bool

Whether to compress all items of a list when grid formatting
Source§

fn nested_value(&self) -> Option<&Value>

Get a nested value
Source§

fn has_wildcard(&self) -> bool

Check if this element has the wildcard value
Source§

fn summary_min_elems() -> usize

The minimum number of elements that require a summary
Source§

fn alignment() -> ElemAlign

How to align elements when formatting
Source§

fn max_col_width<'a>(rows: impl Iterator<Item = &'a [char]> + Clone) -> usize

How to determine the maximum width of a formatted column
Source§

impl Clone for Complex

Source§

fn clone(&self) -> Complex

Returns a copy 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 Debug for Complex

Source§

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

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

impl Default for Complex

Source§

fn default() -> Complex

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

impl<'de> Deserialize<'de> for Complex

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Complex

Source§

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

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

impl Div<Complex> for f64

Source§

type Output = Complex

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div for Complex

Source§

type Output = Complex

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for Complex
where Complex: Div<T, Output = Complex>,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl From<(f64, f64)> for Complex

Source§

fn from((re, im): (f64, f64)) -> Self

Converts to this type from the input type.
Source§

impl From<Complex> for (f64, f64)

Source§

fn from(c: Complex) -> Self

Converts to this type from the input type.
Source§

impl From<Complex> for Value

Source§

fn from(item: Complex) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Complex

Source§

fn from(re: f64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Complex

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Complex> for Value

Source§

fn from_iter<I: IntoIterator<Item = Complex>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Mul<Complex> for f64

Source§

type Output = Complex

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for Complex

Source§

type Output = Complex

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Complex
where Complex: Mul<T, Output = Complex>,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl Neg for Complex

Source§

type Output = Complex

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Complex

Source§

fn eq(&self, other: &Self) -> 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 PartialOrd for Complex

Source§

fn partial_cmp(&self, other: &Complex) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rem<Complex> for f64

Source§

type Output = Complex

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Complex) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for Complex

Source§

type Output = Complex

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl Serialize for Complex

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub<Complex> for f64

Source§

type Output = Complex

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for Complex

Source§

type Output = Complex

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T> SubAssign<T> for Complex
where Complex: Sub<T, Output = Complex>,

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl Copy for Complex

Source§

impl Eq for Complex

Auto Trait Implementations§

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, dst: *mut u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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§

default 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,