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 typesnum_integer: Integer-specific functions (gcd, lcm, etc.)
Modules§
- advanced_
simd - Advanced-optimized SIMD operations for numerical computations
- num_
complex - Complex numbers.
- num_
integer - Integer trait and functions.
- num_
traits - Numeric traits for generic mathematics
- 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
- A complex number in Cartesian form.
- Extended
Gcd - Greatest common divisor and Bézout coefficients
- Scalar
- Type-safe representation of a unitless quantity
Traits§
- Angle
Conversion - Trait for converting between degrees and radians
- AsPrimitive
- A generic interface for casting between machine scalars with the
asoperator, which admits narrowing and precision loss. Implementers of this traitAsPrimitiveshould behave like a primitive numeric type (e.g. a newtype around another primitive), and the intended conversion must never fail. - Average
- Provides methods to compute the average of two integers, without overflows.
- Bounded
- Numbers which have upper and lower bounds
- Checked
Add - Performs addition that returns
Noneinstead of wrapping around on overflow. - Checked
Div - Performs division that returns
Noneinstead of panicking on division by zero and instead of wrapping around on underflow and overflow. - Checked
Mul - Performs multiplication that returns
Noneinstead of wrapping around on underflow or overflow. - Checked
Neg - Performs negation that returns
Noneif the result can’t be represented. - Checked
Rem - Performs an integral remainder that returns
Noneinstead of panicking on division by zero and instead of wrapping around on underflow and overflow. - Checked
Shl - Performs a left shift that returns
Noneon shifts larger than or equal to the type width. - Checked
Shr - Performs a right shift that returns
Noneon shifts larger than or equal to the type width. - Checked
Sub - Performs subtraction that returns
Noneinstead of wrapping around on underflow. - Complex
Float - Generic trait for floating point complex numbers.
- Complex
Number - A trait for complex number types
- Float
- Generic trait for floating point numbers
- Float
Const - From
Primitive - A generic trait for converting a number to a value.
- Integer
- Inv
- Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value.
- MulAdd
- Fused multiply-add. Computes
(self * a) + bwith only one rounding error, yielding a more accurate result than an unfused multiply-add. - MulAdd
Assign - The fused multiply-add assignment operation
*self = (*self * a) + b - Num
- The base trait for numeric types, covering
0and1values, comparisons, basic numeric operations, and string conversion. - NumAssign
- The trait for
Numtypes which also implement assignment operators. - NumAssign
Ops - Generic trait for types implementing numeric assignment operators (like
+=). - NumAssign
Ref - The trait for
NumAssigntypes which also implement assignment operations taking the second operand by reference. - NumCast
- An interface for casting between machine scalars.
- NumOps
- Generic trait for types implementing basic numeric operations
- NumRef
- The trait for
Numtypes which also implement numeric operations taking the second operand by reference. - Numeric
Conversion - Conversion between different numeric types
- One
- Defines a multiplicative identity element for
Self. - Pow
- Binary operator for raising a value to a power.
- PrimInt
- Generic trait for primitive integers.
- Real
- A trait for real number types that do not necessarily have floating-point-specific characteristics such as NaN and infinity.
- Real
Number - A trait for real-valued floating point types
- Roots
- Provides methods to compute an integer’s square root, cube root,
and arbitrary
nth root. - Saturating
- Saturating math operations. Deprecated, use
SaturatingAdd,SaturatingSubandSaturatingMulinstead. - Saturating
Add - Performs addition that saturates at the numeric bounds instead of overflowing.
- Saturating
Mul - Performs multiplication that saturates at the numeric bounds instead of overflowing.
- Saturating
Sub - Performs subtraction that saturates at the numeric bounds instead of overflowing.
- Scientific
Integer - A trait for integers that can be used in scientific calculations
- Scientific
Number - A trait for numeric types that can be used in scientific calculations
- Signed
- Useful functions for signed numbers (i.e. numbers that can be negative).
- Sparse
Element - Trait for types that can be used as sparse matrix elements
- ToPrimitive
- A generic trait for converting a value to a number.
- Unsigned
- A trait for values which cannot be negative
- Wrapping
Add - Performs addition that wraps around on overflow.
- Wrapping
Mul - Performs multiplication that wraps around on overflow.
- Wrapping
Neg - Performs a negation that does not panic.
- Wrapping
Shl - Performs a left shift that does not panic.
- Wrapping
Shr - Performs a right shift that does not panic.
- Wrapping
Sub - Performs subtraction that wraps around on overflow.
- Zero
- Defines an additive identity element for
Self.
Functions§
- checked_
pow - Raises a value to the power of exp, returning
Noneif an overflow occurred. - div_
ceil - Ceiled integer division
- div_
floor - Floored integer division
- div_
mod_ floor - Simultaneous floored integer division and modulus
- gcd
- Calculates the Greatest Common Divisor (GCD) of the number and
other. The result is always non-negative. - gcd_lcm
- Calculates the Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) of the number and
other. - lcm
- Calculates the Lowest Common Multiple (LCM) of the number and
other.
Type Aliases§
- Complex32
- Alias for a
Complex<f32> - Complex64
- Alias for a
Complex<f64>