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§
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>
Required Methods§
Sourcefn as_real(self) -> Self::Real
fn as_real(self) -> Self::Real
Converts self to a real number, discarding any imaginary component, if complex.
Sourcefn as_natural(self) -> Self::Natural
fn as_natural(self) -> Self::Natural
Converts self to a natural number, truncating when necessary.
Sourcefn as_integer(self) -> Self::Integer
fn as_integer(self) -> Self::Integer
Converts self to an integer, truncating when necessary.
Sourcefn floor(self) -> Self
fn floor(self) -> Self
Rounds the real and imaginary components of self to the closest integer downward
Sourcefn ceil(self) -> Self
fn ceil(self) -> Self
Rounds the real and imaginary components of self to the closest integer upward
Provided Methods§
Sourcefn modulus_sqrd(self) -> Self
fn modulus_sqrd(self) -> Self
The square of the complex absolute value of self
This is computed as self * self.conj() by default
Sourcefn modulus(self) -> Self::Real
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.