Trait ComplexSubset

Source
pub trait ComplexSubset:
    PartialEq
    + Clone
    + Semiring {
    type Real: Real + ComplexSubset<Natural = Self::Natural, Integer = Self::Integer, Real = Self::Real>;
    type Natural: Natural + IntegerSubset<Signed = Self::Integer, Unsigned = Self::Natural> + ComplexSubset<Natural = Self::Natural, Integer = Self::Integer, Real = Self::Real>;
    type Integer: Integer + IntegerSubset<Signed = Self::Integer, Unsigned = Self::Natural> + ComplexSubset<Natural = Self::Natural, Integer = Self::Integer, Real = Self::Real>;

Show 13 methods // Required methods fn as_real(self) -> Self::Real; fn as_natural(self) -> Self::Natural; fn as_integer(self) -> Self::Integer; fn floor(self) -> Self; fn ceil(self) -> Self; fn round(self) -> Self; fn trunc(self) -> Self; fn fract(self) -> Self; fn im(self) -> Self; fn re(self) -> Self; fn conj(self) -> Self; // Provided methods fn modulus_sqrd(self) -> Self { ... } fn modulus(self) -> Self::Real { ... }
}
Expand description

An algebraic stucture that is a subset of the Complex numbers

This trait is both meant as an ensapsulation of the naturals, integers, real numbers, and complex numbers. This way, users can work with a particular set of similar-precision numeric types abstractly similarly to how they would normally.

Required Associated Types§

Source

type Real: Real + ComplexSubset<Natural = Self::Natural, Integer = Self::Integer, Real = Self::Real>

Source

type Natural: Natural + IntegerSubset<Signed = Self::Integer, Unsigned = Self::Natural> + ComplexSubset<Natural = Self::Natural, Integer = Self::Integer, Real = Self::Real>

Source

type Integer: Integer + IntegerSubset<Signed = Self::Integer, Unsigned = Self::Natural> + ComplexSubset<Natural = Self::Natural, Integer = Self::Integer, Real = Self::Real>

Required Methods§

Source

fn as_real(self) -> Self::Real

Converts self to a real number, discarding any imaginary component, if complex.

Source

fn as_natural(self) -> Self::Natural

Converts self to a natural number, truncating when necessary.

Source

fn as_integer(self) -> Self::Integer

Converts self to an integer, truncating when necessary.

Source

fn floor(self) -> Self

Rounds the real and imaginary components of self to the closest integer downward

Source

fn ceil(self) -> Self

Rounds the real and imaginary components of self to the closest integer upward

Source

fn round(self) -> Self

Rounds the real and imaginary components of self to the closest integer

Source

fn trunc(self) -> Self

Rounds the real and imaginary components of self by removing the factional parts

Source

fn fract(self) -> Self

Removes the integral parts of the real and imaginary components of self

Source

fn im(self) -> Self

Sets the real component of self to 0

Source

fn re(self) -> Self

Sets the imaginary component of self to 0

Source

fn conj(self) -> Self

The complex conjugate of self

Provided Methods§

Source

fn modulus_sqrd(self) -> Self

The square of the complex absolute value of self

This is computed as self * self.conj() by default

Source

fn modulus(self) -> Self::Real

The complex absolute value of self

This is computed as the square root of modulus_sqrd by default

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ComplexSubset for f32

Source§

type Real = f32

Source§

type Natural = u32

Source§

type Integer = i32

Source§

fn as_real(self) -> Self::Real

Source§

fn as_natural(self) -> Self::Natural

Source§

fn as_integer(self) -> Self::Integer

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn im(self) -> Self

Source§

fn re(self) -> Self

Source§

fn conj(self) -> Self

Source§

fn modulus_sqrd(self) -> Self

Source§

fn modulus(self) -> Self::Real

Source§

impl ComplexSubset for f64

Source§

type Real = f64

Source§

type Natural = u64

Source§

type Integer = i64

Source§

fn as_real(self) -> Self::Real

Source§

fn as_natural(self) -> Self::Natural

Source§

fn as_integer(self) -> Self::Integer

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn im(self) -> Self

Source§

fn re(self) -> Self

Source§

fn conj(self) -> Self

Source§

fn modulus_sqrd(self) -> Self

Source§

fn modulus(self) -> Self::Real

Source§

impl ComplexSubset for i32

Source§

type Real = f32

Source§

type Natural = u32

Source§

type Integer = i32

Source§

fn as_real(self) -> Self::Real

Source§

fn as_natural(self) -> Self::Natural

Source§

fn as_integer(self) -> Self::Integer

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn im(self) -> Self

Source§

fn re(self) -> Self

Source§

fn conj(self) -> Self

Source§

fn modulus_sqrd(self) -> Self

Source§

fn modulus(self) -> Self::Real

Source§

impl ComplexSubset for i64

Source§

type Real = f64

Source§

type Natural = u64

Source§

type Integer = i64

Source§

fn as_real(self) -> Self::Real

Source§

fn as_natural(self) -> Self::Natural

Source§

fn as_integer(self) -> Self::Integer

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn im(self) -> Self

Source§

fn re(self) -> Self

Source§

fn conj(self) -> Self

Source§

fn modulus_sqrd(self) -> Self

Source§

fn modulus(self) -> Self::Real

Source§

impl ComplexSubset for u32

Source§

type Real = f32

Source§

type Natural = u32

Source§

type Integer = i32

Source§

fn as_real(self) -> Self::Real

Source§

fn as_natural(self) -> Self::Natural

Source§

fn as_integer(self) -> Self::Integer

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn im(self) -> Self

Source§

fn re(self) -> Self

Source§

fn conj(self) -> Self

Source§

fn modulus_sqrd(self) -> Self

Source§

fn modulus(self) -> Self::Real

Source§

impl ComplexSubset for u64

Source§

type Real = f64

Source§

type Natural = u64

Source§

type Integer = i64

Source§

fn as_real(self) -> Self::Real

Source§

fn as_natural(self) -> Self::Natural

Source§

fn as_integer(self) -> Self::Integer

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn im(self) -> Self

Source§

fn re(self) -> Self

Source§

fn conj(self) -> Self

Source§

fn modulus_sqrd(self) -> Self

Source§

fn modulus(self) -> Self::Real

Implementors§