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.)
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.
- Extended
Gcd - 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§
- Angle
Conversion - 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 traitAsPrimitive
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
- Checked
Add - Complete re-export of num-traits for SciRS2 ecosystem
Performs addition that returns
None
instead of wrapping around on overflow. - Checked
Div - 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. - Checked
Mul - Complete re-export of num-traits for SciRS2 ecosystem
Performs multiplication that returns
None
instead of wrapping around on underflow or overflow. - Checked
Neg - Complete re-export of num-traits for SciRS2 ecosystem
Performs negation that returns
None
if the result can’t be represented. - Checked
Rem - 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. - Checked
Shl - 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. - Checked
Shr - 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. - Checked
Sub - Complete re-export of num-traits for SciRS2 ecosystem
Performs subtraction that returns
None
instead of wrapping around on underflow. - Complex
Float - Complete re-export of num-complex for SciRS2 ecosystem Generic trait for floating point complex numbers.
- Complex
Number - A trait for complex number types
- Float
- Complete re-export of num-traits for SciRS2 ecosystem Generic trait for floating point numbers
- Float
Const - Complete re-export of num-traits for SciRS2 ecosystem
- From
Primitive - 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. - MulAdd
Assign - 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
and1
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. - NumAssign
Ops - Complete re-export of num-traits for SciRS2 ecosystem
Generic trait for types implementing numeric assignment operators (like
+=
). - NumAssign
Ref - 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. - Numeric
Conversion - 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.
- Real
Number - 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
n
th root. - Saturating
- Complete re-export of num-traits for SciRS2 ecosystem
Saturating math operations. Deprecated, use
SaturatingAdd
,SaturatingSub
andSaturatingMul
instead. - Saturating
Add - Complete re-export of num-traits for SciRS2 ecosystem Performs addition that saturates at the numeric bounds instead of overflowing.
- Saturating
Mul - Complete re-export of num-traits for SciRS2 ecosystem Performs multiplication that saturates at the numeric bounds instead of overflowing.
- Saturating
Sub - Complete re-export of num-traits for SciRS2 ecosystem 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
- 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
- Wrapping
Add - Complete re-export of num-traits for SciRS2 ecosystem Performs addition that wraps around on overflow.
- Wrapping
Mul - Complete re-export of num-traits for SciRS2 ecosystem Performs multiplication that wraps around on overflow.
- Wrapping
Neg - Complete re-export of num-traits for SciRS2 ecosystem Performs a negation that does not panic.
- Wrapping
Shl - Complete re-export of num-traits for SciRS2 ecosystem Performs a left shift that does not panic.
- Wrapping
Shr - Complete re-export of num-traits for SciRS2 ecosystem Performs a right shift that does not panic.
- Wrapping
Sub - 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>