Skip to content

Commit ba99a96

Browse files
author
peng.li24
committed
refactor: namespace npy_float_math → numpy::detail
Merge npy_math_float.h functions into numpy::detail namespace (same as svml_bridge.h). Both internal headers now share numpy::detail — applications must never use numpy::detail::*. Public API remains numpy::* from core.h.
1 parent 22cb547 commit ba99a96

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

numpy/npy_math_float.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// INTERNAL HEADER — DO NOT INCLUDE DIRECTLY.
22
// Use #include "numpy/core.h" which pulls this in automatically.
33
//
4+
// All functions live in numpy::detail — do not call directly.
5+
// Use numpy::exp() etc. from core.h.
6+
//
47
// Bit-exact float32 math matching numpy 1.23.5 SIMD polynomial approximations.
58
// Replicates numpy's simd_exp_FLOAT, simd_log_FLOAT, simd_sincos_f32 algorithms.
69

@@ -11,7 +14,10 @@
1114
#include <cmath>
1215

1316
namespace numpy {
14-
namespace npy_float_math {
17+
namespace detail {
18+
// Float32 bit-exact polynomial approximations — internal detail, do not use directly.
19+
// These replicate numpy's simd_exp_FLOAT, simd_log_FLOAT, simd_sincos_f32 algorithms.
20+
// Public API: use numpy::exp() etc. from core.h.
1521

1622
namespace {
1723

@@ -279,5 +285,5 @@ inline float npy_cosf(float x) {
279285
}
280286

281287
} // anonymous namespace
282-
} // namespace npy_float_math
288+
} // namespace detail
283289
} // namespace numpy

numpy/svml_bridge.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ NUMPY_NPY_F64(exp2, std::exp2(x))
168168
// f32 exp/log/sin/cos: numpy's own polynomial approximations (npy_math_float.h)
169169
// are the canonical implementation for float32. dlsym npy_expf/etc. would
170170
// resolve a different (non-matching) code path. Never use dlsym for these.
171-
inline float exp_npy_f32(float x) { return npy_float_math::npy_expf(x); }
172-
inline float log_npy_f32(float x) { return npy_float_math::npy_logf(x); }
173-
inline float sin_npy_f32(float x) { return npy_float_math::npy_sinf(x); }
174-
inline float cos_npy_f32(float x) { return npy_float_math::npy_cosf(x); }
171+
inline float exp_npy_f32(float x) { return npy_expf(x); }
172+
inline float log_npy_f32(float x) { return npy_logf(x); }
173+
inline float sin_npy_f32(float x) { return npy_sinf(x); }
174+
inline float cos_npy_f32(float x) { return npy_cosf(x); }
175175
NUMPY_NPY_F32(tan, std::tan(x))
176176
NUMPY_NPY_F32(asin, std::asin(x))
177177
NUMPY_NPY_F32(acos, std::acos(x))

0 commit comments

Comments
 (0)