pub trait CustomNumeric:
Copy
+ Debug
+ PartialOrd
+ Display
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ Neg<Output = Self>
+ Zero
+ ComplexField {
// Required methods
fn from_f64_unchecked(x: f64) -> Self;
fn convert_from<U: CustomNumeric + 'static>(value: U) -> Self;
fn to_f64(self) -> f64;
fn epsilon() -> Self;
fn pi() -> Self;
fn max(self, other: Self) -> Self;
fn min(self, other: Self) -> Self;
fn is_valid(&self) -> bool;
fn abs_as_same_type(self) -> Self;
fn exp_m1(self) -> Self;
}Expand description
Custom numeric trait for high-precision numerical computation
This trait provides the essential numeric operations needed for gauss module and matrix_from_gauss functions. Supports both f64 and Df64 types.
Uses standard traits for common operations:
- num_traits::Zero for zero()
- simba::scalar::ComplexField for mathematical functions (abs, sqrt, cos, sin, exp, etc.)
- ComplexField::is_finite() for is_finite()
Required Methods§
Sourcefn from_f64_unchecked(x: f64) -> Self
fn from_f64_unchecked(x: f64) -> Self
Convert from f64 to Self (direct conversion, no Option)
This is a static method that can be called as T::from_f64_unchecked(x) Renamed to avoid conflict with num_traits::FromPrimitive::from_f64
Sourcefn convert_from<U: CustomNumeric + 'static>(value: U) -> Self
fn convert_from<U: CustomNumeric + 'static>(value: U) -> Self
Convert from any CustomNumeric type to Self (generic conversion)
This allows conversion between different numeric types while preserving precision. Can be called as T::convert_from(other_numeric_value)
Sourcefn abs_as_same_type(self) -> Self
fn abs_as_same_type(self) -> Self
Check if the value is finite (not NaN or infinite) Get absolute value as the same type (convenience method)
This method wraps ComplexField::abs() and converts the result back to Self to avoid type conversion issues in generic code. Note: Only abs() has this problem - other math functions (exp, cos, sin, sqrt) already return Self directly from ComplexField.
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 CustomNumeric for f64
f64 implementation of CustomNumeric
impl CustomNumeric for f64
f64 implementation of CustomNumeric
fn from_f64_unchecked(x: f64) -> Self
fn convert_from<U: CustomNumeric + 'static>(value: U) -> Self
fn to_f64(self) -> f64
fn epsilon() -> Self
fn pi() -> Self
fn max(self, other: Self) -> Self
fn min(self, other: Self) -> Self
fn is_valid(&self) -> bool
fn abs_as_same_type(self) -> Self
fn exp_m1(self) -> Self
Implementors§
impl CustomNumeric for Df64
Df64 implementation of CustomNumeric