Implementation:Interpretml Interpret MathHpp
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, EBM_Core |
| Last Updated | 2026-02-07 12:00 GMT |
Overview
Provides low-level mathematical building blocks for the SIMD-accelerated exp and log implementations, including mantissa/exponent extraction and polynomial evaluation.
Description
The math.hpp header defines template functions for IEEE 754 floating-point bit manipulation and polynomial evaluation that serve as building blocks for the Exp and Log SIMD implementations. It provides Mantissa32/Mantissa64 functions that extract the mantissa from a float/double by masking the appropriate bits, Exponent32/Exponent64 that extract the exponent field, and Power32/Power64 that construct a float from an exponent value. The Polynomial32 and Polynomial64 functions evaluate polynomials using Horner-like schemes optimized with FusedMultiplyAdd operations to minimize latency by exploiting instruction-level parallelism (computing independent parts of the polynomial in parallel using x2, x4, and x8 intermediate values).
Usage
Used internally by the Exp and Log function implementations in cpu_64.cpp, avx2_32.cpp, and avx512f_32.cpp. These math primitives enable the high-precision polynomial approximations of transcendental functions that are critical for computing gradients in classification objectives.
Code Reference
Source Location
- Repository: Interpretml_Interpret
- File: shared/libebm/compute/math.hpp
Signature
template<typename TFloat> static INLINE_ALWAYS TFloat Mantissa32(const TFloat& val) noexcept;
template<typename TFloat> static INLINE_ALWAYS typename TFloat::TInt Exponent32(const TFloat& val) noexcept;
template<typename TFloat> static INLINE_ALWAYS TFloat Mantissa64(const TFloat& val) noexcept;
template<typename TFloat> static INLINE_ALWAYS TFloat Exponent64(const TFloat& val) noexcept;
template<typename TFloat> static INLINE_ALWAYS TFloat Power32(const TFloat val);
template<typename TFloat> static INLINE_ALWAYS TFloat Power64(const TFloat val);
template<typename TFloat> static INLINE_ALWAYS TFloat Polynomial32(
const TFloat x, const TFloat c0, const TFloat c1, const TFloat c2,
const TFloat c3, const TFloat c4, const TFloat c5);
template<typename TFloat> static INLINE_ALWAYS TFloat Polynomial64(
const TFloat x, const TFloat c2, const TFloat c3, const TFloat c4,
const TFloat c5, const TFloat c6, const TFloat c7, const TFloat c8,
const TFloat c9, const TFloat c10, const TFloat c11, const TFloat c12, const TFloat c13);
I/O Contract
| Function | Input | Output | Description |
|---|---|---|---|
| Mantissa32 | TFloat value | TFloat mantissa | Extracts 23-bit mantissa from float32 |
| Exponent32 | TFloat value | TFloat::TInt exponent | Extracts 8-bit exponent from float32 |
| Power32 | TFloat exponent | TFloat result | Constructs float32 from exponent |
| Polynomial32 | x, coefficients | TFloat result | Evaluates 5th-degree polynomial with FMA |
| Polynomial64 | x, coefficients | TFloat result | Evaluates 11th-degree polynomial with FMA |
Usage Examples
# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X, y) # Math primitives used in Exp/Log computations during training