Expand description
Validated type aliases and kernel configurations for arbitrary-precision types.
§Validated Arbitrary-Precision Types
This module provides validated wrapper types for arbitrary-precision arithmetic using
the rug library, which wraps GNU MPFR.
§Overview
The types in this module combine the power of arbitrary-precision arithmetic with
the safety guarantees of num-valid’s validation system. All values are
guaranteed to be finite and have the correct precision.
§Core Types
RugStrictFinite<PRECISION>: Kernel configuration for arbitrary-precision with strict validationRealRugStrictFinite<PRECISION>: Validated arbitrary-precision real numbersComplexRugStrictFinite<PRECISION>: Validated arbitrary-precision complex numbers
§Precision
Precision is specified as a const generic parameter representing the number of bits in the significand:
53bits: Equivalent tof64precision100bits: ~30 decimal digits200bits: ~60 decimal digits
§Example
use num_valid::{RealRugStrictFinite, functions::Sqrt};
use rug::Float;
use try_create::TryNew;
const PRECISION: u32 = 100;
// Create a validated value from a rug::Float
let x = RealRugStrictFinite::<PRECISION>::try_new(
Float::with_val(PRECISION, 2.0)
).unwrap();
// Mathematical operations are available
let sqrt_x = x.sqrt();§Memory Considerations
Unlike the native f64 backend, rug types are heap-allocated and do not implement
Copy. Use references where possible to avoid unnecessary cloning.
Type Aliases§
- Complex
RugStrict Finite - A type alias for a validated complex scalar using the
Rugkernel with a specified precision and theNumKernelStrictFinitevalidation policy. - Real
RugStrict Finite - A type alias for a validated real scalar using the
Rugkernel with a specified precision and theNumKernelStrictFinitevalidation policy. - RugStrict
Finite - A type alias for a numerical kernel that uses
rugfor arbitrary-precision arithmetic with strict finiteness checks.