A header-based C++ library for core computational mathematics: differentiation, integration, interpolation, and solving differential equations. Designed for clarity, extensibility, and practical use in scientific and engineering projects.
- Differentiation: Numerical derivatives (first, second, etc.)
- Integration: Definite integrals using various quadrature rules
- Interpolation: Lagrange and Newton polynomial interpolation
- ODE Solvers: Euler, Trapezoidal, and Runge-Kutta methods for systems
- Norms: Vector norms for error analysis
- Data Export: Simple CSV export for results
- Unit Tests: GoogleTest-based test suite
- Doxygen Documentation
- C++17 or newer
- CMake 3.25+
- A modern C++ compiler (GCC, Clang, MSVC)
- GoogleTest (automatically fetched for tests)
# Clone the repository
$ git clone https://github.com/canne16/comp_math.git
$ cd comp_math/Cpp/compmath
# Create a build directory
$ mkdir build && cd build
# Configure the project
$ cmake .. -DCMAKE_BUILD_TYPE=Release
# Build the library and tests
$ make# From the build directory
$ ctest --output-on-failureOr run a specific test:
$ ./runInterpolationTests#include "differentiation.hh"
#include <iostream>
int main() {
auto f = [](double x) { return std::sin(x); };
double df = compmath::differentiate(f, 1.0, 1e-5);
std::cout << "f'(1.0) ≈ " << df << std::endl;
return 0;
}Doxygen documentation is generated in Cpp/compmath/docs/html after building:
- Open
Cpp/compmath/docs/html/index.htmlin your browser. - Browse API docs, examples, and module overviews.
To regenerate docs:
$ cd Cpp/compmath
$ doxygen DoxyfileContributions are welcome! To propose a change:
- Fork the repository
- Create a feature branch (
git checkout -b my-feature) - Make your changes (with tests if possible)
- Run the test suite (
ctest) - Open a pull request with a clear description
Please follow the existing code style and document new functions with Doxygen comments.
This project is licensed under the MIT License. See LICENSE for details.
- GoogleTest for unit testing
- Doxygen for documentation
For questions or suggestions, feel free to open an issue.