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:
- Clone the repository:
git clone https://github.com/libnumerixpp/libnumerixpp.git
- Build the library using the provided script:
cd libnumerixpp
./build.sh
- Include the nessary modules in your code using
#include
directives:
#include "libnumerixpp/core/common.hpp"
- 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");
double const num = 100.0;
std::cout << "Square " << num << ": " << num_sq << '\n';
std::cout << "Square root " << num << ": " << num_sqr << '\n';
std::cout << '\n';
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';
std::cout << "100+10%: " << nump << '\n';
std::cout << '\n';
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';
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");
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;
std::cout << "Calculate: speed=" << speed << "m/s" << "; time=" << time << "s"
<< "; path=" << path << "m" << '\n';
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.