API Reference
Modules
The complete numerical computing toolkit for embedded engineers. Each module is self-contained, independently usable, and compiles without modification on every major embedded toolchain.
linalg
completeLinear algebra operations on fixed-size vectors and matrices. All operations work on caller-provided contiguous arrays. No internal allocation. The matrix functions use row-major order by convention.
| Function | Description |
|---|---|
numx_linalg_dot | Dot product of two vectors of length n. |
numx_linalg_norm | Euclidean (L2) norm of a vector. |
numx_linalg_cross | Cross product of two 3D vectors. |
numx_linalg_mat_mul | Matrix multiply: C = A(m x k) * B(k x n). |
numx_linalg_transpose | Transpose A into B. |
numx_linalg_det | Determinant of an n x n matrix via LU factorization. |
numx_linalg_lu | In-place LU decomposition with partial pivoting. |
stats
completeDescriptive statistics on caller-provided data buffers. All functions are O(n) in time and O(1) in additional memory, except median (requires sorted or partially sorted input).
| Function | Description |
|---|---|
numx_stats_mean | Arithmetic mean. |
numx_stats_variance | Sample variance (Bessel-corrected, n-1 denominator). |
numx_stats_std_dev | Sample standard deviation. |
numx_stats_median | Median via partial sort (modifies input buffer). |
numx_stats_percentile | p-th percentile (0 <= p <= 100) via linear interpolation. |
roots
completeRoot-finding for scalar functions. All methods require a caller-provided function pointer. Convergence tolerance and max iterations are configurable per call.
| Function | Description |
|---|---|
numx_roots_bisect | Bisection method. Guaranteed convergence if f(a) and f(b) have opposite signs. |
numx_roots_newton | Newton-Raphson with caller-supplied derivative. Quadratic convergence near the root. |
numx_roots_brent | Brent's method. Combines bisection, secant, and inverse quadratic interpolation for robust convergence. |
integrate
completeNumerical integration of scalar functions over a closed interval. All methods accept a caller-provided function pointer and return a typed status code if the integration fails to converge or the input is invalid.
| Function | Description |
|---|---|
numx_integrate_trap | Trapezoidal rule with n intervals. O(h^2) accuracy. |
numx_integrate_simpson | Simpson's rule with n intervals (must be even). O(h^4) accuracy. |
numx_integrate_gauss | Gaussian-Legendre quadrature with n points. Exact for polynomials of degree up to 2n-1. |
differentiate
completeNumerical differentiation via finite differences. Richardson extrapolation provides higher-order accuracy at the cost of more function evaluations.
| Function | Description |
|---|---|
numx_diff_forward | Forward difference: (f(x+h) - f(x)) / h. O(h) accuracy. |
numx_diff_central | Central difference: (f(x+h) - f(x-h)) / (2h). O(h^2) accuracy. |
numx_diff_richardson | Richardson extrapolation up to the given order. Achieves O(h^(2*order)) accuracy. |
interpolate
completeCurve interpolation and approximation from tabulated data. Caller provides the data points; the library evaluates at any query point without storing hidden state.
| Function | Description |
|---|---|
numx_interp_linear | Piecewise linear interpolation. |
numx_interp_cubic_spline | Natural cubic spline. Caller provides coefficient buffer of size 4*(n-1). |
numx_interp_chebyshev | Chebyshev polynomial approximation. Caller provides coefficient buffer of size n. |
poly
completePolynomial evaluation and root-finding. Horner's method minimizes floating-point operations during evaluation; Newton with deflation finds all roots sequentially.
| Function | Description |
|---|---|
numx_poly_eval | Horner's method evaluation. coeffs[0] is the constant term. |
numx_poly_roots | Newton with deflation: finds all real roots, stores them in caller-provided roots buffer. |
ode
completeOrdinary differential equation solvers for first-order systems. The caller provides the right-hand side function and (for RK45) an error tolerance. All state lives in caller-provided buffers.
| Function | Description |
|---|---|
numx_ode_rk4 | Fixed-step fourth-order Runge-Kutta. Deterministic timing, suitable for real-time loops. |
numx_ode_rk45 | Dormand-Prince adaptive RK45 with error control. Step size adapts to meet the given relative and absolute tolerances. |
signal
completeDigital signal processing primitives. FIR and IIR filters operate on streaming sample buffers. All filters are direct-form implementations with caller-provided state buffers.
| Function | Description |
|---|---|
numx_signal_fir | FIR filter convolution. h is the impulse response, x is the input, y is the output. |
numx_signal_iir | Direct-form II IIR filter with caller-provided state buffer for reentrancy. |
numx_signal_convolve | Linear convolution. Output length is na + nb - 1. |
numx_signal_correlate | Cross-correlation of two equal-length signals. |
numx_signal_window | Generate window functions: Hann, Hamming, Blackman, rectangular, Bartlett. |
numx_signal_ema | Exponential moving average with smoothing factor alpha. |
numx_signal_peaks | Peak detection above threshold. Caller provides peaks index buffer. |
fft
completeCooley-Tukey radix-2 FFT in both float32 and Q15 fixed-point. Input length must be a power of two. All transforms operate in-place on caller-provided buffers.
| Function | Description |
|---|---|
numx_fft_f32 | In-place float32 FFT. data is an array of complex values; n must be a power of two. |
numx_fft_q15 | In-place Q15 fixed-point FFT. Interleaved real/imaginary pairs. |
numx_ifft_f32 | In-place float32 inverse FFT. |
numx_fft_magnitude | Compute magnitude spectrum from complex FFT output. Output has n/2+1 elements. |
autodiff
completeAutomatic differentiation without dynamic allocation. Forward mode uses dual numbers; reverse mode uses a static tape whose size is determined at compile time.
| Function | Description |
|---|---|
numx_ad_dual_eval | Evaluate f at x with its derivative via forward-mode dual numbers. |
numx_ad_tape_init | Initialize a reverse-mode tape with a caller-provided node buffer. |
numx_ad_var | Create a leaf variable on the tape at the given value. |
numx_ad_backward | Run reverse-mode backpropagation from root. Fills grad fields of all variables on the tape. |
compressed_sensing
completeSparse signal recovery from underdetermined linear systems. Both OMP and ISTA operate on caller-provided matrix and vector buffers with configurable sparsity and convergence parameters.
| Function | Description |
|---|---|
numx_cs_omp | Orthogonal Matching Pursuit. Recovers k-sparse x from b = Ax. work buffer size: m*k + k*k + k. |
numx_cs_ista | Iterative Shrinkage-Thresholding Algorithm with L1 regularization parameter lambda. |
sketch
completeRandomized matrix algorithms for large-matrix approximations. The randomized SVD (rSVD) follows the Halko-Martinsson-Tropp (2011) framework and produces a low-rank factorization with caller-configurable rank and oversampling.
| Function | Description |
|---|---|
numx_sketch_rsvd | Randomized SVD. Computes an approximate rank-k factorization A ≈ U * diag(S) * Vt. |
ntt
completeNegacyclic Number Theoretic Transform over Z_3329[x]/(x^256+1) with parameters fixed for CRYSTALS-Kyber and CRYSTALS-Dilithium. Seven Cooley-Tukey forward stages, seven Gentleman-Sande inverse stages with normalization (128^-1 = 3303 mod 3329), pointwise basemul across 128 degree-2 quotient rings, full polynomial multiplication, coefficient-wise addition and subtraction, and Barrett reduction. Constant-time data path. Zero heap allocation.
| Function | Description |
|---|---|
numx_ntt_forward | In-place forward NTT. Maps 256 coefficients in Z_3329 from polynomial domain to NTT domain. |
numx_ntt_inverse | In-place inverse NTT. Includes normalization by 128^-1 = 3303 mod 3329. |
numx_ntt_pointwise_mul | Pointwise multiplication of two NTT-domain arrays via basemul in 128 degree-2 rings. |
numx_ntt_polymul | Full polynomial multiplication: forward NTT, pointwise mul, inverse NTT. Stack-only temporaries. |
numx_ntt_poly_add | Coefficient-wise addition mod 3329. Works in polynomial and NTT domain. |
numx_ntt_poly_sub | Coefficient-wise subtraction mod 3329. Works in polynomial and NTT domain. |
numx_ntt_reduce | Barrett reduction of all 256 coefficients to [0, q-1]. |