Skip to content

fintarin/Fintamath

Repository files navigation

drawing


Coverage Status

Fintamath is a C++ library for symbolic mathematics, supporting both the input of expressions in mathematical format and the use of functions from the library. It is fully featured performing operations on mathematical expressions (polynomials, powers, logarithms, trigonometry, etc.) and solving equations. Using arbitrary precision integers, exact fractions and floating point numbers, Fintamath yields highly accurate numerical results. The library is extensively tested and has 100% line coverage.

Usage Examples

Features

  • Expression — the main class representing mathematical expressions

    • Parsing from string
    • Getting string representation
    • Setting variables
    • Arithmetic operators
  • ExpressionFunctions — a set of functions on expressions

    • Arithmetic functions
    • Comparison functions
    • Powers and logarithms
    • Trigonometric functions
    • Hyperbolic functions
    • Derivative
    • Logic functions
    • Mathematical constants
    • Rounding functions
    • Percent, degrees, factorial, index
    • Solving equations
    • Approximating
  • Integer — a class representing integers of arbitrary precision

    • Arithmetic operators
    • Comparison operators
    • Bitwise operators
  • IntegerFunctions — a set of functions on integers

    • Power and absolute value
    • Number theory functions
    • Combinatorics functions
  • Rational — a class representing exact fractions

    • Arithmetic operators
    • Comparison operators
  • RationalFunctions — a set of functions on rationals

    • Rounding functions
    • Absolute value
  • Real — a class representing high precision floats (up to 80 decimal places)

    • Arithmetic operators
    • Comparison operators
  • RealFunctions — a set of functions on reals

    • Rounding functions
    • Absolute value
    • Powers and logarithms
    • Trigonometric functions
    • Mathematical constants
    • Gamma function
  • Complex — a class representing complex numbers

    • Arithmetic operators
  • Variable — a class representing a letter of the English alphabet with or without unsigned integer index

  • Boolean — a bool wrapper class

  • Functions — classes of mathematical functions supported in expressions

Requirements

  • C++ 20 or higher
  • CMake 3.5 or higher
  • C++ compilers:
    • GCC 11 or higher
    • Clang 16 or higher
    • MSVC 19.30 or higher
    • Apple Clang 14.0.3 or higher
  • Operating systems:
    • Linux
    • Windows
    • macOS
    • Android
  • Libraries:
    • GMP 6.2.0 or higher
    • MPFR 4.2.0 or higher

Note: Fintamath uses pre-built GMP and MPFR if you are building on Windows or Android. But if you are building on Linux or macOS, you should install these libraries using your package manager.

Build

Clone repository.

git clone --recurse-submodules https://github.com/fintarin/Fintamath.git fintamath

Standalone Project

Build in Release mode.

cd fintamath
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build

Incorporating into an Existing CMake Project

Add the following lines to your CMakeLists.txt.

add_subdirectory(fintamath)
add_executable(example example.cpp)
target_link_libraries(example fintamath)

Development

Build in Debug mode with tests enabled.

cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -Dfintamath_build_tests=ON
cmake --build build

Run tests.

cd build
ctest --verbose
cd ..

Run clang-format.

cmake -Bbuild -Dfintamath_enable_clangformat=ON
cmake --build build --target clangformat