Expand description
§Numerical Kernels and Validated Types
This module is the core of the numerical backend for the num-valid crate.
It defines the fundamental traits, types, and operations for floating-point arithmetic.
§Core Architecture
The architecture is built on three key concepts:
-
Raw Traits (
RawScalarTrait,RawRealTrait,RawComplexTrait): These traits define the baseline contract for a “raw” number type (likef64orrug::Float). They provide a comprehensive set ofunchecked_*methods for arithmetic and mathematical functions. The “unchecked” prefix signifies that these methods do not perform any validation (e.g., for domain, finiteness, or division by zero) and are intended for internal use where validity has already been confirmed. -
Validated Structs (
RealValidated,ComplexValidated): These are wrapper types (newtypes) that enforce correctness. An instance ofRealValidated<P>is guaranteed to hold a raw value that has been successfully validated against the policyP. All operations on these types (addition,sqrt, etc.) are designed to preserve this validity, either by returning aResultor by panicking on failure in debug builds. -
Validation Policies (
NumKernel): This trait allows the validation strategy to be generic. A kernel can be configured with different policies, such asNumKernelStrictFinite, which ensures all numbers are finite (not NaN or Infinity).
§Available Kernels
The library provides concrete kernels that bundle these concepts:
Re-exports§
pub use crate::core::types::ComplexValidated;pub use crate::core::types::RealValidated;pub use crate::core::traits::raw::RawComplexTrait;pub use crate::core::traits::raw::RawRealTrait;pub use crate::core::traits::raw::RawScalarHyperbolic;pub use crate::core::traits::raw::RawScalarPow;pub use crate::core::traits::raw::RawScalarTrait;pub use crate::core::traits::raw::RawScalarTrigonometric;
Structs§
- NumKernel
Strict Finite - A strict finite kernel validation policy for raw real numbers. This policy ensures that the real numbers are finite and not NaN.
- NumKernel
Strict Finite InDebug - A debug-only strict finite kernel validation policy for raw real numbers.