Module validated

Module validated 

Source
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 validation
  • RealRugStrictFinite<PRECISION>: Validated arbitrary-precision real numbers
  • ComplexRugStrictFinite<PRECISION>: Validated arbitrary-precision complex numbers

§Precision

Precision is specified as a const generic parameter representing the number of bits in the significand:

  • 53 bits: Equivalent to f64 precision
  • 100 bits: ~30 decimal digits
  • 200 bits: ~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§

ComplexRugStrictFinite
A type alias for a validated complex scalar using the Rug kernel with a specified precision and the NumKernelStrictFinite validation policy.
RealRugStrictFinite
A type alias for a validated real scalar using the Rug kernel with a specified precision and the NumKernelStrictFinite validation policy.
RugStrictFinite
A type alias for a numerical kernel that uses rug for arbitrary-precision arithmetic with strict finiteness checks.