libnumerixpp  0.1.3
A Powerful C++ Library for High-Performance Numerical Computing
libnumerixpp Documentation

Mathematics

libnumerixpp

A Powerful C++ Library for High-Performance Numerical Computing


[!CAUTION] At the moment, libnumerixpp is under active development (alpha), many things may not work, and this version is not recommended for use (all at your own risk).<

Powerful, Modular, and Extensible C++ Library for Numerical Computations in Mathematics, Physics, and Computer Science

libnumerixpp is a powerful ๐Ÿ’ช, modular ๐Ÿงฑ, and well-documented ๐Ÿ“š C++ library that provides a comprehensive set of tools for numerical computations in mathematics, physics, and computer science. This library aims to simplify complex calculations and enable efficient problem-solving across a wide range of domains.

Unlike other numerical libraries that often focus on a specific domain, libnumerixpp offers a unique, multi-disciplinary approach ๐Ÿ”, seamlessly integrating mathematics, physics, and computer science functionalities into a single, cohesive solution. This makes it an invaluable resource for researchers, scientists, engineers, and developers who need to perform advanced numerical computations as part of their work.

libnumerixpp follows the principles of modularity ๐Ÿงฑ, extensibility ๐Ÿ”, and code quality โœจ. The library is designed to be easily integrated into a wide range of projects, with a focus on maintainability, testability, and performance.

Unlike many numerical libraries that are limited to a single domain, libnumerixpp stands out with its multi-disciplinary approach ๐Ÿ”, seamlessly combining mathematics, physics, and computer science functionalities into a single, cohesive solution. This makes it an invaluable tool for researchers, scientists, engineers, and developers who need to perform advanced numerical computations as part of their work.

The library's robust infrastructure ๐Ÿ—๏ธ, including comprehensive documentation, extensive unit tests, and a flexible build system, ensures that users can trust the reliability and quality of the provided functionalities. Additionally, the intuitive and user-friendly API ๐Ÿค— simplifies complex calculations, allowing users to focus on solving their problems rather than wrestling with the underlying implementation details.


You can join to our small russian telegram blog.

You can view docs for libnumerixpp here.

Current version: 0.1.2

Key Features ๐Ÿ”‘

The libnumerixpp library boasts an impressive array of features that set it apart from its competitors:

Mathematics:

  • ๐Ÿงฎ Robust equation solving (including linear, quadratic, and higher-order equations)
  • ๐Ÿ“Š Comprehensive statistical and probability functions
  • ๐Ÿ”ฌ Powerful trigonometric, exponential, and logarithmic functions
  • Unparalleled accuracy and performance ๐Ÿ† compared to standard math libraries

Physics:

  • ๐Ÿ” Detailed kinematics calculations (displacement, velocity, acceleration, and more)
  • Intuitive and user-friendly API ๐Ÿค— that simplifies complex physical computations
  • Seamless integration with the mathematics module ๐Ÿ”— for interdisciplinary projects

Computer Science:

  • ๐Ÿ”ข Efficient number system conversion (decimal, binary, hexadecimal, and more)
  • Versatile and extensible design ๐Ÿง  that allows for easy integration with other libraries and frameworks
  • Extensive documentation and examples ๐Ÿ“– to help users get started quickly

Robust Infrastructure:

  • Doxygen-generated documentation ๐Ÿ“š for easy navigation and understanding
  • Catch2 unit tests โœ… for ensuring code quality and reliability
  • CMake build system ๐Ÿ› ๏ธ for cross-platform compatibility and easy installation
  • clang-format code formatting ๐Ÿ’… for consistent and readable code

Comparison to Alternatives ๐Ÿค”

To help you decide whether libnumerixpp is the right choice for your project, here's a comparison table with some popular numerical computation libraries:

Feature libnumerixpp Eigen Boost.Numeric LAPACK
Multi-disciplinary Approach โœ… โŒ โŒ โŒ
Equation Solving โœ… โŒ โœ… โŒ
Statistical Functions โŒ โŒ โœ… โŒ
Kinematics Calculations โœ… โŒ โŒ โŒ
Number System Conversion โœ… โŒ โŒ โŒ
Doxygen Documentation โœ… โœ… โœ… โŒ
Unit Tests โœ… โœ… โœ… โœ…
Cross-platform Support โœ… โœ… โœ… โœ…

As you can see, libnumerixpp offers a unique combination of features that sets it apart from other popular numerical computation libraries. Its multi-disciplinary approach, comprehensive functionality, and robust infrastructure make it a compelling choice for a wide range of projects.

Getting Started ๐Ÿš€

To get started with libnumerixpp, follow these simple steps:

  1. Clone the repository:
git clone https://github.com/libnumerixpp/libnumerixpp.git
  1. Build the library using the provided script:
cd libnumerixpp
./build.sh
  1. Include the nessary modules in your code using #include directives:
#include "libnumerixpp/core/common.hpp" // example
  1. Start using the library functions in your applications! You can view examples of usage here.

Examples ๐Ÿ’ป

<details>

#include <iostream>
#include <vector>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
auto main() -> int {
println("LIBNUMERIXPP");
// SQUARE AND SQR //
double const num = 100.0;
double const num_sq = mathematics::square_it_up(num);
double const num_sqr = mathematics::get_square_root(num);
std::cout << "Square " << num << ": " << num_sq << '\n';
std::cout << "Square root " << num << ": " << num_sqr << '\n';
std::cout << '\n';
// CALCULATE QUADRATIC EQUATION BY DISCRIMINANT //
double const a = -2;
double const b = 5;
double const c = 5;
double const d = mathematics::quadratic::calculateDiscriminant(a, b, c);
std::vector<double> const roots = mathematics::quadratic::calculateRootsByDiscriminant(d, a, b);
std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << '\n';
std::cout << "D=" << d << '\n';
std::cout << "Roots:" << '\n';
for (double const root : roots) {
std::cout << root << '\n';
}
std::cout << '\n';
// PERCENTAGE //
double const nump = mathematics::add_percent_to_number(100.0, 10.0);
std::cout << "100+10%: " << nump << '\n';
std::cout << '\n';
// POWER / Algorithms for fast exponentiation //
double const best_pow_val = 100;
double const pow_results[5] = { mathematics::oldApproximatePower(10.0, 2.0),
mathematics::anotherApproximatePower(10.0, 2.0),
mathematics::binaryPower(10.0, 2),
mathematics::fastPowerDividing(10.0, 2.0),
mathematics::fastPowerFractional(10.0, 2.0) };
std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << '\n';
std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << '\n';
std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2]
<< '\n';
std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << '\n';
std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << '\n';
for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) {
double const error = best_pow_val - pow_results[i];
std::cout << "POW Algorithm #" << i << ": error=" << error << '\n';
}
std::cout << '\n';
// Other //
std::cout << "-10 number module: " << mathematics::intabs(-10) << '\n';
return 0;
}
void credits()
print credits
Definition: common.cpp:8
Core utils for mathematics.
auto get_square_root(double num) -> double
Gets the square root.
Definition: core.cpp:94
auto intabs(int x) -> int
Getting the modulus of a number without a comparison operation.
Definition: core.cpp:119
auto square_it_up(double num) -> double
Gets the number square (N^2).
Definition: core.cpp:92
auto add_percent_to_number(double number, double percentage) -> double
Adds a percent to number.
Definition: core.cpp:85
Quadratic utils for mathematics.
#include <cmath>
#include <iostream>
#include <string>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) {
int const iterations = 100;
double z = NAN;
std::cout << "Equation solution " << eq << ":\t";
z = mathematics::equations::successiveApproximationsFindingRoot(f_eq, x0, iterations);
std::cout << z << '\n';
std::cout << "Check finding solution:\t";
std::cout << z << " = " << f_eq(z) << '\n';
for (int i = 0; i <= 50; i++) {
std::cout << "-";
}
std::cout << '\n';
}
auto main() -> int {
println("LIBNUMERIXPP");
test_eq_sa(mathematics::equations::f_eq, 0, "x=0.5cos(x)");
test_eq_sa(mathematics::equations::g_eq, 0, "x=exp(-x)");
test_eq_sa(mathematics::equations::h_eq, 1, "x=(x*x+6)/5");
return 0;
}
Mathematics utils for equations.
auto h_eq(double x) -> double
Function h for determining the right side of solved equations.
Definition: equations.cpp:59
auto f_eq(double x) -> double
Function f for determining the right side of solved equations.
Definition: equations.cpp:55
auto g_eq(double x) -> double
Function g for determining the right side of solved equations.
Definition: equations.cpp:57

</details>

<details>

Physics

#include <iostream>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
auto main() -> int {
println("LIBNUMERIXPP");
double speed = 10.0;
double time = 5.0;
double const path = physics::kinematics::calculate_path(speed, time);
std::cout << "Calculate: speed=" << speed << "m/s" << "; time=" << time << "s"
<< "; path=" << path << "m" << '\n';
double const final_velocity = physics::kinematics::calculate_final_velocity(10.0, 10.0, 10.0);
std::cout << "final velocity (10.0, 10.0, 10.0) = " << final_velocity << '\n';
double const final_position =
std::cout << "final position (10.0, 10.0, 10.0, 10.0) = " << final_velocity << '\n';
return 0;
}
Physics utils for kinematics.
auto calculate_final_position(double initial_position, double initial_velocity, double acceleration, double time) -> double
Calculates the final position.
Definition: kinematics.cpp:20
auto calculate_final_velocity(double initial_velocity, double acceleration, double time) -> double
Calculates the final velocity.
Definition: kinematics.cpp:15
auto calculate_speed(double path, double time) -> double
Calculates the speed.
Definition: kinematics.cpp:11
auto calculate_path(double speed, double time) -> double
Calculates the path.
Definition: kinematics.cpp:9
auto calculate_time(double path, double speed) -> double
Calculates the time.
Definition: kinematics.cpp:13

</details>

<details>

Computer Science

#include <iostream>
#include <string>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
auto main() -> int {
println("LIBNUMERIXPP");
int const decimal_number = 777;
std::string binary_number = computerscience::convertDecimalToBinary(decimal_number);
int const decimal_number2 = computerscience::convertBinaryToDecimal(binary_number);
std::string hexadecimal_number = computerscience::convertDecimalToHexadecimal(decimal_number);
int const decimal_number3 = computerscience::convertHexadecimalToDecimal(hexadecimal_number);
std::string const hexadecimal_number2 =
computerscience::convertBinaryToHexadecimal(binary_number);
std::string const binary_number2 =
computerscience::convertHexadecimalToBinary(hexadecimal_number);
long long const bytes = 1024 * 1024;
std::cout << "Convert decimal " << decimal_number << " to binary: " << binary_number << '\n';
std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2 << '\n';
std::cout << "Convert decimal " << decimal_number << " to hexadecimal: " << hexadecimal_number
<< '\n';
std::cout << "Convert hexadecimal " << hexadecimal_number << " to decimal: " << decimal_number3
<< '\n';
std::cout << "Convert binary " << binary_number << " to hexadecimal: " << hexadecimal_number2
<< '\n';
std::cout << "Convert hexadecimal " << hexadecimal_number << " to binary: " << binary_number2
<< '\n';
std::cout << "Convert " << bytes << ": " << computerscience::humanizeBytesSize(bytes) << '\n';
return 0;
}
Core utils for computer science.

</details>

Architecture

libnumerixpp has a modular architecture consisting of the following core components:

  • core: Provides essential data types, error handling functions, and utility tools.
  • mathematics: Implements algorithms for linear algebra, calculus, and geometry.
  • physics: Offers functions for solving problems in the areas of kinematics, mechanics, thermodynamics and electronics.
  • computerscience: Offers functions for converting data and other CS utils

Each module has its own set of header files and source files, ensuring flexibility and the ability to selectively compile the required parts of the library.

.
โ”œโ”€โ”€ build.sh
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ cmake
โ”‚ โ”œโ”€โ”€ coverage.cmake
โ”‚ โ”œโ”€โ”€ dev-mode.cmake
โ”‚ โ”œโ”€โ”€ docs-ci.cmake
โ”‚ โ”œโ”€โ”€ docs.cmake
โ”‚ โ”œโ”€โ”€ folders.cmake
โ”‚ โ”œโ”€โ”€ install-config.cmake
โ”‚ โ”œโ”€โ”€ install-rules.cmake
โ”‚ โ”œโ”€โ”€ lint.cmake
โ”‚ โ”œโ”€โ”€ lint-targets.cmake
โ”‚ โ”œโ”€โ”€ prelude.cmake
โ”‚ โ”œโ”€โ”€ project-is-top-level.cmake
โ”‚ โ”œโ”€โ”€ spell.cmake
โ”‚ โ”œโ”€โ”€ spell-targets.cmake
โ”‚ โ””โ”€โ”€ variables.cmake
โ”œโ”€โ”€ CMakeLists.txt
โ”œโ”€โ”€ CMakePresets.json
โ”œโ”€โ”€ CMakeUserPresets.json
โ”œโ”€โ”€ conanfile.py
โ”œโ”€โ”€ docs
โ”‚ โ”œโ”€โ”€ doxygen-styles.css
โ”‚ โ”œโ”€โ”€ en
โ”‚ โ”‚ โ””โ”€โ”€ index.md
โ”‚ โ”œโ”€โ”€ man
โ”‚ โ”‚ โ””โ”€โ”€ man3
โ”‚ โ”‚ โ”œโ”€โ”€ common.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ computerscience.3
โ”‚ โ”‚ โ”œโ”€โ”€ core.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ core.hpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ equations.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ equations.hpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ kinematics.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ kinematics.hpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ libnumerixpp.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ mathematics.3
โ”‚ โ”‚ โ”œโ”€โ”€ mathematics_quadratic.3
โ”‚ โ”‚ โ”œโ”€โ”€ mathematics_statistics.3
โ”‚ โ”‚ โ”œโ”€โ”€ physics.3
โ”‚ โ”‚ โ”œโ”€โ”€ physics_kinematics.3
โ”‚ โ”‚ โ”œโ”€โ”€ quadratic_equations.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ quadratic_equations.hpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ statistics.cpp.3
โ”‚ โ”‚ โ”œโ”€โ”€ statistics.hpp.3
โ”‚ โ”‚ โ””โ”€โ”€ todo.3
โ”‚ โ”œโ”€โ”€ README.md
โ”‚ โ””โ”€โ”€ ru
โ”‚ โ”œโ”€โ”€ article2.md
โ”‚ โ”œโ”€โ”€ article.md
โ”‚ โ””โ”€โ”€ index.md
โ”œโ”€โ”€ Doxyfile
โ”œโ”€โ”€ Doxygen.cmake
โ”œโ”€โ”€ examples
โ”‚ โ”œโ”€โ”€ example-1.cpp
โ”‚ โ”œโ”€โ”€ example-2.cpp
โ”‚ โ”œโ”€โ”€ example-3.cpp
โ”‚ โ””โ”€โ”€ example-4.cpp
โ”œโ”€โ”€ format-code.py
โ”œโ”€โ”€ include
โ”‚ โ””โ”€โ”€ libnumerixpp
โ”‚ โ”œโ”€โ”€ computerscience
โ”‚ โ”‚ โ””โ”€โ”€ core.hpp
โ”‚ โ”œโ”€โ”€ core
โ”‚ โ”‚ โ””โ”€โ”€ common.hpp
โ”‚ โ”œโ”€โ”€ export.h
โ”‚ โ”œโ”€โ”€ libnumerixpp.hpp
โ”‚ โ”œโ”€โ”€ mathematics
โ”‚ โ”‚ โ”œโ”€โ”€ core.hpp
โ”‚ โ”‚ โ”œโ”€โ”€ equations.hpp
โ”‚ โ”‚ โ”œโ”€โ”€ quadratic_equations.hpp
โ”‚ โ”‚ โ””โ”€โ”€ statistics.hpp
โ”‚ โ””โ”€โ”€ physics
โ”‚ โ”œโ”€โ”€ core.hpp
โ”‚ โ””โ”€โ”€ kinematics.hpp
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ spacetabs.sh
โ”œโ”€โ”€ src
โ”‚ โ”œโ”€โ”€ computerscience
โ”‚ โ”‚ โ””โ”€โ”€ core.cpp
โ”‚ โ”œโ”€โ”€ core
โ”‚ โ”‚ โ””โ”€โ”€ common.cpp
โ”‚ โ”œโ”€โ”€ libnumerixpp.cpp
โ”‚ โ”œโ”€โ”€ mathematics
โ”‚ โ”‚ โ”œโ”€โ”€ core.cpp
โ”‚ โ”‚ โ”œโ”€โ”€ equations.cpp
โ”‚ โ”‚ โ”œโ”€โ”€ quadratic_equations.cpp
โ”‚ โ”‚ โ””โ”€โ”€ statistics.cpp
โ”‚ โ””โ”€โ”€ physics
โ”‚ โ”œโ”€โ”€ core.cpp
โ”‚ โ””โ”€โ”€ kinematics.cpp
โ””โ”€โ”€ test
โ”œโ”€โ”€ CMakeLists.txt
โ””โ”€โ”€ source
โ””โ”€โ”€ libnumerixpp_test.cpp

Tools and Dependencies

linumerixpp utilizes the following tools and libraries:

  • CMake: Cross-platform build system
  • Doxygen: Documentation generation

Documentation ๐Ÿ“š

Detailed documentation, including user guides, API reference, and code examples, is available in the docs. Or you can see articles or additional info in en docs dir or ru docs dir.

If you have any questions, suggestions, or encounter issues, please create a new issue in the repository. We'll be happy to assist you and improve the library.

You can also write to me on Telegram: @alexeev_dev

libnumerixpp is an Open Source project, and it only survives due to your feedback and support!

Project releases are available at this link.

Requirements ๐Ÿ“‹

To use libnumerixpp, you will need the following:

  • A C++17 compatible compiler (e.g., GCC 8+, Clang 8+, or MSVC 2019+)
  • CMake 3.14 or newer
  • Catch2 testing framework (included as a submodule)

Our Projects ๐Ÿ”ง

Check other our projects:

Contributing ๐Ÿค

We welcome contributions from the community! If you would like to contribute to the libnumerixpp project, please read our contribution guidelines and submit a pull request.

Get Help ๐Ÿ†˜

If you encounter any issues or have questions about using libnumerixpp, you can:

Future Plans ๐Ÿ”ฎ

The libnumerixpp team is continuously working on expanding the library's capabilities and improving its overall performance and usability. Some of our future plans include:

  • ๐Ÿง  Implementing more advanced mathematical and physical computations, such as differential equations, linear algebra, and fluid dynamics
  • โšก Adding support for parallel processing and GPU acceleration to boost performance on large-scale computations
  • ๐ŸŽจ Integrating with popular data visualization and scientific computing frameworks, making it easier to use libnumerixpp in complex project workflows

Stay tuned for more updates! ๐Ÿš€

Testing ๐Ÿงช

libnumerixpp uses the Catch2 testing framework to ensure the quality and reliability of the provided functionalities. The unit tests are located in the tests directory of the repository.

To run the tests, you can execute the following command from the project's root directory:

./build/test/libnumerixpp_test

This will run all the available tests and report the results.

Copyright ๐Ÿ“„

libnumerixpp is released under the Apache License 2.0.

Copyright ยฉ 2024 Alexeev Bronislav. All rights reversed.