pub trait RealScalar:
Clone
+ Copy
+ Sync
+ Send
+ Sized
+ Any
+ Debug
+ Display
+ Sum
+ Product
+ Float
+ FloatConst
+ FromPrimitive
+ ToPrimitive
+ AsPrimitive<f32>
+ AsPrimitive<f64>
+ NumAssign
+ NumAssignRef
+ Default
+ Signed
+ 'static
+ RealField
+ ConstOne
+ ConstZero
+ Memorable
+ BitWidthConvertible<Width32 = f32, Width64 = f64> {
type C: ComplexScalar<R = Self>;
// Required methods
fn into_ratio(self) -> Option<Ratio<BigInt>>;
fn from_ratio(ratio: Ratio<BigInt>) -> Option<Self>;
fn standard_random() -> Self;
fn uniform_random(min: Self, max: Self) -> Self;
fn is_close(self, other: impl RealScalar) -> bool;
fn is_close_with_tolerance(
self,
other: impl RealScalar,
rtol: Self,
atol: Self,
) -> bool;
}Expand description
A generic real number within the OpenQudit library.
Required Associated Types§
Sourcetype C: ComplexScalar<R = Self>
type C: ComplexScalar<R = Self>
The complex number type associated with this real number.
Required Methods§
Sourcefn into_ratio(self) -> Option<Ratio<BigInt>>
fn into_ratio(self) -> Option<Ratio<BigInt>>
Convert this scalar to a rational number representation
Sourcefn from_ratio(ratio: Ratio<BigInt>) -> Option<Self>
fn from_ratio(ratio: Ratio<BigInt>) -> Option<Self>
Create a scalar from a rational number representation
Sourcefn standard_random() -> Self
fn standard_random() -> Self
Generate a random value from the standard normal distribution (mean=0, std=1)
Sourcefn uniform_random(min: Self, max: Self) -> Self
fn uniform_random(min: Self, max: Self) -> Self
Generate a random value from a uniform distribution in the given range [min, max)
Sourcefn is_close(self, other: impl RealScalar) -> bool
fn is_close(self, other: impl RealScalar) -> bool
Check if two values are close using default tolerances
Sourcefn is_close_with_tolerance(
self,
other: impl RealScalar,
rtol: Self,
atol: Self,
) -> bool
fn is_close_with_tolerance( self, other: impl RealScalar, rtol: Self, atol: Self, ) -> bool
Check if two values are close with custom tolerances Uses the formula: abs(a - b) <= (atol + rtol * abs(b))
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.