Complex

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: Complex

The complex number 0 + 0i

Source

pub const ONE: Complex

The complex number 1 + 0i

Source

pub const I: Complex

The complex number 0 + 1i

Source

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

Create a new complex number

Source

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

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

Source

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

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

Source

pub fn floor(self) -> Complex

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

Source

pub fn ceil(self) -> Complex

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

Source

pub fn round(self) -> Complex

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<Complex>) -> Complex

Get the arctangent of a complex number

Source

pub fn normalize(self) -> Complex

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) -> Complex

Convert polar coordinates to a complex number

Source

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

Raise a complex number to a complex power

Source

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

Raise a complex number to a real power

Source

pub fn exp(self) -> Complex

Calculate the exponential of a complex number

Source

pub fn ln(self) -> Complex

Calculate the natural logarithm of a complex number

Source

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

Calculate the logarithm of a complex number

Source

pub fn sqrt(self) -> Complex

Calculate the square root of a complex number

Source

pub fn sin(self) -> Complex

Calculate the sine of a complex number

Source

pub fn cos(self) -> Complex

Calculate the cosine of a complex number

Source

pub fn asin(self) -> Complex

Calculate the arc sine of a complex number

Source

pub fn acos(self) -> Complex

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

Source

pub fn safe_mul(self, rhs: impl Into<Complex>) -> Complex

Multiply by another complex number, with 0 × ∞ = 0

Source

pub fn recip(self) -> Complex

Trait Implementations§

Source§

impl Add<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> <Complex as Add<f64>>::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: Complex) -> <Complex as Add>::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<FillValue<Self>, &'static str>

Get the scalar fill value from the environment
Source§

fn get_array_fill( fill: &Fill<'_>, ) -> Result<FillValue<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 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 sort_list(list: &mut [Self], up: bool)

Sort a list of this type
Source§

fn is_sortable(&self) -> bool

Whether this value can be sorted
Source§

fn dbg_validate(arr: &Array<Self>)

Validate array correctness in debug mode
Source§

impl Clone for Complex

Source§

fn clone(&self) -> Complex

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 Debug for Complex

Source§

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

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<Complex, <__D as Deserializer<'de>>::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<(), Error>

Formats the value using the given formatter. 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) -> <Complex as Div<f64>>::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: Complex) -> <Complex as Div>::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(_: (f64, f64)) -> Complex

Converts to this type from the input type.
Source§

impl From<Complex> for NumWord

Source§

fn from(value: Complex) -> NumWord

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) -> Complex

Converts to this type from the input type.
Source§

impl From<u8> for Complex

Source§

fn from(value: u8) -> Complex

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<f64> for Complex

Source§

type Output = Complex

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> <Complex as Mul<f64>>::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: Complex) -> <Complex as Mul>::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) -> <Complex as Neg>::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Complex

Source§

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

Source§

type Output = Complex

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f64) -> <Complex as Rem<f64>>::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: Complex) -> <Complex as Rem>::Output

Performs the % operation. Read more
Source§

impl Serialize for Complex

Source§

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

Serialize this value into the given Serde serializer. 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) -> <Complex as Sub<f64>>::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: Complex) -> <Complex as Sub>::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 Zeroable for Complex

Source§

fn zeroed() -> Self

Source§

impl Copy for Complex

Source§

impl Eq for Complex

Source§

impl Pod 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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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<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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<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.
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> AnyBitPattern for T
where T: Pod,

Source§

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

Source§

impl<T> NoUninit for T
where T: Pod,

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>,

Source§

impl<T> SendSyncNative for T
where T: Send + Sync,