Skip to content

Examples

Complete programs from examples/, built with -DNUMERICS_BUILD_EXAMPLES=ON. Most save result.json; plotting examples save plot.png with --plot. The plot demo saves it directly.

program summary
00_vectors_and_matrices.cpp Create vectors, matrices and sparse matrices, and combine them.
01_linear_systems.cpp Solve a system of linear equations Ax = b by LU, Cholesky, QR and tridiagonal factorization.
02_iterative_methods.cpp Solve a large sparse system of linear equations by an iterative method.
03_matrix_exponential.cpp Solve (sI - A)x = b for many values of s, and compute exp(tA)v.
04_eigenvalues.cpp Compute eigenvalues, eigenvectors and singular values.
05_differential_equations.cpp Integrate an ordinary differential equation, and compare how well methods conserve energy.
06_poisson_equation.cpp Solve the Poisson equation in three dimensions, and measure the error as the grid is refined.
07_fourier_transforms.cpp Compute the Fourier transform of complex and real data, and its inverse.
08_roots_and_integrals.cpp Find a root of an equation, and compute a definite integral.
09_statistics.cpp Compute the mean, variance and histogram of a stream of samples.
10_banded_systems.cpp Solve a banded system of linear equations.
11_terminal_plot.cpp Plot a function in the terminal.
12_many_shifted_systems.cpp Time two ways of solving (sI - A)x = b for many values of s.
13_inverse_laplace_transform.cpp Compute a probability distribution in time two ways, and check that they agree.
14_positive_definite_matrices.cpp Check that a matrix is symmetric positive definite before a Cholesky factorization.
15_diffusion_equation.cpp Solve a diffusion equation by the conjugate gradient method.
16_updating_a_factorization.cpp Update a factorization after a few rows and columns of the matrix change.
17_low_rank_updates.cpp Solve with a slightly changed matrix without factoring it again.
18_condition_numbers.cpp Estimate the condition number of a matrix, and solve in single precision to double accuracy.
19_diagonal_of_the_inverse.cpp Estimate the diagonal of the inverse of a large sparse matrix.
20_blas_and_kernels.cpp Choose between the built-in routines and BLAS, and call the low-level routines directly.
21_graphs.cpp Build and search graphs, find spanning trees, and solve a graph Laplacian system.
22_heat_equation.cpp Solve the heat equation on a periodic domain by the Fourier transform.
23_frequency_response.cpp Compute the response of a damped system of oscillators at many frequencies.