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 (likef64
orrug::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 aResult
or 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:
Modules§
- native64
- Native 64-bit Floating-Point Kernel
- native64_
validated - Validated Native 64-bit Kernel Types
- rug
Structs§
- Complex
Validated - A validated complex number that is guaranteed to conform to a specific
NumKernel
. - 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 - Real
Validated - A validated real number that is guaranteed to conform to a specific
NumKernel
.
Traits§
- NumKernel
- Defines a complete numerical kernel, acting as the central configuration point.
- RawComplex
Trait - A trait for raw complex scalar types, extending
RawScalarTrait
. - RawKernel
- Defines the identity of a raw numerical kernel by associating its fundamental types.
- RawReal
Trait - A trait for raw real scalar types, extending
RawScalarTrait
with real-specific operations. - RawScalar
Trait - A baseline trait for raw scalar types, defining core operations and properties.