RMath

rmath.scalar (Scalar Precision)

The rmath.scalar module provides high-precision mathematical wrapper classes like Scalar and Complex for individual numeric values, ensuring exact feature parity with the Rust standard library's f64 operations.

Proven: Precision f64 Math

Mathematical functions are implemented as methods on the Scalar class.

scalar_math.py
import rmath.scalar as rs

# Wrap python floats in the native Scalar type
one = rs.Scalar(1.0)
half_pi = rs.Scalar(rs.pi / 2.0)

# Transcendental functions
val = one.exp()
sin_val = half_pi.sin()

print(f"e       : {val:.10f}")
print(f"sin(π/2): {sin_val}")
e : 2.7182818285 sin(π/2): 1.0
Tip: Scalar functions in RMath are designed to be exactly as efficient as the native Rust f64 implementation. They are ideal when you need IEEE-754 accuracy and specific Rust rounding/precision semantics in Python.