pub trait RawScalarTrait:
Serialize
+ Debug
+ Display
+ Clone
+ Sync
+ Send
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ for<'a> Add<&'a Self, Output = Self>
+ for<'a> Sub<&'a Self, Output = Self>
+ for<'a> Mul<&'a Self, Output = Self>
+ for<'a> Div<&'a Self, Output = Self>
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
+ for<'a> AddAssign<&'a Self>
+ for<'a> SubAssign<&'a Self>
+ for<'a> MulAssign<&'a Self>
+ for<'a> DivAssign<&'a Self>
+ Neg<Output = Self>
+ NegAssign
+ NeumaierAddable
+ PartialEq
+ FpChecks
+ 'static {
type ValidationErrors: Error;
Show 35 methods
// Required methods
fn is_zero(&self) -> bool;
fn raw_zero(precision: u32) -> Self;
fn raw_one(precision: u32) -> Self;
fn unchecked_reciprocal(self) -> Self;
fn unchecked_exp(self) -> Self;
fn unchecked_sqrt(self) -> Self;
fn unchecked_sin(self) -> Self;
fn unchecked_asin(self) -> Self;
fn unchecked_cos(self) -> Self;
fn unchecked_acos(self) -> Self;
fn unchecked_tan(self) -> Self;
fn unchecked_atan(self) -> Self;
fn unchecked_sinh(self) -> Self;
fn unchecked_asinh(self) -> Self;
fn unchecked_cosh(self) -> Self;
fn unchecked_acosh(self) -> Self;
fn unchecked_tanh(self) -> Self;
fn unchecked_atanh(self) -> Self;
fn unchecked_ln(self) -> Self;
fn unchecked_log2(self) -> Self;
fn unchecked_log10(self) -> Self;
fn unchecked_pow_exponent_i8(self, exponent: &i8) -> Self;
fn unchecked_pow_exponent_i16(self, exponent: &i16) -> Self;
fn unchecked_pow_exponent_i32(self, exponent: &i32) -> Self;
fn unchecked_pow_exponent_i64(self, exponent: &i64) -> Self;
fn unchecked_pow_exponent_i128(self, exponent: &i128) -> Self;
fn unchecked_pow_exponent_isize(self, exponent: &isize) -> Self;
fn unchecked_pow_exponent_u8(self, exponent: &u8) -> Self;
fn unchecked_pow_exponent_u16(self, exponent: &u16) -> Self;
fn unchecked_pow_exponent_u32(self, exponent: &u32) -> Self;
fn unchecked_pow_exponent_u64(self, exponent: &u64) -> Self;
fn unchecked_pow_exponent_u128(self, exponent: &u128) -> Self;
fn unchecked_pow_exponent_usize(self, exponent: &usize) -> Self;
fn unchecked_mul_add(self, b: &Self, c: &Self) -> Self;
// Provided method
fn raw_negative_one(precision: u32) -> Self { ... }
}
Expand description
A baseline trait for raw scalar types, defining core operations and properties.
This trait must be implemented by the underlying number types used in a kernel,
such as like f64
or rug::Float
.
It provides a standard interface for arithmetic
and a suite of unchecked_*
methods for mathematical functions.
§Safety and Contracts
The unchecked_*
methods are designed for performance and assume that the caller
has already validated the inputs. Calling them with invalid data (e.g., unchecked_sqrt
on a negative real number) may lead to panics, incorrect results, or undefined behavior,
depending on the underlying type’s implementation.
Required Associated Types§
Sourcetype ValidationErrors: Error
type ValidationErrors: Error
The associated error type for validation failures of this raw type.
Required Methods§
fn is_zero(&self) -> bool
fn raw_zero(precision: u32) -> Self
fn raw_one(precision: u32) -> Self
Sourcefn unchecked_reciprocal(self) -> Self
fn unchecked_reciprocal(self) -> Self
Computes the reciprocal (1/x) without validation.
Contract: The caller must ensure self
is not zero.
Sourcefn unchecked_exp(self) -> Self
fn unchecked_exp(self) -> Self
Computes the exponential (e^x) without validation.
Contract: The caller must ensure the input is valid.
Sourcefn unchecked_sqrt(self) -> Self
fn unchecked_sqrt(self) -> Self
Computes the square root without validation.
Contract: For real numbers, the caller must ensure self >= 0
.
fn unchecked_sin(self) -> Self
fn unchecked_asin(self) -> Self
fn unchecked_cos(self) -> Self
fn unchecked_acos(self) -> Self
fn unchecked_tan(self) -> Self
fn unchecked_atan(self) -> Self
fn unchecked_sinh(self) -> Self
fn unchecked_asinh(self) -> Self
fn unchecked_cosh(self) -> Self
fn unchecked_acosh(self) -> Self
fn unchecked_tanh(self) -> Self
fn unchecked_atanh(self) -> Self
fn unchecked_ln(self) -> Self
fn unchecked_log2(self) -> Self
fn unchecked_log10(self) -> Self
Sourcefn unchecked_pow_exponent_i8(self, exponent: &i8) -> Self
fn unchecked_pow_exponent_i8(self, exponent: &i8) -> Self
Raises self
to the power of an i8
exponent without validation.
Contract: The caller must ensure the inputs are valid.
Sourcefn unchecked_pow_exponent_i16(self, exponent: &i16) -> Self
fn unchecked_pow_exponent_i16(self, exponent: &i16) -> Self
Raises self
to the power of an i16
exponent without validation.
Contract: The caller must ensure the inputs are valid.
Sourcefn unchecked_pow_exponent_i32(self, exponent: &i32) -> Self
fn unchecked_pow_exponent_i32(self, exponent: &i32) -> Self
Raises self
to the power of an i32
exponent without validation.
Contract: The caller must ensure the inputs are valid.
Sourcefn unchecked_pow_exponent_i64(self, exponent: &i64) -> Self
fn unchecked_pow_exponent_i64(self, exponent: &i64) -> Self
Raises self
to the power of an i64
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_pow_exponent_i128(self, exponent: &i128) -> Self
fn unchecked_pow_exponent_i128(self, exponent: &i128) -> Self
Raises self
to the power of an i128
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_pow_exponent_isize(self, exponent: &isize) -> Self
fn unchecked_pow_exponent_isize(self, exponent: &isize) -> Self
Raises self
to the power of an isize
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_pow_exponent_u8(self, exponent: &u8) -> Self
fn unchecked_pow_exponent_u8(self, exponent: &u8) -> Self
Raises self
to the power of an u8
exponent without validation.
Contract: The caller must ensure the inputs are valid.
Sourcefn unchecked_pow_exponent_u16(self, exponent: &u16) -> Self
fn unchecked_pow_exponent_u16(self, exponent: &u16) -> Self
Raises self
to the power of an u16
exponent without validation.
Contract: The caller must ensure the inputs are valid.
Sourcefn unchecked_pow_exponent_u32(self, exponent: &u32) -> Self
fn unchecked_pow_exponent_u32(self, exponent: &u32) -> Self
Raises self
to the power of an u32
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_pow_exponent_u64(self, exponent: &u64) -> Self
fn unchecked_pow_exponent_u64(self, exponent: &u64) -> Self
Raises self
to the power of an u64
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_pow_exponent_u128(self, exponent: &u128) -> Self
fn unchecked_pow_exponent_u128(self, exponent: &u128) -> Self
Raises self
to the power of an u128
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_pow_exponent_usize(self, exponent: &usize) -> Self
fn unchecked_pow_exponent_usize(self, exponent: &usize) -> Self
Raises self
to the power of an usize
exponent without validation.
Contract: The caller must ensure the inputs are valid. For integer powers, this
includes ensuring the exponent
is within the representable range of the underlying
power function (e.g., i32
for f64::powi
).
Sourcefn unchecked_mul_add(self, b: &Self, c: &Self) -> Self
fn unchecked_mul_add(self, b: &Self, c: &Self) -> Self
Multiplies and adds in one fused operation, rounding to the nearest with only one rounding error.
a.mul_add(b, c)
produces a result like a * &b + &c
.
Contract: The caller must ensure all inputs are valid.
Provided Methods§
fn raw_negative_one(precision: u32) -> Self
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 RawScalarTrait for f64
impl RawScalarTrait for f64
Source§fn unchecked_mul_add(self, b: &Self, c: &Self) -> Self
fn unchecked_mul_add(self, b: &Self, c: &Self) -> Self
Multiplies and adds in one fused operation, rounding to the nearest with only one rounding error.
a.mul_add(b, c)
produces a result like a * &b + &c
.
type ValidationErrors = ErrorsValidationRawReal<f64>
fn raw_zero(_precision: u32) -> f64
fn is_zero(&self) -> bool
fn raw_one(_precision: u32) -> f64
fn unchecked_reciprocal(self) -> f64
fn unchecked_exp(self) -> f64
fn unchecked_sqrt(self) -> f64
fn unchecked_sin(self) -> f64
fn unchecked_asin(self) -> f64
fn unchecked_cos(self) -> f64
fn unchecked_acos(self) -> f64
fn unchecked_tan(self) -> f64
fn unchecked_atan(self) -> f64
fn unchecked_sinh(self) -> f64
fn unchecked_asinh(self) -> f64
fn unchecked_cosh(self) -> f64
fn unchecked_acosh(self) -> f64
fn unchecked_tanh(self) -> f64
fn unchecked_atanh(self) -> f64
fn unchecked_ln(self) -> f64
fn unchecked_log2(self) -> f64
fn unchecked_log10(self) -> f64
fn unchecked_pow_exponent_i8(self, exponent: &i8) -> f64
fn unchecked_pow_exponent_i16(self, exponent: &i16) -> f64
fn unchecked_pow_exponent_u8(self, exponent: &u8) -> f64
fn unchecked_pow_exponent_u16(self, exponent: &u16) -> f64
fn unchecked_pow_exponent_i32(self, exponent: &i32) -> Self
fn unchecked_pow_exponent_i64(self, exponent: &i64) -> f64
fn unchecked_pow_exponent_i128(self, exponent: &i128) -> f64
fn unchecked_pow_exponent_isize(self, exponent: &isize) -> f64
fn unchecked_pow_exponent_u32(self, exponent: &u32) -> f64
fn unchecked_pow_exponent_u64(self, exponent: &u64) -> f64
fn unchecked_pow_exponent_u128(self, exponent: &u128) -> f64
fn unchecked_pow_exponent_usize(self, exponent: &usize) -> f64
Source§impl RawScalarTrait for Complex<f64>
impl RawScalarTrait for Complex<f64>
Source§fn unchecked_mul_add(self, b: &Self, c: &Self) -> Self
fn unchecked_mul_add(self, b: &Self, c: &Self) -> Self
Multiplies and adds in one fused operation, rounding to the nearest with only one rounding error.
a.mul_add(b, c)
produces a result like a * &b + &c
.