Skip to main content

Module math

Module math 

Source
Expand description

Transcendental functions, called as math::hypot(x, y) the way the C sources call hypot(x, y).

On macOS, f64::hypot and friends call the system libm, the same one C Graphviz uses, so the port reproduces C’s last bits. On other targets Rust takes them from a different libm (glibc on Linux, compiler-builtins’ musl port on wasm32) that disagrees in the last ulp on some inputs, which is enough to change a force-directed layout. Every call in the port goes through this module, and on those targets it uses [portable] implementations: a reproduction of Apple’s hypot, and the libm crate (the musl port Rust itself uses on wasm32) for the rest, so that every non-Apple target computes the same bits. See docs/porting/libm.md.

sqrt and mul_add are correctly rounded everywhere and stay f64 methods.

Enums§

Profile
Which libm this build computes with. The corpus ratchets keep one baseline per profile: Apple results are C’s bit for bit, Portable ones document the gap to C (see docs/porting/libm.md).

Constants§

PORTABLE
Whether this build uses [portable] rather than the platform libm. The portable-math feature forces it on macOS, to check the portable code against the corpus natively.
PROFILE
The math profile of this build.

Functions§

acos
C acos(x).
asin
C asin(x).
atan2
C atan2(y, x) is math::atan2(y, x).
cbrt
C cbrt(x).
cos
C cos(x).
exp
C exp(x).
hypot
C hypot(x, y).
ln
C log(x).
log2
C log2(x).
powf
C pow(x, y).
sin
C sin(x).
tan
C tan(x).