Theoretica
A C++ numerical and automatic mathematical library
Theoretica

GitHub last commit GitHub Workflow Status Codacy Badge Documentation License

A C++ math library for scientific computing with a simple and elegant interface.

Theoretica provides access to numerical methods with applications in science and engineering, is easy to setup and use, and is completely open source. Applications include scientific computing, statistical analysis of data and numerical approximation. The library is tested using Chebyshev, a unit testing framework specifically developed for scientific and numerical software.

A short example

The following code solves a differential equation, such as the Lorenz attractor, and writes the result to file:

int main() {
// Initial conditions
vec3 x0 = {0.0, 0.1, 0.0};
// Use Runge-Kutta between t=0 and t=50
auto solution = ode::solve_rk4(f, x0, 0.0, 50.0);
std::ofstream file ("solution.dat");
file << solution;
}
ode_solution_t< Vector > solve_rk4(OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.01)
Integrate an ordinary differential equation over a certain domain with the given initial conditions u...
Definition: ode.h:456
vec< real, 3 > vec3
A 3-dimensional vector with real elements.
Definition: algebra_types.h:42

Features

Some features of the library include:

  • Cross-platform with x86 and OpenMP enhancements
  • Common real and complex functions
  • Numerical Linear Algebra
  • Complex numbers (algebraic & exponential form) and quaternions
  • Numerical calculus, from integrals to ODEs
  • Multivariate Automatic Differentiation with differential operators
  • Univariate and multivariate optimization and root-finding
  • Descriptive and inferential statistics and Monte Carlo methods
  • Bezier curves and spline interpolation

Theoretica is constantly developed and improved with new ideas!

Setup

Theoretica is a header-only library and has no dependencies, so you can include it in your projects straight-away! You can build all tests and example programs by running make all in the main folder, ensuring that it works on your machine. To use the library, you can include single headers or use theoretica.h which includes all modules, or alternatively include theoretica_mini.h which includes only common use modules.

Quickstart

You can compile this simple code to check your setup:

#include "theoretica.h"
using namespace th;
int main() {
// Declare a 3D vector
vec3 v = {1, 2, 3};
// Create a 3x3 identity matrix
// Transform v by A
vec3 w = A * v;
}
static mat< Type, N, K > identity()
Returns the identity matrix.
Definition: mat.h:733
Main namespace of the library which contains all functions and objects.
Definition: algebra.h:27
mat< real, 3, 3 > mat3
A 3x3 matrix with real entries.
Definition: algebra_types.h:20
Include file for all modules of the library.

Examples

The examples folder contains simple programs that showcase usage of the library:

Documentation

The documentation for the project is available at this link. The documentation is written using Doxygen syntax alongside the source code and the website is automatically updated on each commit. The HTML documentation is also available for download in the gh-pages branch. The bibliography used during research for the library is listed in BIBLIOGRAPHY.md. You may learn more about the design choices behind the library reading the Software Specification.

Contributing

Contributions are welcome and appreciated! Have a look at the Contributing Guide to learn more about how you can help. Contributions include writing code and documentation, testing and researching algorithms.

Workflow

Test on Linux Test on Windows Test on MacOS

Theoretica uses automated workflows for recurring tasks. On each commit to master, tests are run on Linux, Windows and MacOS, benchmarks are launched and documentation is built and deployed to the online website. This ensures that the library works correctly and the documentation is always up-to-date.

License

The project is currently under the GNU Lesser General Public License 3.0. You may learn more about it here.