100,000+ lines of numerical computing • one #include • cross-platform visualization included
🚀 Just #include <MML.h> and compute — vectors, matrices & tensors; dense & sparse linear algebra; ODE & DAE solvers; derivation and integration; optimization and Fourier algorithms; computational geometry and more.
Official Website • Quick Start • Installation • What's Inside • New in 2.0 • Serialization • Visualization • Docs
| 100,000+ | 334 | 174,147 |
| lines of numerical code | modular headers | assertions (4,365 cases in 173 files) |
| 13 | 3 | 0 |
| subsystem families | platforms (Win/Linux/Mac) | external dependencies |
One MML.h single header (100K lines) — or include only what you need.
MML is a comprehensive, single-header C++ numerical computing toolkit. With one #include <MML.h> you get an entire computational stack — from vectors and matrices to tensor calculus on manifolds, from dense and sparse linear algebra to stiff DAE solvers, from adaptive integration to Fourier and spectral BVP methods, from computational geometry to cross-platform visualization.
|
Most C++ math libraries require complex build systems, multiple linked libraries, platform-specific configuration, and steep learning curves — often wasting hours on setup (or precious AI tokens today) before writing actual code . And when you need to see your results, you reach for a second toolchain entirely. |
#include <MML.h>
// That's it. Start computing.
|
You can also use MML piece-wise by including only selected headers from the mml/ directory.
|
An entire numerical stack — 100K lines spanning 13 subsystem families — behind one intuitive, header-only API. |
174,147 assertions across 4,365 test cases validate against analytical solutions. |
Cross-platform viewers (WPF/Qt/FLTK) for functions, surfaces, fields, curves, and particle systems — launched from code. |
A new serialization framework — durable |
Gauss's divergence theorem connects a field's behavior inside a volume with the flux through its boundary:
For the unit cube and
// Verify ∫∫∫(∇·F)dV = ∮∮(F·n̂)dS over a unit cube, F(x,y,z) = (x², y², z²)
VectorFunction<3> F([](const VectorN<Real, 3>& p) {
return VectorN<Real, 3>{ p[0]*p[0], p[1]*p[1], p[2]*p[2] };
});
// Divergence computed NUMERICALLY — MML calculates ∇·F automatically
ScalarFunctionFromStdFunc<3> divF([&F](const VectorN<Real, 3>& p) {
return VectorFieldOperations::DivCart<3>(F, p);
});
auto y_lo = [](Real){ return 0.0; }; auto y_hi = [](Real){ return 1.0; };
auto z_lo = [](Real,Real){ return 0.0; }; auto z_hi = [](Real,Real){ return 1.0; };
Real volIntegral = Integrate3D(divF, GAUSS10, 0, 1, y_lo, y_hi, z_lo, z_hi).value;
Cube3D unitCube(1.0, Point3Cartesian(0.5, 0.5, 0.5));
Real surfIntegral = SurfaceIntegration::SurfaceIntegral(F, unitCube, 1e-8);
std::cout << "Volume: " << volIntegral << "\n"; // 3.0000000000
std::cout << "Surface: " << surfIntegral << "\n"; // 3.0000000000
std::cout << "Error: " << std::abs(volIntegral - surfIntegral) << "\n"; // ~9.8e-15 ✓Option 1 — Single header
curl -O https://raw.githubusercontent.com/zvanjak/MML/master/mml/single_header/MML.h
# then: #include <MML.h>Option 2 — CMake FetchContent
include(FetchContent)
FetchContent_Declare(
minimalmathlib
GIT_REPOSITORY https://github.com/zvanjak/MML.git
GIT_TAG master # or a tagged release, e.g. v2.0.0 when available
)
FetchContent_MakeAvailable(minimalmathlib)
target_link_libraries(my_app PRIVATE minimalmathlib::minimalmathlib)Option 3 — Full repository build
git clone https://github.com/zvanjak/MML.git
cd MML && cmake -B build && cmake --build buildFull repository clones include prebuilt visualizers under tools/visualizers for Windows,
Linux, and macOS, so the visualization examples can run without a separate visualizer install.
This clone-mode bundle is in addition to the standalone visualizer release archives. The bundled
visualizer binaries are licensed separately from MML core; see
tools/visualizers/LICENSE.md. The macOS visualizer apps are large
and add roughly 1 GB to the checkout.
Option 4 — vcpkg overlay port
git clone https://github.com/zvanjak/MML.git
vcpkg install minimalmathlib --overlay-ports=MML\portsThen use the exported CMake target:
find_package(minimalmathlib CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE minimalmathlib::minimalmathlib)The current overlay port is repository-local and uses the checked-out source tree. Official vcpkg registry submission is planned after the 2.0 release is tagged.
Option 5 — VS Code: Git: Clone the repo, install recommended extensions (C/C++, CMake Tools), then CMake: Configure and build.
#include <MML.h>
using namespace MML;
int main() {
Matrix<Real> A{3, 3, { 4, 1, 2,
1, -5, -3,
-1, 1, 6}};
Vector<Real> b{1, 4, -3};
LUSolver<Real> solver(A);
Vector<Real> x = solver.Solve(b);
std::cout << "Solution: " << x << std::endl;
std::cout << "Residual: " << (A * x - b).NormL2() << std::endl;
std::cout << "Determinant: " << solver.det() << std::endl;
auto eigenResult = EigenSolver::Solve(A);
std::cout << "Eigenvalues:" << std::endl;
for (const auto& eigenvalue : eigenResult.eigenvalues)
std::cout << " " << eigenvalue << std::endl;
return 0;
}
/* Expected OUTPUT:
Solution: [ 0.5378151261, -0.4957983193, -0.3277310924]
Residual: 0.0000000000
Determinant: -119.0000000000
Eigenvalues:
4.8937181442 + 0.9530217116i
4.8937181442 - 0.9530217116i
-4.7874362884 + 0.0000000000i
*/g++ -std=c++20 -O3 myprogram.cpp -o myprogramWhere next? Two documents take you from here:
Fundamentals — the five ideas behind every MML API (precision builds, concepts, the function-interface hierarchy, Config + Result, library-wide contracts)
Cookbook — task-oriented recipes (solve a linear system, find all roots, ...), every one backed by compiled, runnable code in src/docs_demos/
┌──────────────────────────────────────────────────────────────────────────────┐
│ MML.h (single header, 100K LOC) │
├──────────────────────────────────────────────────────────────────────────────┤
│ mml/ │
│ ├── base/ Vectors, Matrices, Sparse Matrices, Tensors, Functions, │
│ │ Polynomials, Quaternions, Geometry, Function Objects │
│ ├── core/ Derivation, Integration, Dense & Sparse Solvers, Fields, │
│ │ Coord Transforms, Metric Tensors, Function Spaces, Vec Spaces│
│ ├── algorithms/ ODE & DAE Solvers, Root Finding, Optimization, Eigen, │
│ │ Fourier, Interpolation, Computational Geometry, Statistics │
│ ├── systems/ Dynamical Systems, Attractors, Lyapunov, Bifurcation │
│ ├── interfaces/ Abstract interfaces for functions, systems, tensors │
│ └── tools/ Visualization, Serialization framework, Data loading │
└──────────────────────────────────────────────────────────────────────────────┘
The public API follows five implementation layers. Abstract contracts in mml/interfaces/ support all five rather than forming a separate feature layer.
| Facility | What it provides |
|---|---|
| Algebra & discrete mathematics | Groups, finite fields, permutations, representations, modular arithmetic, combinatorics, number theory, and graphs |
| Vectors | Dynamic and fixed-size vectors plus coordinate-vector types |
| Matrices | Dynamic and fixed-size matrices plus specialized symmetric, tridiagonal, and band storage |
| Sparse matrices | COO, CSR, and CSC storage for large sparse problems |
| Tensors & differential forms | Rank 1-5 tensors, tensor fields, tangent/cotangent objects, forms, and Hodge operations |
| Functions | Real, scalar, vector, and parametric function objects |
| Interpolation | Linear, polynomial, spline, Akima, Hermite, barycentric, and rational interpolation |
| Polynomials & scalar structures · Intervals | Generic polynomials, Chebyshev approximation, rational numbers, intervals, special functions, and Richardson extrapolation |
| Geometry 2D & 3D | 2D/3D primitives and bodies, bounding volumes, spherical geometry, and rigid motions |
| Quaternions | Quaternion types and rotations |
| Random & quasi-random sequences | Pseudorandom generators, distributions, and low-discrepancy sampling |
| Facility | What it provides |
|---|---|
| Algebra algorithms | Finite-group algorithms, group actions, polynomial arithmetic, representations, and algebra/geometry integration |
| Vector spaces · Function spaces | Bases, subspaces, dual and inner-product spaces, linear maps/operators, trial spaces, collocation, and 1D BVP machinery |
| Numerical derivation | First through third derivatives, gradients, Jacobians, Hessians, automatic differentiation, and O(h) to O(h⁸) stencils |
| Numerical integration · Multidimensional | Newton-Cotes, Romberg, Gaussian and adaptive quadrature, improper integrals, and 2D/3D integration |
| Dense linear solvers | LU, QR, SVD, Cholesky, and dense linear-system diagnostics |
| Sparse solvers | CG, BiCGSTAB, GMRES, and preconditioners for sparse systems |
| Fields · Field operations | Scalar/vector/tensor fields; gradient, divergence, curl, Laplacian, and common physical field models |
| Coordinates · Metrics | Coordinate maps and transformations, frames, atlases/charts, metric tensors, induced metrics, and differential-form integration |
| Curves & surfaces | Parametric geometry, predefined shapes, tangent frames, curvature, and surface operations |
| Orthogonal bases | Legendre, Chebyshev, Hermite, and Laguerre bases with quadrature and spectral support |
| Complex analysis | Complex functions, derivatives, contour integration, winding numbers, residues, and argument-principle tools |
| Facility | What it provides |
|---|---|
| Matrix analysis · Eigensolvers | Matrix properties and decompositions, symmetric/general eigensystems, and linear-system diagnostics |
| Root finding | Bracketing, Bisection, Brent, Newton, Ridders, polynomial/complex roots, all-real-roots isolation, and nonlinear systems |
| ODE solvers | Fixed/adaptive explicit methods, Backward Euler, and event detection |
| DAE solvers | BDF2/BDF4, Radau IIA, RODAS, and stiff differential-algebraic systems |
| Optimization | One-dimensional and multidimensional optimization, simplex LP, Nelder-Mead, Powell, quasi-Newton, and constrained methods |
| Fourier & spectral algorithms | FFT/real FFT, DCT, spectra, convolution, filtering, and windowing |
| Approximation & curve fitting | Adaptive Chebyshev approximation, linear/nonlinear least squares, weighted fitting, and regularization |
| Computational geometry | Convex hulls, Delaunay triangulation, Voronoi diagrams, KD-trees, polygon operations, and robust predicates |
| Graph algorithms | Traversals, connectivity, shortest paths, DAG structure, spanning trees, flows, matching, coloring, and matrix conversions |
| Statistics | Continuous/discrete distributions, descriptive and robust statistics, histograms, correlation, and sampling |
| Function analysis | Roots, extrema, inflection points, continuity, monotonicity, and scalar/vector field analysis |
| Path integration · Surface integration | Line/surface/volume integrals and flux calculations |
| Differential geometry | Curvature, geodesics, tensor geometry, and relativity support |
| Facility | What it provides |
|---|---|
| Linear systems | First-class Ax=b models, solver orchestration, residuals, conditioning, and diagnostics |
| Continuous dynamical systems | Lorenz, Rössler, Van der Pol, pendulum, Hamiltonian, and user-defined continuous systems |
| Discrete maps | Logistic, Hénon, standard, tent, and user-defined iterated maps |
| Dynamical-system analysis | Fixed points and stability, Lyapunov spectra, attractors, phase portraits, Poincaré sections, and bifurcations |
| Facility | What it provides |
|---|---|
| Persistence & serialization | Versioned JSON/binary round-trips for mathematical objects plus simulation and visualizer export |
| Visualization | Cross-platform plotting of functions, fields, curves, surfaces, particles, and rigid-body simulations |
| Console & export | Styled tables and TXT, CSV, JSON, HTML, LaTeX, and Markdown export |
| Data loading | CSV, TSV, JSON, and text loading with type inference, date/time handling, and structured I/O results |
| Runtime utilities | Timers, thread pools, asynchronous task execution, and exception propagation |
MML 2.0 is a massive expansion over the last official 1.2.1 release:
- 🧮 Sparse linear algebra —
SparseMatrixCOO/CSR/CSCwith Krylov solvers (CG, BiCGSTAB, GMRES) and preconditioners. - 🌐 DAE solvers — stiff differential-algebraic systems raised to full ODE-solver quality: Radau IIA, BDF2/BDF4, RODAS, Backward Euler, adaptive stepping, and event detection.
- 🔺 Computational geometry — convex hull (2D/3D), Delaunay triangulation, Voronoi diagrams, KD-trees, polygon clipping, and robust geometric predicates.
- 📈 Function spaces & spectral methods — Chebyshev collocation, orthogonal bases (Legendre, Chebyshev, Hermite, Laguerre), trial spaces, linear operators, and 1D boundary-value-problem solvers.
- 🧊 Vector spaces — abstract
Basis,Subspace,DualSpace,LinearMap,InnerProductSpace, and affine spaces. - 🧠 Complex analysis — complex functions, complex root finding, contour integration, and residues.
- 📊 Statistics — continuous/discrete distributions, histograms, and descriptive statistics (inferential statistics — hypothesis tests, confidence intervals, rank correlation — live in MML-Packages).
- 🌊 Fourier suite — real FFT, spectrum analysis, convolution, and windowing.
- 💎 Tensors & relativity — Minkowski/Lorentzian metrics with timelike/spacelike/null interval classification.
- 💾 Serialization framework — durable object persistence (see below).
MML 2.0 introduces a first-class serialization framework under mml/tools/serializer/ — durable object round-trips plus rich presentation export and data loading.
| Format | Extension | Purpose | Human-readable |
|---|---|---|---|
| MML JSON object | .mmlj |
Structured object persistence (schema + metadata) | ✅ |
| MML binary object | .mmlb |
Compact, exact binary payloads | — |
| Visualizer export | .mml |
Presentation files for functions, curves, fields, ODE, particles | ✅ |
| Data helpers | .csv, .json, .txt |
Load/inspect tabular data | ✅ |
#include <mml/tools/Serializer.h>
using namespace MML;
Vector<Real> v{1.25, -2.5, 3.75};
// Durable round-trip — format inferred from extension (.mmlj JSON, .mmlb binary)
Serializer::Save(v, "vector.mmlj");
Vector<Real> loaded;
Serializer::Load("vector.mmlj", loaded);Dedicated serializers cover functions, curves, surfaces, vector fields, field lines, ODE solutions, and particle simulations; the data_loader module reads CSV, TSV, and JSON datasets (with DATE/TIME support). See Serialization & Persistence.
Cross-platform visualizers for functions, fields, curves, surfaces, and particle systems — Windows (WPF), Linux (Qt), macOS (Qt), with FLTK for lightweight 2D. Launched directly from code, no manual export needed. Full gallery, per-platform screenshots, and code: docs/README_Visualization_suite.md.
Prebuilt visualizer binary packaging for Windows, Linux, and macOS is planned separately from the header-only core package flow. For now, build visualizer demos from source with the repository.
| Windows (WPF) | Linux (Qt) | macOS (Qt) |
|---|---|---|
![]() |
![]() |
![]() |
Ready-to-run demos: src/visualization_examples/.
Concise, copy-pasteable snippets for the core API live in docs/README_Code_examples.md:
- Vectors & Matrices · Linear Systems & Eigenvalues · Polynomials & Algebra
- Defining Functions · Interpolation · Numerical Derivatives · Numerical Integration
- Root Finding · Field Operations · Coordinate Transformations · Parametric Curves
- Path & Line Integrals · Function Analysis · Differential Equations · Dynamical Systems
Full compilable sources are in src/code_examples/.
Self-contained, runnable physics simulations demonstrating MML in practice. Full gallery and code: docs/README_Usage_examples.md.
Star-cluster collision simulation with Newtonian gravity and multiple integrators.
|
Cluster overview |
Cluster approach |
Early interaction |
|
Gravitational mixing |
Post-encounter structure |
Trajectory visualization |
Real telemetry data analyzed with parametric curves, curvature, speed, and lateral/longitudinal G-force calculations.
|
Track layout from telemetry |
G-force profile around lap |
Speed profile analysis |
Large-scale elastic collision simulation with spatial partitioning, parallel execution, and shock-wave propagation.
|
Initial shock front |
Wave propagation |
Shock wave dispersion |
More runnable simulations:
| # | Example | Topic |
|---|---|---|
| 01 | Projectile Launch | Ballistics with air resistance |
| 02 | Double Pendulum | Deterministic chaos, butterfly effect |
| 05 | Rigid Body Collisions | 3D dynamics with quaternions |
| 06 | Lorentz Transformations | Special relativity, worldlines & Twin Paradox |
cmake -B build && cmake --build build
./build/src/examples/Release/Example00_NBodyGravity # Windows
./build/src/examples/Example00_NBodyGravity # LinuxMML takes numerical accuracy seriously — every algorithm is validated against analytical solutions, with 174,147 assertions in 4,365 test cases across 173 registered test files.
| Domain | Key Validations |
|---|---|
| Linear Algebra | LU/QR/SVD, eigensolvers, sparse Krylov solvers, condition numbers up to 10¹⁵ |
| Calculus | Derivation (orders 1-8), 1D/2D/3D integration, Gauss-Kronrod |
| ODE & DAE | All steppers, event detection, stiff systems (λ = -10⁶) |
| Geometry | 2D/3D primitives, convex hull, Voronoi, KD-tree, triangulation |
| Fields & Diff. Geometry | Gradient/divergence/curl, metric tensors, manifolds |
| Root Finding | Scalar methods, all-roots isolation, polynomial/complex, nonlinear Newton |
Predefined test beds (TestBeds::) provide battle-tested inputs: ill-conditioned matrices (Hilbert, Vandermonde, Kahan; κ = 10³–10¹⁵), stiff ODEs (Lorenz, Van der Pol, Robertson), singular/oscillatory integrands, and curves with analytical curvature.
Precision benchmarks — derivative of sin(x) at x=1.0: NDer1 ~10⁻⁸ → NDer8 ~10⁻¹⁵ (machine ε). Kepler orbit energy drift after 1000 periods: RK4 ~10⁻⁶, RKF45 ~10⁻¹², DP8(5,3) ~10⁻¹⁴.
# Build, then run the complete Catch2 suite directly in one process
cmake --build build --config Debug --target MML_Tests --parallel
& .\build\tests\Debug\MML_Tests.exe
# Run related categories in one focused process
& .\build\tests\Debug\MML_Tests.exe '[integration],[interpolation]'📚 Precision Analysis Reports: Overview • Derivation • Integration • ODE Solvers
📁 Test Bed Documentation: Functions • ODE Systems • Linear Systems • Curves & Surfaces
MML is benchmarked and compared in the companion repository ComparingCppMathLibs, alongside Boost, Eigen, GSL, Armadillo, Blaze, MFEM, and Intel MKL. The results are intentionally practical: specialist libraries often win their specialist benchmarks, while MML's advantage is breadth, cohesion, zero runtime dependencies, and a single C++ API spanning many domains that usually require several separate libraries.
| Library | Best at | Trade-off |
|---|---|---|
| GSL | Mature C scientific routines: interpolation, integration, roots, special functions, statistics | GPL license, C-style API, limited geometry/tensor/coordinate-system coverage |
| Boost | Powerful specialist modules: Boost.Math, Boost.Odeint, Boost.Geometry, Boost.QVM | Broad ecosystem rather than one cohesive numerical toolkit; Boost.uBLAS lags modern linear algebra libraries in benchmarks |
| MML | One dependency-free stack: vectors, matrices, sparse solvers, calculus, ODE/DAE, fields, tensors, geometry, graph algorithms, visualization, and persistence | Native implementations prioritize clarity, portability, and integration over BLAS/LAPACK-tuned peak dense linear algebra performance |
In the comparison suite, Armadillo/MKL/Eigen/Blaze lead many dense linear algebra benchmarks, Boost.Math and Boost.Odeint lead several numerical-analysis categories, and GSL is especially strong for interpolation. MML is most compelling when you want a broad, inspectable toolkit that works from one include and carries mathematical objects across domains: for example from a vector field to a divergence calculation, to a volume/surface integral, to a visualizer export.
Choose the specialist library when one narrow workload must be maximally tuned. Choose MML when setup simplicity, API consistency, source readability, and cross-domain mathematical coverage matter more.
Unlock advanced capabilities with our commercial add-on packages.
Domain-specific numerical libraries extending core MML functionality.
| Package | Capabilities |
|---|---|
| Optimization | Genetic algorithms, NSGA-II, MOEA/D, simulated annealing, revised simplex LP, constrained optimization |
| PDE | Finite differences, grids, Poisson/Heat/Wave equation solvers |
| Fourier | FFT, DFT, DCT, spectral analysis, windowing functions |
| Statistics | Hypothesis testing, confidence intervals, rank correlation, time series, data descriptors |
| Symbolic | Automatic differentiation, expression trees, symbolic manipulation |
| mml_ext | MML extension tree: spectral graph analytics (PageRank, centralities), field line tracing |
Learn more about MML Packages →
███████╗██╗ ██████╗ ███╗ ███╗ █████╗
██╔════╝██║██╔════╝ ████╗ ████║██╔══██╗
███████╗██║██║ ███╗██╔████╔██║███████║
╚════██║██║██║ ██║██║╚██╔╝██║██╔══██║
███████║██║╚██████╔╝██║ ╚═╝ ██║██║ ██║
╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
Interactive Mathematical Expression Engine for runtime computation with C++ code generation.
| Feature | Description |
|---|---|
| Expression Parsing | Parse & evaluate mathematical expressions in real-time |
| Session State | Variables, constants, persistent state across evaluations |
| User Functions | Define custom functions: func f(x,y) = x^2 + y^2 |
| Typed Functions | scalarfunc f(v:3) = norm(v), vectorfunc F(v:3) = v/norm(v) |
| Built-in Library | 40+ functions: trig, exp, log, special functions |
| Data Types | Scalars, vectors, matrices, polynomials |
| Save/Load | Save sessions to .sigma files and reload them |
| C++ Code Gen | Live preview of your session as generated C++ code |
SigmaEngine in action:
Learn more about Sigma Engine →
| Resource | Description |
|---|---|
| 🌐 Official Website | Public home for MML: overview, docs entry points, examples, and project news |
| 🎯 Fundamentals | Start here — the five ideas behind every MML API: Real/precision builds, concepts (MMLScalar, Field), function interfaces, Config + Result, library-wide contracts |
| 🍳 Cookbook | Task-oriented recipes (linear systems, root finding, ...) — every snippet backed by runnable code in src/docs_demos/ |
| Base Types | Vectors, Matrices, Sparse Matrices, Tensors, Functions |
| Core Operations | Derivation, Integration, Solvers, Fields, Function Spaces |
| Algorithms | ODE/DAE Solvers, Root Finding, Optimization, Geometry |
| Systems | Dynamical Systems, Phase Space, Stability |
| Tools | Visualization, Serialization, Data Loading |
| Code Examples · Usage Examples · Visualization | Snippets, physics sims, viz gallery |
| 📖 Book References · 📄 Paper References | Textbooks and papers behind the algorithms |
cmake -B build
cmake --build build
# Run all tests directly in one process
& .\build\tests\Debug\MML_Tests.exe
# Build examples
cmake --build build --target examplesMML core is released under the MIT License — free for personal, academic, and commercial use.
Prebuilt MML Visualizers bundled under tools/visualizers are provided for
clone-mode convenience and are licensed separately under the
MML Visualizers License: free for personal and educational use;
commercial use requires a paid license. See NOTICE.md for the repo-level license
boundary.
If MML has been useful to you, consider sponsoring its continued development. Your support helps maintain and improve MML! 🚀
Made with ❤️ for the C++ scientific computing community
🔢 MML 2.0 — Minimal Math Library · 100,000+ lines. One #include. Just compute.















