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

complete

Linear 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.

View Docs →
FunctionDescription
numx_linalg_dotDot product of two vectors of length n.
numx_linalg_normEuclidean (L2) norm of a vector.
numx_linalg_crossCross product of two 3D vectors.
numx_linalg_mat_mulMatrix multiply: C = A(m x k) * B(k x n).
numx_linalg_transposeTranspose A into B.
numx_linalg_detDeterminant of an n x n matrix via LU factorization.
numx_linalg_luIn-place LU decomposition with partial pivoting.

stats

complete

Descriptive 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).

View Docs →
FunctionDescription
numx_stats_meanArithmetic mean.
numx_stats_varianceSample variance (Bessel-corrected, n-1 denominator).
numx_stats_std_devSample standard deviation.
numx_stats_medianMedian via partial sort (modifies input buffer).
numx_stats_percentilep-th percentile (0 <= p <= 100) via linear interpolation.

roots

complete

Root-finding for scalar functions. All methods require a caller-provided function pointer. Convergence tolerance and max iterations are configurable per call.

View Docs →
FunctionDescription
numx_roots_bisectBisection method. Guaranteed convergence if f(a) and f(b) have opposite signs.
numx_roots_newtonNewton-Raphson with caller-supplied derivative. Quadratic convergence near the root.
numx_roots_brentBrent's method. Combines bisection, secant, and inverse quadratic interpolation for robust convergence.

integrate

complete

Numerical 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.

View Docs →
FunctionDescription
numx_integrate_trapTrapezoidal rule with n intervals. O(h^2) accuracy.
numx_integrate_simpsonSimpson's rule with n intervals (must be even). O(h^4) accuracy.
numx_integrate_gaussGaussian-Legendre quadrature with n points. Exact for polynomials of degree up to 2n-1.

differentiate

complete

Numerical differentiation via finite differences. Richardson extrapolation provides higher-order accuracy at the cost of more function evaluations.

View Docs →
FunctionDescription
numx_diff_forwardForward difference: (f(x+h) - f(x)) / h. O(h) accuracy.
numx_diff_centralCentral difference: (f(x+h) - f(x-h)) / (2h). O(h^2) accuracy.
numx_diff_richardsonRichardson extrapolation up to the given order. Achieves O(h^(2*order)) accuracy.

interpolate

complete

Curve interpolation and approximation from tabulated data. Caller provides the data points; the library evaluates at any query point without storing hidden state.

View Docs →
FunctionDescription
numx_interp_linearPiecewise linear interpolation.
numx_interp_cubic_splineNatural cubic spline. Caller provides coefficient buffer of size 4*(n-1).
numx_interp_chebyshevChebyshev polynomial approximation. Caller provides coefficient buffer of size n.

poly

complete

Polynomial evaluation and root-finding. Horner's method minimizes floating-point operations during evaluation; Newton with deflation finds all roots sequentially.

View Docs →
FunctionDescription
numx_poly_evalHorner's method evaluation. coeffs[0] is the constant term.
numx_poly_rootsNewton with deflation: finds all real roots, stores them in caller-provided roots buffer.

ode

complete

Ordinary 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.

View Docs →
FunctionDescription
numx_ode_rk4Fixed-step fourth-order Runge-Kutta. Deterministic timing, suitable for real-time loops.
numx_ode_rk45Dormand-Prince adaptive RK45 with error control. Step size adapts to meet the given relative and absolute tolerances.

signal

complete

Digital signal processing primitives. FIR and IIR filters operate on streaming sample buffers. All filters are direct-form implementations with caller-provided state buffers.

View Docs →
FunctionDescription
numx_signal_firFIR filter convolution. h is the impulse response, x is the input, y is the output.
numx_signal_iirDirect-form II IIR filter with caller-provided state buffer for reentrancy.
numx_signal_convolveLinear convolution. Output length is na + nb - 1.
numx_signal_correlateCross-correlation of two equal-length signals.
numx_signal_windowGenerate window functions: Hann, Hamming, Blackman, rectangular, Bartlett.
numx_signal_emaExponential moving average with smoothing factor alpha.
numx_signal_peaksPeak detection above threshold. Caller provides peaks index buffer.

fft

complete

Cooley-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.

View Docs →
FunctionDescription
numx_fft_f32In-place float32 FFT. data is an array of complex values; n must be a power of two.
numx_fft_q15In-place Q15 fixed-point FFT. Interleaved real/imaginary pairs.
numx_ifft_f32In-place float32 inverse FFT.
numx_fft_magnitudeCompute magnitude spectrum from complex FFT output. Output has n/2+1 elements.

autodiff

complete

Automatic differentiation without dynamic allocation. Forward mode uses dual numbers; reverse mode uses a static tape whose size is determined at compile time.

View Docs →
FunctionDescription
numx_ad_dual_evalEvaluate f at x with its derivative via forward-mode dual numbers.
numx_ad_tape_initInitialize a reverse-mode tape with a caller-provided node buffer.
numx_ad_varCreate a leaf variable on the tape at the given value.
numx_ad_backwardRun reverse-mode backpropagation from root. Fills grad fields of all variables on the tape.

compressed_sensing

complete

Sparse signal recovery from underdetermined linear systems. Both OMP and ISTA operate on caller-provided matrix and vector buffers with configurable sparsity and convergence parameters.

View Docs →
FunctionDescription
numx_cs_ompOrthogonal Matching Pursuit. Recovers k-sparse x from b = Ax. work buffer size: m*k + k*k + k.
numx_cs_istaIterative Shrinkage-Thresholding Algorithm with L1 regularization parameter lambda.

sketch

complete

Randomized 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.

View Docs →
FunctionDescription
numx_sketch_rsvdRandomized SVD. Computes an approximate rank-k factorization A ≈ U * diag(S) * Vt.

ntt

complete

Negacyclic 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.

View Docs →
FunctionDescription
numx_ntt_forwardIn-place forward NTT. Maps 256 coefficients in Z_3329 from polynomial domain to NTT domain.
numx_ntt_inverseIn-place inverse NTT. Includes normalization by 128^-1 = 3303 mod 3329.
numx_ntt_pointwise_mulPointwise multiplication of two NTT-domain arrays via basemul in 128 degree-2 rings.
numx_ntt_polymulFull polynomial multiplication: forward NTT, pointwise mul, inverse NTT. Stack-only temporaries.
numx_ntt_poly_addCoefficient-wise addition mod 3329. Works in polynomial and NTT domain.
numx_ntt_poly_subCoefficient-wise subtraction mod 3329. Works in polynomial and NTT domain.
numx_ntt_reduceBarrett reduction of all 256 coefficients to [0, q-1].