Module numeric

Module numeric 

Source
Expand description

Numeric traits and utilities for SciRS2

This module provides unified access to numeric traits and complex numbers.

§SciRS2 POLICY Compliance

This is the only module in the SciRS2 ecosystem that should directly import external numeric libraries. All other crates must use this module.

§Re-exports

  • num_traits: All numeric traits (Float, Zero, One, etc.)
  • num_complex: Complex number types
  • num_integer: Integer-specific functions (gcd, lcm, etc.)

Re-exports§

pub use num_traits;
pub use num_complex;
pub use num_integer;

Modules§

advanced_simd
Advanced-optimized SIMD operations for numerical computations
precision_tracking
Automated precision tracking for numerical computations
scientific_types
Specialized numeric types for scientific domains
stability
Numerical stability improvements
stable_algorithms
Stable numerical algorithms

Structs§

Complex
Complete re-export of num-complex for SciRS2 ecosystem A complex number in Cartesian form.
ExtendedGcd
Complete re-export of num-integer for SciRS2 ecosystem Greatest common divisor and Bézout coefficients
Scalar
Type-safe representation of a unitless quantity

Traits§

AngleConversion
Trait for converting between degrees and radians
AsPrimitive
Complete re-export of num-traits for SciRS2 ecosystem A generic interface for casting between machine scalars with the as operator, which admits narrowing and precision loss. Implementers of this trait AsPrimitive should behave like a primitive numeric type (e.g. a newtype around another primitive), and the intended conversion must never fail.
Average
Complete re-export of num-integer for SciRS2 ecosystem Provides methods to compute the average of two integers, without overflows.
Bounded
Complete re-export of num-traits for SciRS2 ecosystem Numbers which have upper and lower bounds
CheckedAdd
Complete re-export of num-traits for SciRS2 ecosystem Performs addition that returns None instead of wrapping around on overflow.
CheckedDiv
Complete re-export of num-traits for SciRS2 ecosystem Performs division that returns None instead of panicking on division by zero and instead of wrapping around on underflow and overflow.
CheckedMul
Complete re-export of num-traits for SciRS2 ecosystem Performs multiplication that returns None instead of wrapping around on underflow or overflow.
CheckedNeg
Complete re-export of num-traits for SciRS2 ecosystem Performs negation that returns None if the result can’t be represented.
CheckedRem
Complete re-export of num-traits for SciRS2 ecosystem Performs an integral remainder that returns None instead of panicking on division by zero and instead of wrapping around on underflow and overflow.
CheckedShl
Complete re-export of num-traits for SciRS2 ecosystem Performs a left shift that returns None on shifts larger than or equal to the type width.
CheckedShr
Complete re-export of num-traits for SciRS2 ecosystem Performs a right shift that returns None on shifts larger than or equal to the type width.
CheckedSub
Complete re-export of num-traits for SciRS2 ecosystem Performs subtraction that returns None instead of wrapping around on underflow.
ComplexFloat
Complete re-export of num-complex for SciRS2 ecosystem Generic trait for floating point complex numbers.
ComplexNumber
A trait for complex number types
Float
Complete re-export of num-traits for SciRS2 ecosystem Generic trait for floating point numbers
FloatConst
Complete re-export of num-traits for SciRS2 ecosystem
FromPrimitive
Complete re-export of num-traits for SciRS2 ecosystem A generic trait for converting a number to a value.
Integer
Complete re-export of num-integer for SciRS2 ecosystem
Inv
Complete re-export of num-traits for SciRS2 ecosystem Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value.
MulAdd
Complete re-export of num-traits for SciRS2 ecosystem Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.
MulAddAssign
Complete re-export of num-traits for SciRS2 ecosystem The fused multiply-add assignment operation *self = (*self * a) + b
Num
Complete re-export of num-traits for SciRS2 ecosystem The base trait for numeric types, covering 0 and 1 values, comparisons, basic numeric operations, and string conversion.
NumAssign
Complete re-export of num-traits for SciRS2 ecosystem The trait for Num types which also implement assignment operators.
NumAssignOps
Complete re-export of num-traits for SciRS2 ecosystem Generic trait for types implementing numeric assignment operators (like +=).
NumAssignRef
Complete re-export of num-traits for SciRS2 ecosystem The trait for NumAssign types which also implement assignment operations taking the second operand by reference.
NumCast
Complete re-export of num-traits for SciRS2 ecosystem An interface for casting between machine scalars.
NumOps
Complete re-export of num-traits for SciRS2 ecosystem Generic trait for types implementing basic numeric operations
NumRef
Complete re-export of num-traits for SciRS2 ecosystem The trait for Num types which also implement numeric operations taking the second operand by reference.
NumericConversion
Conversion between different numeric types
One
Complete re-export of num-traits for SciRS2 ecosystem Defines a multiplicative identity element for Self.
Pow
Complete re-export of num-traits for SciRS2 ecosystem Binary operator for raising a value to a power.
PrimInt
Complete re-export of num-traits for SciRS2 ecosystem Generic trait for primitive integers.
Real
Complete re-export of num-traits for SciRS2 ecosystem A trait for real number types that do not necessarily have floating-point-specific characteristics such as NaN and infinity.
RealNumber
A trait for real-valued floating point types
Roots
Complete re-export of num-integer for SciRS2 ecosystem Provides methods to compute an integer’s square root, cube root, and arbitrary nth root.
Saturating
Complete re-export of num-traits for SciRS2 ecosystem Saturating math operations. Deprecated, use SaturatingAdd, SaturatingSub and SaturatingMul instead.
SaturatingAdd
Complete re-export of num-traits for SciRS2 ecosystem Performs addition that saturates at the numeric bounds instead of overflowing.
SaturatingMul
Complete re-export of num-traits for SciRS2 ecosystem Performs multiplication that saturates at the numeric bounds instead of overflowing.
SaturatingSub
Complete re-export of num-traits for SciRS2 ecosystem Performs subtraction that saturates at the numeric bounds instead of overflowing.
ScientificInteger
A trait for integers that can be used in scientific calculations
ScientificNumber
A trait for numeric types that can be used in scientific calculations
Signed
Complete re-export of num-traits for SciRS2 ecosystem Useful functions for signed numbers (i.e. numbers that can be negative).
ToPrimitive
Complete re-export of num-traits for SciRS2 ecosystem A generic trait for converting a value to a number.
Unsigned
Complete re-export of num-traits for SciRS2 ecosystem A trait for values which cannot be negative
WrappingAdd
Complete re-export of num-traits for SciRS2 ecosystem Performs addition that wraps around on overflow.
WrappingMul
Complete re-export of num-traits for SciRS2 ecosystem Performs multiplication that wraps around on overflow.
WrappingNeg
Complete re-export of num-traits for SciRS2 ecosystem Performs a negation that does not panic.
WrappingShl
Complete re-export of num-traits for SciRS2 ecosystem Performs a left shift that does not panic.
WrappingShr
Complete re-export of num-traits for SciRS2 ecosystem Performs a right shift that does not panic.
WrappingSub
Complete re-export of num-traits for SciRS2 ecosystem Performs subtraction that wraps around on overflow.
Zero
Complete re-export of num-traits for SciRS2 ecosystem Defines an additive identity element for Self.

Functions§

checked_pow
Complete re-export of num-traits for SciRS2 ecosystem Raises a value to the power of exp, returning None if an overflow occurred.
div_ceil
Complete re-export of num-integer for SciRS2 ecosystem Ceiled integer division
div_floor
Complete re-export of num-integer for SciRS2 ecosystem Floored integer division
div_mod_floor
Complete re-export of num-integer for SciRS2 ecosystem Simultaneous floored integer division and modulus
gcd
Complete re-export of num-integer for SciRS2 ecosystem Calculates the Greatest Common Divisor (GCD) of the number and other. The result is always non-negative.
gcd_lcm
Complete re-export of num-integer for SciRS2 ecosystem Calculates the Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) of the number and other.
lcm
Complete re-export of num-integer for SciRS2 ecosystem Calculates the Lowest Common Multiple (LCM) of the number and other.

Type Aliases§

Complex32
Complete re-export of num-complex for SciRS2 ecosystem Alias for a Complex<f32>
Complex64
Complete re-export of num-complex for SciRS2 ecosystem Alias for a Complex<f64>