Struct uiua::Complex

source ·
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

Trait Implementations§

source§

impl Add<Complex> for f64

§

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

§

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

§

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 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 = 1u8

An ID for the type
source§

fn get_fill(env: &Uiua) -> Result<Self, &'static str>

Get the 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 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§

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

source§

fn debug_string(&self, depth: usize, prefix: bool) -> String

String representation that can be read by the interpreter
source§

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

Row delimiters that can be read by the interpreter
source§

fn debug_separator() -> &'static str

Separator that can be read by the interpreter
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

§

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

§

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

§

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

§

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

§

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

§

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

§

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: &Complex) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Rem<Complex> for f64

§

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

§

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

§

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

§

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

§

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

§

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

source§

impl StructuralPartialEq 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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,

§

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

§

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

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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