/** * WASM dispatch bridge for polynomial hot-loop kernels. * * Four kernels are exposed: * - `poly_mul_f64` — O(n·m) coefficient convolution * - `poly_div_mod_f64` — polynomial long division (returns concat [quot|rem]) * - `poly_resultant_f64` — Sylvester-matrix determinant (Slice 4.5) * - `poly_discriminant_f64` — discriminant via Res(p, p') (Slice 4.5) * * Behavior: * - When `wasmLoader.getModule()` returns null (module not loaded or * load failed), every helper here returns the JS fallback result * without throwing. * - When the loaded AS binary exposes the matching managed export, we * marshal the Float64Array operands into WASM-owned memory, run * the kernel, and return a JS-side copy of the result. * - Any thrown error is swallowed and the JS fallback runs — the * WASM tier is an optimisation, not a correctness requirement. * * Threshold: * The marshal cost (two memcpys in + one out) pays off when the * O(n·m) inner loop is large enough. A polynomial length ≥ 256 * coefficients is the empirically-chosen break-even point; see * `tools/benchmark/wasm/poly.bench.ts`. */ /** * Coefficient-count threshold above which we attempt the WASM kernel. * For `poly_mul_f64`, we gate on either operand reaching this length; * for `poly_div_mod_f64`, we gate on `num.length`. */ export declare const WASM_POLY_THRESHOLD = 256; /** * Multiply two polynomials `a` and `b` via the AS WASM kernel when either * operand length exceeds the threshold, otherwise falls back to inline JS. * * Returns a `Float64Array` of length `a.length + b.length - 1`. */ export declare function polyMulDispatch(a: Float64Array, b: Float64Array): Float64Array; /** * Divide polynomial `num` by `den` via WASM when `num.length` exceeds * the threshold, otherwise falls back to inline JS. * * Returns `{ quotient: Float64Array, remainder: Float64Array }`. */ export declare function polyDivModDispatch(num: Float64Array, den: Float64Array): { quotient: Float64Array; remainder: Float64Array; }; /** * Compute the resultant of `p` and `q` via WASM when either polynomial * length exceeds the threshold, otherwise falls back to inline JS. */ export declare function resultantDispatch(p: Float64Array, q: Float64Array): number; /** * Compute the discriminant of `p` via WASM when the polynomial length * exceeds the threshold, otherwise falls back to inline JS. */ export declare function discriminantDispatch(p: Float64Array): number; /** * Sample-count threshold above which we attempt the WASM kernel for * poly_fit / cheb_fit / legendre_fit. Below this, the marshal cost * (two memcpys in + one out) dominates; above it, the O(n·k²) QR * factorisation pays off. */ export declare const WASM_POLY_FIT_THRESHOLD = 1024; /** * Fit a polynomial via Vandermonde + normal equations (JS). * * Returns a `Float64Array` of length `degree + 1` with coefficients * `[a0, a1, ..., a_degree]` (constant-first / power-ascending order). * * Throws when the system is rank-deficient (e.g. all xs equal). */ export declare function polyFitDispatch(xs: Float64Array, ys: Float64Array, degree: number): Float64Array; /** * Fit a Chebyshev-series via Vandermonde + normal equations (JS). * * Returns a `Float64Array` of length `degree + 1` with Chebyshev coefficients. * * Throws when the system is rank-deficient. */ export declare function chebFitDispatch(xs: Float64Array, ys: Float64Array, degree: number): Float64Array; /** * Fit a Legendre-series via Vandermonde + normal equations (JS). * * Returns a `Float64Array` of length `degree + 1` with Legendre coefficients. * * Throws when the system is rank-deficient. */ export declare function legendreFitDispatch(xs: Float64Array, ys: Float64Array, degree: number): Float64Array; /** * Test-only hook — re-exported so tests can reset loader state * without importing WasmLoader directly. */ export declare function resetPolyWasm(): void; //# sourceMappingURL=wasm-bridge.d.ts.map