Skip to content

Examples

Complete programs from examples/, built with -DNUMERICS_BUILD_EXAMPLES=ON.

program summary
00_core_storage_and_helpers.cpp Vectors, matrices, sparse matrices, expressions and the helpers around them.
01_direct_factorizations.cpp LU, Cholesky, QR least squares and the Thomas algorithm, all solved through solve(F, b, x).
02_iterative_krylov_solvers.cpp CG, preconditioned CG, MINRES and GMRES on sparse and matrix-free operators.
03_resolvent_and_expv.cpp Shifted solves (sI - A)x = b at many shifts, and the action of the matrix exponential.
04_eigen_and_svd.cpp Symmetric eigendecomposition, Lanczos, power iteration and the SVD.
05_symplectic_nbody_ode.cpp Explicit, adaptive and symplectic integrators on the harmonic oscillator.
06_pde_poisson_solver.cpp A 3D Poisson problem on scalar fields, converging at second order.
07_spectral_fft_transforms.cpp FFT and inverse FFT, the real FFT, and the backend that runs them.
08_root_finding_and_quadrature.cpp Root finding with bisection, Newton, secant and Brent, and five quadrature rules.
09_mcmc_bayesian_sampling.cpp Running statistics and histograms over a stream of samples.
10_banded_and_spd_operators.cpp Band storage, banded LU with pivoting, and solves with one or many right-hand sides.
11_terminal_ascii_plot.cpp Quick-start guide for in-terminal ASCII plotting via gnuplot set terminal dumb.
12_hessenberg_resolvent_benchmark.cpp Benchmark comparing naive O(kn^3) full LU batch resolvent against O(n^3 + kn^2) Hessenberg resolvent.
13_talbot_spectral_validation.cpp High-precision validation of Talbot contour inversion against Krylov Arnoldi expv using num:: toolkit.
14_concepts_and_property_invariants.cpp Demonstrates C++20 linear algebra concepts, compile-time invariant tagging (assume_spd), and loud warnings on untagged storage.
15_diffusion_evidence_cg.cpp End-to-end invariant propagation from a PDE construction into CG.
16_factor_reuse.cpp Refactoring after local changes, with Woodbury-corrected LU and prefix-reusing block LU.
17_woodbury_low_rank_update.cpp Solving with A + PQ^T from a factorization of A, by the Woodbury identity.
18_mixed_precision_and_conditioning.cpp Condition estimates from any factorization, and LU in float refined to double.
19_probed_inverse_diagonal.cpp diag(A^{-1}) of a sparse M-matrix from a block of random probes.
20_backends_and_kernel.cpp Backend namespaces, the build's default, and the raw-pointer kernel on plain buffers.
21_graphs_and_structures.cpp Graphs, traversal, spanning trees, disjoint sets, and a Laplacian solve with ApproxChol.