Skip to content

numerics

numerics is a C++20 library of numerical methods. It covers dense, banded and sparse linear algebra, Krylov solvers, eigenvalues and the SVD, ODE integrators, PDE operators, spectral transforms, quadrature, root finding, graphs and sampling. The arithmetic lives in num::kernel, a set of allocation-free loops over raw pointers with no dependencies. BLAS, LAPACK, OpenMP, CUDA, FFTW and SuiteSparse are used when they are present.

I started numerics to pull the code from my research and my numerical methods courses (fluid simulation, stochastic modeling, graph algorithms, linear algebra) into one library. I maintain it myself, and it keeps growing alongside my research, so use it with appropriate caution!!

Every feature below is explained by an example, a complete program in examples/ shown with the output it prints.

Setup

include(FetchContent)
FetchContent_Declare(numerics
    GIT_REPOSITORY https://github.com/AdityaDendukuri/numerics.git
    GIT_TAG v1.0.0)
FetchContent_MakeAvailable(numerics)
target_link_libraries(my_program PRIVATE numerics::numerics)
Target Contents
numerics::numerics Everything, with each backend the configuration found
numerics::core Containers, concepts and the portable kernels, no external dependency
numerics::kernel num::kernel alone
numerics::blas, lapack, openmp, fftw, suitesparse, simd, mpi, cuda One backend each

#include <numerics.hpp> includes the whole library.

Standout features from my PhD research

Feature Example
Refactoring after a local change, with Woodbury-corrected LU while few states differ and block LU that keeps every block before the first change 16_factor_reuse
Solving with \(A + PQ^T\) from a factorization of \(A\) 17_woodbury_low_rank_update
\(\operatorname{diag}(A^{-1})\) of a sparse M-matrix from a block of random probes 19_probed_inverse_diagonal
Shifted systems \((sI - A)x = b\) at many shifts from one Hessenberg reduction, and Talbot inversion 03_resolvent_and_expv, 13_talbot_spectral_validation

Feature index

Area Features Example
Containers vec<T>, mat<T>, spmat, num::ops expressions, in-place matvec, axpy, selection helpers 00
Direct solvers lu, lu(A, no_pivot), cholesky, qr least squares, thomas, det, inverse, rcond, one solve(F, b, x) for all 01
Iterative solvers cg, pcg with Jacobi, minres, gmres, sparse and matrix-free operators 02
Shifted systems hessenberg_resolvent, shift, solve_batch, expv 03, 12, 13
Eigenvalues eig_sym, lanczos, power_iteration, svd 04
ODEs ode_rk4, ode_rk45, ode_verlet, ode_yoshida4 05
PDEs 3D fields, field_solver::solve_poisson, SPD operators reaching CG 06, 15
Spectral fft, ifft, rfft, irfft, backends 07
Roots and quadrature bisection, newton, secant, brent, trapz, simpson, gauss_legendre, adaptive_simpson, romberg 08
Statistics running_stats, histogram 09
Banded matrices band_mat, banded LU with pivoting, many right-hand sides 10
Plotting gnuplot figures, plots in the terminal 11
Laws and diagnostics assume_spd, make_spd, compile-time requirements, num::unsafe, diagnostic presets 14, 15
Factor reuse lu(R, no_pivot, previous, changed), lu(R, blocks(levels), previous, changed) 16
Low-rank updates low_rank_difference, woodbury_solver, transpose(F) 17
Precision and conditioning rcond, inverse_norm1_estimate, lu(A, mixed_precision) 18
Inverse diagonal inverse_diagonal(F, A) 19
Backends and kernel num::seq, blas, omp, lapack, num::kernel on raw pointers 20
Graphs graph, dijkstra, minimum_spanning_tree, disjoint_set, Laplacian PCG with ApproxChol 21

Reference

Page Contents
Containers Every container and the operations on it
Concepts Every concept and law
Kernels The BLAS layer, num::kernel
Linear algebra Factorizations, solvers, eigenvalues, the SVD
ODEs Integrators and their step ranges
PDEs and fields Grids, fields, stencils, diffusion, Poisson
Spectral FFT and sine transforms
Quadrature and roots Integration rules and root finding
Statistics and sampling Running statistics, random engines, MCMC
Data structures Graphs, queues, union-find, cell lists
Algorithms BFS, DFS, Dijkstra, spanning trees, generators
All names One page per public name, by directory
Benchmark report Measured performance