cascade_sim 1b: exact exp/div stubs for C++ port, keep structural proxy

This commit is contained in:
2026-08-29 15:31:01 +03:00
parent ab9334f8ab
commit 04c51e5be0
+14
View File
@@ -42,12 +42,26 @@ def k_exp(x):
return np.exp(x)
def k_exp_exact(x):
"""Bit-exact expf 180296c80 (BLOCKMAP:569) — float32 FMA poly, guard 87.3365.
Python структурный прокси: np.exp (float64) — точный C++ порт в dsp/exp2.cpp
через fmaf+бит-манипуляции (1824c...), ошибка <0.5 ulp vs плагин."""
return np.exp(np.asarray(x, dtype=np.float64)).astype(np.float32)
def k_div(a, b):
"""divide-ядро 1803a06a0: dst = B/A (~0.5 ulp, rcp+таблицы+полином).
Структурная фаза: точное деление."""
return b / a
def k_div_exact(a, b):
"""Bit-exact DIVIDE 1803a06a0 (BLOCKMAP:580) — rcp+quant+vpermps+poly.
Структурный прокси: точное деление; C++ порт копирует 0.5ulp полином
0.207515 -0.241687 0.288535 -0.360671 ... 0.240264 через vpermps tbl@1821269c0."""
return np.asarray(b, dtype=np.float64) / np.asarray(a, dtype=np.float64)
# ------------------------------------------------------------ данные -----
def load_tract(path):
"""tract_*.txt: k am res lvl_raw band_level prewarp w"""